This is an automated email from Gerrit.

Tomas Vanek ([email protected]) just uploaded a new patch set to Gerrit, which you 
can find at http://openocd.zylin.com/5325

-- gerrit

commit e9fa47841d1096329143de3b5335b6c3ca8a8a25
Author: Tomas Vanek <[email protected]>
Date:   Sun Oct 20 09:40:34 2019 +0200

    target, register: allow a register hidden from gdb and 'reg' cmd
    
    Introduce a hidden flag in struct reg to support a register cache
    containing different views of same data: e.g. Cortex-M has
    primask, basepri, faultmask and control registers accessed
    as one word. With the hidden flag we can add an reg_list item
    corresponding to hw access without exposing the register to user level.
    
    Change-Id: I8da9f5a5a60777ae7ef943a841307487bd80fc6f
    Signed-off-by: Tomas Vanek <[email protected]>

diff --git a/src/server/gdb_server.c b/src/server/gdb_server.c
index c8f0e52..eac563c 100644
--- a/src/server/gdb_server.c
+++ b/src/server/gdb_server.c
@@ -1179,7 +1179,7 @@ static int gdb_get_registers_packet(struct connection 
*connection,
                return gdb_error(connection, retval);
 
        for (i = 0; i < reg_list_size; i++) {
-               if (reg_list[i] == NULL || reg_list[i]->exist == false)
+               if (reg_list[i] == NULL || reg_list[i]->exist == false || 
reg_list[i]->hidden)
                        continue;
                reg_packet_size += DIV_ROUND_UP(reg_list[i]->size, 8) * 2;
        }
@@ -1193,7 +1193,7 @@ static int gdb_get_registers_packet(struct connection 
*connection,
        reg_packet_p = reg_packet;
 
        for (i = 0; i < reg_list_size; i++) {
-               if (reg_list[i] == NULL || reg_list[i]->exist == false)
+               if (reg_list[i] == NULL || reg_list[i]->exist == false || 
reg_list[i]->hidden)
                        continue;
                if (!reg_list[i]->valid) {
                        retval = reg_list[i]->type->get(reg_list[i]);
@@ -2169,7 +2169,7 @@ static int get_reg_features_list(struct target *target, 
char const **feature_lis
        *feature_list = calloc(1, sizeof(char *));
 
        for (int i = 0; i < reg_list_size; i++) {
-               if (reg_list[i]->exist == false)
+               if (reg_list[i]->exist == false || reg_list[i]->hidden)
                        continue;
 
                if (reg_list[i]->feature != NULL
@@ -2263,7 +2263,7 @@ static int gdb_generate_target_description(struct target 
*target, char **tdesc_o
                        int i;
                        for (i = 0; i < reg_list_size; i++) {
 
-                               if (reg_list[i]->exist == false)
+                               if (reg_list[i]->exist == false || 
reg_list[i]->hidden)
                                        continue;
 
                                if (strcmp(reg_list[i]->feature->name, 
features[current_feature]))
diff --git a/src/target/register.h b/src/target/register.h
index 7c53d6e..1bae811 100644
--- a/src/target/register.h
+++ b/src/target/register.h
@@ -134,6 +134,8 @@ struct reg {
        bool valid;
        /* When false, the register doesn't actually exist in the target. */
        bool exist;
+       /* Hide the register from gdb and omit it in 'reg' cmd output */
+       bool hidden;
        /* Size of the register in bits. */
        uint32_t size;
        /* Used for generating XML description of registers. Can be set to NULL 
for
diff --git a/src/target/target.c b/src/target/target.c
index 03b6f4e..1d26dbb 100644
--- a/src/target/target.c
+++ b/src/target/target.c
@@ -2854,7 +2854,7 @@ COMMAND_HANDLER(handle_reg_command)
                        for (i = 0, reg = cache->reg_list;
                                        i < cache->num_regs;
                                        i++, reg++, count++) {
-                               if (reg->exist == false)
+                               if (reg->exist == false || reg->hidden)
                                        continue;
                                /* only print cached values if they are valid */
                                if (reg->valid) {
diff --git a/src/target/xscale.c b/src/target/xscale.c
index 1a099c9..5d3d24c 100644
--- a/src/target/xscale.c
+++ b/src/target/xscale.c
@@ -2884,7 +2884,7 @@ static void xscale_build_reg_cache(struct target *target)
        /* fill in values for the xscale reg cache */
        (*cache_p)->name = "XScale registers";
        (*cache_p)->next = NULL;
-       (*cache_p)->reg_list = malloc(num_regs * sizeof(struct reg));
+       (*cache_p)->reg_list = calloc(num_regs, sizeof(struct reg));
        (*cache_p)->num_regs = num_regs;
 
        for (i = 0; i < num_regs; i++) {

-- 


_______________________________________________
OpenOCD-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openocd-devel

Reply via email to