Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Simon Marchi <simon.marchi@ericsson.com>
To: John Baldwin <jhb@FreeBSD.org>
Cc: "gdb-patches@sourceware.org" <gdb-patches@sourceware.org>
Subject: Re: [PATCH] Add "set debug minsyms" command
Date: Fri, 21 Dec 2018 23:07:00 -0000	[thread overview]
Message-ID: <fe43f1a7-024e-0e98-c0c5-21ed718b452f@ericsson.com> (raw)
In-Reply-To: <18230036-5562-b705-a9b5-b9e435d63c32@FreeBSD.org>

On 2018-12-21 4:59 p.m., John Baldwin wrote:
>> diff --git a/gdb/auto-load.c b/gdb/auto-load.c
>> index 33d282afe83..e35fd29426b 100644
>> --- a/gdb/auto-load.c
>> +++ b/gdb/auto-load.c
>> @@ -1175,6 +1175,8 @@ load_auto_scripts_for_objfile (struct objfile *objfile)
>>  static void
>>  auto_load_new_objfile (struct objfile *objfile)
>>  {
>> +  std::vector <int> c;
>> +  c.clear();
>>    if (!objfile)
>>      {
>>        /* OBJFILE is NULL when loading a new "main" symbol-file.  */
> 
> This seems spurious (also not in ChangeLog)?
> 
>> diff --git a/gdb/elfread.c b/gdb/elfread.c
>> index 71e6fcca6ec..359089b166c 100644
>> --- a/gdb/elfread.c
>> +++ b/gdb/elfread.c
>> @@ -249,6 +249,8 @@ elf_symtab_read (minimal_symbol_reader &reader,
>>  	  continue;
>>  	}
>>  
>> +      printf(" --- %s\n", sym->name);
>> +
>>        /* Skip "special" symbols, e.g. ARM mapping symbols.  These are
>>  	 symbols which do not correspond to objects in the symbol table,
>>  	 but have some other target-specific meaning.  */
> 
> Likewise.

Woops, I meant to remove those changes, looks like I amended instead by mistake.

>> diff --git a/gdb/minsyms.c b/gdb/minsyms.c
>> index 0f854422e0f..98ce969eed0 100644
>> --- a/gdb/minsyms.c
>> +++ b/gdb/minsyms.c
>> @@ -1112,6 +1143,11 @@ minimal_symbol_reader::record_full (const char *name, int name_len,
>>    if (ms_type == mst_file_text && startswith (name, "__gnu_compiled"))
>>      return (NULL);
>>  
>> +  if (debug_minsyms)
>> +    printf_unfiltered
>> +      ("minsym: recording minsym type: %-21s  addr: 0x%016llx  section: %-5d  name: %s\n",
>> +       mst_str (ms_type), (long long) address, section, name);
> 
> Maybe plongest() instead of %llx?  Or does plongest not do the leading 0 fill
> you want?
I don't really mind about the leading 0s, it's just that having fixed width, right aligned
and padded with spaces would give something like "0x       1234".  But I ended up using
hex_string.

Here's v2:


From 388db2a2b0299ac769943f7840c3cd4e01a216ac Mon Sep 17 00:00:00 2001
From: Simon Marchi <simon.marchi@ericsson.com>
Date: Thu, 20 Dec 2018 11:43:52 -0500
Subject: [PATCH] Add debug output for recorded minsyms

While discussing this issue:

  https://sourceware.org/ml/gdb-patches/2018-12/threads.html#00082

I added a printf to be able to quickly see all minimal symbols recorded
by GDB.  I thought it would be useful to have it built-in, for the
future.

  Recording minsym:  mst_data                         0x400780    15  _IO_stdin_used
  Recording minsym:  mst_text                         0x400700    13  __libc_csu_init
  Recording minsym:  mst_bss                          0x601058    25  _end

New since v1:

- Remove unrelated changes
- Don't print field names
- Use hex_string to print addresses
- Don't add a new "set debug" knob, use "set debug symtab-create" instead.
  Output this when the value is >= 2, since there can be quite a lot of
  symbols.

gdb/ChangeLog:

	* minsyms.c (mst_str): New.
	(minimal_symbol_reader::record_full): Add debug output.
---
 gdb/minsyms.c | 31 +++++++++++++++++++++++++++++++
 1 file changed, 31 insertions(+)

diff --git a/gdb/minsyms.c b/gdb/minsyms.c
index 0f854422e0f..71d630374ac 100644
--- a/gdb/minsyms.c
+++ b/gdb/minsyms.c
@@ -1080,6 +1080,33 @@ minimal_symbol_reader::record (const char *name, CORE_ADDR address,
   record_with_info (name, address, ms_type, section);
 }

+/* Convert an enumerator of type minimal_symbol_type to its string
+   representation.  */
+
+static const char *
+mst_str (minimal_symbol_type t)
+{
+#define MST_TO_STR(x) case x: return #x;
+  switch (t)
+  {
+    MST_TO_STR (mst_unknown);
+    MST_TO_STR (mst_text);
+    MST_TO_STR (mst_text_gnu_ifunc);
+    MST_TO_STR (mst_slot_got_plt);
+    MST_TO_STR (mst_data);
+    MST_TO_STR (mst_bss);
+    MST_TO_STR (mst_abs);
+    MST_TO_STR (mst_solib_trampoline);
+    MST_TO_STR (mst_file_text);
+    MST_TO_STR (mst_file_data);
+    MST_TO_STR (mst_file_bss);
+
+    default:
+      return "mst_???";
+  }
+#undef MST_TO_STR
+}
+
 /* See minsyms.h.  */

 struct minimal_symbol *
@@ -1112,6 +1139,10 @@ minimal_symbol_reader::record_full (const char *name, int name_len,
   if (ms_type == mst_file_text && startswith (name, "__gnu_compiled"))
     return (NULL);

+  if (symtab_create_debug >= 2)
+    printf_unfiltered ("Recording minsym:  %-21s  %18s  %4d  %s\n",
+		       mst_str (ms_type), hex_string (address), section, name);
+
   if (m_msym_bunch_index == BUNCH_SIZE)
     {
       newobj = XCNEW (struct msym_bunch);
-- 
2.20.1



  reply	other threads:[~2018-12-21 23:07 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20181221214706.26981-1-simon.marchi@ericsson.com>
2018-12-21 21:59 ` John Baldwin
2018-12-21 23:07   ` Simon Marchi [this message]
     [not found]     ` <798386c1-43f5-862e-1ee4-6e439ccf3133@FreeBSD.org>
2018-12-22  2:20       ` Simon Marchi
2018-12-22  7:29         ` Eli Zaretskii
2018-12-22 15:17           ` Simon Marchi
2018-12-24 20:51             ` Tom Tromey
2018-12-26 16:43               ` Simon Marchi
2018-12-26 17:19                 ` Eli Zaretskii
2018-12-26 17:24                   ` Simon Marchi
2018-12-26 18:48                     ` Eli Zaretskii
2018-12-29 18:55                 ` Tom Tromey

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=fe43f1a7-024e-0e98-c0c5-21ed718b452f@ericsson.com \
    --to=simon.marchi@ericsson.com \
    --cc=gdb-patches@sourceware.org \
    --cc=jhb@FreeBSD.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