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

Greg Clayton via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Tue Oct 25 16:24:42 PDT 2022


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


================
Comment at: lldb/test/API/tools/lldb-vscode/breakpoint/TestVSCode_logpoints.py:52
         logMessage_prefix = "This is log message for { -- "
-        # Trailing newline is needed for splitlines()
-        logMessage = logMessage_prefix + "{i + 3}\n"
+        logMessage = logMessage_prefix + "{i + 3}"
         [loop_breakpoint_id, post_loop_breakpoint_id] = self.set_source_breakpoints(
----------------
Are we now auto appending a newline if there isn't one? If so we need to test this functionality. We should append on if the string doesn't end with "\n" and not if it does?


================
Comment at: lldb/tools/lldb-vscode/BreakpointBase.cpp:47-52
+  while (!text.empty()) {
+    if (text[0] != '\\') {
+      formatted.push_back(text[0]);
+      text = text.drop_front();
+      continue;
+    }
----------------
Please use StringRef::find(char). Something like:

Please use StringRef::find_first_of(...) instead of iterating per character. Something like:

```
formatted.clear();
while (!text.empty()) {
  size_t backslash_pos = text.find_first_of('\\');
  if (backslash_pos = StringRef::npos) {
    // No more backslash chars append the rest of the string
    formatted += text.str();
    return error;
  }
  // Append anything before the backslash character.
  if (backslash_pos > 0)
    formatted += text.drop_front(backslash_pos).str();
```


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