Author: Gabriele Mondada Date: 2026-01-05T15:31:27Z New Revision: e2fa8dcb0d508cdf9d8a4b18a12838b5adfd8194
URL: https://github.com/llvm/llvm-project/commit/e2fa8dcb0d508cdf9d8a4b18a12838b5adfd8194 DIFF: https://github.com/llvm/llvm-project/commit/e2fa8dcb0d508cdf9d8a4b18a12838b5adfd8194.diff LOG: [lldb][lldb-dap] Do not expose internal breakpoints to DAP clients (#173848) **This commit fixes the following problem:** When debugging an APK running on Android, and the Android process stops due to a user breakpoint, sometimes a second breakpoint is hit at the same time, and the corresponding thread is marked as stopped for reason `jit-debug-register`. This second breakpoint is used by lldb internally, to track code generated by the JIT compiler (JVM). Instead of displaying the code corresponding to the user breakpoint, the debugger displays the disassembled code corresponding to this internal breakpoint. **Solution:** Internal breakpoints must stay internal, not visible by VS Code or any other DAP-based debugger. **Notes:** * This is part on an effort to get lldb working for debugging Swift on Android: https://github.com/swiftlang/llvm-project/issues/10831 * Reproducing the problems is not simple because you need an environment allowing to run lldb-server in the Android emulator. See https://github.com/gmondada/swift-on-android/blob/main/Docs/exploring-apk-debugging.md * The problem has been seen on Android, but `jit-debug-register` is not Android specific and there are probably other scenarios where internal breakpoints are used. Added: Modified: lldb/tools/lldb-dap/LLDBUtils.cpp Removed: ################################################################################ diff --git a/lldb/tools/lldb-dap/LLDBUtils.cpp b/lldb/tools/lldb-dap/LLDBUtils.cpp index 22e4012b238ac..8a651249aee02 100644 --- a/lldb/tools/lldb-dap/LLDBUtils.cpp +++ b/lldb/tools/lldb-dap/LLDBUtils.cpp @@ -16,6 +16,7 @@ #include "lldb/API/SBStringList.h" #include "lldb/API/SBStructuredData.h" #include "lldb/API/SBThread.h" +#include "lldb/lldb-defines.h" #include "lldb/lldb-enumerations.h" #include "llvm/ADT/ArrayRef.h" #include "llvm/Support/Error.h" @@ -129,7 +130,6 @@ bool ThreadHasStopReason(lldb::SBThread &thread) { switch (thread.GetStopReason()) { case lldb::eStopReasonTrace: case lldb::eStopReasonPlanComplete: - case lldb::eStopReasonBreakpoint: case lldb::eStopReasonWatchpoint: case lldb::eStopReasonInstrumentation: case lldb::eStopReasonSignal: @@ -142,6 +142,20 @@ bool ThreadHasStopReason(lldb::SBThread &thread) { case lldb::eStopReasonInterrupt: case lldb::eStopReasonHistoryBoundary: return true; + case lldb::eStopReasonBreakpoint: { + // Stop reason data for breakpoints consists of breakpoint ID and location + // ID pairs. Internal breakpoints (identified by their ID) are not + // considered valid stop reasons. + const uint64_t data_count = thread.GetStopReasonDataCount(); + if (data_count == 0) + return true; + for (uint64_t i = 0; i < data_count; i += 2) { + const lldb::break_id_t bp_id = thread.GetStopReasonDataAtIndex(i); + if (!LLDB_BREAK_ID_IS_INTERNAL(bp_id)) + return true; + } + return false; + } case lldb::eStopReasonThreadExiting: case lldb::eStopReasonInvalid: case lldb::eStopReasonNone: _______________________________________________ lldb-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
