2
 ?58 pinNodes.push_back(node); ?
 ?59 } ?
 ?60 nlb::application::Application::instance().interpreter().eval(QString("unset %1").arg(pinIterListVarName)); ?
 ?61 ?
 ?62 if (!pinNodes.empty()) { ?
 ?63 insert(0, pinNodes.begin(), pinNodes.end()); ?
 ?64 } ?
 ?65 } catch (const std::exception& e) { ?
B+>?66 SA_ASSERT(false, e.what()); ?
 ?67 } ?
 ?68 } 

This is from gdb. I have set breakpoint to failing assert. When I am trying to print the reason of failure using p e.what() gdb prints Couldn't find method (null)what

Printing e gives that is is incomplete.

(gdb) p e
4ドル = (const struct std::exception &) @0x58f1990: <incomplete type>

How I can print it?

If SA_ASSERT's condition is false it calls this

void printTrace(unsigned int startDepth, QString& buff)
{
 const size_t maxDepth = 200;
 size_t stackDepth;
 void *stackAddrs[maxDepth];
 char **stackStrings;
 stackDepth = backtrace(stackAddrs, maxDepth);
 stackStrings = backtrace_symbols(stackAddrs, stackDepth);
 buff += "Call stack\n";
 unsigned int line = 1;
 for (size_t i = startDepth; i < stackDepth; i++) {
 size_t sz = 500; // just a guess, template names will go much wider
 char *function = reinterpret_cast<char*>(malloc(sz));
 char *begin = 0, *end = 0;
 // find the parentheses and address offset surrounding the mangled name
 for (char *j = stackStrings[i]; *j != 0; ++j) {
 if (*j == '(') {
 begin = j;
 } else if (*j == '+') {
 end = j;
 }
 }
 if (begin && end) {
 begin++;
 *end = 0;
 // found our mangled name, now in [begin, end)
 int status;
 char *ret = abi::__cxa_demangle(begin, function, &sz, &status);
 if (ret) {
 // return value may be a realloc() of the input
 function = ret;
 } else {
 // demangling failed, just pretend it's a C function
 // with no args
 std::strncpy(function, begin, sz);
 std::strncat(function, "()", sz);
 function[sz-1] = ' ';
 }
 buff += QString::number(line++) + QString(") ") + function + "\n";
 } else {
 // didn't find the mangled name, just print the whole line
 buff += QString::number(line++) + QString(") ") + stackStrings[i] + "\n";
 }
 free(function);
 }
 free(stackStrings); // malloc()ed by backtrace_symbols
}

The gdb version

GNU gdb 6.8
Copyright (C) 2008 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-unknown-linux-gnu".
asked Jun 5, 2013 at 13:44
8
  • I think e is null because you do not enter the catch block? Commented Jun 5, 2013 at 13:47
  • 1
    Nevermind, what does SA_ASSERT() do? Commented Jun 5, 2013 at 13:57
  • Before SA_ASSERT, why is e incomplete ? Commented Jun 5, 2013 at 14:19
  • Well this just got way out of my reach, sorry. Commented Jun 5, 2013 at 14:19
  • I would assume that somewhere in the code, a reference to NULL / nullptr is formed and throwed, like throw *((const std::exception*) nullptr);. Try throwing nullptr this way and see if you get the same error. Commented Jun 5, 2013 at 15:01

1 Answer 1

2

An incomplete type means you are missing some debuginfo. Without it, gdb can't do much. For example it can't print an object of that type, because it doesn't know how the type is laid out.

Version 6.8 is quite old. You should upgrade if you can. There have been many, many bug fixes to C++ support since then.

The "(null)" looks like a gdb bug. This is what happens when you try to printf NULL (at least with glibc). However, it is probable that this bug has been fixed sometime in the last 5 years.

answered Jun 5, 2013 at 17:24
Sign up to request clarification or add additional context in comments.

1 Comment

I don't know why that would happen. A bug report would be nice, if you have a simple way to reproduce. If you don't fix the incomplete type problem, though, you shouldn't expect much success.

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.