[Lldb-commits] [lldb] c8f7285 - [lldb-dap] Fixing a type encoding issue with dap Stopped events. (#72292)

via lldb-commits lldb-commits at lists.llvm.org
Thu Nov 30 12:17:18 PST 2023


Author: John Harrison
Date: 2023-11-30T15:17:12-05:00
New Revision: c8f72856dbdd0039fc16eae51726da105ea679c0

URL: https://github.com/llvm/llvm-project/commit/c8f72856dbdd0039fc16eae51726da105ea679c0
DIFF: https://github.com/llvm/llvm-project/commit/c8f72856dbdd0039fc16eae51726da105ea679c0.diff

LOG: [lldb-dap] Fixing a type encoding issue with dap Stopped events. (#72292)

Previously the type of the breakpoint id in the Stopped event was a
uint64_t, however thats the wrong type for a breakpoint id, which can
cause encoding issues when internal breakpoints are hit.

Added: 
    

Modified: 
    lldb/tools/lldb-dap/JSONUtils.cpp

Removed: 
    


################################################################################
diff  --git a/lldb/tools/lldb-dap/JSONUtils.cpp b/lldb/tools/lldb-dap/JSONUtils.cpp
index 03a43f9da87f241..3a63046d9a888bf 100644
--- a/lldb/tools/lldb-dap/JSONUtils.cpp
+++ b/lldb/tools/lldb-dap/JSONUtils.cpp
@@ -13,6 +13,7 @@
 #include <string.h>
 
 #include "llvm/Support/FormatAdapters.h"
+#include "llvm/Support/FormatVariadic.h"
 #include "llvm/Support/Path.h"
 #include "llvm/Support/ScopedPrinter.h"
 
@@ -959,11 +960,10 @@ llvm::json::Value CreateThreadStopped(lldb::SBThread &thread,
       EmplaceSafeString(body, "description", exc_bp->label);
     } else {
       body.try_emplace("reason", "breakpoint");
-      char desc_str[64];
-      uint64_t bp_id = thread.GetStopReasonDataAtIndex(0);
-      uint64_t bp_loc_id = thread.GetStopReasonDataAtIndex(1);
-      snprintf(desc_str, sizeof(desc_str), "breakpoint %" PRIu64 ".%" PRIu64,
-               bp_id, bp_loc_id);
+      lldb::break_id_t bp_id = thread.GetStopReasonDataAtIndex(0);
+      lldb::break_id_t bp_loc_id = thread.GetStopReasonDataAtIndex(1);
+      std::string desc_str =
+          llvm::formatv("breakpoint {0}.{1}", bp_id, bp_loc_id);
       body.try_emplace("hitBreakpointIds",
                        llvm::json::Array{llvm::json::Value(bp_id)});
       EmplaceSafeString(body, "description", desc_str);


        


More information about the lldb-commits mailing list