Hello. I've been using CodeBlocks for a long time. Recently I started setting it up in order to improve the GDB debugging performance, so I've configured various pretty printers. However, one thing that bugged me was that hovering a mouse over a pointer shows only the pointer address in the tooltip. Programmers are interested in the pointer content, not the address. Therefore, I've downloaded and compiled C::B code and run it through the debugger. I found the following code in gdb_commands.h, function GdbCmd_TooltipEvaluation::ParseOutput:
ParseGDBWatchValue(watch, contents);
if (!m_Address.empty() && m_autoDereferenced)
watch->SetValue(m_Address);
In case of a pointer, contents already contains the dereferenced value which is correctly stored in watch. However, the next two lines write the pointer address back into watch, so the tooltip shows only the address.
Simply by removing (commenting out) these two lines I was able to show the dereferenced pointer's content in the tooltip, without any side effects observed (except for null pointers that write the "Cannot access memory at 0x0" string). So my question is what are these lines needed for?
What do the devs think about this modification? Can it be made in the trunk? I think that it improves the debugging ergonomy, no need to use the watches panel.
Tested on python-enabled GNU gdb (GDB) 7.4.50.20120522-cvs, from this forum, on Windows XP.
Lets start with a minimal sample that demonstrates the problem or at least posting the full log from the debugger.
Here goes a minimal sample:
int main() {
int i = 123;
int* pi = &i;
return 0;
}
Cursor over pi. Debugger log:
[debug]> whatis pi
[debug]type = int *
[debug]>>>>>>cb_gdb:
[debug]> output pi
[debug](int *) 0x23fee8>>>>>>cb_gdb:
[debug]> output *pi
[debug]123>>>>>>cb_gdb:
Good, gdb dereferenced the value. Now, passing through the mentioned code:
ParseGDBWatchValue(watch, contents);
if (!m_Address.empty() && m_autoDereferenced)
watch->SetValue(m_Address);
After ParseGDBWatchValue:
(gdb) p *(watch._M_ptr)
$26 = {<cbWatch> = {_vptr.cbWatch = 0x6d903d28, m_parent = warning: (Internal er
ror: pc 0x0 in read in psymtab, but not in symtab.)
warning: (Internal error: pc 0x0 in read in psymtab, but not in symtab.)
std::tr1::weak_ptr (empty) 0x0,
m_children = std::vector of length 0, capacity 0, m_changed = true,
m_removed = false, m_expanded = false, m_autoUpdate = true},
m_symbol = {<wxStringBase> = {static npos = <optimized out>,
m_pchData = 0x7817334 L"*pi"}, <No data fields>},
m_type = {<wxStringBase> = {static npos = <optimized out>,
m_pchData = 0x7d63214 L"int *"}, <No data fields>},
m_raw_value = {<wxStringBase> = {static npos = <optimized out>,
m_pchData = 0x77ee47c L"123"}, <No data fields>},
m_debug_value = {<wxStringBase> = {static npos = <optimized out>,
m_pchData = 0x62b92134 L""}, <No data fields>}, m_format = Undefined,
m_array_start = 0, m_array_count = 0, m_is_array = false,
m_forTooltip = false}
Still good, m_raw_value contains the dereferenced value. But after the next two lines:
(gdb) p *(watch._M_ptr)
$27 = {<cbWatch> = {_vptr.cbWatch = 0x6d903d28, m_parent = warning: (Internal er
ror: pc 0x0 in read in psymtab, but not in symtab.)
warning: (Internal error: pc 0x0 in read in psymtab, but not in symtab.)
std::tr1::weak_ptr (empty) 0x0,
m_children = std::vector of length 0, capacity 0, m_changed = true,
m_removed = false, m_expanded = false, m_autoUpdate = true},
m_symbol = {<wxStringBase> = {static npos = <optimized out>,
m_pchData = 0x7817334 L"*pi"}, <No data fields>},
m_type = {<wxStringBase> = {static npos = <optimized out>,
m_pchData = 0x7d63214 L"int *"}, <No data fields>},
m_raw_value = {<wxStringBase> = {static npos = <optimized out>,
m_pchData = 0x77e4ca4 L"0x23fee8"}, <No data fields>},
m_debug_value = {<wxStringBase> = {static npos = <optimized out>,
m_pchData = 0x62b92134 L""}, <No data fields>}, m_format = Undefined,
m_array_start = 0, m_array_count = 0, m_is_array = false,
m_forTooltip = false}
The pointer address overwrote the dereferenced value which is nowhere to be seen.
Tooltip displays: *pi | 0x23fee8 | int *
and it's wrong, it's 'pi', not '*pi'.
After these two lines are commented out, tooltip is: *pi | 123 | int *
So it works as I expected.
I hope I made it clear. I tested this on clean CB installation (latest SVN) on different computers and it always worked like this.