<HTML><HEAD><TITLE>Samsung Enterprise Portal mySingle</TITLE>
<META content="text/html; charset=utf-8" http-equiv=Content-Type>
<STYLE id=mysingle_style type=text/css>P {
        MARGIN-TOP: 5px; FONT-FAMILY: Arial, arial; MARGIN-BOTTOM: 5px; FONT-SIZE: 9pt
}
TD {
        MARGIN-TOP: 5px; FONT-FAMILY: Arial, arial; MARGIN-BOTTOM: 5px; FONT-SIZE: 9pt
}
LI {
        MARGIN-TOP: 5px; FONT-FAMILY: Arial, arial; MARGIN-BOTTOM: 5px; FONT-SIZE: 9pt
}
BODY {
        LINE-HEIGHT: 1.4; MARGIN: 10px; FONT-FAMILY: Arial, arial; FONT-SIZE: 9pt
}
</STYLE>

<META name=GENERATOR content=ActiveSquare></HEAD>
<BODY>
<P> </P>
<P>    I have debugged clang 3.2 static analyzer using following steps, someone might know a better approach. These are the steps I have used for a c++ checker.</P>
<P> </P>
<P>1) built with CC=gcc & CXX=g++,  might work with CC=clang and CXX=clang++ also I think</P>
<P>2) used following command from inside gdb, I remember getting these args either using -v or ### option </P>
<P> r "/home/camel/osa/bin/clang++" "-cc1" "-analyze" "-analyzer-checker" "Mychecker" "-internal-isystem" "/usr/lib/gcc/i686-linux-gnu/4.5/../../../../include/c++/4.5" "-internal-isystem" "/usr/lib/gcc/i686-linux-gnu/4.5/../../../../include/c++/4.5/i686-linux-gnu" "-internal-isystem" "/usr/lib/gcc/i686-linux-gnu/4.5/../../../../include/c++/4.5/backward" "-internal-isystem" "/usr/local/include" "-internal-isystem" "/usr/local/bin/../lib/clang/3.1/include" "-internal-isystem" "/usr/lib/gcc/i686-linux-gnu/4.5/../../../gcc/i686-linux-gnu/4.5/include" "-internal-isystem" "/usr/lib/gcc/i686-linux-gnu/4.5/../../../gcc/i686-linux-gnu/4.5/include-fixed" "-internal-externc-isystem" "/include" "-internal-externc-isystem" "/usr/include" testfile.cpp </P>
<P> </P>
<P>backtrace in gdb always showed segfaults for me incase of checker segfaults.</P>
<P> </P>
<P>Regards</P>
<P>Senthil Kumar</P>
<P> </P>
<P>------- <B>Original Message</B> -------</P>
<P><B>Sender</B> : G�bor Koz�r<kozargabor@gmail.com></P>
<P><B>Date</B> : Apr 29, 2013 21:15 (GMT+09:00)</P>
<P><B>Title</B> : [cfe-dev] Debugging Clang Static Analyzer segfault (clang 3.2)</P>
<P> </P>
<DIV dir=ltr>
<DIV>
<DIV>
<DIV>
<DIV>
<DIV>
<DIV>Hi,<BR><BR></DIV>I wrote a custom checker based on SimpleStreamChecker for the Clang Static Analyzer. I'm using clang version 3.2.<BR><BR></DIV>Upon running /.../llvm-3.2/build/bin/clang++ testfile.cpp -std=c++11 -Xclang -analyze -Xclang -analyzer-checker=mychecker, I get the following:<BR><BR>0  clang-3.2       0x0000000001b8a52c<BR>1  clang-3.2       0x0000000001b8a21c<BR>2  libpthread.so.0 0x00007f577ad715d0<BR>3  clang-3.2       0x000000000291903c<BR>4  clang-3.2       0x00000000029193f1<BR>5  clang-3.2       0x000000000291ada1<BR>6  clang-3.2       0x000000000298b9dc<BR>7  clang-3.2       0x0000000002987223<BR>8  clang-3.2       0x00000000029894b9<BR>9  clang-3.2       0x00000000029872dd clang::ento::CheckerManager::runCheckersForCallEvent(bool, clang::ento::ExplodedNodeSet&, clang::ento::ExplodedNodeSet const&, clang::ento::CallEvent const&, clang::ento::ExprEngine&, bool) + 159<BR>10 clang-3.2       0x00000000029c8736<BR>11 clang-3.2       0x00000000029cb0db clang::ento::ExprEngine::evalCall(clang::ento::ExplodedNodeSet&, clang::ento::ExplodedNode*, clang::ento::CallEvent const&) + 127<BR>12 clang-3.2       0x00000000029cafbd clang::ento::ExprEngine::VisitCallExpr(clang::CallExpr const*, clang::ento::ExplodedNode*, clang::ento::ExplodedNodeSet&) + 397<BR>13 clang-3.2       0x00000000029b1163 clang::ento::ExprEngine::Visit(clang::Stmt const*, clang::ento::ExplodedNode*, clang::ento::ExplodedNodeSet&) + 3785<BR>14 clang-3.2       0x00000000029af477 clang::ento::ExprEngine::ProcessStmt(clang::CFGStmt, clang::ento::ExplodedNode*) + 523<BR>15 clang-3.2       0x00000000029ae9b7 clang::ento::ExprEngine::processCFGElement(clang::CFGElement, clang::ento::ExplodedNode*, unsigned int, clang::ento::NodeBuilderContext*) + 205<BR>16 clang-3.2       0x000000000299d85c clang::ento::CoreEngine::HandlePostStmt(clang::CFGBlock const*, unsigned int, clang::ento::ExplodedNode*) + 282<BR>17 clang-3.2       0x000000000299cb40 clang::ento::CoreEngine::dispatchWorkItem(clang::ento::ExplodedNode*, clang::ProgramPoint, clang::ento::WorkListUnit const&) + 630<BR>18 clang-3.2       0x000000000299c838 clang::ento::CoreEngine::ExecuteWorkList(clang::LocationContext const*, unsigned int, llvm::IntrusiveRefCntPtr<clang::ento::ProgramState const>) + 918<BR>19 clang-3.2       0x00000000027fa752<BR>20 clang-3.2       0x00000000027d9bd1<BR>21 clang-3.2       0x00000000027d9ce2<BR>22 clang-3.2       0x00000000027d99c9<BR>23 clang-3.2       0x00000000027d8f9a<BR>24 clang-3.2       0x00000000027d92b7<BR>25 clang-3.2       0x0000000001f08c21 clang::ParseAST(clang::Sema&, bool, bool) + 786<BR>26 clang-3.2       0x0000000001e2427c clang::ASTFrontendAction::ExecuteAction() + 298<BR>27 clang-3.2       0x0000000001e23e97 clang::FrontendAction::Execute() + 197<BR>28 clang-3.2       0x0000000001e00bbb clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) + 717<BR>29 clang-3.2       0x0000000001b8f09d clang::ExecuteCompilerInvocation(clang::CompilerInstance*) + 1054<BR>30 clang-3.2       0x0000000000d0138c cc1_main(char const**, char const**, char const*, void*) + 678<BR>31 clang-3.2       0x0000000000cfb1d3 main + 508<BR>32 libc.so.6       0x00007f577a2a9bc6 __libc_start_main + 230<BR>33 clang-3.2       0x0000000000cf9879<BR>Stack dump:<BR>0.    Program arguments: /home/ekozgbo/work/dev/llvm-3.2/build/bin/clang-3.2 -cc1 -triple x86_64-unknown-linux-gnu -emit-obj -mrelax-all -disable-free -main-file-name t2.cpp -mrelocation-model static -mdisable-fp-elim -fmath-errno -masm-verbose -mconstructor-aliases -munwind-tables -target-cpu x86-64 -momit-leaf-frame-pointer -resource-dir /home/ekozgbo/work/dev/llvm-3.2/build/bin/../lib/clang/3.2 -fmodule-cache-path /var/tmp/clang-module-cache -internal-isystem /usr/lib64/gcc/x86_64-suse-linux/4.3/../../../../include/c++/4.3 -internal-isystem /usr/lib64/gcc/x86_64-suse-linux/4.3/../../../../include/c++/4.3/x86_64-suse-linux -internal-isystem /usr/lib64/gcc/x86_64-suse-linux/4.3/../../../../include/c++/4.3/backward -internal-isystem /usr/local/include -internal-isystem /home/ekozgbo/work/dev/llvm-3.2/build/bin/../lib/clang/3.2/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -std=c++11 -fdeprecated-macro -fdebug-compilation-dir /home/ekozgbo/work/dev/test -ferror-limit 19 -fmessage-length 237 -mstackrealign -fobjc-runtime=gcc -fcxx-exceptions -fexceptions -fdiagnostics-show-option -fcolor-diagnostics -analyze -analyzer-checker=mychecker -o /tmp/t2-lNeYsr.o -x c++ testfile.cpp <BR>1.    <eof> parser at end of file<BR>2.    testfile.cpp:32:2: Error evaluating statement<BR>3.    testfile.cpp:32:2: Error evaluating statement<BR>clang-3: error: unable to execute command: Segmentation fault<BR>clang-3: error: clang frontend command failed due to signal (use -v to see invocation)<BR>clang version 3.2 (tags/RELEASE_32/final 180012)<BR>Target: x86_64-unknown-linux-gnu<BR>Thread model: posix<BR>clang-3: note: diagnostic msg: PLEASE submit a bug report to <A href="http://llvm.org/bugs/">http://llvm.org/bugs/</A> and include the crash backtrace, preprocessed source, and associated run script.<BR>clang-3: error: unable to execute command: Segmentation fault<BR>clang-3: note: diagnostic msg: Error generating preprocessed source(s).<BR><BR></DIV>I'm fairly certain the issue is in my checker code, but I have no idea how to debug it. Clang seems to handle the segfault on its own, so I can't really do much with gdb.<BR>So how can I debug this issue? (Apart from the llvm::errs() or std::cout solution.)<BR><BR></DIV>The only changes I made to clang 3.2 is that I compile it with C++11, and of course I added two custom checkers. Oh and I'm also linking the static analyzer with libASTMatchers. So far I haven't had any issues, although the previous checker was much simpler.<BR><BR></DIV>Any help would be greatly appreciated.<BR></DIV><BR>Gabor<BR></DIV>
<P> </P>
<P> </P><!--SP:senthil.t-->
<P>Regards</P>
<P>Senthil Kumar</P>
<P> </P><!--senthil.t:EP-->
<P> </P>
<TABLE id=confidentialsignimg>
<TBODY>
<TR>
<TD NAMO_LOCK>
<P><IMG border=0 src="cid:BEI0XT4NZ5JE@namo.co.kr" width=520></P></TD></TR></TBODY></TABLE></BODY></HTML><img src='http://ext.samsung.net/mailcheck/SeenTimeChecker?do=75369c8e5c548a6e240c16c8773551632147438b08b6fada9cdd14f0554fc2de1d78c8484d0968ef1d70666c366810d91b20909a04efd4d2748cfe1d4e847419cf878f9a26ce15a0' border=0 width=0 height=0 style='display:none'>