I wonder why evaluate function doesn't work in gdb? In my source file I include, when debugging in gdb, these examples are wrong evaluations.
(gdb) p pow(3,2) $10 = 1 (gdb) p pow(3,3) $11 = 1 (gdb) p sqrt(9) $12 = 0
evaluate the expression in gdb, doing print strcmp(current_node->word,min_node->word) . Surprisingly, this works: gdb can evaluate function calls, by injecting code into the running program and having it execute the code.
You can use the command inside of gdb info functions to print every function that has been loaded up to this point of execution. Additionally you can use info functions regexp to look for specific functions.
Yes, just examine the EAX register by typing print $eax . For most functions, the return value is stored in that register, even if it's not used. The exceptions to this are functions returning types larger than 32 bits, specifically 64-bit integers ( long long ), double s, and structs or classes .
You need to tell gdb that it will find the return value in the floating point registers, not the normal ones, in addition to give the parameters the right types.
I.e.:
(gdb) p ((double(*)())pow)(2.,2.)
$1 = 4
The syntax for calling a function in gdb is
call pow(3,2)
Type
help call
at the gdb prompt for more information.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With