public inbox for gdb@sourceware.org
 help / color / mirror / Atom feed
From: Jim Ingham <jingham@apple.com>
To: gdb@sources.redhat.com
Subject: Re: Unambiguously specifying source locations
Date: Mon, 13 Oct 2003 17:24:00 -0000	[thread overview]
Message-ID: <38B36630-FDA2-11D7-BB88-000A958F4C44@apple.com> (raw)
In-Reply-To: <1065875539.13549.ezmlm@sources.redhat.com>

I think the intent here is great!

I have a heartfelt plea, however, from one who while not as 
battle-scarred as some others, have waded my way through plenty of 
decode_line_1 bugs...

Is there any way we can not have to keep overloading the expression 
parser with more specifications?  It seems to me this is just a way to 
obfuscate the user's intent so that we can get it wrong trying to 
decode it later.  Daniel's proposed syntax - no offense intended - is 
sufficiently awful that it should give us pause.  Would:

break -shlib foo.dylib -file foo.c MyStaticFunction

be all that awful?  This is unambiguous, represents the user's intent 
exactly, is not too hard to type, and trivial to parse.  Then 
internally, the breakpoint could actually hold all these separate bits 
separately, rather than munging them into a canonical form which we can 
trip over later on...

We will probably have to support the specifications that we do now for 
ever - though adding switches for them would allow unambiguous entry 
and would probably be taken up by a good number of users cause it is 
almost impossible to get wrong...

Jim

On Oct 11, 2003, at 5:32 AM, gdb-digest-help@sources.redhat.com wrote:

> This isn't a proposal - I haven't clearly thought out the details - 
> just
> some ramblings on a problem.
>
> I would like to have a way to clearly identify a location, not by 
> address.
> Primarily this would be for breakpoints; when we re-read an objfile's
> symbols, we need to replace breakpoints somehow, and the more of the 
> user's
> intent we can preserve the better.  Obviously this is not a perfectly
> solvable problem, but we can do pretty well.
>
> It's an important problem, too.  Not only is recompile/reload a pretty
> common thing to do, but IDEs which save breakpoints across sessions 
> would
> use this also.  Et cetera.
>
> I think it's only source locations that I need to identify in this 
> way, in
> the short term, but we should use an extensible syntax.  For a
> way-beyond-current-state example, consider an inlined function with 
> multiple
> inlined instances.  One of the simpler things we could do is:
>
>   record the number of instances in this objfile before reloading
>   check the number of instances in this objfile after reloading
>   if same, then we can preserve things like the breakpoint enabled 
> state
>     to the new set
>   if not, punt - enable all?  warn?
>
> The goal there being to preserve the status of particular breakpoints 
> across
> reload, as best as we can, when unrelated changes are made to the 
> source.
> Someone fixes emit_foo () and recompiles and we try not to disturb 
> their
> eight disabled and one enabled breakpoint on inlined copies of 
> obstack_alloc
> where they were tracking the allocation of the bad object.
>
> We could be much more thorough.  Try this on for size:
>   Record the source location of the emitted function which contains 
> each
>     inlined instance, as unambiguously as we can.
>   Record the inlining path.
>
> The result would look something like (I don't like this syntax, just
> illustrating):
>   [libfoo.so.2][foo-1.cc:foo_func:75][bar-1.h:inline_one:33]\
>     [bar-1.h:inline_two:36]
> Then after reload if the path still leads to an inlined copy of 
> inline_two
> we can re-establish the breakpoint.  Or there are various fuzzy 
> matching
> things we could do.  Et cetera.
>
> Generating such paths would be useful for output anyway; and if we can 
> do
> them in such a way as to accept them for input too, that would be 
> useful to
> our users.  We could also accept as input ambiguous paths and do 
> basically
> wildcarding:
>   break [libfoo.so.2][bar-1.h]inline_two
>
> Wouldn't that be nice?
>
> The use of braces is not entirely coincidental.  decode_line_1 
> currently
> does not accept anything that starts with a '[' as far as I can see; 
> ObjC
> selectors always have +[ or -[.  Using braces simplifies quoting and 
> parsing
> quite a bit.  And it could be extended as necessary without too much
> trouble.
>
> There are other problems: for instance, we might want to use linker 
> names
> for non-inlined functions where possible, for GDB-generated location
> descriptions; that would handle keeping track of which constructor we 
> were
> stopped on.  Otherwise we'd need some other method for that.
>
> Another nice thing to have might be an element in that list describing
> C++ template instantiation.  Not sure if that's necessary or should 
> just be
> added to the function name as needed.
>
> Include paths may also be needed.  This happens in C, with static 
> functions
> in headers.  Here's an example that bites me all the time:
>   [libbfd.so][elf32-i386.c][elflink.h:2300]
>   [libbfd.so][elf32-sparc.c][elflink.h:2300]
> or maybe it should be:
>   [libbfd.so][elf32-i386.c:elflink.h:2300]
>   [libbfd.so][elf32-sparc.c:elflink.h:2300]
> The latter, I think.
>
> Right now the equivalent to this is handled in 
> build_canonical_line_spec.
> It's a little simple-minded; there are plenty of cases it doesn't 
> handle.
> It would be nice to do better.
>
> Any specification of this should be explicit about quoting rules, 
> comma,
> dammit.
>
> What other thoughts do you all have?  Am I on the right track, should 
> we
> draw up a formal specification for these?
>
> -- 
> Daniel Jacobowitz
> MontaVista Software                         Debian GNU/Linux Developer
>
--
Jim Ingham                                   jingham@apple.com
Developer Tools
Apple Computer

       reply	other threads:[~2003-10-13 17:24 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <1065875539.13549.ezmlm@sources.redhat.com>
2003-10-13 17:24 ` Jim Ingham [this message]
2003-10-13 17:32   ` Daniel Jacobowitz
     [not found] <1066172792.26963.ezmlm@sources.redhat.com>
2003-10-14 23:47 ` Jim Ingham
     [not found] <drow@mvista.com>
2003-10-10 15:30 ` Daniel Jacobowitz
2003-10-10 15:44   ` David Ayers
2003-10-10 15:46     ` Daniel Jacobowitz
2003-10-11  2:21   ` Felix Lee

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=38B36630-FDA2-11D7-BB88-000A958F4C44@apple.com \
    --to=jingham@apple.com \
    --cc=gdb@sources.redhat.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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).