diff options
author | Eugene Tarassov | 2019-06-12 03:21:06 +0000 |
---|---|---|
committer | Eugene Tarassov | 2019-06-12 03:21:06 +0000 |
commit | 30f0914f67a54acac35f7fb8a7c7a8086ed3632f (patch) | |
tree | c31322defaed7f59c98a8f7ccf4facb5c4476c94 | |
parent | dc373fa9fedc12e0ea155a4cd2984170e4d7bb20 (diff) | |
download | org.eclipse.tcf.agent-30f0914f67a54acac35f7fb8a7c7a8086ed3632f.tar.gz org.eclipse.tcf.agent-30f0914f67a54acac35f7fb8a7c7a8086ed3632f.tar.xz org.eclipse.tcf.agent-30f0914f67a54acac35f7fb8a7c7a8086ed3632f.zip |
TCF Agent: added support for faster traversal of registers hierarchy
-rw-r--r-- | agent/tcf/framework/cpudefs.c | 28 | ||||
-rw-r--r-- | agent/tcf/framework/cpudefs.h | 14 | ||||
-rw-r--r-- | agent/tcf/services/registers.c | 17 |
3 files changed, 56 insertions, 3 deletions
diff --git a/agent/tcf/framework/cpudefs.c b/agent/tcf/framework/cpudefs.c index 489f4e8e..0615739a 100644 --- a/agent/tcf/framework/cpudefs.c +++ b/agent/tcf/framework/cpudefs.c @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007-2018 Wind River Systems, Inc. and others. + * Copyright (c) 2007-2019 Wind River Systems, Inc. and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * and Eclipse Distribution License v1.0 which accompany this distribution. @@ -33,6 +33,32 @@ #include <tcf/framework/cpudefs-ext.h> +void create_reg_children_refs(RegisterDefinition * defs) { +#if ENABLE_RegisterChildrenRefs + RegisterDefinition * r = NULL; + RegisterDefinition ** p = NULL; + RegisterDefinition * c = NULL; + unsigned size = 0; + assert(defs->parent == NULL); + assert(defs->children == NULL); + for (r = defs; r->name != NULL; r++) size++; + p = (RegisterDefinition **)tmp_alloc_zero(sizeof(RegisterDefinition *) * size); + for (r = defs; r->name != NULL; r++) { + assert(r->sibling == NULL); + if (r->parent == NULL) { + if (c != NULL) c->sibling = r; + c = r; + } + else { + RegisterDefinition ** y = p + (r->parent - defs); + if (*y == NULL) r->parent->children = r; + else (*y)->sibling = r; + *y = r; + } + } +#endif +} + int read_reg_value(StackFrame * frame, RegisterDefinition * reg_def, uint64_t * value) { uint8_t buf[8]; if (reg_def == NULL) { diff --git a/agent/tcf/framework/cpudefs.h b/agent/tcf/framework/cpudefs.h index 16bf0181..a11a1342 100644 --- a/agent/tcf/framework/cpudefs.h +++ b/agent/tcf/framework/cpudefs.h @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007-2018 Wind River Systems, Inc. and others. + * Copyright (c) 2007-2019 Wind River Systems, Inc. and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * and Eclipse Distribution License v1.0 which accompany this distribution. @@ -42,6 +42,10 @@ typedef uintptr_t ContextAddress; #define ENABLE_StackRegisterLocations 0 #endif +#ifndef ENABLE_RegisterChildrenRefs +#define ENABLE_RegisterChildrenRefs 0 +#endif + #define REGNUM_DWARF 1 #define REGNUM_EH_FRAME 2 @@ -80,6 +84,11 @@ struct RegisterDefinition { const char * role; /* the role the register plays in a program execution */ const char * description; /* the description of the register */ void * ext; /* to be used by debug context implementation */ +#if ENABLE_RegisterChildrenRefs + /* Optional support for faster browsing of register definitions */ + RegisterDefinition * children; + RegisterDefinition * sibling; +#endif }; typedef struct RegisterIdScope { @@ -246,6 +255,9 @@ typedef struct StackFrame { /* Return array of CPU register definitions. Last item in the array has name == NULL */ extern RegisterDefinition * get_reg_definitions(Context * ctx); +/* Set 'children' and 'siblings' fields of register definitions */ +extern void create_reg_children_refs(RegisterDefinition * defs); + /* Search register definition for given register ID, return NULL if not found */ extern RegisterDefinition * get_reg_by_id(Context * ctx, unsigned id, RegisterIdScope * scope); diff --git a/agent/tcf/services/registers.c b/agent/tcf/services/registers.c index 2f7677fa..190cded6 100644 --- a/agent/tcf/services/registers.c +++ b/agent/tcf/services/registers.c @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007-2017 Wind River Systems, Inc. and others. + * Copyright (c) 2007-2019 Wind River Systems, Inc. and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * and Eclipse Distribution License v1.0 which accompany this distribution. @@ -308,6 +308,21 @@ static void command_get_children_cache_client(void * x) { write_errno(&c->out, trap.error); write_stream(&c->out, '['); +#if ENABLE_RegisterChildrenRefs + if (defs != NULL && (defs->children != NULL || defs->sibling != NULL) && + defs->parent == NULL && (frame < 0 || frame_info->is_top_frame)) { + int cnt = 0; + RegisterDefinition * reg_def = parent == NULL ? defs : parent->children; + while (reg_def != NULL) { + assert(reg_def->parent == parent); + if (cnt > 0) write_stream(&c->out, ','); + json_write_string(&c->out, register2id(ctx, frame, reg_def)); + reg_def = reg_def->sibling; + cnt++; + } + defs = NULL; + } +#endif if (defs != NULL) { int cnt = 0; RegisterDefinition * reg_def; |