<div dir="ltr"><div><br></div><div>> We would need to query if the current process supports restarting so if</div><div>> you run the "process launch" command and the current process is alive, </div><div>> we would then need to try and restart.</div>
<div><br></div><div>I am working on the support for restarting in remote debugging. When the "process launch" command is run and if the process is alive I am sending the 'R' packet. I have attached the file that contains the implementation of Process::Restart() and ProcessGDBRemote::DoRestart(). I wrote these two methods by referring the methods Process::Destroy() and ProcessGDBRemote::DoDestroy().</div>
<div><br></div><div>Now when I run "process launch" command when the process is alive (i.e. at a breakpoint), the 'R' packet is sent to the target and also the process launch packets 'A' are sent. But I get the error "error: initial process state wasn't stopped: exited" and the previous breakpoint status message is printed on the console as shown below.</div>
<div><br></div><div>$ lldb --arch vliw-unknown-unknown workplace/app.elf </div><div>Current executable set to 'workplace/app.elf' (vliw).</div><div>(lldb)process connect --plugin gdb-remote connect://localhost:51000</div>
<div>Process 0 connected</div><div>(lldb)b main.c:31</div><div>breakpoint set --file 'main.c' --line 31</div><div>Breakpoint created: 1: file ='main.c', line = 31, locations = 1</div><div>(lldb)run</div><div>
Process 1 launched: '/home/chandra/app01/workplace/app.elf' (vliw)</div><div>Process 1 stopped</div><div>* thread #1: tid = 0x0001, 0x20016440 app.elf`main + 304 at main.c:31, stop reason = breakpoint 1.1</div><div>
frame #0: 0x20016440 app.elf`main + 304 at main.c:31</div><div> 28 <span class="" style="white-space:pre"> </span> for (i=0; i<N; i++)</div><div> 29 <span class="" style="white-space:pre"> </span> {</div><div>
30 <span class="" style="white-space:pre"> </span> result += i*10;</div><div>-> 31 <span class="" style="white-space:pre"> </span> A[i] = result;</div><div> 32 <span class="" style="white-space:pre"> </span> }</div>
<div> 33 <span class="" style="white-space:pre"> </span></div><div>(lldb) run</div><div>There is a running process, kill it and restart?: [Y/n] </div><div>Y</div><div>Process 1 launched: '/home/chandra/app01/workplace/app.elf' (vliw)</div>
<div>error: initial process state wasn't stopped: exited</div><div>Process 1 stopped</div><div>* thread #1: tid = 0x0001, 0x20016440 app.elf`main + 304 at main.c:31, stop reason = signal SIGSTOP</div><div> frame #0: 0x20016440 app.elf`main + 304 at main.c:31</div>
<div> 28 <span class="" style="white-space:pre"> </span> for (i=0; i<N; i++)</div><div> 29 <span class="" style="white-space:pre"> </span> {</div><div> 30 <span class="" style="white-space:pre"> </span> result += i*10;</div>
<div>-> 31 <span class="" style="white-space:pre"> </span> A[i] = result;</div><div> 32 <span class="" style="white-space:pre"> </span> }</div><div> 33 <span class="" style="white-space:pre"> </span></div><div>
(lldb)</div><div><br></div><div>On debugging the code, I found - lldb sends the 'R' packets, lldb updates the process state for 'R' packet response, lldb sends the arguments packet for launching, lldb waits for the process to stop and lldb gets the process state as "eStateExited".</div>
<div><br></div><div>Below is the communication between lldb and simulator.</div><div><br></div><div>(lldb) run</div><div>There is a running process, kill it and restart?: [Y/n] </div><div>Y</div><div>< 17> send packet: $z0,20016440,0#c3</div>
<div>< 1> read packet: +</div><div>< 6> read packet: $OK#9a</div><div>< 1> send packet: +</div><div>< 5> send packet: $R#52</div><div>< 1> read packet: +</div><div>< 7> read packet: $W00#b7</div>
<div>< 1> send packet: +</div><div>< 36> send packet: $QSetSTDIN:2f6465762f7074732f3135#4b</div><div>< 1> read packet: +</div><div>< 6> read packet: $OK#9a</div><div>< 1> send packet: +</div>
<div>< 37> send packet: $QSetSTDOUT:2f6465762f7074732f3135#ac</div><div>< 1> read packet: +</div><div>< 6> read packet: $OK#9a</div><div>< 1> send packet: +</div><div>< 37> send packet: $QSetSTDERR:2f6465762f7074732f3135#9d</div>
<div>< 1> read packet: +</div><div>< 6> read packet: $OK#9a</div><div>< 1> send packet: +</div><div>< 21> send packet: $QSetDisableASLR:1#ce</div><div>< 1> read packet: +</div><div>< 6> read packet: $OK#9a</div>
<div>< 1> send packet: +</div><div>< 19> send packet: $QLaunchArch:vliw#9f</div><div>< 1> read packet: +</div><div>< 6> read packet: $OK#9a</div><div>< 1> send packet: +</div><div>< 251> send packet: $A240,0,2f686f6d652f6368616e6472612f61707030312f776f726b706c6163652f6170702e656c66#75</div>
<div>< 1> read packet: +</div><div>< 6> read packet: $OK#9a</div><div>< 1> send packet: +</div><div>< 18> send packet: $qLaunchSuccess#a5</div><div>< 1> read packet: +</div><div>< 6> read packet: $OK#9a</div>
<div>< 1> send packet: +</div><div>< 6> send packet: $qC#b4</div><div>< 1> read packet: +</div><div>< 7> read packet: $QC1#c5</div><div>< 1> send packet: +</div><div>< 5> send packet: $?#3f</div>
<div>< 1> read packet: +</div><div>< 19> read packet: $T11thread:0001;#64</div><div>< 1> send packet: +</div><div>< 16> send packet: $qfThreadInfo#bb</div><div>< 1> read packet: +</div>
<div>< 6> read packet: $m1#9e</div><div>< 1> send packet: +</div><div>< 16> send packet: $qsThreadInfo#c8</div><div>< 1> read packet: +</div><div>< 5> read packet: $l#6c</div><div>< 1> send packet: +</div>
<div>Process 1 launched: '/home/chandra/app01/workplace/app.elf' (vliw)</div><div>error: initial process state wasn't stopped: exited</div><div>Process 1 stopped</div><div>* thread #1: tid = 0x0001, 0x20016440 app.elf`main + 304 at main.c:31, stop reason = signal SIGSTOP</div>
<div> frame #0: 0x20016440 app.elf`main + 304 at main.c:31</div><div> 28 <span class="" style="white-space:pre"> </span> for (i=0; i<N; i++)</div><div> 29 <span class="" style="white-space:pre"> </span> {</div>
<div> 30 <span class="" style="white-space:pre"> </span> result += i*10;</div><div>-> 31 <span class="" style="white-space:pre"> </span> A[i] = result;</div><div> 32 <span class="" style="white-space:pre"> </span> }</div>
<div> 33 <span class="" style="white-space:pre"> </span></div><div>(lldb) </div><div><br></div><div>I doubt my 'restart' implementation done with inadequate understanding. It would be very helpful if someone guides me in correcting the 'restart' implementation attached with this mail.</div>
<div><br></div><div>Thank you,</div><div>Chandra Kumar R.</div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Tue, Aug 20, 2013 at 6:23 AM, Greg Clayton <span dir="ltr"><<a href="mailto:gclayton@apple.com" target="_blank">gclayton@apple.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="im"><br>
On Aug 19, 2013, at 7:44 AM, chansarav <<a href="mailto:chansarav@gmail.com">chansarav@gmail.com</a>> wrote:<br>
<br>
> > Send a “WXX” packet to indicate the program exited.<br>
><br>
> Thank you. Sending the "WXX"” packet to indicate the program exited worked. I received the following message at the lldb prompt.<br>
><br>
> Process 1 exited with status = 0<br>
><br>
> And now to restart the application I gave the 'run' command for which I received the error "'A' packet returned an error: -1". When I checked the simulator for this I found that the simulator didn't receive the 'A' packet.<br>
><br>
> When debugged the lldb, I found that the problem is with the platform that has been chosen for my target. I had made platform "gdb-server" as my default platform explicitly by modifying the "PlatformRemoteGDBServer::Initialize ()" method.<br>
><br>
> $ lldb --arch vliw workplace/app.elf<br>
> Current executable set to 'workplace/app.elf' (vliw).<br>
> (lldb) target list<br>
> Current targets:<br>
> * target #0: /home/chandra/app01/workplace/app.elf ( arch=vliw-unknown-unknown, platform=remote-gdb-server )<br>
><br>
> Since I was connecting the target simulator using the Process plugin 'gdb-remote', the platform "gdb-server" didn't come into picture of connecting the simulator.<br>
><br>
> (lldb) process connect --plugin gdb-remote connect://localhost:51000<br>
><br>
> The connection and the debugging happened through the 'gdb-remote' Process plugin. And the problem comes when I restart the program after it terminates with an exit status. I.e. When I give the 'run' command to restart the program, the platform "gdb-server" sends the argument packet 'A' for program launching. But there is no connection associated with the platform "gdb-server". Hence lldb gives the following error:<br>
><br>
> error: 'A' packet returned an error: -1<br>
><br>
><br>
> With my existing porting of lldb I am able to connect the simulator and successfully debug a program once. But I am not able to do the following:<br>
><br>
> 1. Restart the program for debugging with disconnecting the connection.<br>
<br>
</div>LLDB doesn't currently support the restart packet ("RXX"). Feel free to add support for it.<br>
<div class="im"><br>
> 2. Send launch command to the simulator from lldb.<br>
<br>
</div>The launch command will send the "A" packet which sends the program and arguments. I believe that LLDB will disconnect from the remote server when the process exits, though it doesn't need to.<br>
<div class="im"><br>
> Can't I support the above two features from the 'gdb-remote' Process plugin? Can you please suggest the way of supporting the above two features?<br>
<br>
</div>Currently the "restart" support uses lldb_private::Process primitives like Process::Kill() to kill the current program, then it will just call "Process::Launch()" again. We could modify lldb_private::Process with a few new calls:<br>
<br>
bool<br>
Process::SupportsRestart();<br>
<br>
Error<br>
Process::Restart();<br>
<br>
We would need to query if the current process supports restarting so if you run the "process launch" command and the current process is alive, we would then need to try and restart.<br>
<br>
So yes, this is possible, but we don't have any support for restart except for using the current Process primitives.<br>
<div class="HOEnZb"><div class="h5"><br>
Greg<br>
<br>
><br>
> Thanks,<br>
> Chandra Kumar R.<br>
><br>
><br>
> On Sat, Aug 10, 2013 at 1:26 AM, Greg Clayton <<a href="mailto:gclayton@apple.com">gclayton@apple.com</a>> wrote:<br>
><br>
> On Aug 8, 2013, at 6:04 AM, chansarav <<a href="mailto:chansarav@gmail.com">chansarav@gmail.com</a>> wrote:<br>
><br>
> > I have ported lldb for remotely debugging our target. The lldb is connected to the target simulator using the gdb remote protocol.<br>
> ><br>
> > $lldb --arch vliw app.elf<br>
> > (lldb)process connect --plugin gdb-remote connect://localhost:51000<br>
> ><br>
> > The above command connects the lldb with the target simulator waiting at port '51000'. And the debug commands work properly.<br>
> ><br>
> > But once the execution of the application completes, I am facing the problem in restarting the application for debugging again.<br>
> ><br>
> > For restarting the application being debugged, I think lldb should send the 'R' packet. When would lldb send the 'R' packet?<br>
> ><br>
> > Currently the target simulator sends the SIGTERM signal (T0fthread:0001) after completing the program execution. And on receiving this signal, lldb doesn't doesn't display the message "Program exited normally”.<br>
><br>
> The “T0F” means we stopped with a signal. Send a “WXX” packet to indicate the program exited.<br>
> ><br>
> > Also when I gave the 'continue' command to restart the application debugging again, lldb sends the 'C0f' packet.<br>
><br>
> Yes, you indicated you stopped with a signal. We often catch signals before they get passed onto the signal handlers and we can decide to not pass on the signal. See “help process handle” for more information, but again, if your process exits with a signal, send a “WXX” packet where XX is the hex exit status of the program.<br>
><br>
> Greg<br>
><br>
> ><br>
> ><br>
> > Thanks,<br>
> > Chandra Kumar R.<br>
> > _______________________________________________<br>
> > lldb-dev mailing list<br>
> > <a href="mailto:lldb-dev@cs.uiuc.edu">lldb-dev@cs.uiuc.edu</a><br>
> > <a href="http://lists.cs.uiuc.edu/mailman/listinfo/lldb-dev" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/lldb-dev</a><br>
><br>
><br>
<br>
</div></div></blockquote></div><br></div>