public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH v2 0/2] Fix regression with lazy-loading of partial symbols
@ 2022-05-19 18:45 Lancelot SIX
  2022-05-19 18:45 ` [PATCH v2 1/2] gdb: Require psymtab before calling quick_functions in objfile Lancelot SIX
  2022-05-19 18:45 ` [PATCH v2 2/2] gdb: Simplify psymbol_functions::require_partial_symbols Lancelot SIX
  0 siblings, 2 replies; 11+ messages in thread
From: Lancelot SIX @ 2022-05-19 18:45 UTC (permalink / raw)
  To: gdb-patches; +Cc: lsix, Lancelot SIX

This series is a V2 for https://sourceware.org/pipermail/gdb-patches/2022-April/188385.html.

Since V1:

- Instead of only changing cooked_index_functions::expand_symtabs_matching,
  change objfile so each call to a method of a quick_function is done after
  ensuring the partial symbols have been read (the exception being the methods
  used to actually read partial symbols).
- Added patch #2 which does some cleanup in
  psymbol_functions::require_partial_symbols.
- Addressed Pedro's comments regarding the testcase.

All feedback are welcome.

Best,
Lancelot.

---

The recent DWARF indexer rewrite introduced a regression when debugging
a forking program.

Here is a way to reproduce the issue (there might be other ways, but one
is enough and this one mimics the situation we encountered).  Consider a
program which forks, and the child loads a shared library and calls a
function in this shared library:

    if (fork () == 0)
      {
        void *solib = dlopen (some_solib, RTLD_NOW);
        void (*foo) () = dlsym (some_solib, "foo");
        foo ();
      }

Suppose that this program is compiled without debug info, but the shared
library it loads has debug info enabled.

When debugging such program with the following options:

  - set detach-on-fork off
  - set follow-fork-mode child

we see something like:

    (gdb) b foo
    Function "foo" not defined.
    Make breakpoint pending on future shared library load? (y or [n]) y
    Breakpoint 1 (foo) pending.
    (gdb) run
    Starting program: a.out
    [Attaching after process 19720 fork to child process 19723]
    [New inferior 2 (process 19723)]
    [Switching to process 19723]

    Thread 2.1 "a.out" hit Breakpoint 1, 0x00007ffff7fc3101 in foo () from .../libfoo.so
    (gdb) list

    Fatal signal: Segmentation fault
    ----- Backtrace -----
    [...]
    ---------------------

Lancelot SIX (2):
  gdb: Require psymtab before calling quick_functions in objfile
  gdb: Simplify psymbol_functions::require_partial_symbols

 gdb/objfiles.h                                | 10 ++++
 gdb/psymtab.c                                 |  2 +-
 gdb/symfile-debug.c                           | 30 +++++-----
 ...fork-no-detach-follow-child-dlopen-shlib.c | 23 ++++++++
 .../fork-no-detach-follow-child-dlopen.c      | 40 +++++++++++++
 .../fork-no-detach-follow-child-dlopen.exp    | 57 +++++++++++++++++++
 6 files changed, 146 insertions(+), 16 deletions(-)
 create mode 100644 gdb/testsuite/gdb.base/fork-no-detach-follow-child-dlopen-shlib.c
 create mode 100644 gdb/testsuite/gdb.base/fork-no-detach-follow-child-dlopen.c
 create mode 100644 gdb/testsuite/gdb.base/fork-no-detach-follow-child-dlopen.exp


base-commit: c4dd8eb523fae5c9d312f4b7b21377eec66e70c3
-- 
2.25.1


^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2022-05-26 20:42 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-19 18:45 [PATCH v2 0/2] Fix regression with lazy-loading of partial symbols Lancelot SIX
2022-05-19 18:45 ` [PATCH v2 1/2] gdb: Require psymtab before calling quick_functions in objfile Lancelot SIX
2022-05-20 15:51   ` Tom Tromey
2022-05-20 23:07     ` Lancelot SIX
2022-05-21  1:07       ` Tom Tromey
2022-05-19 18:45 ` [PATCH v2 2/2] gdb: Simplify psymbol_functions::require_partial_symbols Lancelot SIX
2022-05-20 15:51   ` Tom Tromey
2022-05-20 16:07   ` Simon Marchi
2022-05-20 22:55     ` [PATCH v3 2/2] gdb: Change psymbol_functions::require_partial_symbols to partial_symbols Lancelot SIX
2022-05-26 17:57       ` Tom Tromey
2022-05-26 20:42         ` Lancelot SIX

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).