Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Michael Snyder <msnyder@vmware.com>
To: Pedro Alves <pedro@codesourcery.com>
Cc: "gdb-patches@sourceware.org" <gdb-patches@sourceware.org>
Subject: Re: pending breakpoints without any symbols loaded yet
Date: Tue, 19 Aug 2008 22:48:00 -0000	[thread overview]
Message-ID: <48AB4D22.8050704@vmware.com> (raw)
In-Reply-To: <200808182358.49164.pedro@codesourcery.com>

This looks good to me...

Pedro Alves wrote:
> Ping?
> 
> Is has been a couple of months, so below are some examples of what this patch
> enables.
> 
> Before, this was possible (we have symbols loaded):
> 
>> gdb ./gdb/gdb --quiet
> (gdb) b foobar
> Function "foobar" not defined.
> Make breakpoint pending on future shared library load? (y or [n]) y
> Breakpoint 1 (foobar) pending.
> (gdb) info b
> Num     Type           Disp Enb Address            What
> 1       breakpoint     keep y   <PENDING>          foobar
> (gdb)
> 
> But this was not (no symbols loaded)::
> 
>> gdb --quiet
> (gdb) b main
> No symbol table is loaded.  Use the "file" command.
> (gdb)
> 
> With the patch installed, this is now possible (no symbols loaded):
> 
>> ./gdb/gdb --quiet
> (gdb) b main
> No symbol table is loaded.  Use the "file" command.
> Make breakpoint pending on future shared library load? (y or [n]) y
> Breakpoint 1 (main) pending.
> (gdb) info breakpoints
> Num     Type           Disp Enb Address    What
> 1       breakpoint     keep y   <PENDING>  main
> 
> Now load symbols:
> 
> (gdb) file gdb/gdb
> Reading symbols from /home/pedro/gdb/pending/build/gdb/gdb...done.
> 
> And the pending breakpoint is resolved using the normal
> pending breakpoint mechanisms:
> 
> (gdb) info breakpoints
> Num     Type           Disp Enb Address            What
> 1       breakpoint     keep y   0x000000000044ee37 in main
> at ../../src/gdb/gdb.c:28
> (gdb) r
> Starting program: /home/pedro/gdb/pending/build/gdb/gdb
> [Thread debugging using libthread_db enabled]
> 
> Breakpoint 1, main (argc=1, argv=0x7fffffffe458) at ../../src/gdb/gdb.c:28
> 28        memset (&args, 0, sizeof args);
> (gdb)
> 
> Retested on x86_64-unknown-linux-gnu, no regressions,
> new test passes.
> 
> --
> Pedro Alves
> 
> 
> On Thursday 03 April 2008 20:31:11, Pedro Alves wrote:
>> Hi all,
>>
>> This is a follow up to a discussion that started a few months ago
>> related to setting breakpoints in shared lib when you don't have
>> any symbols in the main executable.  This is more visible
>> on Windows when you want debugging a dll you build with gcc that
>> is loaded by a stripped application built with MSVC.  We can't
>> debug the MSVC built executable, but we should be able
>> to debug the code in the dll.  Users should be able to set
>> breakpoints in the dll before it gets loaded, but gdb refuses
>> to, claiming:
>>
>> (gdb) b func_in_dll
>> No symbol table is loaded.  Use the "file" command.
>>
>> Original patch and discussion here:
>> [Debugging a Vlc dll with GDB.]
>> http://sourceware.org/ml/gdb-patches/2007-12/msg00112.html
>>
>> Coincidently, Matt Rice was asking on IRC why he couldn't
>> set pending breakpoints in his .gdbinit file, which
>> made me come back to the issue.  It's exactly the same
>> checks in gdb.  This patch should also fix his use case.
>>
>> At the time of that thread, I proposed a patch the removes the
>> limitation, by letting the user set pending breakpoints even
>> if no symbols are loaded yet, but I also changed the
>> messages we output, but in a form not everyone liked.  As
>> we were discussing then, the messages gdb prints aren't
>> 100% accurate -- if we let the user set pending breakpoints
>> before an exec file is loaded, the question we ask is still
>> "Make breakapoints pending on future shared library load?".  I
>> spent quite some time staring at the messages we output, and
>> trying to come up with a good generic one, but the ones
>> I came up with, still had this feeling they would be
>> rejected again.  :-)
>>
>> So, this time I propose a code change only.  Let's make
>> message changes separately.
>>
>> Here goes the patch.  Testcase included.  Tested on
>> x86_64-unknown-linux-gnu.
>>
>> ------------------------------------------------------------------------
>>
>> 2008-04-03  Pedro Alves  <pedro@codesourcery.com>
>>
>> 	gdb/
>> 	* linespec.c (symtab_from_filename): Also throw NOT_FOUND_ERROR if
>> 	there are no symbols loaded, instead of throwing a generic error.
>> 	(decode_variable): Likewise.
>>
>> 	gdb/testsuite/
>> 	* gdb.base/pending.exp: Test pending breakpoints without symbols
>> 	loaded.
>>
>> ---
>>  gdb/linespec.c                     |   15 +++++++++------
>>  gdb/testsuite/gdb.base/pending.exp |   26 ++++++++++++++++++++++++++
>>  2 files changed, 35 insertions(+), 6 deletions(-)
>>
>> Index: src/gdb/linespec.c
>> ===================================================================
>> --- src.orig/gdb/linespec.c	2008-08-18 21:42:42.000000000 +0100
>> +++ src/gdb/linespec.c	2008-08-18 21:43:30.000000000 +0100
>> @@ -1556,10 +1556,11 @@ symtab_from_filename (char **argptr, cha
>>    file_symtab = lookup_symtab (copy);
>>    if (file_symtab == 0)
>>      {
>> -      if (!have_full_symbols () && !have_partial_symbols ())
>> -	error (_("No symbol table is loaded.  Use the \"file\" command."));
>>        if (not_found_ptr)
>>  	*not_found_ptr = 1;
>> +      if (!have_full_symbols () && !have_partial_symbols ())
>> +	throw_error (NOT_FOUND_ERROR,
>> +		     _("No symbol table is loaded.  Use the \"file\" command."));
>>        throw_error (NOT_FOUND_ERROR, _("No source file named %s."), copy);
>>      }
>>  
>> @@ -1760,12 +1761,14 @@ decode_variable (char *copy, int funfirs
>>    if (msymbol != NULL)
>>      return minsym_found (funfirstline, msymbol);
>>  
>> -  if (!have_full_symbols () &&
>> -      !have_partial_symbols () && !have_minimal_symbols ())
>> -    error (_("No symbol table is loaded.  Use the \"file\" command."));
>> -
>>    if (not_found_ptr)
>>      *not_found_ptr = 1;
>> +
>> +  if (!have_full_symbols ()
>> +      && !have_partial_symbols ()
>> +      && !have_minimal_symbols ())
>> +    throw_error (NOT_FOUND_ERROR,
>> +		 _("No symbol table is loaded.  Use the \"file\" command."));
>>    throw_error (NOT_FOUND_ERROR, _("Function \"%s\" not defined."), copy);
>>  }
>>  
>> Index: src/gdb/testsuite/gdb.base/pending.exp
>> ===================================================================
>> --- src.orig/gdb/testsuite/gdb.base/pending.exp	2008-08-18 21:42:42.000000000 +0100
>> +++ src/gdb/testsuite/gdb.base/pending.exp	2008-08-18 21:43:30.000000000 +0100
>> @@ -54,6 +54,32 @@ if { [gdb_compile_shlib $libsrc $lib_sl 
>>  gdb_exit
>>  gdb_start
>>  gdb_reinitialize_dir $srcdir/$subdir
>> +
>> +gdb_test_multiple "break pendfunc1" "set pending breakpoint" {
>> +     -re ".*Make breakpoint pending.*y or \\\[n\\\]. $" {
>> +	    gdb_test "y" "Breakpoint.*pendfunc1.*pending." "set pending breakpoint (without symbols)"
>> +     }
>> +}
>> +
>> +gdb_test "info break" \
>> +    "Num     Type\[ \]+Disp Enb Address\[ \]+What.*
>> +\[0-9\]+\[\t \]+breakpoint     keep y.*PENDING.*pendfunc1.*" \
>> +"single pending breakpoint info (without symbols)"
>> +
>> +gdb_load ${binfile}
>> +gdb_load_shlibs $lib_sl
>> +
>> +set pendfunc1_loc [gdb_get_line_number "y = x + 4" ${libfile}.c]
>> +gdb_test "run" \
>> +".*Breakpoint.*pendfunc1.*at.*pendshr.c:$pendfunc1_loc.*y = x \\+ 4.*" \
>> +"run to resolved breakpoint 1 (without symbols)"
>> +
>> +# Restart with a fresh gdb.
>> +
>> +gdb_exit
>> +gdb_start
>> +gdb_reinitialize_dir $srcdir/$subdir
>> +
>>  gdb_load ${binfile}
>>  gdb_load_shlibs $lib_sl
>>  


  reply	other threads:[~2008-08-19 22:48 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-04-03 20:24 Pedro Alves
2008-08-18 22:58 ` Pedro Alves
2008-08-19 22:48   ` Michael Snyder [this message]
2008-08-20 11:49     ` Pedro Alves

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=48AB4D22.8050704@vmware.com \
    --to=msnyder@vmware.com \
    --cc=gdb-patches@sourceware.org \
    --cc=pedro@codesourcery.com \
    /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