This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH v2 2/2] gdbinit.in: allow to pass function argument explicitly




On Чт, ноя 14, 2019 at 16:57, Alexander Monakov <amonakov@ispras.ru> wrote:
On Thu, 14 Nov 2019, Konstantin Kharlamov wrote:

Though, this wouldn't be equivalent to what new people, who just want to call `debug()` with the arg, would expect :) If you want to deduplicate the
 function call, I can reorganize the code to be like this:

 define pp
  if ($argc == 0)
    set $arg = $
  else
    set $arg = $arg0
  end
  call debug ($arg)
 end

I wish there was a less verbose way :) I don't insist on this deduplication, so at this point I guess it's up to the reviewers. Your suggestion seems slightly preferable to duplicating commands, but please wait for feedback from others.

Sure; you know, actually I just found out how we can deduplicate the code! Can we use this or not depends on whether we can tolerate dependency on python (I dunno, I can ‾\_(ツ)_/‾). The code:

   py
   def choose_arg0_into_gdbarg():
     if gdb.execute('output $argc', to_string=True) == '1':
       gdb.execute('set debug_arg = $arg0', to_string=True)
     else:
       gdb.execute('set debug_arg = $', to_string=True)
   end

   define pp
     py choose_arg0_into_gdbarg()
     call debug (debug_arg)
   end

I also named `dbgarg` as `debug_arg` because I figured I confuse whether it was `gdbarg` or `gdbarg` :D



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]