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