[prev in list] [next in list] [prev in thread] [next in thread] 

List:       openocd-development
Subject:    [OpenOCD-devel] [PATCH]: 5022a0c gdb_server: add support for architecture element
From:       gerrit () openocd ! org (gerrit)
Date:       2017-03-21 15:38:37
Message-ID: 20170321153837.D4EF12522991 () mail ! openocd ! org
[Download RAW message or body]

This is an automated email from Gerrit.

Steven Stallion (sstallion@gmail.com) just uploaded a new patch set to Gerrit, which \
you can find at http://openocd.zylin.com/4078

-- gerrit

commit 5022a0c47e5888432aa7e5dccb98b859bb50286e
Author: Steven Stallion <stallion@squareup.com>
Date:   Tue Mar 21 10:33:09 2017 -0500

    gdb_server: add support for architecture element
    
    This change adds optional support for a target to report architecture
    information in the target description to GDB. This is needed by some GDB
    implementations to properly support remote target with custom behavior.
    More information on the architecture element can be found here:
    
        https://sourceware.org/gdb/onlinedocs/gdb/Target-Description-Format.html#Target-Description-Format
  
    Change-Id: I57b19cae5ac3496256e4e5cc52cf6526ca5c322d
    Signed-off-by: Steven Stallion <stallion@squareup.com>

diff --git a/src/server/gdb_server.c b/src/server/gdb_server.c
index 483e551..063c566 100644
--- a/src/server/gdb_server.c
+++ b/src/server/gdb_server.c
@@ -2072,6 +2072,7 @@ static int gdb_generate_target_description(struct target \
*target, char **tdesc_o  int retval = ERROR_OK;
 	struct reg **reg_list = NULL;
 	int reg_list_size;
+	char const *architecture;
 	char const **features = NULL;
 	int feature_list_size = 0;
 	char *tdesc = NULL;
@@ -2109,6 +2110,12 @@ static int gdb_generate_target_description(struct target \
*target, char **tdesc_o  "<!DOCTYPE target SYSTEM \"gdb-target.dtd\">\n"
 			"<target version=\"1.0\">\n");
 
+	/* generate architecture element if supported by target */
+	architecture = target_get_gdb_arch(target);
+	if (architecture != NULL)
+		xml_printf(&retval, &tdesc, &pos, &size,
+				"<architecture>%s</architecture>\n", architecture);
+
 	/* generate target description according to register list */
 	if (features != NULL) {
 		while (features[current_feature]) {
diff --git a/src/target/target.c b/src/target/target.c
index ee302ee..ad75566 100644
--- a/src/target/target.c
+++ b/src/target/target.c
@@ -1162,6 +1162,13 @@ int target_hit_watchpoint(struct target *target,
 	return target->type->hit_watchpoint(target, hit_watchpoint);
 }
 
+const char *target_get_gdb_arch(struct target *target)
+{
+	if (target->type->get_gdb_arch == NULL)
+		return NULL;
+	return target->type->get_gdb_arch(target);
+}
+
 int target_get_gdb_reg_list(struct target *target,
 		struct reg **reg_list[], int *reg_list_size,
 		enum target_register_class reg_class)
diff --git a/src/target/target.h b/src/target/target.h
index 76630b9..c312485 100644
--- a/src/target/target.h
+++ b/src/target/target.h
@@ -465,6 +465,13 @@ int target_hit_watchpoint(struct target *target,
 		struct watchpoint **watchpoint);
 
 /**
+ * Obtain the architecture for GDB.
+ *
+ * This routine is a wrapper for target->type->get_gdb_arch.
+ */
+const char *target_get_gdb_arch(struct target *target);
+
+/**
  * Obtain the registers for GDB.
  *
  * This routine is a wrapper for target->type->get_gdb_reg_list.
diff --git a/src/target/target_type.h b/src/target/target_type.h
index 34e2778..d5e8954 100644
--- a/src/target/target_type.h
+++ b/src/target/target_type.h
@@ -273,6 +273,10 @@ struct target_type {
 	 */
 	int (*profiling)(struct target *target, uint32_t *samples,
 			uint32_t max_num_samples, uint32_t *num_samples, uint32_t seconds);
+
+	/* get GDB architecture from target
+	 */
+	const char *(*get_gdb_arch)(struct target *target);
 };
 
 #endif /* OPENOCD_TARGET_TARGET_TYPE_H */

-- 

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
OpenOCD-devel mailing list
OpenOCD-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/openocd-devel


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic