<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class="">Sounds good!<br class=""><div><br class=""><blockquote type="cite" class=""><div class="">On Sep 24, 2018, at 10:45 AM, Leonard Mosescu <<a href="mailto:mosescu@google.com" class="">mosescu@google.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class="">Thanks Greg, this is what I had in mind. <div class=""><br class=""></div><div class="">I have some ideas which involve this kind of debugger console. We'll likely start with a basic version built on top of evaluate `cmd and once we get around to building a full console I'll ping you.</div></div><div class="gmail_extra"><br class=""><div class="gmail_quote">On Sat, Sep 22, 2018 at 8:50 AM, Greg Clayton <span dir="ltr" class=""><<a href="mailto:clayborg@gmail.com" target="_blank" class="">clayborg@gmail.com</a>></span> wrote:<br class=""><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word;line-break:after-white-space" class=""><br class=""><div class=""><span class=""><br class=""><blockquote type="cite" class=""><div class="">On Sep 21, 2018, at 1:20 PM, Leonard Mosescu <<a href="mailto:mosescu@google.com" target="_blank" class="">mosescu@google.com</a>> wrote:</div><br class=""><div class=""><div dir="ltr" class="">Great. Do you think that having an abstracted stream I/O tunneled through DAP would lose anything compared to the direct file handle? I can see a few problems using a native platform file handle: <div class=""><br class=""></div><div class="">1. It's specific to the platform (with subtle differences between platforms)</div><div class="">2. It assumes a local setup, where the consumer and DAP implementation are running on the same machine, likely in the context of the same user.</div><div class=""><br class=""></div><div class="">If DAP had some basic read/write stream packets you can easily build a flexible remote setup. What do you think?</div></div></div></blockquote><div class=""><br class=""></div></span>Yeah, I forgot about remote. Maybe best to set it all up through DAP and just tell the IDE that you have a command interpreter and maybe what its prompt should be. </div><div class=""><br class=""></div><div class="">The init packet would be sent:</div><div class=""><br class=""></div><div class="">{"command":"initialize","type"<wbr class="">:"request","seq":1, "arguments":{...}}</div><div class=""><br class=""></div><div class="">Then in the response we would say we have an interpreter:</div><div class=""><br class=""></div><div class="">{"command":"initialize","type"<wbr class="">:"response", "request_seq":1,"seq":0,"<wbr class="">success":true,"body":{</div><div class="">    "supportsCommandInterpreter":<wbr class="">true, </div><div class="">    "interpreterPrompt":"(lldb)"</div><div class="">  }</div><div class="">}<br class=""><br class=""></div><div class=""><br class=""></div><div class="">Then the IDE would need to support output going into (STDIN) that would go to the command interpreter somehow, and accept output coming from the command interpreter via the "output" event by adding support for a new output type "interpreter":</div><div class=""><br class=""></div><div class="">{"event":"output","seq":0,"<wbr class="">type":"event", "body":{"category":"<wbr class="">interpreter","output":"output text here"}}</div><div class=""><br class=""></div><div class="">Then the IDE would only need either have another window for the interpreter, or allow the standard debugger console to be switched over into interpreter mode and show both outputs there.</div><div class=""><div class="h5"><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><blockquote type="cite" class=""><div class=""><div class="gmail_extra"><br class=""><div class="gmail_quote">On Fri, Sep 21, 2018 at 10:39 AM, Greg Clayton <span dir="ltr" class=""><<a href="mailto:clayborg@gmail.com" target="_blank" class="">clayborg@gmail.com</a>></span> wrote:<br class=""><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word;line-break:after-white-space" class=""><br class=""><div class=""><span class=""><br class=""><blockquote type="cite" class=""><div class="">On Sep 21, 2018, at 10:31 AM, Leonard Mosescu <<a href="mailto:mosescu@google.com" target="_blank" class="">mosescu@google.com</a>> wrote:</div><br class=""><div class=""><div dir="ltr" class=""><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">

<span style="font-size:12.8px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline" class="">The solution I would love to see is to have the initialize packet return something via the DAP that says "I have a command line interpreter, please send a packet with a file handle (slave path to slave side of pseudo terminal maybe)". VS Code and Nuclide both emulated tty already, so we could have a true command line that exposes the "(gdb)" prompt for GDB and "(lldb)" for lldb and all the power that comes with it. </span>

<br class=""></blockquote><div class=""><br class=""></div><div class="">I agree, that's the main reason I asked. Having a per-DAP convention seems unfortunate. Also, with the current DAP messages it doesn't seem we can do things like auto-complete or passing control characters to the debugger first (ex Ctrl-C).</div><div class=""><br class=""></div><div class="">I like your idea to manage an extra file handle. What if DAP offered "console stream" packets? Yet another option would be going around DAP completely for the pseudo terminal functionality, although it would be nice if everything can be built on top of DAP.</div></div></div></blockquote><div class=""><br class=""></div></span>Yeah there are two solutions to get a command line:</div><div class="">1 - have initialize packet return "I need a console named 'LLDB Commands'" and then have the IDE be able to switch from "Debugger Console" (which evaluates expressions over to "LLDB Commands" and it repurposes the existing debugger console to just send LLDB commands. The user would be able to switch between the two. </div><div class="">2 - Use a file handle to the terminals that are supported in the IDEs. The benefit here is the ability to due curses style output where you can control the cursor position and emit color control codes to colorize output.</div><div class=""><span class=""><br class=""><blockquote type="cite" class=""><div class=""><div dir="ltr" class=""><div class=""><br class=""></div><div class="">Not urgent but perhaps we can use LLDB to design and prototype such a DAP extension, then propose it to the vscode team? Is this something you'd be interested in?</div></div></div></blockquote><div class=""><br class=""></div></span>I would be yes. I would love the ability to due approach #2 by adding something to the reply to the initialize packet and if the IDE supports it, they will send down a file handle that could be used. Right now their TTY support seems to be centered around running a sub process only (like /bin/sh or other command line executable), not around, just give me a terminal and a file handle I can read and write to.</div><span class=""><font color="#888888" class=""><div class=""><br class=""></div><div class="">Greg Clayton</div></font></span><div class=""><div class=""><div class=""><br class=""><blockquote type="cite" class=""><div class=""><div dir="ltr" class=""><div class=""><br class=""></div></div><div class="gmail_extra"><br class=""><div class="gmail_quote">On Fri, Sep 21, 2018 at 9:56 AM, Greg Clayton <span dir="ltr" class=""><<a href="mailto:clayborg@gmail.com" target="_blank" class="">clayborg@gmail.com</a>></span> wrote:<br class=""><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word;line-break:after-white-space" class=""><br class=""><div class=""><span class=""><br class=""><blockquote type="cite" class=""><div class="">On Sep 20, 2018, at 3:05 PM, Leonard Mosescu <<a href="mailto:mosescu@google.com" target="_blank" class="">mosescu@google.com</a>> wrote:</div><br class=""><div class=""><div dir="ltr" class=""><div dir="ltr" class="">Hi Greg, looking at request_evaluate() I noticed that it will evaluate the string as a lldb command if prefixed by ` . </div><div dir="ltr" class=""><br class=""></div><div dir="ltr" class="">This is a great feature (it allows building REPL consoles on top of DAP), but I'm curious how you picked up this convention? For example I believe that the gdb DAP uses -exec 'command' instead.</div></div></div></blockquote><div class=""><br class=""></div></span>` is an illegal expression character so it won't stop you from evaluating any possible expression. The gdb prefix "-exec" stops you from being able to negate a local variable named "exec". Not a huge deal.  So I just picked a good prefix character that wouldn't stop anyone from evaluating any valid expression (at least in C/C++/ObjC/Swift).</div><div class=""><br class=""></div><div class="">The solution I would love to see is to have the initialize packet return something via the DAP that says "I have a command line interpreter, please send a packet with a file handle (slave path to slave side of pseudo terminal maybe)". VS Code and Nuclide both emulated tty already, so we could have a true command line that exposes the "(gdb)" prompt for GDB and "(lldb)" for lldb and all the power that comes with it. </div><div class=""><br class=""></div><div class="">I needed something that could run LLDB commands when things go wrong to do trouble shooting (enable logging, run commands to dump vital information) so I hacked it in with `</div><span class=""><font color="#888888" class=""><div class=""><br class=""></div><div class="">Greg</div></font></span><div class=""><div class=""><div class=""><br class=""></div><div class=""><blockquote type="cite" class=""><div class=""><div class="gmail_extra"><br class=""><div class="gmail_quote">On Thu, Aug 16, 2018 at 11:01 AM, Phabricator via Phabricator <span dir="ltr" class=""><<a href="mailto:reviews@reviews.llvm.org" target="_blank" class="">reviews@reviews.llvm.org</a>></span> wrote:<br class=""><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">This revision was automatically updated to reflect the committed changes.<br class="">
Closed by commit rL339911: Add a new tool named &quot;lldb-vscode&quot; that implements the Visual Studio Code Debug… (authored by gclayton, committed by ).<br class="">
Herald added a subscriber: llvm-commits.<br class="">
<br class="">
Changed prior to commit:<br class="">
  <a href="https://reviews.llvm.org/D50365?vs=161058&id=161067#toc" rel="noreferrer" target="_blank" class="">https://reviews.llvm.org/D5036<wbr class="">5?vs=161058&id=161067#toc</a><br class="">
<br class="">
Repository:<br class="">
  rL LLVM<br class="">
<br class="">
<a href="https://reviews.llvm.org/D50365" rel="noreferrer" target="_blank" class="">https://reviews.llvm.org/D5036<wbr class="">5</a><br class="">
<br class="">
Files:<br class="">
  lldb/trunk/lldb.xcodeproj/proj<wbr class="">ect.pbxproj<br class="">
  lldb/trunk/packages/Python/lld<wbr class="">bsuite/test/dotest.py<br class="">
  lldb/trunk/packages/Python/lld<wbr class="">bsuite/test/lldbtest.py<br class="">
  lldb/trunk/packages/Python/lld<wbr class="">bsuite/test/tools/lldb-vscode/<wbr class="">.categories<br class="">
  lldb/trunk/packages/Python/lld<wbr class="">bsuite/test/tools/lldb-vscode/<wbr class="">attach/Makefile<br class="">
  lldb/trunk/packages/Python/lld<wbr class="">bsuite/test/tools/lldb-vscode/<wbr class="">attach/TestVSCode_attach.py<br class="">
  lldb/trunk/packages/Python/lld<wbr class="">bsuite/test/tools/lldb-vscode/<wbr class="">attach/main.c<br class="">
  lldb/trunk/packages/Python/lld<wbr class="">bsuite/test/tools/lldb-vscode/<wbr class="">breakpoint/Makefile<br class="">
  lldb/trunk/packages/Python/lld<wbr class="">bsuite/test/tools/lldb-vscode/<wbr class="">breakpoint/TestVSCode_setBreak<wbr class="">points.py<br class="">
  lldb/trunk/packages/Python/lld<wbr class="">bsuite/test/tools/lldb-vscode/<wbr class="">breakpoint/TestVSCode_setExcep<wbr class="">tionBreakpoints.py<br class="">
  lldb/trunk/packages/Python/lld<wbr class="">bsuite/test/tools/lldb-vscode/<wbr class="">breakpoint/TestVSCode_setFunct<wbr class="">ionBreakpoints.py<br class="">
  lldb/trunk/packages/Python/lld<wbr class="">bsuite/test/tools/lldb-vscode/<wbr class="">breakpoint/main.cpp<br class="">
  lldb/trunk/packages/Python/lld<wbr class="">bsuite/test/tools/lldb-vscode/<wbr class="">launch/Makefile<br class="">
  lldb/trunk/packages/Python/lld<wbr class="">bsuite/test/tools/lldb-vscode/<wbr class="">launch/TestVSCode_launch.py<br class="">
  lldb/trunk/packages/Python/lld<wbr class="">bsuite/test/tools/lldb-vscode/<wbr class="">launch/main.c<br class="">
  lldb/trunk/packages/Python/lld<wbr class="">bsuite/test/tools/lldb-vscode/<wbr class="">lldbvscode_testcase.py<br class="">
  lldb/trunk/packages/Python/lld<wbr class="">bsuite/test/tools/lldb-vscode/<wbr class="">stackTrace/Makefile<br class="">
  lldb/trunk/packages/Python/lld<wbr class="">bsuite/test/tools/lldb-vscode/<wbr class="">stackTrace/TestVSCode_stackTra<wbr class="">ce.py<br class="">
  lldb/trunk/packages/Python/lld<wbr class="">bsuite/test/tools/lldb-vscode/<wbr class="">stackTrace/main.c<br class="">
  lldb/trunk/packages/Python/lld<wbr class="">bsuite/test/tools/lldb-vscode/<wbr class="">step/Makefile<br class="">
  lldb/trunk/packages/Python/lld<wbr class="">bsuite/test/tools/lldb-vscode/<wbr class="">step/TestVSCode_step.py<br class="">
  lldb/trunk/packages/Python/lld<wbr class="">bsuite/test/tools/lldb-vscode/<wbr class="">step/main.cpp<br class="">
  lldb/trunk/packages/Python/lld<wbr class="">bsuite/test/tools/lldb-vscode/<wbr class="">variables/Makefile<br class="">
  lldb/trunk/packages/Python/lld<wbr class="">bsuite/test/tools/lldb-vscode/<wbr class="">variables/TestVSCode_variables<wbr class="">.py<br class="">
  lldb/trunk/packages/Python/lld<wbr class="">bsuite/test/tools/lldb-vscode/<wbr class="">variables/main.cpp<br class="">
  lldb/trunk/packages/Python/lld<wbr class="">bsuite/test/tools/lldb-vscode/<wbr class="">vscode.py<br class="">
  lldb/trunk/tools/CMakeLists.tx<wbr class="">t<br class="">
  lldb/trunk/tools/lldb-vscode/B<wbr class="">reakpointBase.cpp<br class="">
  lldb/trunk/tools/lldb-vscode/B<wbr class="">reakpointBase.h<br class="">
  lldb/trunk/tools/lldb-vscode/C<wbr class="">MakeLists.txt<br class="">
  lldb/trunk/tools/lldb-vscode/E<wbr class="">xceptionBreakpoint.cpp<br class="">
  lldb/trunk/tools/lldb-vscode/E<wbr class="">xceptionBreakpoint.h<br class="">
  lldb/trunk/tools/lldb-vscode/F<wbr class="">unctionBreakpoint.cpp<br class="">
  lldb/trunk/tools/lldb-vscode/F<wbr class="">unctionBreakpoint.h<br class="">
  lldb/trunk/tools/lldb-vscode/J<wbr class="">SONUtils.cpp<br class="">
  lldb/trunk/tools/lldb-vscode/J<wbr class="">SONUtils.h<br class="">
  lldb/trunk/tools/lldb-vscode/L<wbr class="">LDBUtils.cpp<br class="">
  lldb/trunk/tools/lldb-vscode/L<wbr class="">LDBUtils.h<br class="">
  lldb/trunk/tools/lldb-vscode/R<wbr class="">EADME.md<br class="">
  lldb/trunk/tools/lldb-vscode/S<wbr class="">ourceBreakpoint.cpp<br class="">
  lldb/trunk/tools/lldb-vscode/S<wbr class="">ourceBreakpoint.h<br class="">
  lldb/trunk/tools/lldb-vscode/S<wbr class="">ourceReference.h<br class="">
  lldb/trunk/tools/lldb-vscode/V<wbr class="">SCode.cpp<br class="">
  lldb/trunk/tools/lldb-vscode/V<wbr class="">SCode.h<br class="">
  lldb/trunk/tools/lldb-vscode/V<wbr class="">SCodeForward.h<br class="">
  lldb/trunk/tools/lldb-vscode/l<wbr class="">ldb-vscode-Info.plist<br class="">
  lldb/trunk/tools/lldb-vscode/l<wbr class="">ldb-vscode.cpp<br class="">
  lldb/trunk/tools/lldb-vscode/p<wbr class="">ackage.json<br class="">
<br class="">
</blockquote></div><br class=""></div>
</div></blockquote></div><br class=""></div></div></div></blockquote></div><br class=""></div>
</div></blockquote></div><br class=""></div></div></div></blockquote></div><br class=""></div>
</div></blockquote></div><br class=""></div></div></div></blockquote></div><br class=""></div>
</div></blockquote></div><br class=""></body></html>