aboutsummaryrefslogtreecommitdiff
path: root/gdb/i386-darwin-nat.c
diff options
context:
space:
mode:
authorTristan Gingold <tristan.gingold@adacore.com>2014-10-16 13:50:07 +0200
committerTristan Gingold <tristan.gingold@adacore.com>2014-10-16 13:52:24 +0200
commit89c7137fad41711072e2a15ce539e2ad293bd065 (patch)
tree83319235aa54860c3c175e60748da092f368c93d /gdb/i386-darwin-nat.c
parentf1885d1e59a7e6e0627429cd3068740d96f8a184 (diff)
downloadgdb-89c7137fad41711072e2a15ce539e2ad293bd065.zip
gdb-89c7137fad41711072e2a15ce539e2ad293bd065.tar.gz
gdb-89c7137fad41711072e2a15ce539e2ad293bd065.tar.bz2
Darwin: sanitize %gs and %fs values.
Some Darwin kernels return values out of bounds for gs and fs segments. With this commit, they are masked to avoid garbage. gdb/ChangeLog: * i386-darwin-nat.c (i386_darwin_fetch_inferior_registers) (i386_darwin_store_inferior_registers): Sanitize gs and fs values on amd64.
Diffstat (limited to 'gdb/i386-darwin-nat.c')
-rw-r--r--gdb/i386-darwin-nat.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/gdb/i386-darwin-nat.c b/gdb/i386-darwin-nat.c
index a60bc6c..f99e415 100644
--- a/gdb/i386-darwin-nat.c
+++ b/gdb/i386-darwin-nat.c
@@ -73,6 +73,11 @@ i386_darwin_fetch_inferior_registers (struct target_ops *ops,
(unsigned long) current_thread);
MACH_CHECK_ERROR (ret);
}
+
+ /* Some kernels don't sanitize the values. */
+ gp_regs.uts.ts64.__fs &= 0xffff;
+ gp_regs.uts.ts64.__gs &= 0xffff;
+
amd64_supply_native_gregset (regcache, &gp_regs.uts, -1);
fetched++;
}
@@ -183,6 +188,10 @@ i386_darwin_store_inferior_registers (struct target_ops *ops,
amd64_collect_native_gregset (regcache, &gp_regs.uts, regno);
+ /* Some kernels don't sanitize the values. */
+ gp_regs.uts.ts64.__fs &= 0xffff;
+ gp_regs.uts.ts64.__gs &= 0xffff;
+
ret = thread_set_state (current_thread, x86_THREAD_STATE,
(thread_state_t) &gp_regs,
x86_THREAD_STATE_COUNT);