From: OpenOCD-Gerrit <ope...@us...> - 2020-08-08 21:18:07
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "Main OpenOCD repository". The branch, master has been updated via 2f92598f0d6d8304a9c15f7050c9e888279cd2fa (commit) via 6d45e485f98bb1712c0ec2f48c879ceaf6fd06ac (commit) from 86777768ebef236f1f90a4abb6a6e1487884d753 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit 2f92598f0d6d8304a9c15f7050c9e888279cd2fa Author: Antonio Borneo <bor...@gm...> Date: Tue Jun 4 12:06:44 2019 +0200 gdb_server: refuse gdb connection if target is not examined If the target is not examined, many internal data required for the gdb connections are not ready nor allocated. This causes OpenOCD to hit a segmentation fault. After the execution of the gdb-attach event handler, check if target has been examined and eventually return error to refuse the gdb connection. Plus, since OpenOCD does not implements non-stop mode yet, gdb expects the target to be halted by the inferior when the connection is established. Print a warning to inform the user in case the target is not halted, but still accept the gdb connection to permit the non-intrusive memory inspection with gdb, as explained in http://openocd.org/doc/html/GDB-and-OpenOCD.html#gdbmeminspect Change-Id: If727d68f683c3a94e4826e8c62977de41274ceff Signed-off-by: Antonio Borneo <bor...@gm...> Reviewed-on: http://openocd.zylin.com/5201 Tested-by: jenkins diff --git a/src/server/gdb_server.c b/src/server/gdb_server.c index 327d96b17..61d7686c4 100644 --- a/src/server/gdb_server.c +++ b/src/server/gdb_server.c @@ -1018,6 +1018,17 @@ static int gdb_new_connection(struct connection *connection) target_name(target), target_state_name(target)); + if (!target_was_examined(target)) { + LOG_ERROR("Target %s not examined yet, refuse gdb connection %d!", + target_name(target), gdb_actual_connections); + gdb_actual_connections--; + return ERROR_TARGET_NOT_EXAMINED; + } + + if (target->state == TARGET_HALTED) + LOG_WARNING("GDB connection %d on target %s not halted", + gdb_actual_connections, target_name(target)); + /* DANGER! If we fail subsequently, we must remove this handler, * otherwise we occasionally see crashes as the timer can invoke the * callback fn. commit 6d45e485f98bb1712c0ec2f48c879ceaf6fd06ac Author: Mikhail Rasputin <mik...@ya...> Date: Sat Jun 27 23:30:42 2020 +0300 target: fix registers reading from non examined target If a target is not examined when the debugger tries to connect to it then it can lead to undesired/undefined behavior. In particular it leads to a zero pointer dereference on the aarch64. Change-Id: I67f2b714ab8b2727fd36f3de16d7f9017b4c55fe Signed-off-by: Mikhail Rasputin <mik...@ya...> Reviewed-on: http://openocd.zylin.com/5727 Tested-by: jenkins Reviewed-by: Tomas Vanek <va...@fb...> Reviewed-by: Antonio Borneo <bor...@gm...> diff --git a/src/target/target.c b/src/target/target.c index b39254826..5efa088b2 100644 --- a/src/target/target.c +++ b/src/target/target.c @@ -1224,8 +1224,17 @@ int target_get_gdb_reg_list(struct target *target, struct reg **reg_list[], int *reg_list_size, enum target_register_class reg_class) { - int result = target->type->get_gdb_reg_list(target, reg_list, + int result = ERROR_FAIL; + + if (!target_was_examined(target)) { + LOG_ERROR("Target not examined yet"); + goto done; + } + + result = target->type->get_gdb_reg_list(target, reg_list, reg_list_size, reg_class); + +done: if (result != ERROR_OK) { *reg_list = NULL; *reg_list_size = 0; ----------------------------------------------------------------------- Summary of changes: src/server/gdb_server.c | 11 +++++++++++ src/target/target.c | 11 ++++++++++- 2 files changed, 21 insertions(+), 1 deletion(-) hooks/post-receive -- Main OpenOCD repository |