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

llvm-svn: 235983
This commit is contained in:
Ilia K 2015-04-28 12:51:16 +00:00
parent 6e46512ec3
commit 7f83624222
11 changed files with 141 additions and 0 deletions

View File

@ -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;

View File

@ -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_

View File

@ -100,6 +100,7 @@ HEADER_FILES="${SRC_ROOT}/include/lldb/lldb.h"\
" ${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/interface/SBAddress.i"\
" ${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"\

View File

@ -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",

View File

@ -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

View File

@ -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"

View File

@ -33,6 +33,7 @@ add_lldb_library(liblldb SHARED
SBHostOS.cpp
SBInstruction.cpp
SBInstructionList.cpp
SBLanguageRuntime.cpp
SBLaunchInfo.cpp
SBLineEntry.cpp
SBListener.cpp

View File

@ -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);
}

View File

@ -96,6 +96,29 @@ class MiGdbSetShowTestCase(lldbmi_testcase.MiTestCaseBase):
self.runCmd("-gdb-show target-async")
self.expect("\^done,value=\"on\"")
@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")

View File

@ -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 CMIUtilString::VecString_t &vrWords)
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.

View File

@ -68,6 +68,7 @@ class CMICmdCmdGdbShow : public CMICmdBase
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: