In an answer to How to evaluate functions in GDB? I found the recipe to call a function outside of my program called floor
from within GDB like this:
(gdb) p floor
$20 = {<text variable, no debug info>} 0x38e10197b0 <floor>
(gdb) p ((double(*)(double))floor)(2.9999)
$21 = 2
(gdb) p ((double(*)(double))floor)(2.000001)
$22 = 2
(gdb)
What do I need to do, short of a compiler upgrade which is not an option for me at the moment, in order for me to call the function in the same manner in which I would do inside the original C/C++ text file, e.g.,:
p floor(2.9999)
Specifically, I would like to not have to open up the man page on floor
to find the function signature:
double floor(double x);
and then concoct an expression to feed to gdb's print
command that is a pointer taking a double
returning a double
, with lots of parentheses.
So, is this the only way for us to call these types of low level functions in GDB? Or is there something I'm missing? Is it because I simply don't have some type of "debug symbols" loaded or something like that? Reference no debug info
in the output above that leads me to believe that perhaps my machine is lacking some package for "debug symbols" or the equivalent that would allow me to express this in the native C or C++?
This is specifically for Linux. I'm not interested in platform-agnostic answers as they are irrelevant in my use-case (not in general, though, just for this question).
p (double)floor(2.9999)
– Chalk