<html>
<head>
<meta content="text/html; charset=windows-1252"
http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
I figured out myself, just add `SBDebugger::Initialize()` at the
first line of main function.<br>
<br>
Besides, the code in Qt Creator and in command line actually behaved
the same. But Qt Creator redirected the segment fault message to
another window so I didn't noticed.<br>
<br>
<div class="moz-cite-prefix">On 11/10/2014 04:36 AM, Song Ziming
wrote:<br>
</div>
<blockquote
cite="mid:BLU436-SMTP6345BE69673F3F178B1B7F8C830@phx.gbl"
type="cite">
<meta http-equiv="content-type" content="text/html;
charset=windows-1252">
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=windows-1252">
<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>
<br>
<fieldset class="mimeAttachmentHeader"></fieldset>
<br>
<pre wrap="">_______________________________________________
lldb-dev mailing list
<a class="moz-txt-link-abbreviated" href="mailto:lldb-dev@cs.uiuc.edu">lldb-dev@cs.uiuc.edu</a>
<a class="moz-txt-link-freetext" href="http://lists.cs.uiuc.edu/mailman/listinfo/lldb-dev">http://lists.cs.uiuc.edu/mailman/listinfo/lldb-dev</a>
</pre>
</blockquote>
<br>
</body>
</html>