<div dir="ltr"><div dir="ltr"><br></div><br><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">joan.lluch@icloud.com</a>> wrote:<br></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;">Hi David,<div><br></div><div>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><br></div><div>I know how to use the debugger, this is what I attempt to debug:</div><div><br></div><div> <span style="font-family:Monaco;font-size:10px;background-color:rgb(255,255,255)">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)">   </span></div></div></blockquote><div><br>OK, so wherever you have that ^  you should replace it with this \/<br><br>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><br>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><br>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> </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;"><div><br></div><div>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)">posix_spawn </span></div><div><span style="font-family:Monaco;font-size:11px;background-color:rgb(255,255,255)"><br></span></div><div>The call to <span style="font-family:Monaco;font-size:11px;background-color:rgb(255,255,255)">posix_spawn</span> happens in file “Program.inc” on the ‘Execute' function. The actual call is this</div><div><br></div><div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Monaco;background-color:rgb(255,255,255)">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)">                        <span style="color:rgb(0,132,0)">/*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)">                        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)"><br></div><div style="margin:0px;line-height:normal;background-color:rgb(255,255,255)">the variable <span style="font-family:Monaco;font-size:11px">Program.str() </span>contains <font face="Menlo"><span style="font-size:11px">"/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)"><br></div><div style="margin:0px;line-height:normal;background-color:rgb(255,255,255)">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)"><br></div><div style="margin:0px;line-height:normal;background-color:rgb(255,255,255)">I hope my issue is clearer now.</div><div style="margin:0px;line-height:normal;background-color:rgb(255,255,255)"><br></div><div style="margin:0px;line-height:normal;background-color:rgb(255,255,255)">Thanks anyway.</div><div style="margin:0px;line-height:normal;background-color:rgb(255,255,255)"><br></div><div style="margin:0px;line-height:normal;background-color:rgb(255,255,255)">John</div><div><br></div><div><br><div><blockquote type="cite"><div>On 4 Nov 2019, at 21:43, David Blaikie <<a href="mailto:dblaikie@gmail.com" target="_blank">dblaikie@gmail.com</a>> wrote:</div><br><div><div dir="ltr">that command:<br><br>"/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><br>Or wherever you had: -emit-llvm -S -g main.c (or something like that)<br>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><br></div><br><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">joan.lluch@icloud.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div>Hi David,<div><br></div><div>Thank you for your help. Please, can you elaborate on this?. The command line that I get with -### starts with this:</div><div><br></div><div><div style="margin:0px;font-size:10px;line-height:normal;font-family:Monaco;background-color:rgb(255,255,255)"><div style="margin:0px;line-height:normal"><span style="font-variant-ligatures:no-common-ligatures">clang version 9.0.1 (<a href="https://github.com/llvm/llvm-project.git" target="_blank">https://github.com/llvm/llvm-project.git</a> 6e38ee067b8fa08792f551fb565bbb8ada4864b1)</span></div><div style="margin:0px;line-height:normal"><span style="font-variant-ligatures:no-common-ligatures">Target: msp430</span></div><div style="margin:0px;line-height:normal"><span style="font-variant-ligatures:no-common-ligatures">Thread model: posix</span></div><div style="margin:0px;line-height:normal"><span style="font-variant-ligatures:no-common-ligatures">InstalledDir: /Users/joan/LLVM-9/llvm-project/build/Debug/bin</span></div><div style="margin:0px;line-height:normal"><span style="font-variant-ligatures:no-common-ligatures"> "/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)"><span style="font-variant-ligatures:no-common-ligatures"><br></span></div><div style="margin:0px;line-height:normal;background-color:rgb(255,255,255)">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)"><span style="font-family:Helvetica;font-size:12px"><br></span></div><div style="margin:0px;font-size:10px;line-height:normal;font-family:Monaco;background-color:rgb(255,255,255)"><span style="font-family:Helvetica;font-size:12px">Thanks</span></div><div style="margin:0px;font-size:10px;line-height:normal;font-family:Monaco;background-color:rgb(255,255,255)"><span style="font-family:Helvetica;font-size:12px"><br></span></div><div style="margin:0px;font-size:10px;line-height:normal;font-family:Monaco;background-color:rgb(255,255,255)"><span style="font-family:Helvetica;font-size:12px">John</span></div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div><div><br><div><blockquote type="cite"><div>On 4 Nov 2019, at 21:03, David Blaikie <<a href="mailto:dblaikie@gmail.com" target="_blank">dblaikie@gmail.com</a>> wrote:</div><br><div><div dir="ltr">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><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">llvm-dev@lists.llvm.org</a>> wrote:<br></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>
<br>
I want to understand some parts of ‘clang' by setting debug breakpoints. <br>
<br>
I have successfully done so with “llc” but I found that debugger breakpoints do not work for ‘clang’<br>
<br>
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>
<br>
Thanks in advance for any help.<br>
<br>
John<br>
_______________________________________________<br>
LLVM Developers mailing list<br>
<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a><br>
<a href="https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" rel="noreferrer" target="_blank">https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a><br>
</blockquote></div>
</div></blockquote></div><br></div></div></blockquote></div>
</div></blockquote></div><br></div></div></blockquote></div></div>