This is the mail archive of the
mailing list for the GDB project.
Re: How to compare $arg0 with string literal?
- From: Aleksey Midenkov <midenok at gmail dot com>
- To: Doug Evans <dje at google dot com>
- Cc: "gdb at sourceware dot org" <gdb at sourceware dot org>
- Date: Fri, 3 Apr 2015 12:36:32 +0300
- Subject: Re: How to compare $arg0 with string literal?
- Authentication-results: sourceware.org; auth=none
- References: <CAF8BazAOQC-otNoogUc92mnjoxJwt8R166tx0=7JX04qFks_+g at mail dot gmail dot com> <CADPb22Rs0pEnF73E+3E46WPHNYhqpM0Lp2gm-Kws4mbYCcKGVg at mail dot gmail dot com> <CAF8BazDH4qpuAbakQ8u6C6C-OcHW-eZ1Yi09uNDu6s7R4SjV0g at mail dot gmail dot com> <CADPb22RDHdaCHiZ=ct04uWuCYPHyFOjTZRnqZBwvHmA=akDbmw at mail dot gmail dot com>
On Fri, Mar 27, 2015 at 7:25 PM, Doug Evans <email@example.com> wrote:
> On Thu, Mar 26, 2015 at 11:35 PM, Aleksey Midenkov <firstname.lastname@example.org> wrote:
>> On Thu, Mar 26, 2015 at 9:28 PM, Doug Evans <email@example.com> 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
>>> if $_streq("$arg0", "stop")
>>> set logging off
>>> set logging $arg0
>>> set logging $arg0 $arg1
>>> show logging
>>> 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?
That host where this error occurs is always outdated. 7.2-60.el6_4.1
On my local machine is latest version and $_streq() works.
On 7.2 'py print' :
(gdb) py print 42
(gdb) py prind 42
File "<string>", line 1
SyntaxError: unexpected EOF while parsing
Error while executing Python code.