[llvm] r181471 - Make sure debug info contains linkage names (DW_AT_MIPS_linkage_name)

Yacine Belkadi yacine.belkadi.1 at gmail.com
Thu May 9 06:23:28 PDT 2013


Hi,

It seems that the test (gdp.cp/templates.exp) is marked as XFAIL for gcc.
There is an associated bug report:
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51668

As I understand it, for constructors and destructors, if a
DW_AT_MIPS_linkage_name is present, gdb uses it, but seems to expect that
the class name in the demangled name of the ctor/dtor matches the DW_AT_NAME
of the class.

In the failing test (gdb.cp/templates.cc), there is:
template<class T, char sz>
class Baz {
public:
  ~Baz () { };
  /// ...
}
typedef Baz<int, 1> intBazOne;

gcc ((Ubuntu/Linaro 4.7.2-2ubuntu1) 4.7.2) produces:
DW_AT_name: Baz<int, '\001'> for the class
DW_AT_MIPS_linkage_name: _ZN3BazIiLc1EED2Ev for the destructor

Clang (llvm at 181471) produces:
DW_AT_name: Baz<int, '\x01'> for the class
DW_AT_MIPS_linkage_name: _ZN3BazIiLc1EED1Ev for the destructor

The demangling for the destructor produces "Baz<int, (char)1>::~Baz()" in
which "Baz<int, (char)1>" doesn't match "Baz<int, '\x01'>" of DW_AT_name (or
Baz<int, '\001'> for gcc). This may be the reason why gdb complains on
"print intBazOne::~Baz".
When the two match (quick hack below), gdb doesn't complain.

diff --git a/lib/AST/TemplateBase.cpp b/lib/AST/TemplateBase.cpp
index d68b95e..b10e3d6 100644
--- a/lib/AST/TemplateBase.cpp
+++ b/lib/AST/TemplateBase.cpp
@@ -41,10 +41,8 @@ static void printIntegral(const TemplateArgument &TemplArg,
   if (T->isBooleanType()) {
     Out << (Val.getBoolValue() ? "true" : "false");
   } else if (T->isCharType()) {
-    const char Ch = Val.getZExtValue();
-    Out << ((Ch == '\'') ? "'\\" : "'");
-    Out.write_escaped(StringRef(&Ch, 1), /*UseHexEscapes=*/ true);
-    Out << "'";
+    Out << "(char)";
+    Out << Val;
   } else {
     Out << Val;
   }

It's not clear to me whether the two should match, or if there is another
way (something with the template related dwarf entries?).

Yacine.



More information about the llvm-commits mailing list