[Lldb-commits] [lldb] r345563 - [lldb-mi] Implement -gdb-set breakpoint pending on/off
Marc-Andre Laperle via lldb-commits
lldb-commits at lists.llvm.org
Mon Oct 29 20:10:42 PDT 2018
Author: malaperle
Date: Mon Oct 29 20:10:41 2018
New Revision: 345563
URL: http://llvm.org/viewvc/llvm-project?rev=345563&view=rev
Log:
[lldb-mi] Implement -gdb-set breakpoint pending on/off
Summary:
This allows creating pending breakpoint automatically when a location is not found.
This is used by some front-ends instead of doing "-break-insert -f" every time.
See also https://sourceware.org/gdb/onlinedocs/gdb/Set-Breaks.html
Signed-off-by: Marc-Andre Laperle <malaperle at gmail.com>
Subscribers: MaskRay, llvm-commits, lldb-commits, ki.stfu
Tags: #lldb
Differential Revision: https://reviews.llvm.org/D52953
Added:
lldb/trunk/lit/tools/lldb-mi/breakpoint/break-insert-enable-pending.test
lldb/trunk/lit/tools/lldb-mi/breakpoint/inputs/break-insert-pending.c
Modified:
lldb/trunk/tools/lldb-mi/MICmdCmdBreak.cpp
lldb/trunk/tools/lldb-mi/MICmdCmdGdbSet.cpp
lldb/trunk/tools/lldb-mi/MICmdCmdGdbSet.h
lldb/trunk/tools/lldb-mi/MICmdCmdGdbShow.cpp
lldb/trunk/tools/lldb-mi/MICmdCmdGdbShow.h
lldb/trunk/tools/lldb-mi/MICmnResources.cpp
lldb/trunk/tools/lldb-mi/MICmnResources.h
Added: lldb/trunk/lit/tools/lldb-mi/breakpoint/break-insert-enable-pending.test
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/lit/tools/lldb-mi/breakpoint/break-insert-enable-pending.test?rev=345563&view=auto
==============================================================================
--- lldb/trunk/lit/tools/lldb-mi/breakpoint/break-insert-enable-pending.test (added)
+++ lldb/trunk/lit/tools/lldb-mi/breakpoint/break-insert-enable-pending.test Mon Oct 29 20:10:41 2018
@@ -0,0 +1,47 @@
+# XFAIL: windows
+# -> llvm.org/pr24452
+#
+# RUN: %cc -o %t %p/inputs/break-insert-pending.c -g
+# RUN: %lldbmi %t < %s | FileCheck %s
+
+# Test for enabling pending breakpoints globally
+
+-break-insert printf
+# CHECK: ^error,msg="Command 'break-insert'. Breakpoint location 'printf' not found
+
+-gdb-set breakpoint pending on
+# CHECK: ^done
+-gdb-show breakpoint pending
+# CHECK: ^done,value="on"
+-break-insert printf
+# CHECK: ^done,bkpt={number="2",type="breakpoint",disp="keep",enabled="y",addr="0xffffffffffffffff",func="??",file="??",fullname="??/??",line="0",pending=["printf"],times="0",original-location="printf"}
+
+-exec-run
+# CHECK: ^running
+# CHECK: *stopped,reason="breakpoint-hit",disp="del",bkptno="2",frame={level="0",addr="{{0x[0-9a-f]*[^f][0-9a-f]*}}"
+-break-disable 2
+# CHECK: ^done
+-exec-continue
+# CHECK: ^running
+# CHECK: *stopped,reason="exited-normally"
+
+# Test that it can be turned back off
+-gdb-show breakpoint pending
+# CHECK: ^done,value="on"
+-gdb-set breakpoint pending off
+# CHECK: ^done
+-gdb-show breakpoint pending
+# CHECK: ^done,value="off"
+-break-insert printf-non-existent
+# CHECK: ^error,msg="Command 'break-insert'. Breakpoint location 'printf-non-existent' not found"
+# Check that enable/disable with 1 and 0 works
+-gdb-set breakpoint pending 1
+# CHECK: ^done
+-gdb-show breakpoint pending
+# CHECK: ^done,value="on"
+-gdb-set breakpoint pending 0
+# CHECK: ^done
+-gdb-show breakpoint pending
+# CHECK: ^done,value="off"
+-gdb-set breakpoint pending garbage
+# CHECK: ^done
Added: lldb/trunk/lit/tools/lldb-mi/breakpoint/inputs/break-insert-pending.c
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/lit/tools/lldb-mi/breakpoint/inputs/break-insert-pending.c?rev=345563&view=auto
==============================================================================
--- lldb/trunk/lit/tools/lldb-mi/breakpoint/inputs/break-insert-pending.c (added)
+++ lldb/trunk/lit/tools/lldb-mi/breakpoint/inputs/break-insert-pending.c Mon Oct 29 20:10:41 2018
@@ -0,0 +1,6 @@
+#include <stdio.h>
+
+int main(int argc, char const *argv[]) {
+ printf("Print a formatted string so that GCC does not optimize this printf call: %s\n", argv[0]);
+ return 0;
+}
Modified: lldb/trunk/tools/lldb-mi/MICmdCmdBreak.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/lldb-mi/MICmdCmdBreak.cpp?rev=345563&r1=345562&r2=345563&view=diff
==============================================================================
--- lldb/trunk/tools/lldb-mi/MICmdCmdBreak.cpp (original)
+++ lldb/trunk/tools/lldb-mi/MICmdCmdBreak.cpp Mon Oct 29 20:10:41 2018
@@ -165,8 +165,15 @@ bool CMICmdCmdBreakInsert::Execute() {
if (sbTarget == rSessionInfo.GetDebugger().GetDummyTarget())
m_bBrkPtIsPending = true;
- else
+ else {
m_bBrkPtIsPending = pArgPendingBrkPt->GetFound();
+ if (!m_bBrkPtIsPending) {
+ CMIUtilString pending;
+ if (m_rLLDBDebugSessionInfo.SharedDataRetrieve("breakpoint.pending", pending)) {
+ m_bBrkPtIsPending = pending == "on";
+ }
+ }
+ }
if (pArgLocation->GetFound())
m_brkName = pArgLocation->GetValue();
Modified: lldb/trunk/tools/lldb-mi/MICmdCmdGdbSet.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/lldb-mi/MICmdCmdGdbSet.cpp?rev=345563&r1=345562&r2=345563&view=diff
==============================================================================
--- lldb/trunk/tools/lldb-mi/MICmdCmdGdbSet.cpp (original)
+++ lldb/trunk/tools/lldb-mi/MICmdCmdGdbSet.cpp Mon Oct 29 20:10:41 2018
@@ -28,7 +28,8 @@ const CMICmdCmdGdbSet::MapGdbOptionNameT
{"output-radix", &CMICmdCmdGdbSet::OptionFnOutputRadix},
{"solib-search-path", &CMICmdCmdGdbSet::OptionFnSolibSearchPath},
{"disassembly-flavor", &CMICmdCmdGdbSet::OptionFnDisassemblyFlavor},
- {"fallback", &CMICmdCmdGdbSet::OptionFnFallback}};
+ {"fallback", &CMICmdCmdGdbSet::OptionFnFallback},
+ {"breakpoint", &CMICmdCmdGdbSet::OptionFnBreakpoint}};
//++
//------------------------------------------------------------------------------------
@@ -428,6 +429,56 @@ bool CMICmdCmdGdbSet::OptionFnDisassembl
return MIstatus::failure;
}
+ return MIstatus::success;
+}
+
+//++
+//------------------------------------------------------------------------------------
+// Details: Carry out work to complete the GDB set option 'breakpoint' to
+// prepare
+// and send back information asked for.
+// Type: Method.
+// Args: vrWords - (R) List of additional parameters used by this option.
+// Return: MIstatus::success - Function succeeded.
+// MIstatus::failure - Function failed.
+// Throws: None.
+//--
+bool CMICmdCmdGdbSet::OptionFnBreakpoint(
+ const CMIUtilString::VecString_t &vrWords) {
+ bool bPending = false;
+ bool bOk = true;
+
+ if (vrWords.size() != 2)
+ // Wrong number of arguments.
+ bOk = false;
+ else if (CMIUtilString::Compare(vrWords[0], "pending") &&
+ (CMIUtilString::Compare(vrWords[1], "on") ||
+ CMIUtilString::Compare(vrWords[1], "1")))
+ bPending = true;
+ else if (CMIUtilString::Compare(vrWords[0], "pending") &&
+ (CMIUtilString::Compare(vrWords[1], "off") ||
+ CMIUtilString::Compare(vrWords[1], "0")))
+ bPending = false;
+ else
+ // Unrecognized argument(s).
+ bOk = false;
+
+ if (!bOk) {
+ // Report error.
+ m_bGbbOptionFnHasError = false;
+ SetError(MIRSRC(IDS_CMD_ERR_GDBSET_OPT_BREAKPOINT));
+ return MIstatus::failure;
+ }
+
+ CMIUtilString sPendingVal = bPending ? "on" : "off";
+ CMIUtilString sKey = "breakpoint.pending";
+ if (!m_rLLDBDebugSessionInfo.SharedDataAdd(sKey, sPendingVal)) {
+ m_bGbbOptionFnHasError = false;
+ SetError(CMIUtilString::Format(MIRSRC(IDS_DBGSESSION_ERR_SHARED_DATA_ADD),
+ m_cmdData.strMiCmd.c_str(), sKey.c_str()));
+ return MIstatus::failure;
+ }
+
return MIstatus::success;
}
Modified: lldb/trunk/tools/lldb-mi/MICmdCmdGdbSet.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/lldb-mi/MICmdCmdGdbSet.h?rev=345563&r1=345562&r2=345563&view=diff
==============================================================================
--- lldb/trunk/tools/lldb-mi/MICmdCmdGdbSet.h (original)
+++ lldb/trunk/tools/lldb-mi/MICmdCmdGdbSet.h Mon Oct 29 20:10:41 2018
@@ -80,6 +80,7 @@ private:
bool OptionFnSolibSearchPath(const CMIUtilString::VecString_t &vrWords);
bool OptionFnOutputRadix(const CMIUtilString::VecString_t &vrWords);
bool OptionFnDisassemblyFlavor(const CMIUtilString::VecString_t &vrWords);
+ bool OptionFnBreakpoint(const CMIUtilString::VecString_t &vrWords);
bool OptionFnFallback(const CMIUtilString::VecString_t &vrWords);
// Attributes:
Modified: lldb/trunk/tools/lldb-mi/MICmdCmdGdbShow.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/lldb-mi/MICmdCmdGdbShow.cpp?rev=345563&r1=345562&r2=345563&view=diff
==============================================================================
--- lldb/trunk/tools/lldb-mi/MICmdCmdGdbShow.cpp (original)
+++ lldb/trunk/tools/lldb-mi/MICmdCmdGdbShow.cpp Mon Oct 29 20:10:41 2018
@@ -32,7 +32,8 @@ const CMICmdCmdGdbShow::MapGdbOptionName
{"print", &CMICmdCmdGdbShow::OptionFnPrint},
{"language", &CMICmdCmdGdbShow::OptionFnLanguage},
{"disassembly-flavor", &CMICmdCmdGdbShow::OptionFnDisassemblyFlavor},
- {"fallback", &CMICmdCmdGdbShow::OptionFnFallback}};
+ {"fallback", &CMICmdCmdGdbShow::OptionFnFallback},
+ {"breakpoint", &CMICmdCmdGdbShow::OptionFnBreakpoint}};
//++
//------------------------------------------------------------------------------------
@@ -347,6 +348,43 @@ bool CMICmdCmdGdbShow::OptionFnDisassemb
return MIstatus::success;
}
+//++
+//------------------------------------------------------------------------------------
+// Details: Carry out work to complete the GDB show option 'breakpoint' to
+// prepare
+// and send back the requested information.
+// Type: Method.
+// Args: vrWords - (R) List of additional parameters used by this option.
+// Return: MIstatus::success - Function succeeded.
+// MIstatus::failure - Function failed.
+// Throws: None.
+//--
+bool CMICmdCmdGdbShow::OptionFnBreakpoint(
+ const CMIUtilString::VecString_t &vrWords) {
+ if (vrWords.size() != 1) {
+ m_bGbbOptionFnHasError = true;
+ m_strGdbOptionFnError = MIRSRC(IDS_CMD_ERR_GDBSHOW_OPT_BREAKPOINT_BAD_ARGS);
+ return MIstatus::failure;
+ }
+
+ const CMIUtilString strOption(vrWords[0]);
+ if (!CMIUtilString::Compare(strOption, "pending")) {
+ m_bGbbOptionFnHasError = true;
+ m_strGdbOptionFnError = CMIUtilString::Format(
+ MIRSRC(IDS_CMD_ERR_GDBSHOW_OPT_BREAKPOINT_UNKNOWN_OPTION),
+ strOption.c_str());
+ return MIstatus::failure;
+ }
+
+ if (!m_rLLDBDebugSessionInfo.SharedDataRetrieve("breakpoint.pending",
+ m_strValue)) {
+ if (m_strValue.empty())
+ m_strValue = "off";
+ }
+
+ return MIstatus::success;
+}
+
//++
//------------------------------------------------------------------------------------
// Details: Carry out work to complete the GDB show option to prepare and send
Modified: lldb/trunk/tools/lldb-mi/MICmdCmdGdbShow.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/lldb-mi/MICmdCmdGdbShow.h?rev=345563&r1=345562&r2=345563&view=diff
==============================================================================
--- lldb/trunk/tools/lldb-mi/MICmdCmdGdbShow.h (original)
+++ lldb/trunk/tools/lldb-mi/MICmdCmdGdbShow.h Mon Oct 29 20:10:41 2018
@@ -80,6 +80,7 @@ private:
bool OptionFnLanguage(const CMIUtilString::VecString_t &vrWords);
bool OptionFnDisassemblyFlavor(const CMIUtilString::VecString_t &vrWords);
bool OptionFnFallback(const CMIUtilString::VecString_t &vrWords);
+ bool OptionFnBreakpoint(const CMIUtilString::VecString_t &vrWords);
// Attributes:
private:
Modified: lldb/trunk/tools/lldb-mi/MICmnResources.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/lldb-mi/MICmnResources.cpp?rev=345563&r1=345562&r2=345563&view=diff
==============================================================================
--- lldb/trunk/tools/lldb-mi/MICmnResources.cpp (original)
+++ lldb/trunk/tools/lldb-mi/MICmnResources.cpp Mon Oct 29 20:10:41 2018
@@ -439,6 +439,8 @@ const CMICmnResources::SRsrcTextData
{IDS_CMD_ERR_INFO_PRINTFN_FAILED, "The request '%s' failed."},
{IDS_CMD_ERR_GDBSET_OPT_TARGETASYNC,
"'target-async' expects \"on\" or \"off\""},
+ {IDS_CMD_ERR_GDBSET_OPT_BREAKPOINT,
+ "'breakpoint' expects \"pending on\" or \"pending off\""},
{IDS_CMD_ERR_GDBSET_OPT_SOLIBSEARCHPATH,
"'solib-search-path' requires at least one argument"},
{IDS_CMD_ERR_GDBSET_OPT_PRINT_BAD_ARGS,
@@ -449,6 +451,10 @@ const CMICmnResources::SRsrcTextData
"'print' expects option-name and \"on\" or \"off\""},
{IDS_CMD_ERR_GDBSHOW_OPT_PRINT_UNKNOWN_OPTION,
"'print' error. The option '%s' not found"},
+ {IDS_CMD_ERR_GDBSHOW_OPT_BREAKPOINT_BAD_ARGS,
+ "'breakpoint' expects option-name"},
+ {IDS_CMD_ERR_GDBSHOW_OPT_BREAKPOINT_UNKNOWN_OPTION,
+ "'breakpoint' error. The option '%s' not found"},
{IDS_CMD_ERR_EXPR_INVALID, "Failed to evaluate expression: %s"},
{IDS_CMD_ERR_ATTACH_FAILED,
"Command '%s'. Attach to process failed: %s"},
Modified: lldb/trunk/tools/lldb-mi/MICmnResources.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/lldb-mi/MICmnResources.h?rev=345563&r1=345562&r2=345563&view=diff
==============================================================================
--- lldb/trunk/tools/lldb-mi/MICmnResources.h (original)
+++ lldb/trunk/tools/lldb-mi/MICmnResources.h Mon Oct 29 20:10:41 2018
@@ -264,11 +264,14 @@ enum {
IDS_CMD_ERR_INFO_PRINTFN_NOT_FOUND,
IDS_CMD_ERR_INFO_PRINTFN_FAILED,
IDS_CMD_ERR_GDBSET_OPT_TARGETASYNC,
+ IDS_CMD_ERR_GDBSET_OPT_BREAKPOINT,
IDS_CMD_ERR_GDBSET_OPT_SOLIBSEARCHPATH,
IDS_CMD_ERR_GDBSET_OPT_PRINT_BAD_ARGS,
IDS_CMD_ERR_GDBSET_OPT_PRINT_UNKNOWN_OPTION,
IDS_CMD_ERR_GDBSHOW_OPT_PRINT_BAD_ARGS,
IDS_CMD_ERR_GDBSHOW_OPT_PRINT_UNKNOWN_OPTION,
+ IDS_CMD_ERR_GDBSHOW_OPT_BREAKPOINT_BAD_ARGS,
+ IDS_CMD_ERR_GDBSHOW_OPT_BREAKPOINT_UNKNOWN_OPTION,
IDS_CMD_ERR_EXPR_INVALID,
IDS_CMD_ERR_ATTACH_FAILED,
IDS_CMD_ERR_ATTACH_BAD_ARGS
More information about the lldb-commits
mailing list