I have been trying to pass a value which is stored in a variable called $filename
to dump binary memory
command in gdb.
This is the snippet I am having trouble with:
set $start = table[0].mem_ptr
set $lenght = table[0].mem_ptr + table[0].mem_len
set $filename = table[0].fname
dump binary memory $filename $start $lenght
since the 2nd ($start) and the 3rd ($lenght) arguments of the dump binary memory
command are numeric values, I'm not having any issue with just passing variables $start
and $lenght
as how I did in the snippet.
But the problem is the first argument of the command is suppose to be a string. Let's say the content of the variable $filename
is temp.bin. I store the file name into the variable $filename
and pass it to the command. In this case I am expecting dump binary memory
command to create file temp.bin and write the content respectively into the file. The command writes the correct values into the file but it creates and names file as $filename not as temp.bin.
what I was trying is:
dump binary memory eval "p $filename" $start $lenght
but then gdb returns Unterminated string in expression.
error.
I do not know how else I can treat this part of the command so it can place there the string I store in the variable.
If it could be useful, this is the output of show version
command:
GNU gdb (GNU Tools for ARM Embedded Processors) 7.6.0.20140529-cvs
Copyright (C) 2013 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "--host=i686-w64-mingw32 --target=arm-none-eabi".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Well, I was just keep trying and found the solution quickly :D
this helped me to figure it out:
eval "dump binary memory %s $start $lenght", $filename