[Lldb-commits] [lldb] r234305 - implement gdb-set output-radix
Ilia K
ki.stfu at gmail.com
Tue Apr 7 02:47:24 PDT 2015
Author: ki.stfu
Date: Tue Apr 7 04:47:23 2015
New Revision: 234305
URL: http://llvm.org/viewvc/llvm-project?rev=234305&view=rev
Log:
implement gdb-set output-radix
Summary: Patch from chuckr at microsoft.com
Reviewers: abidh, ChuckR
Reviewed By: abidh
Subscribers: paulmaybee, ki.stfu, greggm, scarroll, lldb-commits
Differential Revision: http://reviews.llvm.org/D8430
Modified:
lldb/trunk/test/tools/lldb-mi/TestMiGdbSetShow.py
lldb/trunk/test/tools/lldb-mi/main.cpp
lldb/trunk/tools/lldb-mi/MICmdCmdGdbSet.cpp
lldb/trunk/tools/lldb-mi/MICmdCmdGdbSet.h
lldb/trunk/tools/lldb-mi/MICmnLLDBDebugSessionInfoVarObj.cpp
lldb/trunk/tools/lldb-mi/MICmnLLDBDebugSessionInfoVarObj.h
Modified: lldb/trunk/test/tools/lldb-mi/TestMiGdbSetShow.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/tools/lldb-mi/TestMiGdbSetShow.py?rev=234305&r1=234304&r2=234305&view=diff
==============================================================================
--- lldb/trunk/test/tools/lldb-mi/TestMiGdbSetShow.py (original)
+++ lldb/trunk/test/tools/lldb-mi/TestMiGdbSetShow.py Tue Apr 7 04:47:23 2015
@@ -117,5 +117,53 @@ class MiGdbSetShowTestCase(lldbmi_testca
self.runCmd("-gdb-show unknown")
self.expect("\^error")
+
+ @lldbmi_test
+ @expectedFailureWindows("llvm.org/pr22274: need a pexpect replacement for windows")
+ @skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races
+ @skipIfLinux # llvm.org/pr22841: lldb-mi tests fail on all Linux buildbots
+ def test_lldbmi_gdb_set_ouptut_radix(self):
+ """Test that 'lldb-mi --interpreter' works for -gdb-set output-radix."""
+
+ self.spawnLldbMi(args = None)
+
+ # Load executable
+ self.runCmd("-file-exec-and-symbols %s" % self.myexe)
+ self.expect("\^done")
+
+ # Run to BP_printf
+ line = line_number('main.cpp', '// BP_printf')
+ self.runCmd("-break-insert main.cpp:%d" % line)
+ self.expect("\^done,bkpt={number=\"1\"")
+ self.runCmd("-exec-run")
+ self.expect("\^running");
+ self.expect("\*stopped,reason=\"breakpoint-hit\"")
+
+ # Setup variable
+ self.runCmd("-var-create var_a * a");
+ self.expect("\^done,name=\"var_a\",numchild=\"0\",value=\"10\",type=\"int\",thread-id=\"1\",has_more=\"0\"")
+
+ # Test default output
+ self.runCmd("-var-evaluate-expression var_a");
+ self.expect("\^done,value=\"10\"");
+
+ # Test hex output
+ self.runCmd("-gdb-set output-radix 16");
+ self.expect("\^done");
+ self.runCmd("-var-evaluate-expression var_a");
+ self.expect("\^done,value=\"0xa\"");
+
+ # Test octal output
+ self.runCmd("-gdb-set output-radix 8");
+ self.expect("\^done");
+ self.runCmd("-var-evaluate-expression var_a");
+ self.expect("\^done,value=\"012\"");
+
+ # Test decimal output
+ self.runCmd("-gdb-set output-radix 10");
+ self.expect("\^done");
+ self.runCmd("-var-evaluate-expression var_a");
+ self.expect("\^done,value=\"10\"");
+
if __name__ == '__main__':
unittest2.main()
Modified: lldb/trunk/test/tools/lldb-mi/main.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/tools/lldb-mi/main.cpp?rev=234305&r1=234304&r2=234305&view=diff
==============================================================================
--- lldb/trunk/test/tools/lldb-mi/main.cpp (original)
+++ lldb/trunk/test/tools/lldb-mi/main.cpp Tue Apr 7 04:47:23 2015
@@ -12,6 +12,8 @@
int
main(int argc, char const *argv[])
{
- printf("argc=%d\n", argc);
+ int a = 10;
+
+ printf("argc=%d\n", argc); // BP_printf
return 0;
}
Modified: lldb/trunk/tools/lldb-mi/MICmdCmdGdbSet.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/lldb-mi/MICmdCmdGdbSet.cpp?rev=234305&r1=234304&r2=234305&view=diff
==============================================================================
--- lldb/trunk/tools/lldb-mi/MICmdCmdGdbSet.cpp (original)
+++ lldb/trunk/tools/lldb-mi/MICmdCmdGdbSet.cpp Tue Apr 7 04:47:23 2015
@@ -22,6 +22,7 @@
const CMICmdCmdGdbSet::MapGdbOptionNameToFnGdbOptionPtr_t CMICmdCmdGdbSet::ms_mapGdbOptionNameToFnGdbOptionPtr = {
{"target-async", &CMICmdCmdGdbSet::OptionFnTargetAsync},
// { "auto-solib-add", &CMICmdCmdGdbSet::OptionFnAutoSolibAdd }, // Example code if need to implement GDB set other options
+ {"output-radix", &CMICmdCmdGdbSet::OptionFnOutputRadix},
{"solib-search-path", &CMICmdCmdGdbSet::OptionFnSolibSearchPath},
{"fallback", &CMICmdCmdGdbSet::OptionFnFallback}};
@@ -287,6 +288,58 @@ CMICmdCmdGdbSet::OptionFnSolibSearchPath
return MIstatus::success;
}
+//++ ------------------------------------------------------------------------------------
+// Details: Carry out work to complete the GDB set option 'output-radix' to prepare
+// and send back information asked for.
+// Type: Method.
+// Args: vrWords - (R) List of additional parameters used by this option.
+// Return: MIstatus::success - Functional succeeded.
+// MIstatus::failure - Functional failed.
+// Throws: None.
+//--
+bool
+CMICmdCmdGdbSet::OptionFnOutputRadix(const CMIUtilString::VecString_t &vrWords)
+{
+ // Check we have at least one argument
+ if (vrWords.size() < 1)
+ {
+ m_bGbbOptionFnHasError = true;
+ m_strGdbOptionFnError = MIRSRC(IDS_CMD_ERR_GDBSET_OPT_SOLIBSEARCHPATH);
+ return MIstatus::failure;
+ }
+ const CMIUtilString &rStrValOutputRadix(vrWords[0]);
+
+ CMICmnLLDBDebugSessionInfoVarObj::varFormat_e format = CMICmnLLDBDebugSessionInfoVarObj::eVarFormat_Invalid;
+ MIint64 radix;
+ if (rStrValOutputRadix.ExtractNumber(radix))
+ {
+ switch (radix)
+ {
+ case 8:
+ format = CMICmnLLDBDebugSessionInfoVarObj::eVarFormat_Octal;
+ break;
+ case 10:
+ format = CMICmnLLDBDebugSessionInfoVarObj::eVarFormat_Natural;
+ break;
+ case 16:
+ format = CMICmnLLDBDebugSessionInfoVarObj::eVarFormat_Hex;
+ break;
+ default:
+ format = CMICmnLLDBDebugSessionInfoVarObj::eVarFormat_Invalid;
+ break;
+ }
+ }
+ if (format == CMICmnLLDBDebugSessionInfoVarObj::eVarFormat_Invalid)
+ {
+ m_bGbbOptionFnHasError = false;
+ SetError(CMIUtilString::Format(MIRSRC(IDS_DBGSESSION_ERR_SHARED_DATA_ADD), m_cmdData.strMiCmd.c_str(), "Output Radix"));
+ return MIstatus::failure;
+ }
+ CMICmnLLDBDebugSessionInfoVarObj::VarObjSetFormat(format);
+
+ return MIstatus::success;
+}
+
//++ ------------------------------------------------------------------------------------
// Details: Carry out work to complete the GDB set option to prepare and send back the
// requested information.
Modified: lldb/trunk/tools/lldb-mi/MICmdCmdGdbSet.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/lldb-mi/MICmdCmdGdbSet.h?rev=234305&r1=234304&r2=234305&view=diff
==============================================================================
--- lldb/trunk/tools/lldb-mi/MICmdCmdGdbSet.h (original)
+++ lldb/trunk/tools/lldb-mi/MICmdCmdGdbSet.h Tue Apr 7 04:47:23 2015
@@ -71,6 +71,7 @@ class CMICmdCmdGdbSet : public CMICmdBas
bool GetOptionFn(const CMIUtilString &vrGdbOptionName, FnGdbOptionPtr &vrwpFn) const;
bool OptionFnTargetAsync(const CMIUtilString::VecString_t &vrWords);
bool OptionFnSolibSearchPath(const CMIUtilString::VecString_t &vrWords);
+ bool OptionFnOutputRadix(const CMIUtilString::VecString_t &vrWords);
bool OptionFnFallback(const CMIUtilString::VecString_t &vrWords);
// Attributes:
Modified: lldb/trunk/tools/lldb-mi/MICmnLLDBDebugSessionInfoVarObj.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/lldb-mi/MICmnLLDBDebugSessionInfoVarObj.cpp?rev=234305&r1=234304&r2=234305&view=diff
==============================================================================
--- lldb/trunk/tools/lldb-mi/MICmnLLDBDebugSessionInfoVarObj.cpp (original)
+++ lldb/trunk/tools/lldb-mi/MICmnLLDBDebugSessionInfoVarObj.cpp Tue Apr 7 04:47:23 2015
@@ -23,6 +23,7 @@ const MIchar *CMICmnLLDBDebugSessionInfo
"<Invalid var format>", "t", "o", "d", "x", "N"};
CMICmnLLDBDebugSessionInfoVarObj::MapKeyToVarObj_t CMICmnLLDBDebugSessionInfoVarObj::ms_mapVarIdToVarObj;
MIuint CMICmnLLDBDebugSessionInfoVarObj::ms_nVarUniqueId = 0; // Index from 0
+CMICmnLLDBDebugSessionInfoVarObj::varFormat_e CMICmnLLDBDebugSessionInfoVarObj::ms_eDefaultFormat = eVarFormat_Natural;
//++ ------------------------------------------------------------------------------------
// Details: CMICmnLLDBDebugSessionInfoVarObj constructor.
@@ -302,8 +303,13 @@ CMICmnLLDBDebugSessionInfoVarObj::GetStr
const CMICmnLLDBDebugSessionInfoVarObj::varFormat_e veVarFormat)
{
CMIUtilString strFormattedValue;
+ CMICmnLLDBDebugSessionInfoVarObj::varFormat_e veFormat = veVarFormat;
+ if (ms_eDefaultFormat != eVarFormat_Invalid && veVarFormat == eVarFormat_Natural)
+ {
+ veFormat = ms_eDefaultFormat;
+ }
- switch (veVarFormat)
+ switch (veFormat)
{
case eVarFormat_Binary:
strFormattedValue = CMIUtilString::FormatBinary(vnValue);
@@ -422,6 +428,20 @@ CMICmnLLDBDebugSessionInfoVarObj::VarObj
}
//++ ------------------------------------------------------------------------------------
+// Details: Default format is globally used as the data format when "natural" is in effect, that is, this overrides the default
+// Type: Static method.
+// Args: None.
+// Returns: None.
+// Throws: None.
+//--
+void
+CMICmnLLDBDebugSessionInfoVarObj::VarObjSetFormat(varFormat_e eDefaultFormat)
+{
+ ms_eDefaultFormat = eDefaultFormat;
+}
+
+
+//++ ------------------------------------------------------------------------------------
// Details: A count is kept of the number of var value objects created. This is count is
// used to ID the var value object. Increment the count by 1.
// Type: Static method.
Modified: lldb/trunk/tools/lldb-mi/MICmnLLDBDebugSessionInfoVarObj.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/lldb-mi/MICmnLLDBDebugSessionInfoVarObj.h?rev=234305&r1=234304&r2=234305&view=diff
==============================================================================
--- lldb/trunk/tools/lldb-mi/MICmnLLDBDebugSessionInfoVarObj.h (original)
+++ lldb/trunk/tools/lldb-mi/MICmnLLDBDebugSessionInfoVarObj.h Tue Apr 7 04:47:23 2015
@@ -67,6 +67,7 @@ class CMICmnLLDBDebugSessionInfoVarObj
static MIuint VarObjIdGet(void);
static void VarObjIdResetToZero(void);
static void VarObjClear(void);
+ static void VarObjSetFormat(varFormat_e eDefaultFormat);
// Methods:
public:
@@ -117,6 +118,7 @@ class CMICmnLLDBDebugSessionInfoVarObj
static const MIchar *ms_aVarFormatChars[];
static MapKeyToVarObj_t ms_mapVarIdToVarObj;
static MIuint ms_nVarUniqueId;
+ static varFormat_e ms_eDefaultFormat; // overrides "natural" format
//
// *** Upate the copy move constructors and assignment operator ***
varFormat_e m_eVarFormat;
More information about the lldb-commits
mailing list