[Lldb-commits] [PATCH] D80659: [lldb-vscode] Redirect stderr and stdout to DAPs console message

António Afonso via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Thu Jul 9 19:01:10 PDT 2020


aadsm updated this revision to Diff 276894.
aadsm added a comment.

This update still doesn't add windows support but I just want to get a feel that I'm going on the right direction.
It addresses the following:

- redirect stdout/err as early as possible to avoid something writing to it, and only starts or ends redirection it once it's safe.
- adds a mutex to OutputStream::write_full to make sure multiple threads don't try to write to the output fd at the same time.

> We should also think about testing all of this. Do we have a reliable mechanism to produce stdout/err output from lldb?

this turned out to be harder than I thought it would be, my plan was to print to stdout in python from a thread but I never see that print anywhere (not sure why though). A sure way to test this (what I did manually) is to put a `script print('foo')` command in lldninit. Unfortunately I can't use a local lldbinit since that's a concept of the lldb binary and not of liblldb (unless we want to add that option to lldb-vscode as well), so not really sure about this as well.
I also tried to use a `breakpoint command add -o 'script print("foo")'` but same behaviour, I never saw that print. Still don't know how to tackle this, need to think more about it.

> Or, if this output is going to the same place as the SBDebuggers notion of stdout/err,

There no guarantee of this, people can just use sys.stdout.write in python.

> given that Richard has found some vscode code which already tries to send stderr to the console window

I would still prefer to wrap liblldb's stderr into a console message so people can see it in the client(e.g.: VSCode) console rather than outputting it through the lldb-vscode stderr which will then be up to the client to decide what to do with it.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D80659/new/

https://reviews.llvm.org/D80659

Files:
  lldb/tools/lldb-vscode/IOStream.cpp
  lldb/tools/lldb-vscode/IOStream.h
  lldb/tools/lldb-vscode/lldb-vscode.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D80659.276894.patch
Type: text/x-patch
Size: 3303 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20200710/186dea39/attachment.bin>


More information about the lldb-commits mailing list