Hi folks,
Whilst starting to play with the lldb C++ API, I've noticed that this
simple little program causes an assertion failure (and hence a core
dump).
#include <cstdio>
#include "lldb/API/LLDB.h"
int main()
{
fprintf(stderr, "lldb-app\n");
// lldb::SBDebugger::Initialize();
lldb::SBDebugger dbgr = lldb::SBDebugger::Create(true);
fprintf(stderr, "SBDebugger::Create!\n");
return 0;
}
As guessed, by uncommenting out the Initialize call, the assertion is
satisfied by Create and friends, and the code runs to completion.
To me, this is bad on 2 counts:
1. If Create depends on Initialize then Initialize should be called
internally.
2. From a public API perspective, even if Create and Initialize need to
be called separately, a crash (failed assert) seems a little harsh.
Shouldn't an error return (or exception throw) be used to communicate
the user's mistake in this case?
I did some digging into SBDebugger::Initialize and it seems safe for
this to be called internally by Create.
So I'm proposing that I fix this issue with following patch:
Index: source/API/SBDebugger.cpp