gdb_server: custom target-specific GDB queries 82/7082/4
authorIan Thompson <ianst@cadence.com>
Mon, 11 Jul 2022 00:14:10 +0000 (17:14 -0700)
committerAntonio Borneo <borneo.antonio@gmail.com>
Mon, 15 Aug 2022 13:23:05 +0000 (13:23 +0000)
Provide a customizable hook for handling target-specific GDB queries

Valgrind-clean, no new Clang analyzer warnings

Signed-off-by: Ian Thompson <ianst@cadence.com>
Change-Id: I684a259ed29f3651cbce668101cff421e522f79e
Reviewed-on: https://review.openocd.org/c/openocd/+/7082
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
src/server/gdb_server.c
src/target/target_type.h

index 3052d0a0e1c364ff5dae1fe36bf4fa8b5d4d9858..1e50b43f3fbc16bc71ae3f18b204d935368d77c6 100644 (file)
@@ -2965,6 +2965,11 @@ static int gdb_query_packet(struct connection *connection,
                gdb_connection->noack_mode = 1;
                gdb_put_packet(connection, "OK", 2);
                return ERROR_OK;
+       } else if (target->type->gdb_query_custom) {
+               char *buffer = NULL;
+               int ret = target->type->gdb_query_custom(target, packet, &buffer);
+               gdb_put_packet(connection, buffer, strlen(buffer));
+               return ret;
        }
 
        gdb_put_packet(connection, "", 0);
index 1933e1cc7c3c209d386ed44f34a4c37074869dac..947080381c172812b2751d65141c6be63882cbf1 100644 (file)
@@ -286,6 +286,15 @@ struct target_type {
         */
        int (*gdb_fileio_end)(struct target *target, int retcode, int fileio_errno, bool ctrl_c);
 
+       /* Parse target-specific GDB query commands.
+        * The string pointer "response_p" is always assigned by the called function
+        * to a pointer to a NULL-terminated string, even when the function returns
+        * an error. The string memory is not freed by the caller, so this function
+        * must pay attention for possible memory leaks if the string memory is
+        * dynamically allocated.
+        */
+       int (*gdb_query_custom)(struct target *target, const char *packet, char **response_p);
+
        /* do target profiling
         */
        int (*profiling)(struct target *target, uint32_t *samples,

Linking to existing account procedure

If you already have an account and want to add another login method you MUST first sign in with your existing account and then change URL to read https://review.openocd.org/login/?link to get to this page again but this time it'll work for linking. Thank you.

SSH host keys fingerprints

1024 SHA256:YKx8b7u5ZWdcbp7/4AeXNaqElP49m6QrwfXaqQGJAOk gerrit-code-review@openocd.zylin.com (DSA)
384 SHA256:jHIbSQa4REvwCFG4cq5LBlBLxmxSqelQPem/EXIrxjk gerrit-code-review@openocd.org (ECDSA)
521 SHA256:UAOPYkU9Fjtcao0Ul/Rrlnj/OsQvt+pgdYSZ4jOYdgs gerrit-code-review@openocd.org (ECDSA)
256 SHA256:A13M5QlnozFOvTllybRZH6vm7iSt0XLxbA48yfc2yfY gerrit-code-review@openocd.org (ECDSA)
256 SHA256:spYMBqEYoAOtK7yZBrcwE8ZpYt6b68Cfh9yEVetvbXg gerrit-code-review@openocd.org (ED25519)
+--[ED25519 256]--+
|=..              |
|+o..   .         |
|*.o   . .        |
|+B . . .         |
|Bo. = o S        |
|Oo.+ + =         |
|oB=.* = . o      |
| =+=.+   + E     |
|. .=o   . o      |
+----[SHA256]-----+
2048 SHA256:0Onrb7/PHjpo6iVZ7xQX2riKN83FJ3KGU0TvI0TaFG4 gerrit-code-review@openocd.zylin.com (RSA)