[Lldb-commits] [lldb] r235983 - Add language option in -gdb-show command (MI)
Ilia K
ki.stfu at gmail.com
Tue Apr 28 05:51:17 PDT 2015
Author: ki.stfu
Date: Tue Apr 28 07:51:16 2015
New Revision: 235983
URL: http://llvm.org/viewvc/llvm-project?rev=235983&view=rev
Log:
Add language option in -gdb-show command (MI)
Summary:
Add language option in -gdb-show command + test:
```
$ bin/lldb-mi ~/p/hello
[...]
b main
[...]
r
[...]
(gdb)
-gdb-show language
^done,value="c++"
(gdb)
quit
```
Test Plan: ./dotest.py -v --executable $BUILDDIR/bin/lldb tools/lldb-mi/
Reviewers: abidh, granata.enrico, jingham, clayborg
Reviewed By: clayborg
Subscribers: lldb-commits, jingham, granata.enrico, clayborg, abidh
Differential Revision: http://reviews.llvm.org/D9279
Added:
lldb/trunk/include/lldb/API/SBLanguageRuntime.h
lldb/trunk/scripts/interface/SBLanguageRuntime.i
lldb/trunk/source/API/SBLanguageRuntime.cpp
Modified:
lldb/trunk/include/lldb/API/SBDefines.h
lldb/trunk/scripts/Python/build-swig-Python.sh
lldb/trunk/scripts/Python/buildSwigPython.py
lldb/trunk/scripts/lldb.swig
lldb/trunk/source/API/CMakeLists.txt
lldb/trunk/test/tools/lldb-mi/TestMiGdbSetShow.py
lldb/trunk/tools/lldb-mi/MICmdCmdGdbShow.cpp
lldb/trunk/tools/lldb-mi/MICmdCmdGdbShow.h
Modified: lldb/trunk/include/lldb/API/SBDefines.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBDefines.h?rev=235983&r1=235982&r2=235983&view=diff
==============================================================================
--- lldb/trunk/include/lldb/API/SBDefines.h (original)
+++ lldb/trunk/include/lldb/API/SBDefines.h Tue Apr 28 07:51:16 2015
@@ -55,6 +55,7 @@ class LLDB_API SBFunction;
class LLDB_API SBHostOS;
class LLDB_API SBInstruction;
class LLDB_API SBInstructionList;
+class LLDB_API SBLanguageRuntime;
class LLDB_API SBLaunchInfo;
class LLDB_API SBLineEntry;
class LLDB_API SBListener;
Added: lldb/trunk/include/lldb/API/SBLanguageRuntime.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBLanguageRuntime.h?rev=235983&view=auto
==============================================================================
--- lldb/trunk/include/lldb/API/SBLanguageRuntime.h (added)
+++ lldb/trunk/include/lldb/API/SBLanguageRuntime.h Tue Apr 28 07:51:16 2015
@@ -0,0 +1,29 @@
+//===-- SBLanguageRuntime.h -------------------------------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLDB_SBLanguageRuntime_h_
+#define LLDB_SBLanguageRuntime_h_
+
+#include "lldb/API/SBDefines.h"
+
+namespace lldb {
+
+class SBLanguageRuntime
+{
+public:
+ static lldb::LanguageType
+ GetLanguageTypeFromString (const char *string);
+
+ static const char *
+ GetNameForLanguageType (lldb::LanguageType language);
+};
+
+} // namespace lldb
+
+#endif // LLDB_SBLanguageRuntime_h_
Modified: lldb/trunk/scripts/Python/build-swig-Python.sh
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/Python/build-swig-Python.sh?rev=235983&r1=235982&r2=235983&view=diff
==============================================================================
--- lldb/trunk/scripts/Python/build-swig-Python.sh (original)
+++ lldb/trunk/scripts/Python/build-swig-Python.sh Tue Apr 28 07:51:16 2015
@@ -100,6 +100,7 @@ HEADER_FILES="${SRC_ROOT}/include/lldb/l
" ${SRC_ROOT}/include/lldb/API/SBHostOS.h"\
" ${SRC_ROOT}/include/lldb/API/SBInstruction.h"\
" ${SRC_ROOT}/include/lldb/API/SBInstructionList.h"\
+" ${SRC_ROOT}/include/lldb/API/SBLanguageRuntime.h"\
" ${SRC_ROOT}/include/lldb/API/SBLaunchInfo.h"\
" ${SRC_ROOT}/include/lldb/API/SBLineEntry.h"\
" ${SRC_ROOT}/include/lldb/API/SBListener.h"\
@@ -154,6 +155,7 @@ INTERFACE_FILES="${SRC_ROOT}/scripts/int
" ${SRC_ROOT}/scripts/interface/SBHostOS.i"\
" ${SRC_ROOT}/scripts/interface/SBInstruction.i"\
" ${SRC_ROOT}/scripts/interface/SBInstructionList.i"\
+" ${SRC_ROOT}/scripts/interface/SBLanguageRuntime.i"\
" ${SRC_ROOT}/scripts/interface/SBLaunchInfo.i"\
" ${SRC_ROOT}/scripts/interface/SBLineEntry.i"\
" ${SRC_ROOT}/scripts/interface/SBListener.i"\
Modified: lldb/trunk/scripts/Python/buildSwigPython.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/Python/buildSwigPython.py?rev=235983&r1=235982&r2=235983&view=diff
==============================================================================
--- lldb/trunk/scripts/Python/buildSwigPython.py (original)
+++ lldb/trunk/scripts/Python/buildSwigPython.py Tue Apr 28 07:51:16 2015
@@ -97,6 +97,7 @@ def get_header_files( vDictArgs ):
"/include/lldb/API/SBInputReader.h",
"/include/lldb/API/SBInstruction.h",
"/include/lldb/API/SBInstructionList.h",
+ "/include/lldb/API/SBLanguageRuntime.h",
"/include/lldb/API/SBLaunchInfo.h",
"/include/lldb/API/SBLineEntry.h",
"/include/lldb/API/SBListener.h",
@@ -175,6 +176,7 @@ def get_interface_files( vDictArgs ):
"/scripts/interface/SBInputReader.i",
"/scripts/interface/SBInstruction.i",
"/scripts/interface/SBInstructionList.i",
+ "/scripts/interface/SBLanguageRuntime.i",
"/scripts/interface/SBLaunchInfo.i",
"/scripts/interface/SBLineEntry.i",
"/scripts/interface/SBListener.i",
Added: lldb/trunk/scripts/interface/SBLanguageRuntime.i
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/interface/SBLanguageRuntime.i?rev=235983&view=auto
==============================================================================
--- lldb/trunk/scripts/interface/SBLanguageRuntime.i (added)
+++ lldb/trunk/scripts/interface/SBLanguageRuntime.i Tue Apr 28 07:51:16 2015
@@ -0,0 +1,22 @@
+//===-- SWIG Interface for SBLanguageRuntime --------------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+namespace lldb {
+
+class SBLanguageRuntime
+{
+public:
+ static lldb::LanguageType
+ GetLanguageTypeFromString (const char *string);
+
+ static const char *
+ GetNameForLanguageType (lldb::LanguageType language);
+};
+
+} // namespace lldb
Modified: lldb/trunk/scripts/lldb.swig
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/lldb.swig?rev=235983&r1=235982&r2=235983&view=diff
==============================================================================
--- lldb/trunk/scripts/lldb.swig (original)
+++ lldb/trunk/scripts/lldb.swig Tue Apr 28 07:51:16 2015
@@ -76,6 +76,7 @@ import os
#include "lldb/API/SBHostOS.h"
#include "lldb/API/SBInstruction.h"
#include "lldb/API/SBInstructionList.h"
+#include "lldb/API/SBLanguageRuntime.h"
#include "lldb/API/SBLaunchInfo.h"
#include "lldb/API/SBLineEntry.h"
#include "lldb/API/SBListener.h"
@@ -153,6 +154,7 @@ import os
%include "./interface/SBHostOS.i"
%include "./interface/SBInstruction.i"
%include "./interface/SBInstructionList.i"
+%include "./interface/SBLanguageRuntime.i"
%include "./interface/SBLaunchInfo.i"
%include "./interface/SBLineEntry.i"
%include "./interface/SBListener.i"
Modified: lldb/trunk/source/API/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/CMakeLists.txt?rev=235983&r1=235982&r2=235983&view=diff
==============================================================================
--- lldb/trunk/source/API/CMakeLists.txt (original)
+++ lldb/trunk/source/API/CMakeLists.txt Tue Apr 28 07:51:16 2015
@@ -33,6 +33,7 @@ add_lldb_library(liblldb SHARED
SBHostOS.cpp
SBInstruction.cpp
SBInstructionList.cpp
+ SBLanguageRuntime.cpp
SBLaunchInfo.cpp
SBLineEntry.cpp
SBListener.cpp
Added: lldb/trunk/source/API/SBLanguageRuntime.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBLanguageRuntime.cpp?rev=235983&view=auto
==============================================================================
--- lldb/trunk/source/API/SBLanguageRuntime.cpp (added)
+++ lldb/trunk/source/API/SBLanguageRuntime.cpp Tue Apr 28 07:51:16 2015
@@ -0,0 +1,26 @@
+//===-- SBLanguageRuntime.cpp -----------------------------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#include "lldb/API/SBLanguageRuntime.h"
+#include "lldb/Target/LanguageRuntime.h"
+
+using namespace lldb;
+using namespace lldb_private;
+
+lldb::LanguageType
+SBLanguageRuntime::GetLanguageTypeFromString (const char *string)
+{
+ return LanguageRuntime::GetLanguageTypeFromString(string);
+}
+
+const char *
+SBLanguageRuntime::GetNameForLanguageType (lldb::LanguageType language)
+{
+ return LanguageRuntime::GetNameForLanguageType(language);
+}
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=235983&r1=235982&r2=235983&view=diff
==============================================================================
--- lldb/trunk/test/tools/lldb-mi/TestMiGdbSetShow.py (original)
+++ lldb/trunk/test/tools/lldb-mi/TestMiGdbSetShow.py Tue Apr 28 07:51:16 2015
@@ -98,6 +98,29 @@ class MiGdbSetShowTestCase(lldbmi_testca
@lldbmi_test
@expectedFailureWindows("llvm.org/pr22274: need a pexpect replacement for windows")
+ @skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races
+ def test_lldbmi_gdb_show_language(self):
+ """Test that 'lldb-mi --interpreter' can get current language."""
+
+ self.spawnLldbMi(args = None)
+
+ # Load executable
+ self.runCmd("-file-exec-and-symbols %s" % self.myexe)
+ self.expect("\^done")
+
+ # Run to main
+ self.runCmd("-break-insert -f main")
+ self.expect("\^done,bkpt={number=\"1\"")
+ self.runCmd("-exec-run")
+ self.expect("\^running")
+ self.expect("\*stopped,reason=\"breakpoint-hit\"")
+
+ # Test that -gdb-show language gets current language
+ self.runCmd("-gdb-show language")
+ self.expect("\^done,value=\"c\+\+\"")
+
+ @lldbmi_test
+ @expectedFailureWindows("llvm.org/pr22274: need a pexpect replacement for windows")
@unittest2.expectedFailure("-gdb-set ignores unknown properties")
def test_lldbmi_gdb_set_unknown(self):
"""Test that 'lldb-mi --interpreter' fails when setting an unknown property."""
Modified: lldb/trunk/tools/lldb-mi/MICmdCmdGdbShow.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/lldb-mi/MICmdCmdGdbShow.cpp?rev=235983&r1=235982&r2=235983&view=diff
==============================================================================
--- lldb/trunk/tools/lldb-mi/MICmdCmdGdbShow.cpp (original)
+++ lldb/trunk/tools/lldb-mi/MICmdCmdGdbShow.cpp Tue Apr 28 07:51:16 2015
@@ -9,6 +9,12 @@
// Overview: CMICmdCmdGdbShow implementation.
+// Third party headers:
+#include "lldb/API/SBCompileUnit.h"
+#include "lldb/API/SBFrame.h"
+#include "lldb/API/SBLanguageRuntime.h"
+#include "lldb/API/SBThread.h"
+
// In-house headers:
#include "MICmdCmdGdbShow.h"
#include "MICmnMIResultRecord.h"
@@ -22,6 +28,7 @@
const CMICmdCmdGdbShow::MapGdbOptionNameToFnGdbOptionPtr_t CMICmdCmdGdbShow::ms_mapGdbOptionNameToFnGdbOptionPtr = {
{"target-async", &CMICmdCmdGdbShow::OptionFnTargetAsync},
{"print", &CMICmdCmdGdbShow::OptionFnPrint},
+ {"language", &CMICmdCmdGdbShow::OptionFnLanguage},
{"fallback", &CMICmdCmdGdbShow::OptionFnFallback}};
//++ ------------------------------------------------------------------------------------
@@ -286,6 +293,31 @@ CMICmdCmdGdbShow::OptionFnPrint(const CM
return MIstatus::success;
}
+//++ ------------------------------------------------------------------------------------
+// Details: Carry out work to complete the GDB show option 'language' 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::OptionFnLanguage(const CMIUtilString::VecString_t &vrWords)
+{
+ MIunused(vrWords);
+
+ // Get current language
+ CMICmnLLDBDebugSessionInfo &rSessionInfo(CMICmnLLDBDebugSessionInfo::Instance());
+ lldb::SBThread sbThread = rSessionInfo.GetProcess().GetSelectedThread();
+ const lldb::SBFrame sbFrame = sbThread.GetSelectedFrame();
+ lldb::SBCompileUnit sbCompileUnit = sbFrame.GetCompileUnit();
+ const lldb::LanguageType eLanguageType = sbCompileUnit.GetLanguage();
+
+ m_strValue = lldb::SBLanguageRuntime::GetNameForLanguageType(eLanguageType);
+ return MIstatus::success;
+}
+
//++ ------------------------------------------------------------------------------------
// Details: Carry out work to complete the GDB show option to prepare and send back the
// requested information.
Modified: lldb/trunk/tools/lldb-mi/MICmdCmdGdbShow.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/lldb-mi/MICmdCmdGdbShow.h?rev=235983&r1=235982&r2=235983&view=diff
==============================================================================
--- lldb/trunk/tools/lldb-mi/MICmdCmdGdbShow.h (original)
+++ lldb/trunk/tools/lldb-mi/MICmdCmdGdbShow.h Tue Apr 28 07:51:16 2015
@@ -68,6 +68,7 @@ class CMICmdCmdGdbShow : public CMICmdBa
bool GetOptionFn(const CMIUtilString &vrGdbOptionName, FnGdbOptionPtr &vrwpFn) const;
bool OptionFnTargetAsync(const CMIUtilString::VecString_t &vrWords);
bool OptionFnPrint(const CMIUtilString::VecString_t &vrWords);
+ bool OptionFnLanguage(const CMIUtilString::VecString_t &vrWords);
bool OptionFnFallback(const CMIUtilString::VecString_t &vrWords);
// Attributes:
More information about the lldb-commits
mailing list