<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class=""><br class=""></div><div class="">Hi David,</div><div class=""><br class=""></div><div class="">I understand now what you mean, and it worked. I replied already to someone else. Please accept my apologies as I misread a message before.</div><div class=""><br class=""></div><div class="">Thanks for your help.</div><div class=""><br class=""></div><div class="">John.</div><div class=""><br class=""></div><div><blockquote type="cite" class=""><div class="">On 4 Nov 2019, at 22:14, David Blaikie <<a href="mailto:dblaikie@gmail.com" class="">dblaikie@gmail.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class=""><div dir="ltr" class=""><br class=""></div><br class=""><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Mon, Nov 4, 2019 at 1:10 PM Joan Lluch <<a href="mailto:joan.lluch@icloud.com" class="">joan.lluch@icloud.com</a>> wrote:<br class=""></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div style="overflow-wrap: break-word;" class="">Hi David,<div class=""><br class=""></div><div class="">Thank you for your patience but I still don’t get it:  I don’t see how that is a “command”, as it’s just a list of strings that state command options.</div><div class=""><br class=""></div><div class="">I know how to use the debugger, this is what I attempt to debug:</div><div class=""><br class=""></div><div class=""> <span style="font-family:Monaco;font-size:10px;background-color:rgb(255,255,255)" class="">clang --target=msp430 -emit-llvm -c -S -Oz main.c</span><span style="font-family:Monaco;font-size:10px;background-color:rgb(255,255,255)" class="">   </span></div></div></blockquote><div class=""><br class="">OK, so wherever you have that ^  you should replace it with this \/<br class=""><br class="">clang "-cc1" "-triple" "msp430" "-emit-llvm" "-disable-free" "-main-file-name" "main.c" "-mrelocation-model" "static" "-mthread-model" "posix" "-fmath-errno" "-masm-verbose" "-mconstructor-aliases" "-nostdsysteminc" "-dwarf-column-info" "-debugger-tuning=gdb" "-target-linker-version" "305" "-momit-leaf-frame-pointer" "-coverage-notes-file" "/Users/joan/Documents-Local/Relay/RelayNou/main.gcno" "-resource-dir" "/Users/joan/LLVM-9/llvm-project/build/Debug/lib/clang/9.0.1" "-internal-isystem" "/Users/joan/LLVM-9/llvm-project/build/Debug/bin/../msp430/include" "-Oz" "-fdebug-compilation-dir" "/Users/joan/Documents-Local/Relay/RelayNou" "-ferror-limit" "19" "-fmessage-length" "224" "-fobjc-runtime=gcc" "-fdiagnostics-show-option" "-fcolor-diagnostics" "-vectorize-slp" "-faddrsig" "-o" "main.ll" "-x" "c" "main.c"<br class=""><br class="">It's just a ton of command line arguments, but it's not fundamentally different from the command you were already debugging - it's clang with some command line arguments.<br class=""><br class="">This clang command (the one with the first argument of -cc1) will not invoke a child process - this is the command that the clang command you ran would run as its child process. So it's stripping off that layer so you can debug the underlying command/child process.</div><div class=""> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div style="overflow-wrap: break-word;" class=""><div class=""><br class=""></div><div class="">The debugger works fine, but only on the main thread. However breakpoints do not work with the code that was invoked as a child process with <span style="font-family:Monaco;font-size:11px;background-color:rgb(255,255,255)" class="">posix_spawn </span></div><div class=""><span style="font-family:Monaco;font-size:11px;background-color:rgb(255,255,255)" class=""><br class=""></span></div><div class="">The call to <span style="font-family:Monaco;font-size:11px;background-color:rgb(255,255,255)" class="">posix_spawn</span> happens in file “Program.inc” on the ‘Execute' function. The actual call is this</div><div class=""><br class=""></div><div class=""><div style="margin:0px;font-size:11px;line-height:normal;font-family:Monaco;background-color:rgb(255,255,255)" class="">Err = posix_spawn(&PID, Program.str().c_str(), FileActions,</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Monaco;background-color:rgb(255,255,255)" class="">                        <span style="color:rgb(0,132,0)" class="">/*attrp*/</span> nullptr, const_cast<char **>(Argv),</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Monaco;background-color:rgb(255,255,255)" class="">                        const_cast<char **>(Envp));</div></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Monaco;background-color:rgb(255,255,255)" class=""><br class=""></div><div style="margin:0px;line-height:normal;background-color:rgb(255,255,255)" class="">the variable <span style="font-family:Monaco;font-size:11px" class="">Program.str() </span>contains <font face="Menlo" class=""><span style="font-size:11px" class="">"/Users/joan/LLVM-9/llvm-project/build/Debug/bin/clang” </span></font>at this point, which I got with a breakpoint set at that point.</div><div style="margin:0px;line-height:normal;background-color:rgb(255,255,255)" class=""><br class=""></div><div style="margin:0px;line-height:normal;background-color:rgb(255,255,255)" class="">HOWEVER, any code that is run under that child process is not seen by the debugger. </div><div style="margin:0px;line-height:normal;background-color:rgb(255,255,255)" class=""><br class=""></div><div style="margin:0px;line-height:normal;background-color:rgb(255,255,255)" class="">I hope my issue is clearer now.</div><div style="margin:0px;line-height:normal;background-color:rgb(255,255,255)" class=""><br class=""></div><div style="margin:0px;line-height:normal;background-color:rgb(255,255,255)" class="">Thanks anyway.</div><div style="margin:0px;line-height:normal;background-color:rgb(255,255,255)" class=""><br class=""></div><div style="margin:0px;line-height:normal;background-color:rgb(255,255,255)" class="">John</div><div class=""><br class=""></div><div class=""><br class=""><div class=""><blockquote type="cite" class=""><div class="">On 4 Nov 2019, at 21:43, David Blaikie <<a href="mailto:dblaikie@gmail.com" target="_blank" class="">dblaikie@gmail.com</a>> wrote:</div><br class=""><div class=""><div dir="ltr" class="">that command:<br class=""><br class="">"/Users/joan/LLVM-9/llvm-project/build/Debug/bin/clang" "-cc1" "-triple" "msp430" "-emit-llvm" "-disable-free" "-main-file-name" "main.c" "-mrelocation-model" "static" "-mthread-model" "posix" "-fmath-errno" "-masm-verbose" "-mconstructor-aliases" "-nostdsysteminc" "-dwarf-column-info" "-debugger-tuning=gdb" "-target-linker-version" "305" "-momit-leaf-frame-pointer" "-coverage-notes-file" "/Users/joan/Documents-Local/Relay/RelayNou/main.gcno" "-resource-dir" "/Users/joan/LLVM-9/llvm-project/build/Debug/lib/clang/9.0.1" "-internal-isystem" "/Users/joan/LLVM-9/llvm-project/build/Debug/bin/../msp430/include" "-Oz" "-fdebug-compilation-dir" "/Users/joan/Documents-Local/Relay/RelayNou" "-ferror-limit" "19" "-fmessage-length" "224" "-fobjc-runtime=gcc" "-fdiagnostics-show-option" "-fcolor-diagnostics" "-vectorize-slp" "-faddrsig" "-o" "main.ll" "-x" "c" "main.c"<br class=""><br class="">Or wherever you had: -emit-llvm -S -g main.c (or something like that)<br class="">You now have:  "-cc1" "-triple" "msp430" "-emit-llvm" "-disable-free" "-main-file-name" "main.c" "-mrelocation-model" "static" "-mthread-model" "posix" "-fmath-errno" "-masm-verbose" "-mconstructor-aliases" "-nostdsysteminc" "-dwarf-column-info" "-debugger-tuning=gdb" "-target-linker-version" "305" "-momit-leaf-frame-pointer" "-coverage-notes-file" "/Users/joan/Documents-Local/Relay/RelayNou/main.gcno" "-resource-dir" "/Users/joan/LLVM-9/llvm-project/build/Debug/lib/clang/9.0.1" "-internal-isystem" "/Users/joan/LLVM-9/llvm-project/build/Debug/bin/../msp430/include" "-Oz" "-fdebug-compilation-dir" "/Users/joan/Documents-Local/Relay/RelayNou" "-ferror-limit" "19" "-fmessage-length" "224" "-fobjc-runtime=gcc" "-fdiagnostics-show-option" "-fcolor-diagnostics" "-vectorize-slp" "-faddrsig" "-o" "main.ll" "-x" "c" "main.c"<br class=""><br class=""></div><br class=""><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Mon, Nov 4, 2019 at 12:29 PM Joan Lluch <<a href="mailto:joan.lluch@icloud.com" target="_blank" class="">joan.lluch@icloud.com</a>> wrote:<br class=""></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div class="">Hi David,<div class=""><br class=""></div><div class="">Thank you for your help. Please, can you elaborate on this?. The command line that I get with -### starts with this:</div><div class=""><br class=""></div><div class=""><div style="margin:0px;font-size:10px;line-height:normal;font-family:Monaco;background-color:rgb(255,255,255)" class=""><div style="margin:0px;line-height:normal" class=""><span style="font-variant-ligatures:no-common-ligatures" class="">clang version 9.0.1 (<a href="https://github.com/llvm/llvm-project.git" target="_blank" class="">https://github.com/llvm/llvm-project.git</a> 6e38ee067b8fa08792f551fb565bbb8ada4864b1)</span></div><div style="margin:0px;line-height:normal" class=""><span style="font-variant-ligatures:no-common-ligatures" class="">Target: msp430</span></div><div style="margin:0px;line-height:normal" class=""><span style="font-variant-ligatures:no-common-ligatures" class="">Thread model: posix</span></div><div style="margin:0px;line-height:normal" class=""><span style="font-variant-ligatures:no-common-ligatures" class="">InstalledDir: /Users/joan/LLVM-9/llvm-project/build/Debug/bin</span></div><div style="margin:0px;line-height:normal" class=""><span style="font-variant-ligatures:no-common-ligatures" class=""> "/Users/joan/LLVM-9/llvm-project/build/Debug/bin/clang" "-cc1" "-triple" "msp430" "-emit-llvm" "-disable-free" "-main-file-name" "main.c" "-mrelocation-model" "static" "-mthread-model" "posix" "-fmath-errno" "-masm-verbose" "-mconstructor-aliases" "-nostdsysteminc" "-dwarf-column-info" "-debugger-tuning=gdb" "-target-linker-version" "305" "-momit-leaf-frame-pointer" "-coverage-notes-file" "/Users/joan/Documents-Local/Relay/RelayNou/main.gcno" "-resource-dir" "/Users/joan/LLVM-9/llvm-project/build/Debug/lib/clang/9.0.1" "-internal-isystem" "/Users/joan/LLVM-9/llvm-project/build/Debug/bin/../msp430/include" "-Oz" "-fdebug-compilation-dir" "/Users/joan/Documents-Local/Relay/RelayNou" "-ferror-limit" "19" "-fmessage-length" "224" "-fobjc-runtime=gcc" "-fdiagnostics-show-option" "-fcolor-diagnostics" "-vectorize-slp" "-faddrsig" "-o" "main.ll" "-x" "c" "main.c"</span></div></div></div><div style="margin:0px;font-size:10px;line-height:normal;font-family:Monaco;background-color:rgb(255,255,255)" class=""><span style="font-variant-ligatures:no-common-ligatures" class=""><br class=""></span></div><div style="margin:0px;line-height:normal;background-color:rgb(255,255,255)" class="">So what should I set on the debugger?</div><div style="margin:0px;font-size:10px;line-height:normal;font-family:Monaco;background-color:rgb(255,255,255)" class=""><span style="font-family:Helvetica;font-size:12px" class=""><br class=""></span></div><div style="margin:0px;font-size:10px;line-height:normal;font-family:Monaco;background-color:rgb(255,255,255)" class=""><span style="font-family:Helvetica;font-size:12px" class="">Thanks</span></div><div style="margin:0px;font-size:10px;line-height:normal;font-family:Monaco;background-color:rgb(255,255,255)" class=""><span style="font-family:Helvetica;font-size:12px" class=""><br class=""></span></div><div style="margin:0px;font-size:10px;line-height:normal;font-family:Monaco;background-color:rgb(255,255,255)" class=""><span style="font-family:Helvetica;font-size:12px" class="">John</span></div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><br class=""><div class=""><blockquote type="cite" class=""><div class="">On 4 Nov 2019, at 21:03, David Blaikie <<a href="mailto:dblaikie@gmail.com" target="_blank" class="">dblaikie@gmail.com</a>> wrote:</div><br class=""><div class=""><div dir="ltr" class="">Run clang with -### to get the underlying command line (the one that has the first argument "-cc1") and then run that command under the debugger instead.</div><br class=""><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Mon, Nov 4, 2019 at 12:02 PM Joan Lluch via llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org" target="_blank" class="">llvm-dev@lists.llvm.org</a>> wrote:<br class=""></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Hi All,<br class="">
<br class="">
I want to understand some parts of ‘clang' by setting debug breakpoints. <br class="">
<br class="">
I have successfully done so with “llc” but I found that debugger breakpoints do not work for ‘clang’<br class="">
<br class="">
The apparent cause is that the clang code is run as a child process which is created in the ‘Execute' function of ‘Program.inc'. The debugger stops fine at breakpoints set on the main thread, but breakpoints do not work for any code that is executed as the child process. I am compiling with Xcode in case this makes a difference.<br class="">
<br class="">
Thanks in advance for any help.<br class="">
<br class="">
John<br class="">
_______________________________________________<br class="">
LLVM Developers mailing list<br class="">
<a href="mailto:llvm-dev@lists.llvm.org" target="_blank" class="">llvm-dev@lists.llvm.org</a><br class="">
<a href="https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" rel="noreferrer" target="_blank" class="">https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a><br class="">
</blockquote></div>
</div></blockquote></div><br class=""></div></div></blockquote></div>
</div></blockquote></div><br class=""></div></div></blockquote></div></div>
</div></blockquote></div><br class=""></body></html>