/* Copyright (C) This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ #ifndef DEBUGGER_H #define DEBUGGER_H #include #include #include #include #include #include "../include/readline.h" class Debugger { public: /** * @brief Constructor. * @param argc Count of arguments in argv. * @param argv The argument vector for the debugger. */ Debugger(int argc, char *argv[]); /** * @brief Run the process. */ void Run(); class ChildProcess { public: /** * @brief Constructor. * @param executable The executable we will be starting. */ ChildProcess(const std::string & executable); /** * @brief Run the process associated with this object. */ void Run(); /** * @brief Get the process id of the child. * @pre Must have started the process before requesting the pid. * @return The pid or 0 if the process has not started yet. */ pid_t GetPid() const; /** * @brief Get a list of readable pages for the process. * @return A list of start and end addresses for readable pages. */ std::list > GetReadablePages(); private: std::string program; pid_t pid; }; private: bool debug; bool verbose; /** * @brief Parse the command line options. * @param argc The count of the arguments. * @param argv The argument vector. * @param description The options description pointer. * @return A variables map containing all of the variables parsed. */ boost::program_options::variables_map parseOptions(int argc, char *argv[], boost::program_options::options_description * description = new boost::program_options::options_description("Options: ")); /** * @brief Execute the line from the input. * @param line The line to execute. */ void executeLine(const std::string & line); /** * @brief The functions for the commands. * @param args * @return Status code reflecting the command. */ static int com_run PARAMS((char *)); static int com_brk PARAMS((char *)); static int com_help PARAMS((char *)); static int com_step PARAMS((char *)); static int com_watch PARAMS((char *)); static int com_quit PARAMS((char *)); static int com_cont PARAMS((char *)); static int com_load PARAMS((char *)); static int com_del PARAMS((char *)); }; class DebuggerError { public: DebuggerError(std::string msg); std::string GetMessage() const; protected: std::string msg; }; class DebuggerArgumentError : public DebuggerError { public: DebuggerArgumentError(std::string msg, boost::program_options::options_description description); boost::program_options::options_description GetDescription() const; protected: boost::program_options::options_description description; }; #endif // DEBUGGER_H // kate: indent-mode cstyle; space-indent on; indent-width 4;