From: Doug Evans <dje@google.com>
To: eliz@gnu.org
Cc: gdb-patches <gdb-patches@sourceware.org>
Subject: Re: [doc RFA] "set debug dwarf2-read" and "set debug symtab-create"
Date: Tue, 26 Jun 2012 15:45:00 -0000 [thread overview]
Message-ID: <CADPb22SzBXCRCufriTYyj=ODfmtH-d=TzA-k8dogFizgFNhK0w@mail.gmail.com> (raw)
In-Reply-To: <20120619222645.36C911E26C4@ruffy2.mtv.corp.google.com>
Hi. "Ping." :-)
On Tue, Jun 19, 2012 at 3:26 PM, Doug Evans <dje@google.com> wrote:
> Hi.
>
> I'm committing this after a doc RFA.
> [But feel free to suggest changes or enhancements.]
>
> This adds two options for debugging dwarf2 debug info reading and symbol table
> creation, and adds the beginnings of some useful messages for such.
>
> 2012-06-19 Doug Evans <dje@google.com>
>
> * NEWS: Mention new options "set debug dwarf2-read" and
> "set debug symtab-create".
> * dwarf2read.c (dwarf2_read_debug): New static global.
> (dwarf2_build_psymtabs_hard): Add debugging printfs.
> (process_queue): Ditto.
> (process_full_comp_unit): Ditto.
> (_initialize_dwarf2_read): Add new option "set debug dwarf2-read".
> * elfread.c (elf_symfile_read): Add debugging printf.
> * minsyms.c (install_minimal_symbols): Ditto.
> * psymtab.c (allocate_psymtab): Ditto.
> * symfile.c (allocate_symtab): Ditto.
> * symtab.c (symtab_create_debug): New global.
> (_initialize_symtab): Add new option "set debug symtab-create".
> * symtab.h (symtab_create_debug): Declare.
>
> doc/
> * gdb.texinfo (Debugging Output): Document debug options dwarf2-read
> and symtab-create.
>
> diff --git a/gdb/NEWS b/gdb/NEWS
> index 5450939..e357599 100644
> --- a/gdb/NEWS
> +++ b/gdb/NEWS
> @@ -462,6 +462,16 @@ tstop [NOTES]
>
> * New options
>
> +set debug dwarf2-read
> +show debug dwarf2-read
> + Turns on or off display of GDB info related to reading DWARF debugging
> + information. The default is off.
> +
> +set debug symtab-create
> +show debug symtab-create
> + Turns on or off display of GDB debugging info related to symbol table
> + creation. The default is off.
> +
> set extended-prompt
> show extended-prompt
> Set the GDB prompt, and allow escape sequences to be inserted to
> diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo
> index a14e322..29f7257 100644
> --- a/gdb/doc/gdb.texinfo
> +++ b/gdb/doc/gdb.texinfo
> @@ -21741,6 +21741,12 @@ The value is the number of nesting levels to print.
> A value of zero turns off the display.
> @item show debug dwarf2-die
> Show the current state of DWARF2 DIE debugging.
> +@item set debug dwarf2-read
> +@cindex DWARF2 Reading
> +Turns on or off display of @value{GDBN} info related to reading
> +DWARF debugging information. The default is off.
> +@item show debug dwarf2-read
> +Show the current state of DWARF2 reader debugging.
> @item set debug displaced
> @cindex displaced stepping debugging info
> Turns on or off display of @value{GDBN} debugging info for the
> @@ -21838,6 +21844,12 @@ Turns on or off debugging messages for FR-V shared-library code.
> @item show debug solib-frv
> Display the current state of FR-V shared-library code debugging
> messages.
> +@item set debug symtab-create
> +@cindex Symbol Table Creation
> +Turns on or off display of @value{GDBN} debugging info related to
> +symbol table creation. The default is off.
> +@item show debug symtab-create
> +Show the current state of symbol table creation debugging.
> @item set debug target
> @cindex target debugging info
> Turns on or off display of @value{GDBN} target debugging info. This info
> diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c
> index 097ee7f..d128f77 100644
> --- a/gdb/dwarf2read.c
> +++ b/gdb/dwarf2read.c
> @@ -81,6 +81,10 @@
> typedef struct symbol *symbolp;
> DEF_VEC_P (symbolp);
>
> +/* When non-zero, print basic high level tracing messages.
> + This is in contrast to the low level DIE reading of dwarf2_die_debug. */
> +static int dwarf2_read_debug = 0;
> +
> /* When non-zero, dump DIEs after they are read in. */
> static int dwarf2_die_debug = 0;
>
> @@ -4349,6 +4353,12 @@ dwarf2_build_psymtabs_hard (struct objfile *objfile)
> struct obstack temp_obstack;
> int i;
>
> + if (dwarf2_read_debug)
> + {
> + fprintf_unfiltered (gdb_stdlog, "Building psymtabs of objfile %s ...\n",
> + objfile->name);
> + }
> +
> dwarf2_per_objfile->reading_partial_symbols = 1;
>
> dwarf2_read_section (objfile, &dwarf2_per_objfile->info);
> @@ -4382,6 +4392,10 @@ dwarf2_build_psymtabs_hard (struct objfile *objfile)
> discard_cleanups (addrmap_cleanup);
>
> do_cleanups (back_to);
> +
> + if (dwarf2_read_debug)
> + fprintf_unfiltered (gdb_stdlog, "Done building psymtabs of %s\n",
> + objfile->name);
> }
>
> /* die_reader_func for load_partial_comp_unit. */
> @@ -5286,6 +5300,13 @@ process_queue (void)
> {
> struct dwarf2_queue_item *item, *next_item;
>
> + if (dwarf2_read_debug)
> + {
> + fprintf_unfiltered (gdb_stdlog,
> + "Expanding one or more symtabs of objfile %s ...\n",
> + dwarf2_per_objfile->objfile->name);
> + }
> +
> /* The queue starts out with one item, but following a DIE reference
> may load a new CU, adding it to the end of the queue. */
> for (item = dwarf2_queue; item != NULL; dwarf2_queue = item = next_item)
> @@ -5301,6 +5322,12 @@ process_queue (void)
> }
>
> dwarf2_queue_tail = NULL;
> +
> + if (dwarf2_read_debug)
> + {
> + fprintf_unfiltered (gdb_stdlog, "Done expanding symtabs of %s.\n",
> + dwarf2_per_objfile->objfile->name);
> + }
> }
>
> /* Free all allocated queue entries. This function only releases anything if
> @@ -5690,6 +5717,14 @@ process_full_comp_unit (struct dwarf2_per_cu_data *per_cu,
> struct cleanup *back_to, *delayed_list_cleanup;
> CORE_ADDR baseaddr;
>
> + if (dwarf2_read_debug)
> + {
> + fprintf_unfiltered (gdb_stdlog,
> + "Expanding symtab of %s at offset 0x%x\n",
> + per_cu->is_debug_types ? "TU" : "CU",
> + per_cu->offset.sect_off);
> + }
> +
> baseaddr = ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT (objfile));
>
> buildsym_init ();
> @@ -5765,6 +5800,14 @@ process_full_comp_unit (struct dwarf2_per_cu_data *per_cu,
> VEC_safe_push (dwarf2_per_cu_ptr, dwarf2_per_objfile->just_read_cus, per_cu);
>
> do_cleanups (back_to);
> +
> + if (dwarf2_read_debug)
> + {
> + fprintf_unfiltered (gdb_stdlog,
> + "Done expanding symtab of %s at offset 0x%x\n",
> + per_cu->is_debug_types ? "TU" : "CU",
> + per_cu->offset.sect_off);
> + }
> }
>
> /* Process an imported unit DIE. */
> @@ -18077,6 +18120,15 @@ conversational style, when possible."),
> &set_dwarf2_cmdlist,
> &show_dwarf2_cmdlist);
>
> + add_setshow_boolean_cmd ("dwarf2-read", no_class, &dwarf2_read_debug, _("\
> +Set debugging of the dwarf2 reader."), _("\
> +Show debugging of the dwarf2 reader."), _("\
> +When enabled, debugging messages are printed during dwarf2 reading\n\
> +and symtab expansion."),
> + NULL,
> + NULL,
> + &setdebuglist, &showdebuglist);
> +
> add_setshow_zinteger_cmd ("dwarf2-die", no_class, &dwarf2_die_debug, _("\
> Set debugging of the dwarf2 DIE reader."), _("\
> Show debugging of the dwarf2 DIE reader."), _("\
> diff --git a/gdb/elfread.c b/gdb/elfread.c
> index 679d081..1edfb27 100644
> --- a/gdb/elfread.c
> +++ b/gdb/elfread.c
> @@ -1251,6 +1251,13 @@ elf_symfile_read (struct objfile *objfile, int symfile_flags)
> asymbol **symbol_table = NULL, **dyn_symbol_table = NULL;
> asymbol *synthsyms;
>
> + if (symtab_create_debug)
> + {
> + fprintf_unfiltered (gdb_stdlog,
> + "Reading minimal symbols of objfile %s ...\n",
> + objfile->name);
> + }
> +
> init_minimal_symbol_collection ();
> back_to = make_cleanup_discard_minimal_symbols ();
>
> @@ -1443,6 +1450,9 @@ elf_symfile_read (struct objfile *objfile, int symfile_flags)
> xfree (debugfile);
> }
> }
> +
> + if (symtab_create_debug)
> + fprintf_unfiltered (gdb_stdlog, "Done reading minimal symbols.\n");
> }
>
> /* Callback to lazily read psymtabs. */
> diff --git a/gdb/minsyms.c b/gdb/minsyms.c
> index d762b2d..1070fff 100644
> --- a/gdb/minsyms.c
> +++ b/gdb/minsyms.c
> @@ -1167,6 +1167,13 @@ install_minimal_symbols (struct objfile *objfile)
>
> if (msym_count > 0)
> {
> + if (symtab_create_debug)
> + {
> + fprintf_unfiltered (gdb_stdlog,
> + "Installing %d minimal symbols of objfile %s.\n",
> + msym_count, objfile->name);
> + }
> +
> /* Allocate enough space in the obstack, into which we will gather the
> bunches of new and existing minimal symbols, sort them, and then
> compact out the duplicate entries. Once we have a final table,
> diff --git a/gdb/psymtab.c b/gdb/psymtab.c
> index 647368c..c92cab8 100644
> --- a/gdb/psymtab.c
> +++ b/gdb/psymtab.c
> @@ -1731,6 +1731,26 @@ allocate_psymtab (const char *filename, struct objfile *objfile)
> psymtab->next = objfile->psymtabs;
> objfile->psymtabs = psymtab;
>
> + if (symtab_create_debug)
> + {
> + /* Be a bit clever with debugging messages, and don't print objfile
> + every time, only when it changes. */
> + static char *last_objfile_name = NULL;
> +
> + if (last_objfile_name == NULL
> + || strcmp (last_objfile_name, objfile->name) != 0)
> + {
> + xfree (last_objfile_name);
> + last_objfile_name = xstrdup (objfile->name);
> + fprintf_unfiltered (gdb_stdlog,
> + "Creating one or more psymtabs for objfile %s ...\n",
> + last_objfile_name);
> + }
> + fprintf_unfiltered (gdb_stdlog,
> + "Created psymtab 0x%lx for module %s.\n",
> + (long) psymtab, filename);
> + }
> +
> return (psymtab);
> }
>
> diff --git a/gdb/symfile.c b/gdb/symfile.c
> index 37d98d9..01252e2 100644
> --- a/gdb/symfile.c
> +++ b/gdb/symfile.c
> @@ -2873,6 +2873,26 @@ allocate_symtab (const char *filename, struct objfile *objfile)
> symtab->next = objfile->symtabs;
> objfile->symtabs = symtab;
>
> + if (symtab_create_debug)
> + {
> + /* Be a bit clever with debugging messages, and don't print objfile
> + every time, only when it changes. */
> + static char *last_objfile_name = NULL;
> +
> + if (last_objfile_name == NULL
> + || strcmp (last_objfile_name, objfile->name) != 0)
> + {
> + xfree (last_objfile_name);
> + last_objfile_name = xstrdup (objfile->name);
> + fprintf_unfiltered (gdb_stdlog,
> + "Creating one or more symtabs for objfile %s ...\n",
> + last_objfile_name);
> + }
> + fprintf_unfiltered (gdb_stdlog,
> + "Created symtab 0x%lx for module %s.\n",
> + (long) symtab, filename);
> + }
> +
> return (symtab);
> }
>
> diff --git a/gdb/symtab.c b/gdb/symtab.c
> index 215c53d..ee37f30 100644
> --- a/gdb/symtab.c
> +++ b/gdb/symtab.c
> @@ -109,6 +109,9 @@ void _initialize_symtab (void);
>
> /* */
>
> +/* When non-zero, print debugging messages related to symtab creation. */
> +int symtab_create_debug = 0;
> +
> /* Non-zero if a file may be known by two different basenames.
> This is the uncommon case, and significantly slows down gdb.
> Default set to "off" to not slow down the common case. */
> @@ -5014,5 +5017,13 @@ one base name, and gdb will do file name comparisons more efficiently."),
> NULL, NULL,
> &setlist, &showlist);
>
> + add_setshow_boolean_cmd ("symtab-create", no_class, &symtab_create_debug,
> + _("Set debugging of symbol table creation."),
> + _("Show debugging of symbol table creation."), _("\
> +When enabled, debugging messages are printed when building symbol tables."),
> + NULL,
> + NULL,
> + &setdebuglist, &showdebuglist);
> +
> observer_attach_executable_changed (symtab_observer_executable_changed);
> }
> diff --git a/gdb/symtab.h b/gdb/symtab.h
> index 8ee187e..57f618d 100644
> --- a/gdb/symtab.h
> +++ b/gdb/symtab.h
> @@ -1250,6 +1250,8 @@ void fixup_section (struct general_symbol_info *ginfo,
>
> struct objfile *lookup_objfile_from_block (const struct block *block);
>
> +extern int symtab_create_debug;
> +
> extern int basenames_may_differ;
>
> int compare_filenames_for_search (const char *filename,
next prev parent reply other threads:[~2012-06-26 15:45 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-06-19 22:27 Doug Evans
2012-06-22 14:06 ` Tom Tromey
2012-06-23 22:58 ` Doug Evans
2012-06-26 15:45 ` Doug Evans [this message]
2012-06-26 16:26 ` Eli Zaretskii
2012-06-26 20:16 ` Doug Evans
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CADPb22SzBXCRCufriTYyj=ODfmtH-d=TzA-k8dogFizgFNhK0w@mail.gmail.com' \
--to=dje@google.com \
--cc=eliz@gnu.org \
--cc=gdb-patches@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox