From: Doug Evans <dje@google.com>
To: Aleksey Midenkov <midenok@gmail.com>
Cc: "gdb@sourceware.org" <gdb@sourceware.org>
Subject: Re: How to compare $arg0 with string literal?
Date: Fri, 27 Mar 2015 16:26:00 -0000 [thread overview]
Message-ID: <CADPb22RDHdaCHiZ=ct04uWuCYPHyFOjTZRnqZBwvHmA=akDbmw@mail.gmail.com> (raw)
In-Reply-To: <CAF8BazDH4qpuAbakQ8u6C6C-OcHW-eZ1Yi09uNDu6s7R4SjV0g@mail.gmail.com>
On Thu, Mar 26, 2015 at 11:35 PM, Aleksey Midenkov <midenok@gmail.com> wrote:
> On Thu, Mar 26, 2015 at 9:28 PM, Doug Evans <dje@google.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
>> 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?
next prev parent reply other threads:[~2015-03-27 16:26 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-03-26 16:28 Aleksey Midenkov
2015-03-26 18:28 ` Doug Evans
2015-03-27 6:35 ` Aleksey Midenkov
2015-03-27 16:26 ` Doug Evans [this message]
2015-04-03 9:36 ` Aleksey Midenkov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CADPb22RDHdaCHiZ=ct04uWuCYPHyFOjTZRnqZBwvHmA=akDbmw@mail.gmail.com' \
--to=dje@google.com \
--cc=gdb@sourceware.org \
--cc=midenok@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox