Re: How to compare $arg0 with string literal?

Doug Evans <[email protected]>
Newsgroups gmane.comp.gdb.devel
Message-ID <CADPb22RDHdaCHiZ=ct04uWuCYPHyFOjTZRnqZBwvHmA=akDbmw@mail.gmail.com>
On Thu, Mar 26, 2015 at 11:35 PM, Aleksey Midenkov <[email protected]> wrote:
> On Thu, Mar 26, 2015 at 9:28 PM, Doug Evans <[email protected]> wrote:
>> Such things are not supported in gdb's own scripting language.
>> However, with a bit of Python-provided magic ($_streq):
>>
>> define logging
>>     if $argc == 1
>>         if $_streq("$arg0", "off")
>>             set logging off
>>             set logging file gdb.log
>>         else
>>             if $_streq("$arg0", "stop")
>>                 set logging off
>>             else
>>                 set logging $arg0
>>             end
>>         end
>>     else
>>         set logging $arg0 $arg1
>>     end
>>     show logging
>> end
>>
>> Note that gdb's if/else syntax is a pain.
>
> Sure thing, gdb's syntax could be a bit richer... Also, if I get this
> error message does that mean that my gdb is not Python-powered?
>
> (gdb)  p $_streq("off", "off")
> Invalid data type for function to be called.

I'd use "py print 42" or some such as a more direct test of whether
python is present.

btw, which version of gdb are you using?
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.