User forums > Using Code::Blocks

An annoying problem with debugger interface

(1/1)

Radek:
The complaint is on debugging structures returned by value. For example:


--- Code: ---wxString func()
{
  wxString  rv;

  rv += wxT('a');
  rv += wxT('b');
  rv += wxT('c');

  return rv;
}

--- End code ---

Let us try this with a debugger. You can set watch on rv, you can trace through building rv but the value of rv in the Watches window will not change. Nevertheless, the value is built and returned correctly. There seems to be no way of seeing value of rv nor of detecting changes made to rv. The same seems to happen with any structure returned by value.

Let us change the code a bit:


--- Code: ---wxString func()
{
  wxString  rv;
  wxString  zz;

  zz += wxT('a');
  zz += wxT('b');
  zz += wxT('c');

  rv = zz;

  return rv;
}

--- End code ---

Now, you can watch building zz. All goes well until you reach the assignment statement rv = zz. The debugger crashes here(!) "DWARF-2 internal error". Code Blocks rev. 8500, 32-bit Debian 6.

Speaking the debugger, I also have one wishing. Allow preventing changes in the source files during debugging. A checkbox in the debugger options woud be appreciated. It is a bit boring undoing changes in the source file again and again when you wanted to manipulate the watches window but the cursor happened to be in the source code window...  :-\

ollydbg:

--- Quote from: Radek on November 03, 2012, 04:58:38 pm ---The complaint is on debugging structures returned by value. For example:


--- Code: ---wxString func()
{
  wxString  rv;

  rv += wxT('a');
  rv += wxT('b');
  rv += wxT('c');

  return rv;
}

--- End code ---

Let us try this with a debugger. You can set watch on rv, you can trace through building rv but the value of rv in the Watches window will not change. Nevertheless, the value is built and returned correctly. There seems to be no way of seeing value of rv nor of detecting changes made to rv. The same seems to happen with any structure returned by value.


--- End quote ---
I just test your code under WinXP GCC 4.6.3 wxWidgets 2.8.12, GDB cvs 20121025, C::B nightly build.
I can see rv changes from "" to "abc".
So, I guess that your issue is related to GCC's optimization?



--- Quote ---Speaking the debugger, I also have one wishing. Allow preventing changes in the source files during debugging. A checkbox in the debugger options woud be appreciated. It is a bit boring undoing changes in the source file again and again when you wanted to manipulate the watches window but the cursor happened to be in the source code window...  Undecided

--- End quote ---
Agreed, unless the gdb can support the debugging on-the-fly code(which I know visual c++ can), let the source code read only when debugging.

p2rkw:
This may be caused by Named Return Value Optimization. Disable all GCC's optimizations (in debug profile only), rebuild and try again.

oBFusCATed:

--- Quote from: ollydbg on November 03, 2012, 05:38:33 pm ---Agreed, unless the gdb can support the debugging on-the-fly code(which I know visual c++ can), let the source code read only when debugging.

--- End quote ---
I guess we won't see this ever supported in 64bit mode. Visual C++ has it only in 32bit mode, so I guess it is pretty hard or impossible to implement.

Radek:
The only flag for the Debug target is "-g  produce debug symbols". All other flags are unchecked.

Navigation

[0] Message Index

Go to full version