public inbox for gdb@sourceware.org
 help / color / mirror / Atom feed
* Is it possible to "inject" into the stack or show non-stack entries via frame decorator api?
@ 2021-06-24 22:24 Simon Sobisch
  2021-07-17 14:22 ` Simon Sobisch
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Simon Sobisch @ 2021-06-24 22:24 UTC (permalink / raw)
  To: gdb

Scenario:

the current call-stack currently looks like

#0 func3
#1 func3_wrapper
#2 func2
#3 func2_wrapper
#4 func1
#5 func1_wrapper
#6 main


Using frame filters it is no problem to change that to either

#0 func3
#2 func2
#4 func1

or

#0 func3
    #1 func3_wrapper
#2 func2
    #3 func2_wrapper
#4 func1
    #5 func1_wrapper
#6 main


Question: Is it possibly to also add a "virtual" stack entry (one could 
select/up/down to), or at least show it in the backtrace?

Something like the following:

#0 func3 at ...
    #0.1  func3_part_a at ...
    #0.2  func3_part_c at ...
    #0.3  func3_part_b at ...
    #0.4  func3_part_a at ...
    #0.5  func3_start at ...
#2 func2 at ...


Background:
Each of those "func" entries in the stack have an internal frame 
handling using a linked list that contains label address pointers. It 
would be very cool to list those directly (currently only done with 
additional commands local-backtrace and list-local-frame which I'd like 
to drop).

I _guess_ adding those to the shown stack may be possible, but likely 
only with telling GDB about those (patching GDB), but maybe there's a 
way to at least print those with their positions in "bt" using a frame 
decorator?

Thanks for answers,
Simon



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Is it possible to "inject" into the stack or show non-stack entries via frame decorator api?
  2021-06-24 22:24 Is it possible to "inject" into the stack or show non-stack entries via frame decorator api? Simon Sobisch
@ 2021-07-17 14:22 ` Simon Sobisch
  2021-07-19 15:49 ` How/where is the mi watchpoint-trigger / EXEC_ASYNC_WATCHPOINT_TRIGGER raised? Simon Sobisch
  2021-11-28 15:40 ` Is it possible to "inject" into the stack or show non-stack entries via frame decorator api? Simon Sobisch
  2 siblings, 0 replies; 4+ messages in thread
From: Simon Sobisch @ 2021-07-17 14:22 UTC (permalink / raw)
  To: gdb

Just a friendly ping - any insight highly appreciated.

> Scenario:
> 
> the current call-stack currently looks like
> 
> #0 func3
> #1 func3_wrapper
> #2 func2
> #3 func2_wrapper
> #4 func1
> #5 func1_wrapper
> #6 main
> 
> 
> Using frame filters it is no problem to change that to either
> 
> #0 func3
> #2 func2
> #4 func1
> 
> or
> 
> #0 func3
>     #1 func3_wrapper
> #2 func2
>     #3 func2_wrapper
> #4 func1
>     #5 func1_wrapper
> #6 main
> 
> 
> Question: Is it possibly to also add a "virtual" stack entry (one could 
> select/up/down to), or at least show it in the backtrace?
> 
> Something like the following:
> 
> #0 func3 at ...
>     #0.1  func3_part_a at ...
>     #0.2  func3_part_c at ...
>     #0.3  func3_part_b at ...
>     #0.4  func3_part_a at ...
>     #0.5  func3_start at ...
> #2 func2 at ...
> 
> 
> Background:
> Each of those "func" entries in the stack have an internal frame 
> handling using a linked list that contains label address pointers. It 
> would be very cool to list those directly (currently only done with 
> additional commands local-backtrace and list-local-frame which I'd like 
> to drop).
> 
> I _guess_ adding those to the shown stack may be possible, but likely 
> only with telling GDB about those (patching GDB), but maybe there's a 
> way to at least print those with their positions in "bt" using a frame 
> decorator?
> 
> Thanks for answers,
> Simon

^ permalink raw reply	[flat|nested] 4+ messages in thread

* How/where is the mi watchpoint-trigger / EXEC_ASYNC_WATCHPOINT_TRIGGER raised?
  2021-06-24 22:24 Is it possible to "inject" into the stack or show non-stack entries via frame decorator api? Simon Sobisch
  2021-07-17 14:22 ` Simon Sobisch
@ 2021-07-19 15:49 ` Simon Sobisch
  2021-11-28 15:40 ` Is it possible to "inject" into the stack or show non-stack entries via frame decorator api? Simon Sobisch
  2 siblings, 0 replies; 4+ messages in thread
From: Simon Sobisch @ 2021-07-19 15:49 UTC (permalink / raw)
  To: gdb

I've found the definition in mi/mi-common.h and the translation in 
mi/mi-common.c, but I have no clue:

1 Understanding GDB:
Where is it actually raised? (I _assume_ it somewhere happens if a 
watchpoint's stop method returns True?

2 Extending GDB:
Can I manually trigger the event from a breakpoint? The reasoning behind 
this is that my watchpoint implementation always returns False after 
setting a breakpoint at the place where the user "expects" to see the 
change (when returning to user code, not multiple times in the library 
code). While it "looks" nice on the GDB console MI-Frontends don't get 
any watchpoint events that way.

Thanks
Simon

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Is it possible to "inject" into the stack or show non-stack entries via frame decorator api?
  2021-06-24 22:24 Is it possible to "inject" into the stack or show non-stack entries via frame decorator api? Simon Sobisch
  2021-07-17 14:22 ` Simon Sobisch
  2021-07-19 15:49 ` How/where is the mi watchpoint-trigger / EXEC_ASYNC_WATCHPOINT_TRIGGER raised? Simon Sobisch
@ 2021-11-28 15:40 ` Simon Sobisch
  2 siblings, 0 replies; 4+ messages in thread
From: Simon Sobisch @ 2021-11-28 15:40 UTC (permalink / raw)
  To: gdb

To answer my answer: No, it is currently not possible to do this via the 
frame decorator, there is a gdb.FrameDecoratpr.SymValueWrapper (which 
allows to add synthetic variables for frame locals), but nothing like a 
SymFrameWrapper which would allow to insert a synthetic frame.

So the option I've used is to

1st create a frame filter with eliding frames, like below (#0, #2, #4 
sample), which is by default deactivated

2nd add a new gdb.command of type gdb.COMMAND_STACK that does

   ffilter = gdb.frame_filters["my-eliding-filter"]
   ffilter.enabled = True
   btlines = gdb.execute("backtrace", True, True).split("\n")
   for line in btlines:
     print (line)
     # then print additional content
   ffilter.enabled = False

This has the down-side that the coloring gets lost, but is otherwise 
"working".

Simon


Am 25.06.2021 um 00:24 schrieb Simon Sobisch:
> Scenario:
> 
> the current call-stack currently looks like
> 
> #0 func3
> #1 func3_wrapper
> #2 func2
> #3 func2_wrapper
> #4 func1
> #5 func1_wrapper
> #6 main
> 
> 
> Using frame filters it is no problem to change that to either
> 
> #0 func3
> #2 func2
> #4 func1
> 
> or
> 
> #0 func3
>     #1 func3_wrapper
> #2 func2
>     #3 func2_wrapper
> #4 func1
>     #5 func1_wrapper
> #6 main
> 
> 
> Question: Is it possibly to also add a "virtual" stack entry (one could 
> select/up/down to), or at least show it in the backtrace?
> 
> Something like the following:
> 
> #0 func3 at ...
>     #0.1  func3_part_a at ...
>     #0.2  func3_part_c at ...
>     #0.3  func3_part_b at ...
>     #0.4  func3_part_a at ...
>     #0.5  func3_start at ...
> #2 func2 at ...
> 
> 
> Background:
> Each of those "func" entries in the stack have an internal frame 
> handling using a linked list that contains label address pointers. It 
> would be very cool to list those directly (currently only done with 
> additional commands local-backtrace and list-local-frame which I'd like 
> to drop).
> 
> I _guess_ adding those to the shown stack may be possible, but likely 
> only with telling GDB about those (patching GDB), but maybe there's a 
> way to at least print those with their positions in "bt" using a frame 
> decorator?
> 
> Thanks for answers,
> Simon
> 
> 

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2021-11-28 15:40 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-24 22:24 Is it possible to "inject" into the stack or show non-stack entries via frame decorator api? Simon Sobisch
2021-07-17 14:22 ` Simon Sobisch
2021-07-19 15:49 ` How/where is the mi watchpoint-trigger / EXEC_ASYNC_WATCHPOINT_TRIGGER raised? Simon Sobisch
2021-11-28 15:40 ` Is it possible to "inject" into the stack or show non-stack entries via frame decorator api? 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).