User forums > Using Code::Blocks
get return value of a call while debugging
thomas:
Although this clearly works as you have pointed out, I fear that there may be quite a few pitfalls, it may not be that easy in the end.
For example, how can the debugger plugin know a function's return type without either querying the code completion plugin or demangling the C++ function name? Both is problematic in some way.
One could argue that this functionality is only ever needed for bool and int values as well as pointers. You don't usually do something like if(ReturnsAnObject()) (and with most object types, that won't compile, either).
But anyway, bool and int may have different sizes (normally, but not necessarily sizeof(bool) == sizeof(char)), and you don't really know what kind of tampering the compiler does (and what may be the upper 24/56 bits of a bool), so simply reading the whole register might give random nonsense (or might work fine, who knows...).
And then we have non-stdcall functions, and inline functions, register variables, all that kind of stuff. According to the GCC documentation, it is quite possible and valid to debug optimized code, so we cannot expect everything to be nice and easy.
Life is a lot easier if you do have a symbol, since then you just *ask* GDB for the value, and it is not your problem where it comes from :)
Ceniza:
--- Quote from: thomas ---For example, how can the debugger plugin know a function's return type without either querying the code completion plugin or demangling the C++ function name? Both is problematic in some way.
--- End quote ---
--- Quote from: GDB ---(gdb) whatis function
type = longdouble (longdouble)
(gdb) whatis main
type = int (void)
--- End quote ---
bool: eax is 0 for false and != 0 (1 in GCC) for true.
Inlined functions wouldn't work and all in all the implementation would become architecture specific, GCC only and a whole hack.
Anyway, there you have tricks for some of your needs, but just like thomas said: "Life is a lot easier if you do have a symbol".
MoonKid:
--- Quote from: Ceniza on April 18, 2006, 12:45:55 am ---but just like thomas said: "Life is a lot easier if you do have a symbol".
--- End quote ---
Ok, I will submit a feauter request for gcc and/or gdb. ;)
Navigation
[0] Message Index
[*] Previous page
Go to full version