| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,63 @@ | ||
| //===-- MICmdArgValConsume.h ---------------------------------------*- C++ -*-===// | ||
| // | ||
| // The LLVM Compiler Infrastructure | ||
| // | ||
| // This file is distributed under the University of Illinois Open Source | ||
| // License. See LICENSE.TXT for details. | ||
| // | ||
| //===----------------------------------------------------------------------===// | ||
|
|
||
| //++ | ||
| // File: MICmdArgValConsume.h | ||
| // | ||
| // Overview: CMICmdArgValConsume interface. | ||
| // | ||
| // Environment: Compilers: Visual C++ 12. | ||
| // gcc (Ubuntu/Linaro 4.8.1-10ubuntu9) 4.8.1 | ||
| // Libraries: See MIReadmetxt. | ||
| // | ||
| // Copyright: None. | ||
| //-- | ||
|
|
||
| #pragma once | ||
|
|
||
| // In-house headers: | ||
| #include "MICmdArgValBase.h" | ||
|
|
||
| // Declarations: | ||
| class CMICmdArgContext; | ||
|
|
||
| //++ ============================================================================ | ||
| // Details: MI common code class. Command argument class. Arguments object | ||
| // needing specialization derived from the CMICmdArgValBase class. | ||
| // An argument knows what type of argument it is and how it is to | ||
| // interpret the options (context) string to find and validate a matching | ||
| // argument. This type having recognised its argument name just consumes | ||
| // that argument or option (ignores it). This is the so the validation | ||
| // process can then ask if all arguments or options have been recognised | ||
| // other an error will occurred "argument not recognised". For example | ||
| // this can be used to consume the "--" text which is not an argument in | ||
| // itself. Normally the GetValue() function (in base class) would return | ||
| // a value for the argument but is not the case for *this argument type | ||
| // object. | ||
| // Based on the Interpreter pattern. | ||
| // Gotchas: None. | ||
| // Authors: Illya Rudkin 20/05/2014. | ||
| // Changes: None. | ||
| //-- | ||
| class CMICmdArgValConsume : public CMICmdArgValBaseTemplate< CMIUtilString > | ||
| { | ||
| // Methods: | ||
| public: | ||
| /* ctor */ CMICmdArgValConsume( void ); | ||
| /* ctor */ CMICmdArgValConsume( const CMIUtilString & vrArgName, const bool vbMandatory ); | ||
| // | ||
| bool IsOk( void ) const; | ||
|
|
||
| // Overridden: | ||
| public: | ||
| // From CMICmdArgValBase | ||
| /* dtor */ virtual ~CMICmdArgValConsume( void ); | ||
| // From CMICmdArgSet::IArg | ||
| virtual bool Validate( CMICmdArgContext & vwArgContext ); | ||
| }; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,240 @@ | ||
| //===-- MICmdCmdGdbInfo.cpp ------------------------*- C++ -*-===// | ||
| // | ||
| // The LLVM Compiler Infrastructure | ||
| // | ||
| // This file is distributed under the University of Illinois Open Source | ||
| // License. See LICENSE.TXT for details. | ||
| // | ||
| //===----------------------------------------------------------------------===// | ||
|
|
||
| //++ | ||
| // File: MICmdCmdGdbInfo.cpp | ||
| // | ||
| // Overview: CMICmdCmdGdbInfo implementation. | ||
| // | ||
| // Environment: Compilers: Visual C++ 12. | ||
| // gcc (Ubuntu/Linaro 4.8.1-10ubuntu9) 4.8.1 | ||
| // Libraries: See MIReadmetxt. | ||
| // | ||
| // Copyright: None. | ||
| //-- | ||
|
|
||
| // Third party headers: | ||
| #include <lldb/API/SBCommandReturnObject.h> | ||
|
|
||
| // In-house headers: | ||
| #include "MICmdCmdGdbInfo.h" | ||
| #include "MICmnMIResultRecord.h" | ||
| #include "MICmnMIValueConst.h" | ||
| #include "MICmdArgContext.h" | ||
| #include "MICmdArgValString.h" | ||
| #include "MICmnStreamStdout.h" | ||
| #include "MICmnLLDBDebugSessionInfo.h" | ||
|
|
||
| // Instantiations: | ||
| const CMICmdCmdGdbInfo::MapPrintFnNameToPrintFn_t CMICmdCmdGdbInfo::ms_mapPrintFnNameToPrintFn = | ||
| { | ||
| { "sharedlibrary", &CMICmdCmdGdbInfo::PrintFnSharedLibrary } | ||
| }; | ||
|
|
||
| //++ ------------------------------------------------------------------------------------ | ||
| // Details: CMICmdCmdGdbInfo constructor. | ||
| // Type: Method. | ||
| // Args: None. | ||
| // Return: None. | ||
| // Throws: None. | ||
| //-- | ||
| CMICmdCmdGdbInfo::CMICmdCmdGdbInfo( void ) | ||
| : m_constStrArgNamedPrint( "print" ) | ||
| , m_bPrintFnRecognised( true ) | ||
| , m_bPrintFnSuccessful( false ) | ||
| , m_strPrintFnError( MIRSRC( IDS_WORD_ERR_MSG_NOT_IMPLEMENTED_BRKTS ) ) | ||
| { | ||
| // Command factory matches this name with that received from the stdin stream | ||
| m_strMiCmd = "info"; | ||
|
|
||
| // Required by the CMICmdFactory when registering *this command | ||
| m_pSelfCreatorFn = &CMICmdCmdGdbInfo::CreateSelf; | ||
| } | ||
|
|
||
| //++ ------------------------------------------------------------------------------------ | ||
| // Details: CMICmdCmdGdbInfo destructor. | ||
| // Type: Overrideable. | ||
| // Args: None. | ||
| // Return: None. | ||
| // Throws: None. | ||
| //-- | ||
| CMICmdCmdGdbInfo::~CMICmdCmdGdbInfo( void ) | ||
| { | ||
| } | ||
|
|
||
| //++ ------------------------------------------------------------------------------------ | ||
| // Details: The invoker requires this function. The parses the command line options | ||
| // arguments to extract values for each of those arguments. | ||
| // Type: Overridden. | ||
| // Args: None. | ||
| // Return: MIstatus::success - Functional succeeded. | ||
| // MIstatus::failure - Functional failed. | ||
| // Throws: None. | ||
| //-- | ||
| bool CMICmdCmdGdbInfo::ParseArgs( void ) | ||
| { | ||
| bool bOk = m_setCmdArgs.Add( *(new CMICmdArgValString( m_constStrArgNamedPrint, true, true ) ) ); | ||
| CMICmdArgContext argCntxt( m_cmdData.strMiCmdOption ); | ||
| if( bOk && !m_setCmdArgs.Validate( m_cmdData.strMiCmd, argCntxt ) ) | ||
| { | ||
| SetError( CMIUtilString::Format( MIRSRC( IDS_CMD_ERR_ARGS ), m_cmdData.strMiCmd.c_str(), m_setCmdArgs.GetErrorDescription().c_str() ) ); | ||
| return MIstatus::failure; | ||
| } | ||
|
|
||
| return bOk; | ||
| } | ||
|
|
||
| //++ ------------------------------------------------------------------------------------ | ||
| // Details: The invoker requires this function. The command does work in this function. | ||
| // The command is likely to communicate with the LLDB SBDebugger in here. | ||
| // Type: Overridden. | ||
| // Args: None. | ||
| // Return: MIstatus::success - Functional succeeded. | ||
| // MIstatus::failure - Functional failed. | ||
| // Throws: None. | ||
| //-- | ||
| bool CMICmdCmdGdbInfo::Execute( void ) | ||
| { | ||
| CMICMDBASE_GETOPTION( pArgPrint, String, m_constStrArgNamedPrint ); | ||
| const CMIUtilString & rPrintRequest( pArgPrint->GetValue() ); | ||
|
|
||
| FnPrintPtr pPrintRequestFn = nullptr; | ||
| if( !GetPrintFn( rPrintRequest, pPrintRequestFn ) ) | ||
| { | ||
| m_strPrintFnName = rPrintRequest; | ||
| m_bPrintFnRecognised = false; | ||
| return MIstatus::success; | ||
| } | ||
|
|
||
| m_bPrintFnSuccessful = (this->*(pPrintRequestFn))(); | ||
|
|
||
| return MIstatus::success; | ||
| } | ||
|
|
||
| //++ ------------------------------------------------------------------------------------ | ||
| // Details: The invoker requires this function. The command prepares a MI Record Result | ||
| // for the work carried out in the Execute(). | ||
| // Type: Overridden. | ||
| // Args: None. | ||
| // Return: MIstatus::success - Functional succeeded. | ||
| // MIstatus::failure - Functional failed. | ||
| // Throws: None. | ||
| //-- | ||
| bool CMICmdCmdGdbInfo::Acknowledge( void ) | ||
| { | ||
| if( !m_bPrintFnRecognised ) | ||
| { | ||
| const CMICmnMIValueConst miValueConst( CMIUtilString::Format( MIRSRC( IDS_CMD_ERR_INFO_PRINTFN_NOT_FOUND ), m_strPrintFnName.c_str() ) ); | ||
| const CMICmnMIValueResult miValueResult( "msg", miValueConst ); | ||
| const CMICmnMIResultRecord miRecordResult( m_cmdData.strMiCmdToken, CMICmnMIResultRecord::eResultClass_Error, miValueResult ); | ||
| m_miResultRecord = miRecordResult; | ||
| return MIstatus::success; | ||
| } | ||
|
|
||
| if( m_bPrintFnSuccessful ) | ||
| { | ||
| const CMICmnMIResultRecord miRecordResult( m_cmdData.strMiCmdToken, CMICmnMIResultRecord::eResultClass_Done ); | ||
| m_miResultRecord = miRecordResult; | ||
| return MIstatus::success; | ||
| } | ||
|
|
||
| const CMICmnMIValueConst miValueConst( CMIUtilString::Format( MIRSRC( IDS_CMD_ERR_INFO_PRINTFN_FAILED ), m_strPrintFnError.c_str() ) ); | ||
| const CMICmnMIValueResult miValueResult( "msg", miValueConst ); | ||
| const CMICmnMIResultRecord miRecordResult( m_cmdData.strMiCmdToken, CMICmnMIResultRecord::eResultClass_Error, miValueResult ); | ||
| m_miResultRecord = miRecordResult; | ||
|
|
||
| return MIstatus::success; | ||
| } | ||
|
|
||
| //++ ------------------------------------------------------------------------------------ | ||
| // Details: Required by the CMICmdFactory when registering *this command. The factory | ||
| // calls this function to create an instance of *this command. | ||
| // Type: Static method. | ||
| // Args: None. | ||
| // Return: CMICmdBase * - Pointer to a new command. | ||
| // Throws: None. | ||
| //-- | ||
| CMICmdBase * CMICmdCmdGdbInfo::CreateSelf( void ) | ||
| { | ||
| return new CMICmdCmdGdbInfo(); | ||
| } | ||
|
|
||
| //++ ------------------------------------------------------------------------------------ | ||
| // Details: Retrieve the print function's pointer for the matching print request. | ||
| // Type: Method. | ||
| // Args: vrPrintFnName - (R) The info requested. | ||
| // vrwpFn - (W) The print function's pointer of the function to carry out | ||
| // Return: bool - True = Print request is implemented, false = not found. | ||
| // Throws: None. | ||
| //-- | ||
| bool CMICmdCmdGdbInfo::GetPrintFn( const CMIUtilString & vrPrintFnName, FnPrintPtr & vrwpFn ) const | ||
| { | ||
| vrwpFn = nullptr; | ||
|
|
||
| const MapPrintFnNameToPrintFn_t::const_iterator it = ms_mapPrintFnNameToPrintFn.find( vrPrintFnName ); | ||
| if( it != ms_mapPrintFnNameToPrintFn.end() ) | ||
| { | ||
| vrwpFn = (*it).second; | ||
| return true; | ||
| } | ||
|
|
||
| return false; | ||
| } | ||
|
|
||
| //++ ------------------------------------------------------------------------------------ | ||
| // Details: Carry out work to complete the request to prepare and send back information | ||
| // asked for. | ||
| // Type: Method. | ||
| // Args: None. | ||
| // Return: MIstatus::success - Functional succeeded. | ||
| // MIstatus::failure - Functional failed. | ||
| // Throws: None. | ||
| //-- | ||
| bool CMICmdCmdGdbInfo::PrintFnSharedLibrary( void ) | ||
| { | ||
| CMICmnStreamStdout & rStdout = CMICmnStreamStdout::Instance(); | ||
| bool bOk = rStdout.TextToStdout( "~\"From To Syms Read Shared Object Library\"" ); | ||
|
|
||
| CMICmnLLDBDebugSessionInfo & rSessionInfo( CMICmnLLDBDebugSessionInfo::Instance() ); | ||
| lldb::SBTarget & rTarget = rSessionInfo.m_lldbTarget; | ||
| const MIuint nModules = rTarget.GetNumModules(); | ||
| for( MIuint i = 0; bOk && (i < nModules); i++ ) | ||
| { | ||
| lldb::SBModule module = rTarget.GetModuleAtIndex( i ); | ||
| if( module.IsValid() ) | ||
| { | ||
| const CMIUtilString strModuleFilePath( module.GetFileSpec().GetDirectory() ); | ||
| const CMIUtilString strModuleFileName( module.GetFileSpec().GetFilename() ); | ||
| const CMIUtilString strModuleFullPath( CMIUtilString::Format( "%s/%s", strModuleFilePath.c_str(), strModuleFileName.c_str() ) ); | ||
| const CMIUtilString strHasSymbols = (module.GetNumSymbols() > 0) ? "Yes" : "No"; | ||
| lldb::addr_t addrLoadS = 0xffffffff; | ||
| lldb::addr_t addrLoadSize = 0; | ||
| bool bHaveAddrLoad = false; | ||
| const MIuint nSections = module.GetNumSections(); | ||
| for( MIuint j = 0; j < nSections; j++ ) | ||
| { | ||
| lldb::SBSection section = module.GetSectionAtIndex( j ); | ||
| lldb::addr_t addrLoad = section.GetLoadAddress( rTarget ); | ||
| if( addrLoad != (lldb::addr_t) -1 ) | ||
| { | ||
| if( !bHaveAddrLoad ) | ||
| { | ||
| bHaveAddrLoad = true; | ||
| addrLoadS = addrLoad; | ||
| } | ||
|
|
||
| addrLoadSize += section.GetByteSize(); | ||
| } | ||
| } | ||
| bOk = bOk && rStdout.TextToStdout( CMIUtilString::Format( "~\"0x%08x\t0x%08x\t%s\t\t%s\"", addrLoadS, addrLoadS + addrLoadSize, strHasSymbols.c_str(), strModuleFullPath.c_str() ) ); | ||
| } | ||
| } | ||
|
|
||
| return bOk; | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,93 @@ | ||
| //===-- MICmdCmdGdbInfo.h --------------------------*- C++ -*-===// | ||
| // | ||
| // The LLVM Compiler Infrastructure | ||
| // | ||
| // This file is distributed under the University of Illinois Open Source | ||
| // License. See LICENSE.TXT for details. | ||
| // | ||
| //===----------------------------------------------------------------------===// | ||
|
|
||
| //++ | ||
| // File: MICmdCmdGdbInfo.h | ||
| // | ||
| // Overview: CMICmdCmdGdbInfo interface. | ||
| // | ||
| // To implement new MI commands derive a new command class from the command base | ||
| // class. To enable the new command for interpretation add the new command class | ||
| // to the command factory. The files of relevance are: | ||
| // MICmdCommands.cpp | ||
| // MICmdBase.h / .cpp | ||
| // MICmdCmd.h / .cpp | ||
| // For an introduction to adding a new command see CMICmdCmdSupportInfoMiCmdQuery | ||
| // command class as an example. | ||
| // | ||
| // Environment: Compilers: Visual C++ 12. | ||
| // gcc (Ubuntu/Linaro 4.8.1-10ubuntu9) 4.8.1 | ||
| // Libraries: See MIReadmetxt. | ||
| // | ||
| // Copyright: None. | ||
| //-- | ||
|
|
||
| #pragma once | ||
|
|
||
| // Third party headers: | ||
| #include <map> | ||
|
|
||
| // In-house headers: | ||
| #include "MICmdBase.h" | ||
|
|
||
| //++ ============================================================================ | ||
| // Details: MI command class. MI commands derived from the command base class. | ||
| // *this class implements GDB command "info". | ||
| // The design of matching the info request to a request action (or | ||
| // command) is very simple. The request function which carries out | ||
| // the task of information gathering and printing to stdout is part of | ||
| // *this class. Should the request function become more complicated then | ||
| // that request should really reside in a command type class. Then this | ||
| // class instantiates a request info command for a matching request. The | ||
| // design/code of *this class then does not then become bloated. Use a | ||
| // lightweight version of the current MI command system. | ||
| // Gotchas: None. | ||
| // Authors: Illya Rudkin 05/06/2014. | ||
| // Changes: None. | ||
| //-- | ||
| class CMICmdCmdGdbInfo : public CMICmdBase | ||
| { | ||
| // Statics: | ||
| public: | ||
| // Required by the CMICmdFactory when registering *this command | ||
| static CMICmdBase * CreateSelf( void ); | ||
|
|
||
| // Methods: | ||
| public: | ||
| /* ctor */ CMICmdCmdGdbInfo( void ); | ||
|
|
||
| // Overridden: | ||
| public: | ||
| // From CMICmdInvoker::ICmd | ||
| virtual bool Execute( void ); | ||
| virtual bool Acknowledge( void ); | ||
| virtual bool ParseArgs( void ); | ||
| // From CMICmnBase | ||
| /* dtor */ virtual ~CMICmdCmdGdbInfo( void ); | ||
|
|
||
| // Typedefs: | ||
| private: | ||
| typedef bool (CMICmdCmdGdbInfo::*FnPrintPtr)(); | ||
| typedef std::map< CMIUtilString, FnPrintPtr > MapPrintFnNameToPrintFn_t; | ||
|
|
||
| // Methods: | ||
| private: | ||
| bool GetPrintFn( const CMIUtilString & vrPrintFnName, FnPrintPtr & vrwpFn ) const; | ||
| bool PrintFnSharedLibrary( void ); | ||
|
|
||
| // Attributes: | ||
| private: | ||
| const static MapPrintFnNameToPrintFn_t ms_mapPrintFnNameToPrintFn; | ||
| // | ||
| const CMIUtilString m_constStrArgNamedPrint; | ||
| bool m_bPrintFnRecognised; // True = This command has a function with a name that matches the Print argument, false = not found | ||
| bool m_bPrintFnSuccessful; // True = The print function completed its task ok, false = function failed for some reason | ||
| CMIUtilString m_strPrintFnName; | ||
| CMIUtilString m_strPrintFnError; | ||
| }; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,265 @@ | ||
| //===-- MICmdCmdGdbSet.cpp ------- -------------------------*- C++ -*-===// | ||
| // | ||
| // The LLVM Compiler Infrastructure | ||
| // | ||
| // This file is distributed under the University of Illinois Open Source | ||
| // License. See LICENSE.TXT for details. | ||
| // | ||
| //===----------------------------------------------------------------------===// | ||
|
|
||
| //++ | ||
| // File: MICmdCmdGdbSet.cpp | ||
| // | ||
| // Overview: CMICmdCmdGdbSet implementation. | ||
| // | ||
| // Environment: Compilers: Visual C++ 12. | ||
| // gcc (Ubuntu/Linaro 4.8.1-10ubuntu9) 4.8.1 | ||
| // Libraries: See MIReadmetxt. | ||
| // | ||
| // Copyright: None. | ||
| //-- | ||
|
|
||
| // In-house headers: | ||
| #include "MICmdCmdGdbSet.h" | ||
| #include "MICmnMIResultRecord.h" | ||
| #include "MICmnMIValueConst.h" | ||
| #include "MICmdArgContext.h" | ||
| #include "MICmdArgValString.h" | ||
| #include "MICmdArgValListOfN.h" | ||
| #include "MICmnLLDBDebugSessionInfo.h" | ||
|
|
||
| // Instantiations: | ||
| const CMICmdCmdGdbSet::MapGdbOptionNameToFnGdbOptionPtr_t CMICmdCmdGdbSet::ms_mapGdbOptionNameToFnGdbOptionPtr = | ||
| { | ||
| // { "target-async", &CMICmdCmdGdbSet::OptionFnTargetAsync }, // Example code if need to implement GDB set other options | ||
| // { "auto-solib-add", &CMICmdCmdGdbSet::OptionFnAutoSolibAdd }, // Example code if need to implement GDB set other options | ||
| { "solib-search-path", &CMICmdCmdGdbSet::OptionFnSolibSearchPath }, | ||
| { "fallback", &CMICmdCmdGdbSet::OptionFnFallback } | ||
| }; | ||
|
|
||
| //++ ------------------------------------------------------------------------------------ | ||
| // Details: CMICmdCmdGdbSet constructor. | ||
| // Type: Method. | ||
| // Args: None. | ||
| // Return: None. | ||
| // Throws: None. | ||
| //-- | ||
| CMICmdCmdGdbSet::CMICmdCmdGdbSet( void ) | ||
| : m_constStrArgNamedGdbOption( "option" ) | ||
| , m_bGdbOptionRecognised( true ) | ||
| , m_bGdbOptionFnSuccessful( false ) | ||
| , m_bGbbOptionFnHasError( false ) | ||
| , m_strGdbOptionFnError( MIRSRC( IDS_WORD_ERR_MSG_NOT_IMPLEMENTED_BRKTS ) ) | ||
| { | ||
| // Command factory matches this name with that received from the stdin stream | ||
| m_strMiCmd = "gdb-set"; | ||
|
|
||
| // Required by the CMICmdFactory when registering *this command | ||
| m_pSelfCreatorFn = &CMICmdCmdGdbSet::CreateSelf; | ||
| } | ||
|
|
||
| //++ ------------------------------------------------------------------------------------ | ||
| // Details: CMICmdCmdGdbSet destructor. | ||
| // Type: Overrideable. | ||
| // Args: None. | ||
| // Return: None. | ||
| // Throws: None. | ||
| //-- | ||
| CMICmdCmdGdbSet::~CMICmdCmdGdbSet( void ) | ||
| { | ||
| } | ||
|
|
||
| //++ ------------------------------------------------------------------------------------ | ||
| // Details: The invoker requires this function. The parses the command line options | ||
| // arguments to extract values for each of those arguments. | ||
| // Type: Overridden. | ||
| // Args: None. | ||
| // Return: MIstatus::success - Functional succeeded. | ||
| // MIstatus::failure - Functional failed. | ||
| // Throws: None. | ||
| //-- | ||
| bool CMICmdCmdGdbSet::ParseArgs( void ) | ||
| { | ||
| bool bOk = m_setCmdArgs.Add( *(new CMICmdArgValListOfN( m_constStrArgNamedGdbOption, true, true, CMICmdArgValListBase::eArgValType_StringQuotedNumberPath ) ) ); | ||
| CMICmdArgContext argCntxt( m_cmdData.strMiCmdOption ); | ||
| if( bOk && !m_setCmdArgs.Validate( m_cmdData.strMiCmd, argCntxt ) ) | ||
| { | ||
| SetError( CMIUtilString::Format( MIRSRC( IDS_CMD_ERR_ARGS ), m_cmdData.strMiCmd.c_str(), m_setCmdArgs.GetErrorDescription().c_str() ) ); | ||
| return MIstatus::failure; | ||
| } | ||
|
|
||
| return bOk; | ||
| } | ||
|
|
||
| //++ ------------------------------------------------------------------------------------ | ||
| // Details: The invoker requires this function. The command does work in this function. | ||
| // The command is likely to communicate with the LLDB SBDebugger in here. | ||
| // Type: Overridden. | ||
| // Args: None. | ||
| // Return: MIstatus::success - Functional succeeded. | ||
| // MIstatus::failure - Functional failed. | ||
| // Throws: None. | ||
| //-- | ||
| bool CMICmdCmdGdbSet::Execute( void ) | ||
| { | ||
| CMICMDBASE_GETOPTION( pArgGdbOption, ListOfN, m_constStrArgNamedGdbOption ); | ||
| const CMICmdArgValListBase::VecArgObjPtr_t & rVecWords( pArgGdbOption->GetExpectedOptions() ); | ||
|
|
||
| // Get the gdb-set option to carry out | ||
| CMICmdArgValListBase::VecArgObjPtr_t::const_iterator it = rVecWords.begin(); | ||
| const CMICmdArgValString * pOption = static_cast< const CMICmdArgValString * >( *it ); | ||
| const CMIUtilString strOption( pOption->GetValue() ); | ||
| ++it; | ||
|
|
||
| // Retrieve the parameter(s) for the option | ||
| CMIUtilString::VecString_t vecWords; | ||
| while( it != rVecWords.end() ) | ||
| { | ||
| const CMICmdArgValString * pWord = static_cast< const CMICmdArgValString * >( *it ); | ||
| vecWords.push_back( pWord->GetValue() ); | ||
|
|
||
| // Next | ||
| ++it; | ||
| } | ||
|
|
||
| FnGdbOptionPtr pPrintRequestFn = nullptr; | ||
| if( !GetOptionFn( strOption, pPrintRequestFn ) ) | ||
| { | ||
| // For unimplemented option handlers, fallback on a generic handler | ||
| // ToDo: Remove this when ALL options have been implemented | ||
| if( !GetOptionFn( "fallback", pPrintRequestFn ) ) | ||
| { | ||
| m_bGdbOptionRecognised = false; | ||
| m_strGdbOptionName = "fallback"; // This would be the strOption name | ||
| return MIstatus::success; | ||
| } | ||
| } | ||
|
|
||
| m_bGdbOptionFnSuccessful = (this->*(pPrintRequestFn))( vecWords ); | ||
| if( !m_bGdbOptionFnSuccessful && !m_bGbbOptionFnHasError ) | ||
| return MIstatus::failure; | ||
|
|
||
| return MIstatus::success; | ||
| } | ||
|
|
||
| //++ ------------------------------------------------------------------------------------ | ||
| // Details: The invoker requires this function. The command prepares a MI Record Result | ||
| // for the work carried out in the Execute(). | ||
| // Type: Overridden. | ||
| // Args: None. | ||
| // Return: MIstatus::success - Functional succeeded. | ||
| // MIstatus::failure - Functional failed. | ||
| // Throws: None. | ||
| //-- | ||
| bool CMICmdCmdGdbSet::Acknowledge( void ) | ||
| { | ||
| if( !m_bGdbOptionRecognised ) | ||
| { | ||
| const CMICmnMIValueConst miValueConst( CMIUtilString::Format( MIRSRC( IDS_CMD_ERR_INFO_PRINTFN_NOT_FOUND ), m_strGdbOptionName.c_str() ) ); | ||
| const CMICmnMIValueResult miValueResult( "msg", miValueConst ); | ||
| const CMICmnMIResultRecord miRecordResult( m_cmdData.strMiCmdToken, CMICmnMIResultRecord::eResultClass_Error, miValueResult ); | ||
| m_miResultRecord = miRecordResult; | ||
| return MIstatus::success; | ||
| } | ||
|
|
||
| if( m_bGdbOptionFnSuccessful ) | ||
| { | ||
| const CMICmnMIResultRecord miRecordResult( m_cmdData.strMiCmdToken, CMICmnMIResultRecord::eResultClass_Done ); | ||
| m_miResultRecord = miRecordResult; | ||
| return MIstatus::success; | ||
| } | ||
|
|
||
| const CMICmnMIValueConst miValueConst( CMIUtilString::Format( MIRSRC( IDS_CMD_ERR_INFO_PRINTFN_FAILED ), m_strGdbOptionFnError.c_str() ) ); | ||
| const CMICmnMIValueResult miValueResult( "msg", miValueConst ); | ||
| const CMICmnMIResultRecord miRecordResult( m_cmdData.strMiCmdToken, CMICmnMIResultRecord::eResultClass_Error, miValueResult ); | ||
| m_miResultRecord = miRecordResult; | ||
|
|
||
| return MIstatus::success; | ||
| } | ||
|
|
||
| //++ ------------------------------------------------------------------------------------ | ||
| // Details: Required by the CMICmdFactory when registering *this command. The factory | ||
| // calls this function to create an instance of *this command. | ||
| // Type: Static method. | ||
| // Args: None. | ||
| // Return: CMICmdBase * - Pointer to a new command. | ||
| // Throws: None. | ||
| //-- | ||
| CMICmdBase * CMICmdCmdGdbSet::CreateSelf( void ) | ||
| { | ||
| return new CMICmdCmdGdbSet(); | ||
| } | ||
|
|
||
| //++ ------------------------------------------------------------------------------------ | ||
| // Details: Retrieve the print function's pointer for the matching print request. | ||
| // Type: Method. | ||
| // Args: vrPrintFnName - (R) The info requested. | ||
| // vrwpFn - (W) The print function's pointer of the function to carry out | ||
| // Return: bool - True = Print request is implemented, false = not found. | ||
| // Throws: None. | ||
| //-- | ||
| bool CMICmdCmdGdbSet::GetOptionFn( const CMIUtilString & vrPrintFnName, FnGdbOptionPtr & vrwpFn ) const | ||
| { | ||
| vrwpFn = nullptr; | ||
|
|
||
| const MapGdbOptionNameToFnGdbOptionPtr_t::const_iterator it = ms_mapGdbOptionNameToFnGdbOptionPtr.find( vrPrintFnName ); | ||
| if( it != ms_mapGdbOptionNameToFnGdbOptionPtr.end() ) | ||
| { | ||
| vrwpFn = (*it).second; | ||
| return true; | ||
| } | ||
|
|
||
| return false; | ||
| } | ||
|
|
||
| //++ ------------------------------------------------------------------------------------ | ||
| // Details: Carry out work to complete the GDB set option 'solib-search-path' 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::OptionFnSolibSearchPath( 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 & rStrValSolibPath( vrWords[ 0 ] ); | ||
|
|
||
| // Add 'solib-search-path' to the shared data list | ||
| const CMIUtilString & rStrKeySolibPath( m_rLLDBDebugSessionInfo.m_constStrSharedDataSolibPath ); | ||
| if( !m_rLLDBDebugSessionInfo.SharedDataAdd< CMIUtilString >( rStrKeySolibPath, rStrValSolibPath ) ) | ||
| { | ||
| m_bGbbOptionFnHasError = false; | ||
| SetError( CMIUtilString::Format( MIRSRC( IDS_DBGSESSION_ERR_SHARED_DATA_ADD ), m_cmdData.strMiCmd.c_str(), rStrKeySolibPath.c_str() ) ); | ||
| return MIstatus::failure; | ||
| } | ||
|
|
||
| return MIstatus::success; | ||
| } | ||
|
|
||
| //++ ------------------------------------------------------------------------------------ | ||
| // Details: Carry out work to complete the GDB set option to prepare and send back information | ||
| // asked for. | ||
| // Type: Method. | ||
| // Args: None. | ||
| // Return: MIstatus::success - Functional succeeded. | ||
| // MIstatus::failure - Functional failed. | ||
| // Throws: None. | ||
| //-- | ||
| bool CMICmdCmdGdbSet::OptionFnFallback( const CMIUtilString::VecString_t & vrWords ) | ||
| { | ||
| MIunused( vrWords ); | ||
|
|
||
| // Do nothing - intentional. This is a fallback temporary action function to do nothing. | ||
| // This allows the search for gdb-set options to always suceed when the option is not | ||
| // found (implemented). | ||
|
|
||
| return MIstatus::success; | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,95 @@ | ||
| //===-- MICmdCmdGdbSet.h ------------- ---------------------*- C++ -*-===// | ||
| // | ||
| // The LLVM Compiler Infrastructure | ||
| // | ||
| // This file is distributed under the University of Illinois Open Source | ||
| // License. See LICENSE.TXT for details. | ||
| // | ||
| //===----------------------------------------------------------------------===// | ||
|
|
||
| //++ | ||
| // File: MICmdCmdGdbSet.h | ||
| // | ||
| // Overview: CMICmdCmdGdbSet interface. | ||
| // | ||
| // To implement new MI commands derive a new command class from the command base | ||
| // class. To enable the new command for interpretation add the new command class | ||
| // to the command factory. The files of relevance are: | ||
| // MICmdCommands.cpp | ||
| // MICmdBase.h / .cpp | ||
| // MICmdCmd.h / .cpp | ||
| // For an introduction to adding a new command see CMICmdCmdSupportInfoMiCmdQuery | ||
| // command class as an example. | ||
| // | ||
| // Environment: Compilers: Visual C++ 12. | ||
| // gcc (Ubuntu/Linaro 4.8.1-10ubuntu9) 4.8.1 | ||
| // Libraries: See MIReadmetxt. | ||
| // | ||
| // Copyright: None. | ||
| //-- | ||
|
|
||
| #pragma once | ||
|
|
||
| // In-house headers: | ||
| #include "MICmdBase.h" | ||
|
|
||
| //++ ============================================================================ | ||
| // Details: MI command class. MI commands derived from the command base class. | ||
| // *this class implements MI command "gdb-set". | ||
| // This command does not follow the MI documentation exactly. While *this | ||
| // command is implemented it does not do anything with the gdb-set | ||
| // variable past in. | ||
| // The design of matching the info request to a request action (or | ||
| // command) is very simple. The request function which carries out | ||
| // the task of information gathering and printing to stdout is part of | ||
| // *this class. Should the request function become more complicated then | ||
| // that request should really reside in a command type class. Then this | ||
| // class instantiates a request info command for a matching request. The | ||
| // design/code of *this class then does not then become bloated. Use a | ||
| // lightweight version of the current MI command system. | ||
| // Gotchas: None. | ||
| // Authors: Illya Rudkin 03/03/2014. | ||
| // Changes: None. | ||
| //-- | ||
| class CMICmdCmdGdbSet : public CMICmdBase | ||
| { | ||
| // Statics: | ||
| public: | ||
| // Required by the CMICmdFactory when registering *this command | ||
| static CMICmdBase * CreateSelf( void ); | ||
|
|
||
| // Methods: | ||
| public: | ||
| /* ctor */ CMICmdCmdGdbSet( void ); | ||
|
|
||
| // Overridden: | ||
| public: | ||
| // From CMICmdInvoker::ICmd | ||
| virtual bool Execute( void ); | ||
| virtual bool Acknowledge( void ); | ||
| virtual bool ParseArgs( void ); | ||
| // From CMICmnBase | ||
| /* dtor */ virtual ~CMICmdCmdGdbSet( void ); | ||
|
|
||
| // Typedefs: | ||
| private: | ||
| typedef bool (CMICmdCmdGdbSet::*FnGdbOptionPtr)( const CMIUtilString::VecString_t & vrWords ); | ||
| typedef std::map< CMIUtilString, FnGdbOptionPtr > MapGdbOptionNameToFnGdbOptionPtr_t; | ||
|
|
||
| // Methods: | ||
| private: | ||
| bool GetOptionFn( const CMIUtilString & vrGdbOptionName, FnGdbOptionPtr & vrwpFn ) const; | ||
| bool OptionFnSolibSearchPath( const CMIUtilString::VecString_t & vrWords ); | ||
| bool OptionFnFallback( const CMIUtilString::VecString_t & vrWords ); | ||
|
|
||
| // Attributes: | ||
| private: | ||
| const static MapGdbOptionNameToFnGdbOptionPtr_t ms_mapGdbOptionNameToFnGdbOptionPtr; | ||
| // | ||
| const CMIUtilString m_constStrArgNamedGdbOption; | ||
| bool m_bGdbOptionRecognised; // True = This command has a function with a name that matches the Print argument, false = not found | ||
| bool m_bGdbOptionFnSuccessful; // True = The print function completed its task ok, false = function failed for some reason | ||
| bool m_bGbbOptionFnHasError; // True = The option function has an error condition (not the command!), false = option function ok. | ||
| CMIUtilString m_strGdbOptionName; | ||
| CMIUtilString m_strGdbOptionFnError; | ||
| }; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,100 @@ | ||
| //===-- MICmdCmdGdbThread.cpp -----------------------------------*- C++ -*-===// | ||
| // | ||
| // The LLVM Compiler Infrastructure | ||
| // | ||
| // This file is distributed under the University of Illinois Open Source | ||
| // License. See LICENSE.TXT for details. | ||
| // | ||
| //===----------------------------------------------------------------------===// | ||
|
|
||
| //++ | ||
| // File: MICmdCmdGdbThread.cpp | ||
| // | ||
| // Overview: CMICmdCmdGdbThread implementation. | ||
| // | ||
| // Environment: Compilers: Visual C++ 12. | ||
| // gcc (Ubuntu/Linaro 4.8.1-10ubuntu9) 4.8.1 | ||
| // Libraries: See MIReadmetxt. | ||
| // | ||
| // Copyright: None. | ||
| //-- | ||
|
|
||
| // In-house headers: | ||
| #include "MICmdCmdGdbThread.h" | ||
| #include "MICmnMIResultRecord.h" | ||
| #include "MICmnMIValueConst.h" | ||
|
|
||
| //++ ------------------------------------------------------------------------------------ | ||
| // Details: CMICmdCmdGdbThread constructor. | ||
| // Type: Method. | ||
| // Args: None. | ||
| // Return: None. | ||
| // Throws: None. | ||
| //-- | ||
| CMICmdCmdGdbThread::CMICmdCmdGdbThread( void ) | ||
| { | ||
| // Command factory matches this name with that received from the stdin stream | ||
| m_strMiCmd = "thread"; | ||
|
|
||
| // Required by the CMICmdFactory when registering *this command | ||
| m_pSelfCreatorFn = &CMICmdCmdGdbThread::CreateSelf; | ||
| } | ||
|
|
||
| //++ ------------------------------------------------------------------------------------ | ||
| // Details: CMICmdCmdThread destructor. | ||
| // Type: Overrideable. | ||
| // Args: None. | ||
| // Return: None. | ||
| // Throws: None. | ||
| //-- | ||
| CMICmdCmdGdbThread::~CMICmdCmdGdbThread( void ) | ||
| { | ||
| } | ||
|
|
||
| //++ ------------------------------------------------------------------------------------ | ||
| // Details: The invoker requires this function. The command does work in this function. | ||
| // The command is likely to communicate with the LLDB SBDebugger in here. | ||
| // Type: Overridden. | ||
| // Args: None. | ||
| // Return: MIstatus::success - Functional succeeded. | ||
| // MIstatus::failure - Functional failed. | ||
| // Throws: None. | ||
| //-- | ||
| bool CMICmdCmdGdbThread::Execute( void ) | ||
| { | ||
| // Do nothing | ||
|
|
||
| return MIstatus::success; | ||
| } | ||
|
|
||
| //++ ------------------------------------------------------------------------------------ | ||
| // Details: The invoker requires this function. The command prepares a MI Record Result | ||
| // for the work carried out in the Execute(). | ||
| // Type: Overridden. | ||
| // Args: None. | ||
| // Return: MIstatus::success - Functional succeeded. | ||
| // MIstatus::failure - Functional failed. | ||
| // Throws: None. | ||
| //-- | ||
| bool CMICmdCmdGdbThread::Acknowledge( void ) | ||
| { | ||
| const CMICmnMIValueConst miValueConst( MIRSRC( IDS_WORD_NOT_IMPLEMENTED ) ); | ||
| const CMICmnMIValueResult miValueResult( "msg", miValueConst ); | ||
| const CMICmnMIResultRecord miRecordResult( m_cmdData.strMiCmdToken, CMICmnMIResultRecord::eResultClass_Error, miValueResult ); | ||
| m_miResultRecord = miRecordResult; | ||
|
|
||
| return MIstatus::success; | ||
| } | ||
|
|
||
| //++ ------------------------------------------------------------------------------------ | ||
| // Details: Required by the CMICmdFactory when registering *this command. The factory | ||
| // calls this function to create an instance of *this command. | ||
| // Type: Static method. | ||
| // Args: None. | ||
| // Return: CMICmdBase * - Pointer to a new command. | ||
| // Throws: None. | ||
| //-- | ||
| CMICmdBase * CMICmdCmdGdbThread::CreateSelf( void ) | ||
| { | ||
| return new CMICmdCmdGdbThread(); | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,61 @@ | ||
| //===-- MICmdCmdGdbThread.h -------------------------------------*- C++ -*-===// | ||
| // | ||
| // The LLVM Compiler Infrastructure | ||
| // | ||
| // This file is distributed under the University of Illinois Open Source | ||
| // License. See LICENSE.TXT for details. | ||
| // | ||
| //===----------------------------------------------------------------------===// | ||
|
|
||
| //++ | ||
| // File: MICmdCmdGdbThread.h | ||
| // | ||
| // Overview: CMICmdCmdGdbThread interface. | ||
| // | ||
| // To implement new MI commands derive a new command class from the command base | ||
| // class. To enable the new command for interpretation add the new command class | ||
| // to the command factory. The files of relevance are: | ||
| // MICmdCommands.cpp | ||
| // MICmdBase.h / .cpp | ||
| // MICmdCmd.h / .cpp | ||
| // For an introduction to adding a new command see CMICmdCmdSupportInfoMiCmdQuery | ||
| // command class as an example. | ||
| // | ||
| // Environment: Compilers: Visual C++ 12. | ||
| // gcc (Ubuntu/Linaro 4.8.1-10ubuntu9) 4.8.1 | ||
| // Libraries: See MIReadmetxt. | ||
| // | ||
| // Copyright: None. | ||
| //-- | ||
|
|
||
| #pragma once | ||
|
|
||
| // In-house headers: | ||
| #include "MICmdBase.h" | ||
|
|
||
| //++ ============================================================================ | ||
| // Details: MI command class. MI commands derived from the command base class. | ||
| // *this class implements GDB command "thread". | ||
| // Gotchas: None. | ||
| // Authors: Illya Rudkin 25/02/2014. | ||
| // Changes: None. | ||
| //-- | ||
| class CMICmdCmdGdbThread : public CMICmdBase | ||
| { | ||
| // Statics: | ||
| public: | ||
| // Required by the CMICmdFactory when registering *this command | ||
| static CMICmdBase * CreateSelf( void ); | ||
|
|
||
| // Methods: | ||
| public: | ||
| /* ctor */ CMICmdCmdGdbThread( void ); | ||
|
|
||
| // Overridden: | ||
| public: | ||
| // From CMICmdInvoker::ICmd | ||
| virtual bool Execute( void ); | ||
| virtual bool Acknowledge( void ); | ||
| // From CMICmnBase | ||
| /* dtor */ virtual ~CMICmdCmdGdbThread( void ); | ||
| }; |