Re: How to compare $arg0 with string literal?
Doug Evans <[email protected]>
| Newsgroups | gmane.comp.gdb.devel |
|---|---|
| Message-ID | <CADPb22Rs0pEnF73E+3E46WPHNYhqpM0Lp2gm-Kws4mbYCcKGVg@mail.gmail.com> |
On Thu, Mar 26, 2015 at 9:27 AM, Aleksey Midenkov <[email protected]> wrote: > F.ex. > > define logging > if $argc == 1 > if $arg0 == off > set logging off > set logging file gdb.log > else if $arg0 == stop > set logging off > else > set logging $arg0 > end > else > set logging $arg0 $arg1 > end > show logging > end > > When type 'logging off' I get error about no such symbol 'off'... 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.