[lldb-dev] Using LLDB API Segment Fault
Song Ziming
s.ziming at hotmail.com
Sun Nov 9 12:36:17 PST 2014
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:
```
#include <iostream>
#include <lldb/API/LLDB.h>
#include <lldb/API/SBDebugger.h>
#include <lldb/API/SBTarget.h>
using namespace std;
using namespace lldb;
int main() {
cout << "Hello LLDB!" << endl;
SBDebugger debugger = SBDebugger::Create();
debugger.SetAsync(false);
SBTarget target =
debugger.CreateTargetWithFileAndArch("/home/szm/target", LLDB_ARCH_DEFAULT);
return 0;
}
```
I compile and link the program using command: g++ -std=c++0x -o
lldbwrapper lldbwrapper.cpp -I /usr/lib/llvm-3.5/include -llldb. It
compiled without error, but when I run the program it printed "Helo,
LLDB!" and then printed "Segment fault".
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.
I inspected Qt's compile command is:
```
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
g++ -Wl,-rpath,/opt/Qt5.3.1/5.3/gcc_64 -o lldbtest main.o -I
/usr/lib/llvm-3.5/include -llldb
```
But I didnt see any difference, what's the cause of the segment fault
only in command line?
Thanks,
Song Ziming
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/lldb-dev/attachments/20141110/d3355ed4/attachment.html>
More information about the lldb-dev
mailing list