Discussion:
[Bug macros/22466] New: user-defined function thinks it lacks an argument
hi-angel at yandex dot ru
2017-11-21 02:00:15 UTC
Permalink
https://sourceware.org/bugzilla/show_bug.cgi?id=22466

Bug ID: 22466
Summary: user-defined function thinks it lacks an argument
Product: gdb
Version: 8.0.1
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: macros
Assignee: unassigned at sourceware dot org
Reporter: hi-angel at yandex dot ru
Target Milestone: ---

Steps:
1. Define in gdb_init the following function:

define print_arg2
print ($argc == 0)? $rsi : *($arg0*)$rsi
end

2. Start debugging, and run "print_arg2"

Expected results: print of the $rsi register

Actual results: error "Missing argument 0 in user function."

Additional info: it works with the following, semantically the same, code:

define print_arg2
if ($argc == 0)
print $rsi
else
print *($arg0*)$rsi
end
end
--
You are receiving this mail because:
You are on the CC list for the bug.
tromey at sourceware dot org
2018-04-19 03:19:47 UTC
Permalink
https://sourceware.org/bugzilla/show_bug.cgi?id=22466

Tom Tromey <tromey at sourceware dot org> changed:

What |Removed |Added
----------------------------------------------------------------------------
CC| |tromey at sourceware dot org
Component|macros |cli

--- Comment #1 from Tom Tromey <tromey at sourceware dot org> ---
I think what's happening here is that the argument substitution is
just done by manipulating the string before evaluating the command.
However, this isn't done in the not-taken branch of an "if".

So arguably this isn't a bug so much as just a bad design choice
for how to implement arguments. It's unclear to me if it could
be changed.
--
You are receiving this mail because:
You are on the CC list for the bug.
hi-angel at yandex dot ru
2018-04-19 08:53:50 UTC
Permalink
https://sourceware.org/bugzilla/show_bug.cgi?id=22466

--- Comment #2 from Hi-Angel <hi-angel at yandex dot ru> ---
(In reply to Tom Tromey from comment #1)
Post by tromey at sourceware dot org
I think what's happening here is that the argument substitution is
just done by manipulating the string before evaluating the command.
However, this isn't done in the not-taken branch of an "if".
So arguably this isn't a bug so much as just a bad design choice
for how to implement arguments. It's unclear to me if it could
be changed.
I don't know implementation details, so I might say something silly. But I
think this check of arguments is redundant, at least. It is a dynamic language,
and take for example Python — it won't check if anything is defined until it
gets evaluated.

Funny, never thought I gonna say dynamic typing is nice — but this kind of task
is actually asking for that.
--
You are receiving this mail because:
You are on the CC list for the bug.
Loading...