<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
</head>
<body bgcolor="#FFFFFF" text="#000000">
Hi everyone, I want to build a debugger frontend making use of
LLDB's API (on ubuntu linux 64bit). Since there's not enough
document/tutorial on using LLDB API, I turned to the "Python
reference" and made a little program:<br>
<br>
```<br>
<tt>#include <iostream></tt><tt><br>
</tt><tt>#include <lldb/API/LLDB.h></tt><tt><br>
</tt><tt>#include <lldb/API/SBDebugger.h></tt><tt><br>
</tt><tt>#include <lldb/API/SBTarget.h></tt><tt><br>
</tt><tt>using namespace std;</tt><tt><br>
</tt><tt>using namespace lldb;</tt><tt><br>
</tt><tt><br>
</tt><tt>int main() {</tt><tt><br>
</tt><tt> cout << "Hello LLDB!" << endl;</tt><tt><br>
</tt><tt> SBDebugger debugger = SBDebugger::Create();</tt><tt><br>
</tt><tt> debugger.SetAsync(false);</tt><tt><br>
</tt><tt> SBTarget target =
debugger.CreateTargetWithFileAndArch("/home/szm/target",
LLDB_ARCH_DEFAULT);</tt><tt><br>
</tt><tt> return 0;</tt><tt><br>
</tt><tt>}</tt><br>
```<br>
<br>
I compile and link the program using command: <tt>g++ -std=c++0x -o
lldbwrapper lldbwrapper.cpp -I /usr/lib/llvm-3.5/include -llldb</tt>.
It compiled without error, but when I run the program it printed
"Helo, LLDB!" and then printed "Segment fault".<br>
<br>
What's more, if I use the same code in Qt Creator with a plain c++
project (using qmake, with C++11 enabled), the program just run
normally.<br>
<br>
I inspected Qt's compile command is:<br>
<br>
```<br>
<tt>g++ -c -pipe -g -std=c++0x -Wall -W -fPIE
-I/opt/Qt5.3.1/5.3/gcc_64/mkspecs/linux-g++ -I../lldbtest
-I/usr/lib/llvm-3.5/include -I. -o main.o ../lldbtest/main.cpp</tt><tt><br>
</tt><tt>g++ -Wl,-rpath,/opt/Qt5.3.1/5.3/gcc_64 -o lldbtest main.o
-I /usr/lib/llvm-3.5/include -llldb</tt><br>
```<br>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<style type="text/css">
p, li { white-space: pre-wrap; }
</style>But I didnt see any difference, what's the cause of the segment
fault only in command line?<br>
<br>
Thanks,<br>
<br>
Song Ziming<br>
</body>
</html>