[Lldb-commits] [PATCH] D128541: [WIP][lldb][windows] Handle OutputDebugString from debuggee

Pavel Labath via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Thu Jun 30 00:22:14 PDT 2022


labath added a comment.

In D128541#3608718 <https://reviews.llvm.org/D128541#3608718>, @alvinhochun wrote:

> I think this should be enabled by default, but none of the logging categories for `LLDB_LOG` has default active.

That's because it's not really meant for this use case. The logging infrastructure is for internal lldb logs, not for application output. Reusing it for this purpose is an interesting idea, and it might even make sense, depending on what do people use ODS for (and I really don't know the answer to that), but it is definitely unorthodox.

It also has the problem of only working for in-process debugging (which we'd like to get rid of), as logs don't get sent over the gdb-remote connection (unless you take steps to send them over and *then* log them).

> Is there a better way to do this?

Well.. most OSes don't have this kind of functionality, so we don't really have an exact match for this. I suppose the closest thing would be the way we handle darwin OS logs, so you could try to see if reusing some of that infrastructure makes sense (StructuredDataDarwinLog.cpp and surrounding code).

One cheap way to accomplish this would be to pass this off as program standard output (possibly prefixed by `ODS:` or something). Then it would show up on the lldb console, could be accessed by SBProcess::GetSTDOUT, and everything. It might not even be /too/ confusing, as we currently don't proxy stdout this way (though that's also something that I'd like to see changed).



================
Comment at: lldb/source/Plugins/Process/Windows/Common/ProcessWindows.cpp:826-827
+      llvm::StringRef str_ref(str.data(), str.size());
+      // The string should contain a trailing NUL terminator. Remove it because
+      // it interferes with consume_back.
+      if (!str_ref.empty() && str_ref.back() == '\0')
----------------
How exactly does it interfere? Have you tried a `consume_back(StringRef("\0", 1))` ?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128541



More information about the lldb-commits mailing list