[PATCH v2] Fix raw-frame-arguments in combination with frame-filters

Hannes Domani ssbssa@yahoo.de
Mon May 17 10:54:08 GMT 2021


 Am Montag, 17. Mai 2021, 11:48:27 MESZ hat Andrew Burgess <andrew.burgess@embecosm.com> Folgendes geschrieben:

> * Hannes Domani via Gdb-patches <gdb-patches@sourceware.org> [2021-01-31 14:46:11 +0100]:
>
> > Currently, if frame-filters are active, raw-values is used instead of
> > raw-frame-arguments to decide if a pretty-printer should be invoked for
> > frame arguments in a backtrace.
> >
> > In this example, "super struct" is the output of the pretty-printer:
> >
> >    (gdb) disable frame-filter global BasicFrameFilter
> >    (gdb) bt
> >    #0  foo (x=42, ss=super struct = {...}) at C:/src/repos/gdb-testsuite/gdb/testsuite/gdb.python/py-frame-args.c:47
> >    #1  0x004016aa in main () at C:/src/repos/gdb-testsuite/gdb/testsuite/gdb.python/py-frame-args.c:57
> >
> > If no frame-filter is active, then the raw-values print option does not
> > affect the backtrace output:
> >
> >    (gdb) set print raw-values on
> >    (gdb) bt
> >    #0  foo (x=42, ss=super struct = {...}) at C:/src/repos/gdb-testsuite/gdb/testsuite/gdb.python/py-frame-args.c:47
> >    #1  0x004016aa in main () at C:/src/repos/gdb-testsuite/gdb/testsuite/gdb.python/py-frame-args.c:57
> >    (gdb) set print raw-values off
> >
> > Instead, the raw-frame-arguments option disables the pretty-printer in the
> > backtrace:
> >
> >    (gdb) bt -raw-frame-arguments on
> >    #0  foo (x=42, ss=...) at C:/src/repos/gdb-testsuite/gdb/testsuite/gdb.python/py-frame-args.c:47
> >    #1  0x004016aa in main () at C:/src/repos/gdb-testsuite/gdb/testsuite/gdb.python/py-frame-args.c:57
> >
> > But if a frame-filter is active, the same rules don't apply.
> > The option raw-frame-arguments is ignored, but raw-values decides if the
> > pretty-printer is used:
> >
> >    (gdb) enable frame-filter global BasicFrameFilter
> >    (gdb) bt
> >    #0  foo (x=42, ss=super struct = {...}) at C:/src/repos/gdb-testsuite/gdb/testsuite/gdb.python/py-frame-args.c:47
> >    #1  0x004016aa in main () at C:/src/repos/gdb-testsuite/gdb/testsuite/gdb.python/py-frame-args.c:57
> >    (gdb) set print raw-values on
> >    (gdb) bt
> >    #0  foo (x=42, ss=...) at C:/src/repos/gdb-testsuite/gdb/testsuite/gdb.python/py-frame-args.c:47
> >    #1  0x004016aa in main () at C:/src/repos/gdb-testsuite/gdb/testsuite/gdb.python/py-frame-args.c:57
> >    (gdb) set print raw-values off
> >    (gdb) bt -raw-frame-arguments on
> >    #0  foo (x=42, ss=super struct = {...}) at C:/src/repos/gdb-testsuite/gdb/testsuite/gdb.python/py-frame-args.c:47
> >    #1  0x004016aa in main () at C:/src/repos/gdb-testsuite/gdb/testsuite/gdb.python/py-frame-args.c:57
> >
> > So this adds the PRINT_RAW_FRAME_ARGUMENTS flag to frame_filter_flag, which
> > is then used in the frame-filter to override the raw flag in enumerate_args.
> >
> > Then the output is the same if a frame-filter is active, the pretty-printer
> > for backtraces is only disabled with the raw-frame-arguments option:
> >
> >    (gdb) enable frame-filter global BasicFrameFilter
> >    (gdb) bt
> >    #0  foo (x=42, ss=super struct = {...}) at C:/src/repos/gdb-testsuite/gdb/testsuite/gdb.python/py-frame-args.c:47
> >    #1  0x004016aa in main () at C:/src/repos/gdb-testsuite/gdb/testsuite/gdb.python/py-frame-args.c:57
> >    (gdb) set print raw-values on
> >    (gdb) bt
> >    #0  foo (x=42, ss=super struct = {...}) at C:/src/repos/gdb-testsuite/gdb/testsuite/gdb.python/py-frame-args.c:47
> >    #1  0x004016aa in main () at C:/src/repos/gdb-testsuite/gdb/testsuite/gdb.python/py-frame-args.c:57
> >    (gdb) set print raw-values off
> >    (gdb) bt -raw-frame-arguments on
> >    #0  foo (x=42, ss=...) at C:/src/repos/gdb-testsuite/gdb/testsuite/gdb.python/py-frame-args.c:47
> >    #1  0x004016aa in main () at C:/src/repos/gdb-testsuite/gdb/testsuite/gdb.python/py-frame-args.c:57
>
> Thanks for working on improving this behaviour.
>
> I think that there's something weird going on with the MI behaviour.
>
> I ran the py-frame-args.c test program, stopped at line 47, then I see
> this:
>
>   (gdb) set print raw-frame-arguments off
>   (gdb) set print raw-values off
>   (gdb) interpreter-exec mi "-stack-list-variables 1"
>   ^done,variables=[{name="x",arg="1",value="42"},{name="ss",arg="1",value="super struct = {\n  a = m=<1>,\n  b = m=<2>\n}"}]
>   (gdb) interpreter-exec mi "-stack-list-arguments 1"
>   ^done,stack-args=[frame={level="0",args=[{name="x",value="42"},{name="ss",value="super struct = {\n  a = m=<1>,\n  b = m=<2>\n}"}]},frame={level="1",args=[]}]
>
>   (gdb) set print raw-frame-arguments on
>   (gdb) interpreter-exec mi "-stack-list-arguments 1"
>   ^done,stack-args=[frame={level="0",args=[{name="x",value="42"},{name="ss",value="super struct = {\n  a = m=<1>,\n  b = m=<2>\n}"}]},frame={level="1",args=[]}]
>   (gdb) interpreter-exec mi "-stack-list-variables 1"
>   ^done,variables=[{name="x",arg="1",value="42"},{name="ss",arg="1",value="super struct = {\n  a = m=<1>,\n  b = m=<2>\n}"}]
>
>   (gdb) set print raw-values on
>   (gdb) interpreter-exec mi "-stack-list-arguments 1"
>   ^done,stack-args=[frame={level="0",args=[{name="x",value="42"},{name="ss",value="super struct = {\n  a = m=<1>,\n  b = m=<2>\n}"}]},frame={level="1",args=[]}]
>   (gdb) interpreter-exec mi "-stack-list-variables 1"
>   ^done,variables=[{name="x",arg="1",value="42"},{name="ss",arg="1",value="{\n  a = {\n    m = 1\n  },\n  b = {\n    m = 2\n  }\n}"}]
>   (gdb)
>
> The summary is:
>
>   - when just doing '-stack-list-arguments' neither 'set print
>     raw-values' or 'set print raw-frame-arguments' seem to effect what
>     is printed, and
>
>   - when doing '-stack-list-variables', 'set print raw-values' seems
>     to effect how arguments are printed, but 'set print
>     raw-frame-arguments' does not.
>
> I guess I would expect 'set print raw-frame-arguments' to be the
> controlling option in both these cases.

I'm not completely sure now, is that something this patch breaks?
Or do you mean this should be fixed as well, since it's a very similar problem?


Hannes


More information about the Gdb-patches mailing list