public inbox for gdb@sourceware.org
 help / color / mirror / Atom feed
* jumping within headers leads to unreasonable jump request
@ 2024-01-11 20:26 Simon Sobisch
  0 siblings, 0 replies; only message in thread
From: Simon Sobisch @ 2024-01-11 20:26 UTC (permalink / raw)
  To: gdb

Dar GDB users and hackers,

I've tried several things, but failed (all in GDB 13.2, but the NEWS 
file has no entry that says a change was done anywhere related).


I _think_ the following should just work out of the box:

     jump +1

by always jumping to the next source line - but this isn't the case.

What obviously is happening is that the +1 is resolved to an address by 
using the current source name; and if the same source was used in 
multiple places - for example there was an `#include dbg_help.h` and you 
the current frame is in there, then tbreak +1 would create 93 locations 
- then you get an "unreasonable jump request" response.


Is it possible to change that so from all these 93 locations the single 
one in the current frame is used (the current active frame would be the 
only "safe" jump in any case)?
That would still not work if the include was done in the same function, 
but would work for nearly all cases already.  ... but this would break 
the common handling of "+1" bei


A separate thing is setting the breakpoint. How do we achieve to set a 
breakpoint by source reference only in the current frame?

As GDB 14 includes "." in "list ." to mean the current execution point, 
I suggest to add that in the linespec for "-source ." (meaning the 
current source) and for "-function ." (meaning the current function).

What do you think of this addition?


This could then also be used for the jump case:

     jump -func . -line +1


... apart from that this currently doesn't work when coded explicit (I 
consider this a bug, do you agree?)

This can also be seen with tbreak (to make it even more clear let's make 
the line explicit)

     tbreak -func myfunc -line 44 -source myinc.h

does NOT create a breakpoint at myinc.h:44 in the function myfunc, but 
creates a breakpoint (without any error message that the other options 
are ignored!) at myfunc() (defined in func.c:140).


Is there a way to set a breakpoint (or jump to) an address that matches 
"the current source in the current frame at line N"?

The only _workaround_ I've found so far is

     tbreak 44
     pipe info breakpoint $bpnum | grep myfunc
     d $bpnum
     # manually enter the address seen in the "pipe i b" above
     tbreak 0x00007fffe67b82e3

which of course could be moved out to a python defined command to remove 
all the manual work - but there must be an easier way, no?

Thanks for any input,
Simon

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2024-01-11 20:27 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-01-11 20:26 jumping within headers leads to unreasonable jump request Simon Sobisch

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).