DynamoRIO / DynamoRIO/dynamorio

make it easier to view TLS in gdb (and x64 windbg)

Open
#905 0 comments 0 reactions 0 assignees View on GitHub
Component-Tools Migrated OpSys-Linux Priority-Low Type-Feature
Dominant language
C
Stars
3.2k
Forks
629
Avg merge
2d 15h
Merged PRs (30d)
31

Description

_From [bruen...@google.com](https://code.google.com/u/109494838902877177630/) on September 19, 2012 11:31:36_

gdb does not support viewing far memory references or obtaining info on
segment bases

for win32 gdb I see:
info dos ldt $ds
info sel $fs

can get base by calling into libc:
(gdb) p arch_prctl(0x1003, $rsp-8)
$2 = 0
(gdb) x/4gx $rsp-8
0x7fffffffdae8: 0x00007ffff7fd0700 0x0000000000000000
0x7fffffffdaf8: 0x0000003eeaa2169d 0x0000000000000000
(gdb) x/20gx 0x00007ffff7fd0700
0x7ffff7fd0700: 0x00007ffff7fd0700 0x00007ffff7fcf010
0x7ffff7fd0710: 0x00007ffff7fd0700 0x0000000000000000
0x7ffff7fd0720: 0x0000000000000000 0x52c9d8414bea2300
0x7ffff7fd0730: 0x722ed7028582638a 0x0000000000000000

looks right: those are the self pointers

> grep -r ' ARCH_[GS]ET_' /usr/include
/usr/include/asm/prctl.h:#define ARCH_SET_GS 0x1001
/usr/include/asm/prctl.h:#define ARCH_SET_FS 0x1002
/usr/include/asm/prctl.h:#define ARCH_GET_FS 0x1003
/usr/include/asm/prctl.h:#define ARCH_GET_GS 0x1004

to make it easier:
- have a global array of pairs of thread id, DR base
cut off at N threads, don't bother to update after that:
should work for nearly all apps
(want DR base, not app: can get app once have DR TLS data)
- or just have a DR routine that takes in n and returns gs:n, and then have
gdb invoke it

_Original issue: http://code.google.com/p/dynamorio/issues/detail?id=905_

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.