================
@@ -870,7 +871,95 @@ void ProcessWindows::OnUnloadDll(lldb::addr_t module_addr)
{
dyld->OnUnloadModule(module_addr);
}
-void ProcessWindows::OnDebugString(const std::string &string) {}
+void ProcessWindows::OnDebugString(lldb::addr_t debug_string_addr,
+ bool is_unicode,
+ uint16_t length_lower_word) {
+ Log *log = GetLog(WindowsLog::Process);
+
+ llvm::SmallVector<char, 256> buffer;
+ llvm::Error err =
+ ReadDebugString(debug_string_addr, is_unicode, length_lower_word,
buffer);
+ if (err) {
+ LLDB_LOG_ERROR(log, std::move(err),
+ "Failed to read debug string at {1:x} (size & 0xffff={2}, "
+ "unicode={3}): {0}",
+ debug_string_addr, length_lower_word, is_unicode);
+ return;
+ }
+ if (buffer.empty())
+ return;
+
+ if (is_unicode) {
+ if (buffer.size() % 2 != 0) {
+ LLDB_LOG(log, "Read debug string had uneven size: {0}", buffer.size());
+ return;
+ }
+ llvm::ArrayRef<unsigned short> utf16(
+ reinterpret_cast<const unsigned short *>(buffer.data()),
+ buffer.size() / 2);
+ std::string out;
+ if (!llvm::convertUTF16ToUTF8String(utf16, out)) {
+ LLDB_LOG(log, "Debug string is not valid Utf 16");
+ return;
+ }
+
+ AppendSTDOUT(out.data(), out.size());
+ } else {
+ AppendSTDOUT(buffer.data(), buffer.size());
+ }
+}
+
+llvm::Error
+ProcessWindows::ReadDebugString(lldb::addr_t debug_string_addr, bool
is_unicode,
+ uint16_t length_lower_word,
+ llvm::SmallVectorImpl<char> &output) {
+ if (is_unicode && length_lower_word % 2 != 0) {
+ return llvm::createStringError(
+ "Utf16 string can't have uneven size in bytes");
+ }
----------------
Nerixyz wrote:
Depends on the outcome of
https://discourse.llvm.org/t/rfc-clarify-brace-omission-for-wrapped-single-statement-bodies/90739
I suppose. Though as far as I know, in LLDB, we already went with the "omit if
one _line_".
https://github.com/llvm/llvm-project/pull/196395
_______________________________________________
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits