Author Topic: structure has no component named c_str  (Read 4436 times)

Offline raynebc

  • Almost regular
  • **
  • Posts: 217
structure has no component named c_str
« on: March 05, 2015, 12:12:06 am »
I ran into some strange debugger behavior when tracing through my program, when I added an element of an array of structures to the watches, it displayed "structure has no component named c_str" instead of a list of member variables and their values.  I can't tell why this is, when I added an element of a different array of different structures (with similar members) it displayed that structure's contents normally.  Is this a problem with GDB?  With Code::Blocks?  With my programming?

If it makes any difference, the layout of the structure is as follows:
Code
struct bf_string
{
unsigned long long keyid;
unsigned long offset;
char *string;
char encountered;
};

Thanks in advance.

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: structure has no component named c_str
« Reply #1 on: March 05, 2015, 12:25:28 am »
Can you post a minimal sample that can be used to reproduce the problem?
Do you have watch scripts enabled in the debugger's settings?
What version of CB are you using?
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline raynebc

  • Almost regular
  • **
  • Posts: 217
Re: structure has no component named c_str
« Reply #2 on: March 05, 2015, 01:28:40 am »
I'm afraid I didn't put together a minimal sample, since I couldn't even get it to behave the same for both structure types.  I reproduced this behavior on both the 9-16-14 and 1-17-15 nightly C::B releases.  "Enable watch script" was enabled, but when I disable it and debug my program again, the watches display correctly, so I guess it's a problem with that feature?  The tooltip mentions not to use it with a Python-enabled GDB, but I don't know how to tell if I have such a version of GDB installed.  GDB's help output gives the following:
GNU gdb (GDB) 7.5
...
This GDB was configured as "i686-pc-mingw32".

This GDB version is kind of old, but I'd rather not risk breaking something that's otherwise working just fine if I can avoid it.

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: structure has no component named c_str
« Reply #3 on: March 05, 2015, 01:29:55 am »
Search for gdb python pretty printers.
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline raynebc

  • Almost regular
  • **
  • Posts: 217
Re: structure has no component named c_str
« Reply #4 on: March 05, 2015, 01:52:02 am »
Is this a problem with MinGW's GDB instead of Code::Blocks then?  I honestly don't know why it would have problems displaying standard data types in a structure.  I also don't know what data type it was having problems with, so I wouldn't know where to begin as far as writing my own printer.  I know this GDB can print long long integer values because it displayed the other structure without problem.  In the end, I'm not customizing GDB in any way so I probably don't lose anything by turning off this feature.  Thank you for the tip.

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: structure has no component named c_str
« Reply #5 on: March 05, 2015, 09:17:15 am »
If you disable "watch scripts" it will just works, but you'll see the raw values (struct members of std::string for example).
And watch scripts are know to fail sometimes.
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]