Reputation: 576
The x command can examine memory in GDB. Like
x/4xg 0x60400
Now I am going to define my own x comand which examines memory with specified repeat count, like:
define myXCommand
set var &repeatCount=$arg0
x/(???)xg 0x60400
end
I have tried many ways to pass the variant repeatCount to x command, but I failed finally. My problem is how to pass the repeat count to x command? Appreciated very much if anyone can help.
Upvotes: 1
Views: 528
Reputation: 10271
A convenience variable can be used in most expressions, but the x
command only allows the repeat count to be a string of digits, not an arbitrary expression.
What you can do is use the eval
command, which does a printf
on its arguments and then runs the result as a command.
define myXCommand
set var $repeatCount=$arg0
eval "x/%dxg 0x60400", $repeatCount
end
Upvotes: 2