[Lldb-commits] [PATCH] D136697: Add formatting support for VSCode logpoints message

Greg Clayton via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Wed Oct 26 18:43:19 PDT 2022


clayborg requested changes to this revision.
clayborg added inline comments.
This revision now requires changes to proceed.


================
Comment at: lldb/tools/lldb-vscode/BreakpointBase.cpp:29
+lldb::SBError BreakpointBase::AppendLogMessagePart(llvm::StringRef part,
+                                                          bool is_expr) {
+  if (is_expr) {
----------------
indentation is off here. 


================
Comment at: lldb/tools/lldb-vscode/BreakpointBase.cpp:45
+lldb::SBError BreakpointBase::FormatLogText(llvm::StringRef text,
+                                                   std::string &formatted) {
+  lldb::SBError error;
----------------
indentation is off here


================
Comment at: lldb/tools/lldb-vscode/BreakpointBase.cpp:53
+    }
+    assert(backslash_pos >=0 && backslash_pos < text.size());
+
----------------
Remove assert, this should be already tested in StringRef::find(...)


================
Comment at: lldb/tools/lldb-vscode/BreakpointBase.cpp:55
+
+    formatted += text.substr(0, backslash_pos + 1).str();
+    // Skip the characters before (and include) '\'.
----------------
Is this going to append the backslash character as well? Seems like a bug. Above suggested code did this correctly I think with:

```
  // Append anything before the backslash character.
  if (backslash_pos > 0)
    formatted += text.drop_front(backslash_pos).str();
```
Which was always then followed by:
```
  text = text.drop_front(); // Drop the backslash
```


================
Comment at: lldb/tools/lldb-vscode/BreakpointBase.cpp:306
   }
+  output.push_back('\n'); // Ensure log message has line break.
   g_vsc.SendOutput(OutputType::Console, output.c_str());
----------------
I would still only push one if the output doesn't end with one and add a test for this.
```
if (!output.empty() && output.back() != '\n')
  output.push_back('\n'); // Ensure log message has line break.
```


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D136697



More information about the lldb-commits mailing list