Ilia K | e771b59 | 2015-03-23 20:46:10 +0000 | [diff] [blame] | 1 | //===-- MICmdCmdGdbSet.h ----------------------------------------*- C++ -*-===// |
Deepak Panickal | 877569c | 2014-06-24 16:35:50 +0000 | [diff] [blame] | 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
| 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
| 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | |
Zachary Turner | 1d6af02 | 2014-11-17 18:06:21 +0000 | [diff] [blame] | 10 | // Overview: CMICmdCmdGdbSet interface. |
Deepak Panickal | 877569c | 2014-06-24 16:35:50 +0000 | [diff] [blame] | 11 | // |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame^] | 12 | // To implement new MI commands, derive a new command class from |
| 13 | // the command base |
| 14 | // class. To enable the new command for interpretation add the new |
| 15 | // command class |
Zachary Turner | 1d6af02 | 2014-11-17 18:06:21 +0000 | [diff] [blame] | 16 | // to the command factory. The files of relevance are: |
| 17 | // MICmdCommands.cpp |
| 18 | // MICmdBase.h / .cpp |
| 19 | // MICmdCmd.h / .cpp |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame^] | 20 | // For an introduction to adding a new command see |
| 21 | // CMICmdCmdSupportInfoMiCmdQuery |
Zachary Turner | 1d6af02 | 2014-11-17 18:06:21 +0000 | [diff] [blame] | 22 | // command class as an example. |
Deepak Panickal | 877569c | 2014-06-24 16:35:50 +0000 | [diff] [blame] | 23 | |
| 24 | #pragma once |
| 25 | |
| 26 | // In-house headers: |
| 27 | #include "MICmdBase.h" |
| 28 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame^] | 29 | //++ |
| 30 | //============================================================================ |
Zachary Turner | 1d6af02 | 2014-11-17 18:06:21 +0000 | [diff] [blame] | 31 | // Details: MI command class. MI commands derived from the command base class. |
| 32 | // *this class implements MI command "gdb-set". |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame^] | 33 | // This command does not follow the MI documentation exactly. While |
| 34 | // *this |
Zachary Turner | 1d6af02 | 2014-11-17 18:06:21 +0000 | [diff] [blame] | 35 | // command is implemented it does not do anything with the gdb-set |
| 36 | // variable past in. |
| 37 | // The design of matching the info request to a request action (or |
| 38 | // command) is very simple. The request function which carries out |
| 39 | // the task of information gathering and printing to stdout is part of |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame^] | 40 | // *this class. Should the request function become more complicated |
| 41 | // then |
Zachary Turner | 1d6af02 | 2014-11-17 18:06:21 +0000 | [diff] [blame] | 42 | // that request should really reside in a command type class. Then this |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame^] | 43 | // class instantiates a request info command for a matching request. |
| 44 | // The |
Zachary Turner | 1d6af02 | 2014-11-17 18:06:21 +0000 | [diff] [blame] | 45 | // design/code of *this class then does not then become bloated. Use a |
| 46 | // lightweight version of the current MI command system. |
Deepak Panickal | 877569c | 2014-06-24 16:35:50 +0000 | [diff] [blame] | 47 | //-- |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame^] | 48 | class CMICmdCmdGdbSet : public CMICmdBase { |
| 49 | // Statics: |
| 50 | public: |
| 51 | // Required by the CMICmdFactory when registering *this command |
| 52 | static CMICmdBase *CreateSelf(); |
Deepak Panickal | 877569c | 2014-06-24 16:35:50 +0000 | [diff] [blame] | 53 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame^] | 54 | // Methods: |
| 55 | public: |
| 56 | /* ctor */ CMICmdCmdGdbSet(); |
Deepak Panickal | 877569c | 2014-06-24 16:35:50 +0000 | [diff] [blame] | 57 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame^] | 58 | // Overridden: |
| 59 | public: |
| 60 | // From CMICmdInvoker::ICmd |
| 61 | bool Execute() override; |
| 62 | bool Acknowledge() override; |
| 63 | bool ParseArgs() override; |
| 64 | // From CMICmnBase |
| 65 | /* dtor */ ~CMICmdCmdGdbSet() override; |
Deepak Panickal | 877569c | 2014-06-24 16:35:50 +0000 | [diff] [blame] | 66 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame^] | 67 | // Typedefs: |
| 68 | private: |
| 69 | typedef bool (CMICmdCmdGdbSet::*FnGdbOptionPtr)( |
| 70 | const CMIUtilString::VecString_t &vrWords); |
| 71 | typedef std::map<CMIUtilString, FnGdbOptionPtr> |
| 72 | MapGdbOptionNameToFnGdbOptionPtr_t; |
Deepak Panickal | 877569c | 2014-06-24 16:35:50 +0000 | [diff] [blame] | 73 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame^] | 74 | // Methods: |
| 75 | private: |
| 76 | bool GetOptionFn(const CMIUtilString &vrGdbOptionName, |
| 77 | FnGdbOptionPtr &vrwpFn) const; |
| 78 | bool OptionFnTargetAsync(const CMIUtilString::VecString_t &vrWords); |
| 79 | bool OptionFnPrint(const CMIUtilString::VecString_t &vrWords); |
| 80 | bool OptionFnSolibSearchPath(const CMIUtilString::VecString_t &vrWords); |
| 81 | bool OptionFnOutputRadix(const CMIUtilString::VecString_t &vrWords); |
| 82 | bool OptionFnFallback(const CMIUtilString::VecString_t &vrWords); |
Deepak Panickal | 877569c | 2014-06-24 16:35:50 +0000 | [diff] [blame] | 83 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame^] | 84 | // Attributes: |
| 85 | private: |
| 86 | const static MapGdbOptionNameToFnGdbOptionPtr_t |
| 87 | ms_mapGdbOptionNameToFnGdbOptionPtr; |
| 88 | // |
| 89 | const CMIUtilString m_constStrArgNamedGdbOption; |
| 90 | bool m_bGdbOptionRecognised; // True = This command has a function with a name |
| 91 | // that matches the Print argument, false = not |
| 92 | // found |
| 93 | bool m_bGdbOptionFnSuccessful; // True = The print function completed its task |
| 94 | // ok, false = function failed for some reason |
| 95 | bool m_bGbbOptionFnHasError; // True = The option function has an error |
| 96 | // condition (not the command!), false = option |
| 97 | // function ok. |
| 98 | CMIUtilString m_strGdbOptionName; |
| 99 | CMIUtilString m_strGdbOptionFnError; |
Zachary Turner | 1d6af02 | 2014-11-17 18:06:21 +0000 | [diff] [blame] | 100 | }; |