From: Markus Metzger Date: Tue, 26 Nov 2019 11:02:30 +0000 (+0100) Subject: [wip] gdbserver, x86: support fs_base and gs_base X-Git-Url: http://git.ipfire.org/gitweb/gitweb.cgi?a=commitdiff_plain;h=refs%2Fheads%2Fusers%2Fmmetzger%2Ffsgs;p=thirdparty%2Fbinutils-gdb.git [wip] gdbserver, x86: support fs_base and gs_base When debugging over gdbserver fs/gs_base is not updated when changing the corresponding selector. For 32-bit inferiors, fs/gs_base are now defined but not fetched. Change-Id: I5a4d8637324ee5f0c303fdcc5eeb8ca50b96c577 Signed-off-by: Markus Metzger --- diff --git a/gdb/gdbserver/linux-x86-low.c b/gdb/gdbserver/linux-x86-low.c index 54bd2a26de8..479cec0d709 100644 --- a/gdb/gdbserver/linux-x86-low.c +++ b/gdb/gdbserver/linux-x86-low.c @@ -133,7 +133,7 @@ static const int x86_64_regmap[] = -1, -1, -1, -1, -1, -1, -1, -1, ORIG_RAX * 8, #ifdef HAVE_STRUCT_USER_REGS_STRUCT_FS_BASE - 21 * 8, 22 * 8, + FS_BASE * 8, GS_BASE * 8, #else -1, -1, #endif diff --git a/gdb/gdbserver/linux-x86-tdesc.c b/gdb/gdbserver/linux-x86-tdesc.c index b39ed53549b..ab43ae58c25 100644 --- a/gdb/gdbserver/linux-x86-tdesc.c +++ b/gdb/gdbserver/linux-x86-tdesc.c @@ -87,7 +87,13 @@ i386_linux_read_description (uint64_t xcr0) if (*tdesc == NULL) { - *tdesc = i386_create_target_description (xcr0, true, false); +#ifdef HAVE_STRUCT_USER_REGS_STRUCT_FS_BASE + const bool segment = true; +#else + const bool segment = false; +#endif + + *tdesc = i386_create_target_description (xcr0, true, segment); init_target_desc (*tdesc, i386_expedite_regs); } @@ -118,7 +124,13 @@ amd64_linux_read_description (uint64_t xcr0, bool is_x32) if (*tdesc == NULL) { - *tdesc = amd64_create_target_description (xcr0, is_x32, true, true); +#ifdef HAVE_STRUCT_USER_REGS_STRUCT_FS_BASE + const bool segment = true; +#else + const bool segment = false; +#endif + + *tdesc = amd64_create_target_description (xcr0, is_x32, true, segment); init_target_desc (*tdesc, amd64_expedite_regs); }