This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: debug information


> In GDB, functions that accept std::string as argument are shown as
> `function_name(std::string)', not as `function_name(std::basic_string<char,...>)'.
> As far as I can see, this is written like this in the debug information, not just
> simplified by GDB.  So it is a feature of GNU libstdc++ or GCC itself.  Is there
> a way to do the same for my own code?  This way debugging would be much easier...

Sadly, std::string is a special case for many things, as it has a
unique mangling as part of the IA 64 C++ ABI. It'd probably be better
to discusses this more generally, without std::string's tricks.

If you look at the following example:

#include <iostream>

void
foo(std::wstring s)
{
  std::wstring l(L"passed string is: ");
  l += s;
  std::wcout << l << std::endl;
}

template<typename T>
struct basic_pod
{
  typedef T value_type;
  value_type _M_data;
};

typedef basic_pod<int> ipod;

void
bar(ipod p)
{
  p._M_data = 0;
}

int main()
{
  foo(L"boo!");
  
  ipod p;
  bar(p);

  std::wcout << L"hello" << std::endl;
  return 0;
}

And compile it with -g3 -O0 on linux, you'll see this in the debug info:

<1><f011>: Abbrev Number: 2 (DW_TAG_typedef)
     DW_AT_name        : ipod	

then, the type on bar as above in gdb is:

(gdb) ptype bar
type = void (ipod)

and

(gdb) ptype ipod
type = struct basic_pod<int> {
    int _M_data;
}

So, I guess I would have to tell you to use a DWARF debuginfo
toolchain, and use the above flags with typedefs? 

Not quite sure what you are getting at, but hopefully this answers your
question. 

Another idea for simplifying debugging is to use this approach by Ravi Menon:
http://gcc.gnu.org/ml/libstdc++/2006-08/msg00009.html

I'd be interested to see if this kind of approach is of interest to more people.

best,
-benjamin


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]