aboutsummaryrefslogtreecommitdiff
path: root/gdb/windows-nat.c
diff options
context:
space:
mode:
authorJoel Brobecker <brobecker@adacore.com>2018-06-04 15:03:32 -0500
committerJoel Brobecker <brobecker@adacore.com>2018-06-04 16:07:33 -0400
commit178d6a638693d1a7a66b0553f16b1df95b4f27ee (patch)
treec95fe3a396adb32c5438b7685c62fadebb8fb44c /gdb/windows-nat.c
parent4b8e28c79356265b2c111e044142fb6d6d2db44e (diff)
downloadbinutils-178d6a638693d1a7a66b0553f16b1df95b4f27ee.zip
binutils-178d6a638693d1a7a66b0553f16b1df95b4f27ee.tar.gz
binutils-178d6a638693d1a7a66b0553f16b1df95b4f27ee.tar.bz2
(windows) GDB/MI crash when using "-list-thread-groups --available"
On Windows, using the "-list-thread-groups --available" GDB/MI command before an inferior is being debugged: % gdb -q -i=mi =thread-group-added,id="i1" =cmd-param-changed,param="auto-load safe-path",value="/" (gdb) -list-thread-groups --available Segmentation fault Ooops! The SEGV happens because the -list-thread-groups --available command triggers a windows_nat_target::xfer_partial call for a TARGET_OBJECT_OSDATA object. Until a program is being debugged, the target_ops layer that gets the call is the Windows "native" layer. Except for a couple of specific objects (TARGET_OBJECT_MEMORY and TARGET_OBJECT_LIBRARIES), this layer's xfer_partial method delegates the xfer of other objects to the target beneath: default: return beneath->xfer_partial (object, annex, readbuf, writebuf, offset, len, xfered_len); Unfortunately, there is no "beneath layer" in this case, so beneath is NULL and dereferencing it leads to the SEGV. This patch fixes the issue by checking beneath before trying to delegate the request. gdb/ChangeLog: * windows-nat.c (windows_nat_target::xfer_partial): Return TARGET_XFER_E_IO if we need to delegate to the target beneath but BENEATH is NULL. gdb/testsuite/ChangeLog: * gdb.mi/list-thread-groups-no-inferior.exp: New testcase.
Diffstat (limited to 'gdb/windows-nat.c')
-rw-r--r--gdb/windows-nat.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/gdb/windows-nat.c b/gdb/windows-nat.c
index 0f24257..e3e36cd 100644
--- a/gdb/windows-nat.c
+++ b/gdb/windows-nat.c
@@ -2966,6 +2966,13 @@ windows_nat_target::xfer_partial (enum target_object object,
writebuf, offset, len, xfered_len);
default:
+ if (beneath == NULL)
+ {
+ /* This can happen when requesting the transfer of unsupported
+ objects before a program has been started (and therefore
+ with the current_target having no target beneath). */
+ return TARGET_XFER_E_IO;
+ }
return beneath->xfer_partial (object, annex,
readbuf, writebuf, offset, len,
xfered_len);