Bug 22472 - Arguments evaluation doesn't always work
Summary: Arguments evaluation doesn't always work
Status: RESOLVED INVALID
Alias: None
Product: gdb
Classification: Unclassified
Component: gdb (show other bugs)
Version: 8.0.1
: P2 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-11-22 05:29 UTC by Hi-Angel
Modified: 2017-12-10 12:00 UTC (History)
0 users

See Also:
Host:
Target:
Build:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Hi-Angel 2017-11-22 05:29:18 UTC
Steps to reproduce:

1. start `gdb -nh`
2. define the following command

	(gdb) define argnum
	Type commands for definition of "argnum".
	End with a line saying just "end".
	>print $argc
	>end
	(gdb) 

3. type the following:
	(gdb) argnum (1+1)
	$1 = 1

	works as expected.

4. type the following:
	(gdb) argnum (1 + 1)
	$2 = 3

Expected: same result as at point 3.
Actual result: gdb did not evaluate the argument, and passed three instead of one.
Comment 1 Andreas Schwab 2017-11-22 18:45:54 UTC
Argument parsing is purely textual.
Comment 2 Hi-Angel 2017-11-22 20:41:17 UTC
@Andreas I am sorry about that. But why did you close the bug as invalid?
Comment 3 Hi-Angel 2017-11-25 16:48:25 UTC
@Andreas let me elaborate: such behavior is irrational for obvious reasons. I know a lot of languages, but not a single one, where passing an arithmetic operation in braces without whitespace works different from doing the same with whitespace.

So, do you have a link to docs or whatever to confirm that this is a valid behavior?
Comment 4 Hi-Angel 2017-12-10 07:36:11 UTC
Reopening per lack of elaboration on reasons of closing.
Comment 5 Andreas Schwab 2017-12-10 12:00:31 UTC
Arguments to user-defined commands aren't evaluated, they are textually split on spaces, as documented in the manual.