Message ID | 20191112114734.890813-3-Hi-Angel@yandex.ru |
---|---|
State | New |
Headers | show |
Series | gdbinit.in fixes | expand |
On Nov 12 2019, Konstantin Kharlamov wrote: > Gdb documentation says that gdb-defined functions refer to their args as > $arg0…$argN. The just "$" that gdbinit is using here refers to something > else, That's the last thing printed. > which results in gdb errors, or even crashes of debuggee. Let's > fix that. That breaks all users of these macros, since you are now required to pass an argument. Andreas.
On Вт, ноя 12, 2019 at 13:50, Andreas Schwab <schwab@suse.de> wrote: > On Nov 12 2019, Konstantin Kharlamov wrote: > >> Gdb documentation says that gdb-defined functions refer to their >> args as >> $arg0…$argN. The just "$" that gdbinit is using here refers to >> something >> else, > > That's the last thing printed. Hmm, okay… Am I missing something…? As I'm reading, this looks definitely wrong, because the "last thing printed" is just a random value. To illustrate: I can do a calculation, like `p 2 + 2`, and then I execute, say, `pgg stmt`, and debuggee crashes because it calls `debug_gimple_stmt(4)`. That's what happened to me a lot of times until I figured the problem is in gdbinit. >> which results in gdb errors, or even crashes of debuggee. Let's >> fix that. > > That breaks all users of these macros, since you are now required to > pass an argument. I'm definitely missing something. Who are these users, and how can they make anything useful of these functions if they don't even pass an argument? > Andreas. > > -- > Andreas Schwab, SUSE Labs, schwab@suse.de > GPG Key fingerprint = 0196 BAD8 1CE9 1970 F4BE 1748 E4D4 88E3 0EEA > B9D7 > "And now for something completely different."
On Nov 12 2019, Konstantin Kharlamov wrote: > I'm definitely missing something. Who are these users, and how can they > make anything useful of these functions if they don't even pass an > argument? By printing the desired value. Andreas.
On Вт, ноя 12, 2019 at 14:08, Andreas Schwab <schwab@suse.de> wrote: > On Nov 12 2019, Konstantin Kharlamov wrote: > >> I'm definitely missing something. Who are these users, and how can >> they >> make anything useful of these functions if they don't even pass an >> argument? > > By printing the desired value. Hah, okay. Well, in this case their workflow now gonna be 2 times simpler since they don't have to type in two commands, but only one :) Besides, I suspect, the number of actual users of this gdbinit is around zero, otherwise someone would have noticed the warning that gdb prints on every usage of these functions while the PATCH 1/2 is not applied.
On Nov 12 2019, Konstantin Kharlamov wrote: > Besides, I suspect, the number of actual users of this gdbinit is around > zero, otherwise someone would have noticed the warning that gdb prints on > every usage of these functions while the PATCH 1/2 is not applied. It's easy to ignore it. Andreas.
On Tue, Nov 12, 2019 at 04:17:17PM +0300, Konstantin Kharlamov wrote: > On Вт, ноя 12, 2019 at 14:08, Andreas Schwab <schwab@suse.de> > wrote: > >On Nov 12 2019, Konstantin Kharlamov wrote: > >> I'm definitely missing something. Who are these users, and how can > >>they > >> make anything useful of these functions if they don't even pass an > >> argument? > > > >By printing the desired value. > > Hah, okay. Well, in this case their workflow now gonna be 2 times > simpler since they don't have to type in two commands, but only one :) Do we have to type parentheses now? That more than undoes that gain :-/ > Besides, I suspect, the number of actual users of this gdbinit is > around zero, otherwise someone would have noticed the warning that gdb > prints on every usage of these functions while the PATCH 1/2 is not > applied. There are users. There are users who have been used to this behaviour for many many many years. People just do (say I have an "rtx insn"): p insn pr A new version where you just say pr insn would be nice; something that requires pr(insn) is less nice. It would be great if you could come up with something that keeps the old syntax working as well, especially since many of us have to work with older versions of the gdbinit as well, for years to come. People can adjust their work habits of course, but that causes a lot of friction ;-) Segher
On Wed, Nov 13, 2019 at 6:39 AM Segher Boessenkool < segher@kernel.crashing.org> wrote: > On Tue, Nov 12, 2019 at 04:17:17PM +0300, Konstantin Kharlamov wrote: > > On Вт, ноя 12, 2019 at 14:08, Andreas Schwab <schwab@suse.de> > > wrote: > > >On Nov 12 2019, Konstantin Kharlamov wrote: > > >> I'm definitely missing something. Who are these users, and how can > > >>they > > >> make anything useful of these functions if they don't even pass an > > >> argument? > > > > > >By printing the desired value. > > > > Hah, okay. Well, in this case their workflow now gonna be 2 times > > simpler since they don't have to type in two commands, but only one :) > > Do we have to type parentheses now? That more than undoes that gain :-/ > > > Besides, I suspect, the number of actual users of this gdbinit is > > around zero, otherwise someone would have noticed the warning that gdb > > prints on every usage of these functions while the PATCH 1/2 is not > > applied. > > There are users. There are users who have been used to this behaviour > for many many many years. > > People just do (say I have an "rtx insn"): > p insn > pr > Indeed. I use this constantly. Jason
On Ср, ноя 13, 2019 at 15:23, Jason Merrill <jason@redhat.com> wrote: > On Wed, Nov 13, 2019 at 6:39 AM Segher Boessenkool > <segher@kernel.crashing.org> wrote: >> On Tue, Nov 12, 2019 at 04:17:17PM +0300, Konstantin Kharlamov wrote: >> > On Вт, ноя 12, 2019 at 14:08, Andreas Schwab <schwab@suse.de> >> > wrote: >> > >On Nov 12 2019, Konstantin Kharlamov wrote: >> > >> I'm definitely missing something. Who are these users, and how >> can >> > >>they >> > >> make anything useful of these functions if they don't even >> pass an >> > >> argument? >> > > >> > >By printing the desired value. >> > >> > Hah, okay. Well, in this case their workflow now gonna be 2 times >> > simpler since they don't have to type in two commands, but only >> one :) >> >> Do we have to type parentheses now? That more than undoes that >> gain :-/ >> >> > Besides, I suspect, the number of actual users of this gdbinit is >> > around zero, otherwise someone would have noticed the warning >> that gdb >> > prints on every usage of these functions while the PATCH 1/2 is >> not >> > applied. >> >> There are users. There are users who have been used to this >> behaviour >> for many many many years. >> >> People just do (say I have an "rtx insn"): >> p insn >> pr > > Indeed. I use this constantly. Thanks everyone for answers. No, you don't have to type parentheses. Gdb has it like in Haskell, i.e. arguments are separated by just whitespace. So you type `pr insn` You know what, I came up with an alternative solution that won't break anyone's workflow neither confuse newbies: I can add a check for number of arguments, and to branch on that to use either $ or $arg0. I'll resend then a bit later the patchset with the fixed changelog for the 1st patch, and these alternative changes for the 2nd patch.
On Thu, Nov 14, 2019 at 09:45:28AM +0300, Konstantin Kharlamov wrote: > On Ср, ноя 13, 2019 at 15:23, Jason Merrill <jason@redhat.com> > wrote: > >On Wed, Nov 13, 2019 at 6:39 AM Segher Boessenkool > ><segher@kernel.crashing.org> wrote: > >> There are users. There are users who have been used to this > >>behaviour > >> for many many many years. > >> > >> People just do (say I have an "rtx insn"): > >> p insn > >> pr > > > >Indeed. I use this constantly. > > Thanks everyone for answers. No, you don't have to type parentheses. > Gdb has it like in Haskell, i.e. arguments are separated by just > whitespace. So you type `pr insn` > > You know what, I came up with an alternative solution that won't break > anyone's workflow neither confuse newbies: I can add a check for number > of arguments, and to branch on that to use either $ or $arg0. That sounds great! Thank you :-) Segher
diff --git a/gcc/gdbinit.in b/gcc/gdbinit.in index a933ddc6141..71a01edaa71 100644 --- a/gcc/gdbinit.in +++ b/gcc/gdbinit.in @@ -17,153 +17,153 @@ # <http://www.gnu.org/licenses/>. define pp -call debug ($) +call debug ($arg0) end document pp -Print a representation of the GCC data structure that is $. +Print a representation of the GCC data structure that is $arg0. Works only when an inferior is executing. end define pr -call debug_rtx ($) +call debug_rtx ($arg0) end document pr -Print the full structure of the rtx that is $. +Print the full structure of the rtx that is $arg0. Works only when an inferior is executing. end define prl -call debug_rtx_list ($, debug_rtx_count) +call debug_rtx_list ($arg0, debug_rtx_count) end document prl -Print the full structure of all rtx insns beginning at $. +Print the full structure of all rtx insns beginning at $arg0. Works only when an inferior is executing. Uses variable debug_rtx_count to control number of insns printed: - debug_rtx_count > 0: print from $ on. - debug_rtx_count < 0: print a window around $. + debug_rtx_count > 0: print from $arg0 on. + debug_rtx_count < 0: print a window around $arg0. There is also debug_rtx_find (rtx, uid) that will scan a list for UID and print it using debug_rtx_list. Usage example: set $foo=debug_rtx_find(first, 42) end define pt -call debug_tree ($) +call debug_tree ($arg0) end document pt -Print the full structure of the tree that is $. +Print the full structure of the tree that is $arg0. Works only when an inferior is executing. end define pct -call debug_c_tree ($) +call debug_c_tree ($arg0) end document pct -Print the tree that is $ in C syntax. +Print the tree that is $arg0 in C syntax. Works only when an inferior is executing. end define pgg -call debug_gimple_stmt ($) +call debug_gimple_stmt ($arg0) end document pgg -Print the Gimple statement that is $ in C syntax. +Print the Gimple statement that is $arg0 in C syntax. Works only when an inferior is executing. end define pgq -call debug_gimple_seq ($) +call debug_gimple_seq ($arg0) end document pgq -Print the Gimple sequence that is $ in C syntax. +Print the Gimple sequence that is $arg0 in C syntax. Works only when an inferior is executing. end define pgs -call debug_generic_stmt ($) +call debug_generic_stmt ($arg0) end document pgs -Print the statement that is $ in C syntax. +Print the statement that is $arg0 in C syntax. Works only when an inferior is executing. end define pge -call debug_generic_expr ($) +call debug_generic_expr ($arg0) end document pge -Print the expression that is $ in C syntax. +Print the expression that is $arg0 in C syntax. Works only when an inferior is executing. end define pmz -call mpz_out_str(stderr, 10, $) +call mpz_out_str(stderr, 10, $arg0) end document pmz -Print the mpz value that is $ +Print the mpz value that is $arg0 Works only when an inferior is executing. end define ptc -output (enum tree_code) $.base.code +output (enum tree_code) $arg0.base.code echo \n end document ptc -Print the tree-code of the tree node that is $. +Print the tree-code of the tree node that is $arg0. end define pdn -output $.decl_minimal.name->identifier.id.str +output $arg0.decl_minimal.name->identifier.id.str echo \n end document pdn -Print the name of the decl-node that is $. +Print the name of the decl-node that is $arg0. end define ptn -output $.type.name->decl_minimal.name->identifier.id.str +output $arg0.type.name->decl_minimal.name->identifier.id.str echo \n end document ptn -Print the name of the type-node that is $. +Print the name of the type-node that is $arg0. end define pdd -call debug_dwarf_die ($) +call debug_dwarf_die ($arg0) end document pdd -Print the dw_die_ref that is in $. +Print the dw_die_ref that is in $arg0. end define prc -output (enum rtx_code) $.code +output (enum rtx_code) $arg0.code echo \ ( -output $.mode +output $arg0.mode echo )\n end document prc -Print the rtx-code and machine mode of the rtx that is $. +Print the rtx-code and machine mode of the rtx that is $arg0. end define pi -print $.u.fld[0].rt_rtx@7 +print $arg0.u.fld[0].rt_rtx@7 end document pi -Print the fields of an instruction that is $. +Print the fields of an instruction that is $arg0. end define pbs @@ -176,20 +176,20 @@ including the global binding level. end define pbm -call bitmap_print (stderr, $, "", "\n") +call bitmap_print (stderr, $arg0, "", "\n") end document pbm -Dump the bitmap that is in $ as a comma-separated list of numbers. +Dump the bitmap that is in $arg0 as a comma-separated list of numbers. end define pel -output expand_location ($) +output expand_location ($arg0) echo \n end document pel -Print expanded location of $. +Print expanded location of $arg0. end define pcfun @@ -202,11 +202,11 @@ Print current function. end define trt -print ($.typed.type) +print ($arg0.typed.type) end document trt -Print TREE_TYPE of the tree node that is $ +Print TREE_TYPE of the tree node that is $arg0 end define break-on-diagnostic