diff options
author | Dimitry Andric <dim@FreeBSD.org> | 2016-07-23 20:50:09 +0000 |
---|---|---|
committer | Dimitry Andric <dim@FreeBSD.org> | 2016-07-23 20:50:09 +0000 |
commit | f3fbd1c0586ff6ec7895991e6c28f61a503c36a8 (patch) | |
tree | 48d008fd3df8c0e73271a4b18474e0aac6dbfe33 /tools/lldb-mi | |
parent | 2fc5d2d1dfaf623ce4e24cd8590565902f8c557c (diff) |
Notes
Diffstat (limited to 'tools/lldb-mi')
-rw-r--r-- | tools/lldb-mi/CMakeLists.txt | 5 | ||||
-rw-r--r-- | tools/lldb-mi/MICmdCmdBreak.cpp | 26 | ||||
-rw-r--r-- | tools/lldb-mi/MICmdCmdData.cpp | 9 | ||||
-rw-r--r-- | tools/lldb-mi/MICmdCmdData.h | 2 | ||||
-rw-r--r-- | tools/lldb-mi/MICmdCmdThread.cpp | 23 | ||||
-rw-r--r-- | tools/lldb-mi/MICmdCmdThread.h | 4 | ||||
-rw-r--r-- | tools/lldb-mi/MICmdCmdVar.cpp | 4 | ||||
-rw-r--r-- | tools/lldb-mi/MICmnLLDBDebugSessionInfo.cpp | 16 | ||||
-rw-r--r-- | tools/lldb-mi/MICmnLLDBDebuggerHandleEvents.cpp | 3 | ||||
-rw-r--r-- | tools/lldb-mi/MIUtilFileStd.cpp | 14 | ||||
-rw-r--r-- | tools/lldb-mi/Makefile | 32 | ||||
-rw-r--r-- | tools/lldb-mi/Platform.cpp | 49 | ||||
-rw-r--r-- | tools/lldb-mi/Platform.h | 11 |
13 files changed, 62 insertions, 136 deletions
diff --git a/tools/lldb-mi/CMakeLists.txt b/tools/lldb-mi/CMakeLists.txt index 7fd6ed199e9d..79f657a3ddda 100644 --- a/tools/lldb-mi/CMakeLists.txt +++ b/tools/lldb-mi/CMakeLists.txt @@ -73,7 +73,6 @@ set(LLDB_MI_SOURCES MIUtilString.cpp MIUtilThreadBaseStd.cpp MIUtilVariant.cpp - Platform.cpp ) if ( CMAKE_SYSTEM_NAME MATCHES "Windows" OR CMAKE_SYSTEM_NAME MATCHES "NetBSD" ) @@ -83,8 +82,6 @@ if ( CMAKE_SYSTEM_NAME MATCHES "Windows" OR CMAKE_SYSTEM_NAME MATCHES "NetBSD" ) ) endif () -include(../../cmake/LLDBDependencies.cmake) - add_lldb_executable(lldb-mi ${LLDB_MI_SOURCES}) target_link_libraries(lldb-mi liblldb) @@ -92,8 +89,6 @@ if ( NOT CMAKE_SYSTEM_NAME MATCHES "Windows" ) target_link_libraries(lldb-mi pthread) endif () -# TODO: why isn't this done by add_lldb_executable? -#target_link_libraries(lldb-mi ${LLDB_USED_LIBS}) llvm_config(lldb-mi ${LLVM_LINK_COMPONENTS}) set_target_properties(lldb-mi PROPERTIES VERSION ${LLDB_VERSION}) diff --git a/tools/lldb-mi/MICmdCmdBreak.cpp b/tools/lldb-mi/MICmdCmdBreak.cpp index e758a3dcccef..7238200dfcac 100644 --- a/tools/lldb-mi/MICmdCmdBreak.cpp +++ b/tools/lldb-mi/MICmdCmdBreak.cpp @@ -568,19 +568,9 @@ CMICmdCmdBreakDisable::Acknowledge() { if (m_bBrkPtDisabledOk) { - const CMICmnMIValueConst miValueConst(CMIUtilString::Format("%d", m_nBrkPtId)); - const CMICmnMIValueResult miValueResult("number", miValueConst); - CMICmnMIValueTuple miValueTuple(miValueResult); - const CMICmnMIValueConst miValueConst2("n"); - const CMICmnMIValueResult miValueResult2("enabled", miValueConst2); - miValueTuple.Add(miValueResult2); - const CMICmnMIValueResult miValueResult3("bkpt", miValueTuple); - const CMICmnMIOutOfBandRecord miOutOfBandRecord(CMICmnMIOutOfBandRecord::eOutOfBand_BreakPointModified, miValueResult3); - bool bOk = CMICmnStreamStdout::TextToStdout(miOutOfBandRecord.GetString()); - const CMICmnMIResultRecord miRecordResult(m_cmdData.strMiCmdToken, CMICmnMIResultRecord::eResultClass_Done); m_miResultRecord = miRecordResult; - return bOk; + return MIstatus::success; } const CMIUtilString strBrkPtId(CMIUtilString::Format("%d", m_nBrkPtId)); @@ -683,7 +673,7 @@ CMICmdCmdBreakEnable::Execute() if (brkPt.IsValid()) { m_bBrkPtEnabledOk = true; - brkPt.SetEnabled(false); + brkPt.SetEnabled(true); m_nBrkPtId = nBrk; } @@ -704,19 +694,9 @@ CMICmdCmdBreakEnable::Acknowledge() { if (m_bBrkPtEnabledOk) { - const CMICmnMIValueConst miValueConst(CMIUtilString::Format("%d", m_nBrkPtId)); - const CMICmnMIValueResult miValueResult("number", miValueConst); - CMICmnMIValueTuple miValueTuple(miValueResult); - const CMICmnMIValueConst miValueConst2("y"); - const CMICmnMIValueResult miValueResult2("enabled", miValueConst2); - miValueTuple.Add(miValueResult2); - const CMICmnMIValueResult miValueResult3("bkpt", miValueTuple); - const CMICmnMIOutOfBandRecord miOutOfBandRecord(CMICmnMIOutOfBandRecord::eOutOfBand_BreakPointModified, miValueResult3); - bool bOk = CMICmnStreamStdout::TextToStdout(miOutOfBandRecord.GetString()); - const CMICmnMIResultRecord miRecordResult(m_cmdData.strMiCmdToken, CMICmnMIResultRecord::eResultClass_Done); m_miResultRecord = miRecordResult; - return bOk; + return MIstatus::success; } const CMIUtilString strBrkPtId(CMIUtilString::Format("%d", m_nBrkPtId)); diff --git a/tools/lldb-mi/MICmdCmdData.cpp b/tools/lldb-mi/MICmdCmdData.cpp index 0e0cf12b0080..a46fb5563ce7 100644 --- a/tools/lldb-mi/MICmdCmdData.cpp +++ b/tools/lldb-mi/MICmdCmdData.cpp @@ -117,7 +117,8 @@ CMICmdCmdDataEvaluateExpression::Execute() lldb::SBFrame frame = thread.GetSelectedFrame(); lldb::SBValue value = frame.EvaluateExpression(rExpression.c_str()); - if (!value.IsValid() || value.GetError().Fail()) + m_Error = value.GetError(); + if (!value.IsValid() || m_Error.Fail()) value = frame.FindVariable(rExpression.c_str()); const CMICmnLLDBUtilSBValue utilValue(value, true); if (!utilValue.IsValid() || utilValue.IsValueUnknown()) @@ -177,8 +178,10 @@ CMICmdCmdDataEvaluateExpression::Acknowledge() m_miResultRecord = miRecordResult; return MIstatus::success; } - - const CMICmnMIValueConst miValueConst("Could not evaluate expression"); + CMIUtilString mi_error_msg = "Could not evaluate expression"; + if (const char* err_msg = m_Error.GetCString()) + mi_error_msg = err_msg; + const CMICmnMIValueConst miValueConst(mi_error_msg.Escape(true)); const CMICmnMIValueResult miValueResult("msg", miValueConst); const CMICmnMIResultRecord miRecordResult(m_cmdData.strMiCmdToken, CMICmnMIResultRecord::eResultClass_Error, miValueResult); m_miResultRecord = miRecordResult; diff --git a/tools/lldb-mi/MICmdCmdData.h b/tools/lldb-mi/MICmdCmdData.h index 028c71387f31..a67fd6beaf72 100644 --- a/tools/lldb-mi/MICmdCmdData.h +++ b/tools/lldb-mi/MICmdCmdData.h @@ -32,6 +32,7 @@ // Third party headers: #include "lldb/API/SBCommandReturnObject.h" +#include "lldb/API/SBError.h" // In-house headers: #include "MICmdBase.h" @@ -71,6 +72,7 @@ class CMICmdCmdDataEvaluateExpression : public CMICmdBase private: bool m_bExpressionValid; // True = yes is valid, false = not valid bool m_bEvaluatedExpression; // True = yes is expression evaluated, false = failed + lldb::SBError m_Error; // Error object, which is examined when m_bEvaluatedExpression is false CMIUtilString m_strValue; CMICmnMIValueTuple m_miValueTuple; bool m_bFoundInvalidChar; // True = yes found unexpected character in the expression, false = all ok diff --git a/tools/lldb-mi/MICmdCmdThread.cpp b/tools/lldb-mi/MICmdCmdThread.cpp index 823a3748248c..9435655762a9 100644 --- a/tools/lldb-mi/MICmdCmdThread.cpp +++ b/tools/lldb-mi/MICmdCmdThread.cpp @@ -29,9 +29,10 @@ // Throws: None. //-- CMICmdCmdThreadInfo::CMICmdCmdThreadInfo() - : m_bSingleThread(false) - , m_bThreadInvalid(true) - , m_constStrArgNamedThreadId("thread-id") + : m_bSingleThread(false), + m_bThreadInvalid(true), + m_constStrArgNamedThreadId("thread-id"), + m_bHasCurrentThread(false) { // Command factory matches this name with that received from the stdin stream m_strMiCmd = "thread-info"; @@ -124,6 +125,15 @@ CMICmdCmdThreadInfo::Execute() } } + // -thread-info with multiple threads ends with the current thread id if any + if (thread.IsValid()) + { + const CMIUtilString strId(CMIUtilString::Format("%d", thread.GetIndexID())); + CMICmnMIValueConst miValueCurrThreadId(strId); + m_miValueCurrThreadId = miValueCurrThreadId; + m_bHasCurrentThread = true; + } + return MIstatus::success; } @@ -179,7 +189,12 @@ CMICmdCmdThreadInfo::Acknowledge() ++it; } - const CMICmnMIValueResult miValueResult("threads", miValueList); + CMICmnMIValueResult miValueResult("threads", miValueList); + if (m_bHasCurrentThread) + { + CMIUtilString strCurrThreadId = "current-thread-id"; + miValueResult.Add(strCurrThreadId, m_miValueCurrThreadId); + } const CMICmnMIResultRecord miRecordResult(m_cmdData.strMiCmdToken, CMICmnMIResultRecord::eResultClass_Done, miValueResult); m_miResultRecord = miRecordResult; diff --git a/tools/lldb-mi/MICmdCmdThread.h b/tools/lldb-mi/MICmdCmdThread.h index 7031eabddc33..e3b0adca613a 100644 --- a/tools/lldb-mi/MICmdCmdThread.h +++ b/tools/lldb-mi/MICmdCmdThread.h @@ -60,4 +60,8 @@ class CMICmdCmdThreadInfo : public CMICmdBase bool m_bThreadInvalid; // True = invalid, false = ok VecMIValueTuple_t m_vecMIValueTuple; const CMIUtilString m_constStrArgNamedThreadId; + + // mi value of current-thread-id if multiple threads are requested + bool m_bHasCurrentThread; + CMICmnMIValue m_miValueCurrThreadId; }; diff --git a/tools/lldb-mi/MICmdCmdVar.cpp b/tools/lldb-mi/MICmdCmdVar.cpp index 8e30a2ad0da4..d8e81a44b9d2 100644 --- a/tools/lldb-mi/MICmdCmdVar.cpp +++ b/tools/lldb-mi/MICmdCmdVar.cpp @@ -201,9 +201,7 @@ CMICmdCmdVarCreate::Execute() } else { - lldb::SBStream err; - if (value.GetError().GetDescription(err)) - m_strValue = err.GetData(); + m_strValue = value.GetError().GetCString(); } return MIstatus::success; diff --git a/tools/lldb-mi/MICmnLLDBDebugSessionInfo.cpp b/tools/lldb-mi/MICmnLLDBDebugSessionInfo.cpp index ef99ac9a4207..4ded517a14c6 100644 --- a/tools/lldb-mi/MICmnLLDBDebugSessionInfo.cpp +++ b/tools/lldb-mi/MICmnLLDBDebugSessionInfo.cpp @@ -18,15 +18,16 @@ #include "lldb/API/SBBreakpointLocation.h" // In-house headers: +#include "MICmdData.h" #include "MICmnLLDBDebugSessionInfo.h" #include "MICmnLLDBDebugger.h" -#include "MICmnResources.h" +#include "MICmnLLDBUtilSBValue.h" #include "MICmnMIResultRecord.h" #include "MICmnMIValueConst.h" #include "MICmnMIValueList.h" #include "MICmnMIValueTuple.h" -#include "MICmdData.h" -#include "MICmnLLDBUtilSBValue.h" +#include "MICmnResources.h" +#include "Platform.h" //++ ------------------------------------------------------------------------------------ // Details: CMICmnLLDBDebugSessionInfo constructor. @@ -452,7 +453,12 @@ CMICmnLLDBDebugSessionInfo::MIResponseForVariableInfoInternal(const VariableInfo { CMICmnMIValueTuple miValueTuple; lldb::SBValue value = vwrSBValueList.GetValueAtIndex(i); - const CMICmnMIValueConst miValueConst(value.GetName()); + // If one stops inside try block with, which catch clause type is unnamed + // (e.g std::exception&) then value name will be nullptr as well as value pointer + const char* name = value.GetName(); + if (name == nullptr) + continue; + const CMICmnMIValueConst miValueConst(name); const CMICmnMIValueResult miValueResultName("name", miValueConst); if (vbMarkArgs && vbIsArgs) { @@ -609,7 +615,7 @@ CMICmnLLDBDebugSessionInfo::GetFrameInfo(const lldb::SBFrame &vrFrame, lldb::add { lldb::SBFrame &rFrame = const_cast<lldb::SBFrame &>(vrFrame); - static char pBuffer[MAX_PATH]; + static char pBuffer[PATH_MAX]; const MIuint nBytes = rFrame.GetLineEntry().GetFileSpec().GetPath(&pBuffer[0], sizeof(pBuffer)); MIunused(nBytes); CMIUtilString strResolvedPath(&pBuffer[0]); diff --git a/tools/lldb-mi/MICmnLLDBDebuggerHandleEvents.cpp b/tools/lldb-mi/MICmnLLDBDebuggerHandleEvents.cpp index 848529f0b46a..f92595ac494a 100644 --- a/tools/lldb-mi/MICmnLLDBDebuggerHandleEvents.cpp +++ b/tools/lldb-mi/MICmnLLDBDebuggerHandleEvents.cpp @@ -770,7 +770,8 @@ CMICmnLLDBDebuggerHandleEvents::HandleEventSBCommandInterpreter(const lldb::SBEv // m_pClientDriver->SetExitApplicationFlag(); // vrbYesExit = true; // return MIstatus::success; - //} break; + //} + break; case lldb::SBCommandInterpreter::eBroadcastBitResetPrompt: pEventType = "eBroadcastBitResetPrompt"; break; diff --git a/tools/lldb-mi/MIUtilFileStd.cpp b/tools/lldb-mi/MIUtilFileStd.cpp index 9e5d10d6ba38..ed80466b2df5 100644 --- a/tools/lldb-mi/MIUtilFileStd.cpp +++ b/tools/lldb-mi/MIUtilFileStd.cpp @@ -14,8 +14,11 @@ #include <cerrno> // In-house headers: -#include "MIUtilFileStd.h" #include "MICmnResources.h" +#include "MIUtilFileStd.h" +#include "lldb/Host/FileSystem.h" + +#include "llvm/Support/ConvertUTF.h" //++ ------------------------------------------------------------------------------------ // Details: CMIUtilFileStd constructor. @@ -82,7 +85,14 @@ CMIUtilFileStd::CreateWrite(const CMIUtilString &vFileNamePath, bool &vwrbNewCre m_pFileHandle = ::fopen(vFileNamePath.c_str(), "wb"); #else // Open a file with exclusive write and shared read permissions - m_pFileHandle = ::_fsopen(vFileNamePath.c_str(), "wb", _SH_DENYWR); + std::wstring path; + if (llvm::ConvertUTF8toWide(vFileNamePath.c_str(), path)) + m_pFileHandle = ::_wfsopen(path.c_str(), L"wb", _SH_DENYWR); + else + { + errno = EINVAL; + m_pFileHandle = nullptr; + } #endif // !defined( _MSC_VER ) if (m_pFileHandle == nullptr) diff --git a/tools/lldb-mi/Makefile b/tools/lldb-mi/Makefile deleted file mode 100644 index cdd766633b16..000000000000 --- a/tools/lldb-mi/Makefile +++ /dev/null @@ -1,32 +0,0 @@ -##===- tools/lldb-mi/Makefile -------------------------------*- Makefile -*-===## -# -# The LLVM Compiler Infrastructure -# -# This file is distributed under the University of Illinois Open Source -# License. See LICENSE.TXT for details. -# -##===----------------------------------------------------------------------===## -LLDB_LEVEL := ../.. - -TOOLNAME = lldb-mi - -NO_PEDANTIC = 1 - -LLVMLibsOptions += -ledit -llldb -llldbUtility -LINK_COMPONENTS := support - -include $(LLDB_LEVEL)/Makefile - -ifeq ($(HOST_OS),Darwin) - LLVMLibsOptions += -Wl,-rpath,@loader_path/../lib/ - LLVMLibsOptions += -Wl,-sectcreate -Wl,__TEXT -Wl,__info_plist -Wl,"$(PROJ_SRC_DIR)/lldb-Info.plist" -endif - -ifneq (,$(filter $(HOST_OS), Linux GNU/kFreeBSD NetBSD)) - LLVMLibsOptions += -Wl,-rpath,$(LibDir) -lpthread -endif - -ifeq ($(HOST_OS),FreeBSD) - CPP.Flags += -I/usr/include/edit #-v - LLVMLibsOptions += -Wl,-rpath,$(LibDir) -lpthread -endif diff --git a/tools/lldb-mi/Platform.cpp b/tools/lldb-mi/Platform.cpp deleted file mode 100644 index 7e2eabf51b42..000000000000 --- a/tools/lldb-mi/Platform.cpp +++ /dev/null @@ -1,49 +0,0 @@ -//===-- Platform.cpp --------------------------------------------*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// this file is only relevant for Visual C++ -#if defined(_MSC_VER) - -#include <process.h> -#include <assert.h> - -#include "Platform.h" - -// the control handler or SIGINT handler -static sighandler_t _ctrlHandler = NULL; - -// the default console control handler -BOOL WINAPI CtrlHandler(DWORD ctrlType) -{ - if (_ctrlHandler != NULL) - { - _ctrlHandler(SIGINT); - return TRUE; - } - return FALSE; -} - -sighandler_t -signal(int sig, sighandler_t sigFunc) -{ - switch (sig) - { - case (SIGINT): - { - _ctrlHandler = sigFunc; - SetConsoleCtrlHandler(CtrlHandler, TRUE); - } - break; - default: - assert(!"Not implemented!"); - } - return 0; -} - -#endif diff --git a/tools/lldb-mi/Platform.h b/tools/lldb-mi/Platform.h index 093ceac0fb9d..9db8f7a156ce 100644 --- a/tools/lldb-mi/Platform.h +++ b/tools/lldb-mi/Platform.h @@ -10,12 +10,10 @@ #if defined(_MSC_VER) -// this will stop signal.h being included -#define _INC_SIGNAL - #include <io.h> #include <eh.h> #include <inttypes.h> +#include <signal.h> #include <lldb/Host/windows/Windows.h> #include <lldb/Host/HostGetOpt.h> @@ -60,7 +58,7 @@ struct termios typedef long pid_t; #define STDIN_FILENO 0 -#define PATH_MAX MAX_PATH +#define PATH_MAX 32768 #define snprintf _snprintf extern int ioctl(int d, int request, ...); @@ -73,7 +71,6 @@ typedef void (*sighandler_t)(int); // CODETAG_IOR_SIGNALS // signal.h -#define SIGINT 2 // Terminal interrupt signal #define SIGQUIT 3 // Terminal quit signal #define SIGKILL 9 // Kill (cannot be caught or ignored) #define SIGPIPE 13 // Write on a pipe with no one to read it @@ -81,10 +78,6 @@ typedef void (*sighandler_t)(int); #define SIGTSTP 20 // Terminal stop signal #define SIGSTOP 23 // Stop executing (cannot be caught or ignored) #define SIGWINCH 28 // (== SIGVTALRM) -#define SIG_DFL ((sighandler_t)-1) // Default handler -#define SIG_IGN ((sighandler_t)-2) // Ignored - -extern sighandler_t signal(int sig, sighandler_t); #else |