ldso: notify the debugger when we're doing a dlopen

Otherwise lldb doesn't notice the new library and stack traces
containing it get cut off unhelpfully.
This commit is contained in:
rcombs 2020-10-24 14:31:14 -05:00 committed by Rich Felker
parent 4209a7b104
commit ccba23459e

View File

@ -1947,7 +1947,7 @@ void __dls3(size_t *sp, size_t *auxv)
debug.bp = dl_debug_state; debug.bp = dl_debug_state;
debug.head = head; debug.head = head;
debug.base = ldso.base; debug.base = ldso.base;
debug.state = 0; debug.state = RT_CONSISTENT;
_dl_debug_state(); _dl_debug_state();
if (replace_argv0) argv[0] = replace_argv0; if (replace_argv0) argv[0] = replace_argv0;
@ -1996,6 +1996,9 @@ void *dlopen(const char *file, int mode)
pthread_rwlock_wrlock(&lock); pthread_rwlock_wrlock(&lock);
__inhibit_ptc(); __inhibit_ptc();
debug.state = RT_ADD;
_dl_debug_state();
p = 0; p = 0;
if (shutting_down) { if (shutting_down) {
error("Cannot dlopen while program is exiting."); error("Cannot dlopen while program is exiting.");
@ -2089,9 +2092,10 @@ void *dlopen(const char *file, int mode)
update_tls_size(); update_tls_size();
if (tls_cnt != orig_tls_cnt) if (tls_cnt != orig_tls_cnt)
install_new_tls(); install_new_tls();
_dl_debug_state();
orig_tail = tail; orig_tail = tail;
end: end:
debug.state = RT_CONSISTENT;
_dl_debug_state();
__release_ptc(); __release_ptc();
if (p) gencnt++; if (p) gencnt++;
pthread_rwlock_unlock(&lock); pthread_rwlock_unlock(&lock);