Skip to content
This repository has been archived by the owner on Jan 20, 2022. It is now read-only.

Commit

Permalink
[Pal,LibOS] Fix GDB integration in case of removing maps
Browse files Browse the repository at this point in the history
- The GDB command for removing a symbol file takes text address
  (or any address inside the mapped memory area), not load offset.
  (which might be before the area). Because of that, removing a
  map in GDB did not actually work, and displayed a warning.
- The remove_r_debug() function in LibOS did not actually remove
  the map from list in LibOS. As a result, LibOS attempted to
  report the removal to PAL more than once, causing a harmless but
  annoying warning message.
  • Loading branch information
pwmarcz authored and mkow committed Jan 19, 2021
1 parent 54ee076 commit e395e01
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
10 changes: 8 additions & 2 deletions LibOS/shim/src/shim_debug.c
Original file line number Diff line number Diff line change
Expand Up @@ -73,12 +73,18 @@ void remove_r_debug(void* addr) {

debug("remove a library for gdb: %s\n", m->l_name);

if (m->l_prev)
if (m->l_prev) {
m->l_prev->l_next = m->l_next;
if (m->l_next)
} else {
link_map_list = m->l_next;
}

if (m->l_next) {
m->l_next->l_prev = m->l_prev;
}

DkDebugMapRemove(addr);
free(m);
}

void append_r_debug(const char* uri, void* addr, void* dyn_addr) {
Expand Down
6 changes: 3 additions & 3 deletions Pal/gdb_integration/debug_map_gdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,9 +114,9 @@ def invoke(self, arg, _from_tty):
print("Removing symbol file (was {}) from addr: 0x{:x}".format(
file_name, load_addr))
try:
gdb.execute('remove-symbol-file -a 0x{:x}'.format(load_addr))
except gdb.error:
print('warning: failed to remove symbol file')
gdb.execute('remove-symbol-file -a 0x{:x}'.format(text_addr))
except gdb.error as e:
print('warning: failed to remove symbol file: {}'.format(e))

# Note that we escape text arguments to 'add-symbol-file' (file name and section names)
# using shlex.quote(), because GDB commands use a shell-like argument syntax.
Expand Down

0 comments on commit e395e01

Please sign in to comment.