[Lldb-commits] [lldb] r280751 - *** This commit represents a complete reformatting of the LLDB source code
Kate Stone via lldb-commits
lldb-commits at lists.llvm.org
Tue Sep 6 13:58:36 PDT 2016
Modified: lldb/trunk/tools/debugserver/source/debugserver.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/debugserver/source/debugserver.cpp?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/tools/debugserver/source/debugserver.cpp (original)
+++ lldb/trunk/tools/debugserver/source/debugserver.cpp Tue Sep 6 15:57:50 2016
@@ -7,27 +7,28 @@
//
//===----------------------------------------------------------------------===//
-#include <sys/socket.h>
-#include <sys/types.h>
+#include <arpa/inet.h>
+#include <asl.h>
+#include <crt_externs.h> // for _NSGetEnviron()
#include <errno.h>
#include <getopt.h>
-#include <netinet/in.h>
-#include <sys/select.h>
-#include <sys/sysctl.h>
-#include <string>
-#include <vector>
-#include <asl.h>
-#include <arpa/inet.h>
#include <netdb.h>
#include <netinet/in.h>
+#include <netinet/in.h>
#include <netinet/tcp.h>
-#include <sys/un.h>
+#include <string>
+#include <sys/select.h>
+#include <sys/socket.h>
+#include <sys/sysctl.h>
#include <sys/types.h>
-#include <crt_externs.h> // for _NSGetEnviron()
+#include <sys/types.h>
+#include <sys/un.h>
+#include <vector>
-#if defined (__APPLE__)
+#if defined(__APPLE__)
#include <sched.h>
-extern "C" int proc_set_wakemon_params(pid_t, int, int); // <libproc_internal.h> SPI
+extern "C" int proc_set_wakemon_params(pid_t, int,
+ int); // <libproc_internal.h> SPI
#endif
#include "CFString.h"
@@ -37,9 +38,9 @@ extern "C" int proc_set_wakemon_params(p
#include "OsLogger.h"
#include "PseudoTerminal.h"
#include "RNBContext.h"
+#include "RNBRemote.h"
#include "RNBServices.h"
#include "RNBSocket.h"
-#include "RNBRemote.h"
#include "SysSignal.h"
// Global PID in case we get a signal and need to stop the process...
@@ -48,23 +49,21 @@ nub_process_t g_pid = INVALID_NUB_PROCES
//----------------------------------------------------------------------
// Run loop modes which determine which run loop function will be called
//----------------------------------------------------------------------
-typedef enum
-{
- eRNBRunLoopModeInvalid = 0,
- eRNBRunLoopModeGetStartModeFromRemoteProtocol,
- eRNBRunLoopModeInferiorAttaching,
- eRNBRunLoopModeInferiorLaunching,
- eRNBRunLoopModeInferiorExecuting,
- eRNBRunLoopModePlatformMode,
- eRNBRunLoopModeExit
+typedef enum {
+ eRNBRunLoopModeInvalid = 0,
+ eRNBRunLoopModeGetStartModeFromRemoteProtocol,
+ eRNBRunLoopModeInferiorAttaching,
+ eRNBRunLoopModeInferiorLaunching,
+ eRNBRunLoopModeInferiorExecuting,
+ eRNBRunLoopModePlatformMode,
+ eRNBRunLoopModeExit
} RNBRunLoopMode;
-
//----------------------------------------------------------------------
// Global Variables
//----------------------------------------------------------------------
RNBRemoteSP g_remoteSP;
-static int g_lockdown_opt = 0;
+static int g_lockdown_opt = 0;
static int g_applist_opt = 0;
static nub_launch_flavor_t g_launch_flavor = eLaunchFlavorDefault;
int g_disable_aslr = 0;
@@ -72,8 +71,22 @@ int g_disable_aslr = 0;
int g_isatty = 0;
bool g_detach_on_error = true;
-#define RNBLogSTDOUT(fmt, ...) do { if (g_isatty) { fprintf(stdout, fmt, ## __VA_ARGS__); } else { _DNBLog(0, fmt, ## __VA_ARGS__); } } while (0)
-#define RNBLogSTDERR(fmt, ...) do { if (g_isatty) { fprintf(stderr, fmt, ## __VA_ARGS__); } else { _DNBLog(0, fmt, ## __VA_ARGS__); } } while (0)
+#define RNBLogSTDOUT(fmt, ...) \
+ do { \
+ if (g_isatty) { \
+ fprintf(stdout, fmt, ##__VA_ARGS__); \
+ } else { \
+ _DNBLog(0, fmt, ##__VA_ARGS__); \
+ } \
+ } while (0)
+#define RNBLogSTDERR(fmt, ...) \
+ do { \
+ if (g_isatty) { \
+ fprintf(stderr, fmt, ##__VA_ARGS__); \
+ } else { \
+ _DNBLog(0, fmt, ##__VA_ARGS__); \
+ } \
+ } while (0)
//----------------------------------------------------------------------
// Get our program path and arguments from the remote connection.
@@ -81,306 +94,290 @@ bool g_detach_on_error = true;
// arguments, wait for the new process to finish launching and hit its
// entry point, and then return the run loop mode that should come next.
//----------------------------------------------------------------------
-RNBRunLoopMode
-RNBRunLoopGetStartModeFromRemote (RNBRemote* remote)
-{
- std::string packet;
-
- if (remote)
- {
- RNBContext& ctx = remote->Context();
- uint32_t event_mask = RNBContext::event_read_packet_available |
- RNBContext::event_read_thread_exiting;
-
- // Spin waiting to get the A packet.
- while (1)
- {
- DNBLogThreadedIf (LOG_RNB_MAX, "%s ctx.Events().WaitForSetEvents( 0x%08x ) ...",__FUNCTION__, event_mask);
- nub_event_t set_events = ctx.Events().WaitForSetEvents(event_mask);
- DNBLogThreadedIf (LOG_RNB_MAX, "%s ctx.Events().WaitForSetEvents( 0x%08x ) => 0x%08x", __FUNCTION__, event_mask, set_events);
-
- if (set_events & RNBContext::event_read_thread_exiting)
- {
- RNBLogSTDERR ("error: packet read thread exited.\n");
- return eRNBRunLoopModeExit;
- }
+RNBRunLoopMode RNBRunLoopGetStartModeFromRemote(RNBRemote *remote) {
+ std::string packet;
- if (set_events & RNBContext::event_read_packet_available)
- {
- rnb_err_t err = rnb_err;
- RNBRemote::PacketEnum type;
-
- err = remote->HandleReceivedPacket (&type);
-
- // check if we tried to attach to a process
- if (type == RNBRemote::vattach || type == RNBRemote::vattachwait || type == RNBRemote::vattachorwait)
- {
- if (err == rnb_success)
- {
- RNBLogSTDOUT ("Attach succeeded, ready to debug.\n");
- return eRNBRunLoopModeInferiorExecuting;
- }
- else
- {
- RNBLogSTDERR ("error: attach failed.\n");
- return eRNBRunLoopModeExit;
- }
- }
-
- if (err == rnb_success)
- {
- // If we got our arguments we are ready to launch using the arguments
- // and any environment variables we received.
- if (type == RNBRemote::set_argv)
- {
- return eRNBRunLoopModeInferiorLaunching;
- }
- }
- else if (err == rnb_not_connected)
- {
- RNBLogSTDERR ("error: connection lost.\n");
- return eRNBRunLoopModeExit;
- }
- else
- {
- // a catch all for any other gdb remote packets that failed
- DNBLogThreadedIf (LOG_RNB_MINIMAL, "%s Error getting packet.",__FUNCTION__);
- continue;
- }
+ if (remote) {
+ RNBContext &ctx = remote->Context();
+ uint32_t event_mask = RNBContext::event_read_packet_available |
+ RNBContext::event_read_thread_exiting;
+
+ // Spin waiting to get the A packet.
+ while (1) {
+ DNBLogThreadedIf(LOG_RNB_MAX,
+ "%s ctx.Events().WaitForSetEvents( 0x%08x ) ...",
+ __FUNCTION__, event_mask);
+ nub_event_t set_events = ctx.Events().WaitForSetEvents(event_mask);
+ DNBLogThreadedIf(LOG_RNB_MAX,
+ "%s ctx.Events().WaitForSetEvents( 0x%08x ) => 0x%08x",
+ __FUNCTION__, event_mask, set_events);
- DNBLogThreadedIf (LOG_RNB_MINIMAL, "#### %s", __FUNCTION__);
- }
- else
- {
- DNBLogThreadedIf (LOG_RNB_MINIMAL, "%s Connection closed before getting \"A\" packet.", __FUNCTION__);
- return eRNBRunLoopModeExit;
- }
+ if (set_events & RNBContext::event_read_thread_exiting) {
+ RNBLogSTDERR("error: packet read thread exited.\n");
+ return eRNBRunLoopModeExit;
+ }
+
+ if (set_events & RNBContext::event_read_packet_available) {
+ rnb_err_t err = rnb_err;
+ RNBRemote::PacketEnum type;
+
+ err = remote->HandleReceivedPacket(&type);
+
+ // check if we tried to attach to a process
+ if (type == RNBRemote::vattach || type == RNBRemote::vattachwait ||
+ type == RNBRemote::vattachorwait) {
+ if (err == rnb_success) {
+ RNBLogSTDOUT("Attach succeeded, ready to debug.\n");
+ return eRNBRunLoopModeInferiorExecuting;
+ } else {
+ RNBLogSTDERR("error: attach failed.\n");
+ return eRNBRunLoopModeExit;
+ }
}
+
+ if (err == rnb_success) {
+ // If we got our arguments we are ready to launch using the arguments
+ // and any environment variables we received.
+ if (type == RNBRemote::set_argv) {
+ return eRNBRunLoopModeInferiorLaunching;
+ }
+ } else if (err == rnb_not_connected) {
+ RNBLogSTDERR("error: connection lost.\n");
+ return eRNBRunLoopModeExit;
+ } else {
+ // a catch all for any other gdb remote packets that failed
+ DNBLogThreadedIf(LOG_RNB_MINIMAL, "%s Error getting packet.",
+ __FUNCTION__);
+ continue;
+ }
+
+ DNBLogThreadedIf(LOG_RNB_MINIMAL, "#### %s", __FUNCTION__);
+ } else {
+ DNBLogThreadedIf(LOG_RNB_MINIMAL,
+ "%s Connection closed before getting \"A\" packet.",
+ __FUNCTION__);
+ return eRNBRunLoopModeExit;
+ }
}
- return eRNBRunLoopModeExit;
+ }
+ return eRNBRunLoopModeExit;
}
-
//----------------------------------------------------------------------
// This run loop mode will wait for the process to launch and hit its
// entry point. It will currently ignore all events except for the
// process state changed event, where it watches for the process stopped
// or crash process state.
//----------------------------------------------------------------------
-RNBRunLoopMode
-RNBRunLoopLaunchInferior (RNBRemote *remote, const char *stdin_path, const char *stdout_path, const char *stderr_path, bool no_stdio)
-{
- RNBContext& ctx = remote->Context();
-
- // The Process stuff takes a c array, the RNBContext has a vector...
- // So make up a c array.
-
- DNBLogThreadedIf (LOG_RNB_MINIMAL, "%s Launching '%s'...", __FUNCTION__, ctx.ArgumentAtIndex(0));
-
- size_t inferior_argc = ctx.ArgumentCount();
- // Initialize inferior_argv with inferior_argc + 1 NULLs
- std::vector<const char *> inferior_argv(inferior_argc + 1, NULL);
-
- size_t i;
- for (i = 0; i < inferior_argc; i++)
- inferior_argv[i] = ctx.ArgumentAtIndex(i);
-
- // Pass the environment array the same way:
-
- size_t inferior_envc = ctx.EnvironmentCount();
- // Initialize inferior_argv with inferior_argc + 1 NULLs
- std::vector<const char *> inferior_envp(inferior_envc + 1, NULL);
-
- for (i = 0; i < inferior_envc; i++)
- inferior_envp[i] = ctx.EnvironmentAtIndex(i);
-
- // Our launch type hasn't been set to anything concrete, so we need to
- // figure our how we are going to launch automatically.
-
- nub_launch_flavor_t launch_flavor = g_launch_flavor;
- if (launch_flavor == eLaunchFlavorDefault)
- {
- // Our default launch method is posix spawn
- launch_flavor = eLaunchFlavorPosixSpawn;
+RNBRunLoopMode RNBRunLoopLaunchInferior(RNBRemote *remote,
+ const char *stdin_path,
+ const char *stdout_path,
+ const char *stderr_path,
+ bool no_stdio) {
+ RNBContext &ctx = remote->Context();
+
+ // The Process stuff takes a c array, the RNBContext has a vector...
+ // So make up a c array.
+
+ DNBLogThreadedIf(LOG_RNB_MINIMAL, "%s Launching '%s'...", __FUNCTION__,
+ ctx.ArgumentAtIndex(0));
+
+ size_t inferior_argc = ctx.ArgumentCount();
+ // Initialize inferior_argv with inferior_argc + 1 NULLs
+ std::vector<const char *> inferior_argv(inferior_argc + 1, NULL);
+
+ size_t i;
+ for (i = 0; i < inferior_argc; i++)
+ inferior_argv[i] = ctx.ArgumentAtIndex(i);
+
+ // Pass the environment array the same way:
+
+ size_t inferior_envc = ctx.EnvironmentCount();
+ // Initialize inferior_argv with inferior_argc + 1 NULLs
+ std::vector<const char *> inferior_envp(inferior_envc + 1, NULL);
+
+ for (i = 0; i < inferior_envc; i++)
+ inferior_envp[i] = ctx.EnvironmentAtIndex(i);
+
+ // Our launch type hasn't been set to anything concrete, so we need to
+ // figure our how we are going to launch automatically.
+
+ nub_launch_flavor_t launch_flavor = g_launch_flavor;
+ if (launch_flavor == eLaunchFlavorDefault) {
+ // Our default launch method is posix spawn
+ launch_flavor = eLaunchFlavorPosixSpawn;
#if defined WITH_FBS
- // Check if we have an app bundle, if so launch using BackBoard Services.
- if (strstr(inferior_argv[0], ".app"))
- {
- launch_flavor = eLaunchFlavorFBS;
- }
+ // Check if we have an app bundle, if so launch using BackBoard Services.
+ if (strstr(inferior_argv[0], ".app")) {
+ launch_flavor = eLaunchFlavorFBS;
+ }
#elif defined WITH_BKS
- // Check if we have an app bundle, if so launch using BackBoard Services.
- if (strstr(inferior_argv[0], ".app"))
- {
- launch_flavor = eLaunchFlavorBKS;
- }
+ // Check if we have an app bundle, if so launch using BackBoard Services.
+ if (strstr(inferior_argv[0], ".app")) {
+ launch_flavor = eLaunchFlavorBKS;
+ }
#elif defined WITH_SPRINGBOARD
- // Check if we have an app bundle, if so launch using SpringBoard.
- if (strstr(inferior_argv[0], ".app"))
- {
- launch_flavor = eLaunchFlavorSpringBoard;
- }
-#endif
+ // Check if we have an app bundle, if so launch using SpringBoard.
+ if (strstr(inferior_argv[0], ".app")) {
+ launch_flavor = eLaunchFlavorSpringBoard;
}
+#endif
+ }
- ctx.SetLaunchFlavor(launch_flavor);
- char resolved_path[PATH_MAX];
+ ctx.SetLaunchFlavor(launch_flavor);
+ char resolved_path[PATH_MAX];
- // If we fail to resolve the path to our executable, then just use what we
- // were given and hope for the best
- if ( !DNBResolveExecutablePath (inferior_argv[0], resolved_path, sizeof(resolved_path)) )
- ::strncpy(resolved_path, inferior_argv[0], sizeof(resolved_path));
-
- char launch_err_str[PATH_MAX];
- launch_err_str[0] = '\0';
- const char * cwd = (ctx.GetWorkingDirPath() != NULL ? ctx.GetWorkingDirPath()
- : ctx.GetWorkingDirectory());
- const char *process_event = ctx.GetProcessEvent();
- nub_process_t pid = DNBProcessLaunch (resolved_path,
- &inferior_argv[0],
- &inferior_envp[0],
- cwd,
- stdin_path,
- stdout_path,
- stderr_path,
- no_stdio,
- launch_flavor,
- g_disable_aslr,
- process_event,
- launch_err_str,
- sizeof(launch_err_str));
-
- g_pid = pid;
-
- if (pid == INVALID_NUB_PROCESS && strlen (launch_err_str) > 0)
- {
- DNBLogThreaded ("%s DNBProcessLaunch() returned error: '%s'", __FUNCTION__, launch_err_str);
- ctx.LaunchStatus().SetError(-1, DNBError::Generic);
- ctx.LaunchStatus().SetErrorString(launch_err_str);
- }
- else if (pid == INVALID_NUB_PROCESS)
- {
- DNBLogThreaded ("%s DNBProcessLaunch() failed to launch process, unknown failure", __FUNCTION__);
- ctx.LaunchStatus().SetError(-1, DNBError::Generic);
- ctx.LaunchStatus().SetErrorString("<unknown failure>");
- }
- else
- {
- ctx.LaunchStatus().Clear();
- }
-
- if (remote->Comm().IsConnected())
- {
- // It we are connected already, the next thing gdb will do is ask
- // whether the launch succeeded, and if not, whether there is an
- // error code. So we need to fetch one packet from gdb before we wait
- // on the stop from the target.
-
- uint32_t event_mask = RNBContext::event_read_packet_available;
- nub_event_t set_events = ctx.Events().WaitForSetEvents(event_mask);
-
- if (set_events & RNBContext::event_read_packet_available)
- {
- rnb_err_t err = rnb_err;
- RNBRemote::PacketEnum type;
-
- err = remote->HandleReceivedPacket (&type);
-
- if (err != rnb_success)
- {
- DNBLogThreadedIf (LOG_RNB_MINIMAL, "%s Error getting packet.", __FUNCTION__);
- return eRNBRunLoopModeExit;
- }
- if (type != RNBRemote::query_launch_success)
- {
- DNBLogThreadedIf (LOG_RNB_MINIMAL, "%s Didn't get the expected qLaunchSuccess packet.", __FUNCTION__);
- }
- }
- }
+ // If we fail to resolve the path to our executable, then just use what we
+ // were given and hope for the best
+ if (!DNBResolveExecutablePath(inferior_argv[0], resolved_path,
+ sizeof(resolved_path)))
+ ::strncpy(resolved_path, inferior_argv[0], sizeof(resolved_path));
+
+ char launch_err_str[PATH_MAX];
+ launch_err_str[0] = '\0';
+ const char *cwd =
+ (ctx.GetWorkingDirPath() != NULL ? ctx.GetWorkingDirPath()
+ : ctx.GetWorkingDirectory());
+ const char *process_event = ctx.GetProcessEvent();
+ nub_process_t pid = DNBProcessLaunch(
+ resolved_path, &inferior_argv[0], &inferior_envp[0], cwd, stdin_path,
+ stdout_path, stderr_path, no_stdio, launch_flavor, g_disable_aslr,
+ process_event, launch_err_str, sizeof(launch_err_str));
+
+ g_pid = pid;
+
+ if (pid == INVALID_NUB_PROCESS && strlen(launch_err_str) > 0) {
+ DNBLogThreaded("%s DNBProcessLaunch() returned error: '%s'", __FUNCTION__,
+ launch_err_str);
+ ctx.LaunchStatus().SetError(-1, DNBError::Generic);
+ ctx.LaunchStatus().SetErrorString(launch_err_str);
+ } else if (pid == INVALID_NUB_PROCESS) {
+ DNBLogThreaded(
+ "%s DNBProcessLaunch() failed to launch process, unknown failure",
+ __FUNCTION__);
+ ctx.LaunchStatus().SetError(-1, DNBError::Generic);
+ ctx.LaunchStatus().SetErrorString("<unknown failure>");
+ } else {
+ ctx.LaunchStatus().Clear();
+ }
+
+ if (remote->Comm().IsConnected()) {
+ // It we are connected already, the next thing gdb will do is ask
+ // whether the launch succeeded, and if not, whether there is an
+ // error code. So we need to fetch one packet from gdb before we wait
+ // on the stop from the target.
+
+ uint32_t event_mask = RNBContext::event_read_packet_available;
+ nub_event_t set_events = ctx.Events().WaitForSetEvents(event_mask);
+
+ if (set_events & RNBContext::event_read_packet_available) {
+ rnb_err_t err = rnb_err;
+ RNBRemote::PacketEnum type;
+
+ err = remote->HandleReceivedPacket(&type);
+
+ if (err != rnb_success) {
+ DNBLogThreadedIf(LOG_RNB_MINIMAL, "%s Error getting packet.",
+ __FUNCTION__);
+ return eRNBRunLoopModeExit;
+ }
+ if (type != RNBRemote::query_launch_success) {
+ DNBLogThreadedIf(LOG_RNB_MINIMAL,
+ "%s Didn't get the expected qLaunchSuccess packet.",
+ __FUNCTION__);
+ }
+ }
+ }
+
+ while (pid != INVALID_NUB_PROCESS) {
+ // Wait for process to start up and hit entry point
+ DNBLogThreadedIf(LOG_RNB_EVENTS, "%s DNBProcessWaitForEvent (%4.4x, "
+ "eEventProcessRunningStateChanged | "
+ "eEventProcessStoppedStateChanged, true, "
+ "INFINITE)...",
+ __FUNCTION__, pid);
+ nub_event_t set_events =
+ DNBProcessWaitForEvents(pid, eEventProcessRunningStateChanged |
+ eEventProcessStoppedStateChanged,
+ true, NULL);
+ DNBLogThreadedIf(LOG_RNB_EVENTS, "%s DNBProcessWaitForEvent (%4.4x, "
+ "eEventProcessRunningStateChanged | "
+ "eEventProcessStoppedStateChanged, true, "
+ "INFINITE) => 0x%8.8x",
+ __FUNCTION__, pid, set_events);
+
+ if (set_events == 0) {
+ pid = INVALID_NUB_PROCESS;
+ g_pid = pid;
+ } else {
+ if (set_events & (eEventProcessRunningStateChanged |
+ eEventProcessStoppedStateChanged)) {
+ nub_state_t pid_state = DNBProcessGetState(pid);
+ DNBLogThreadedIf(
+ LOG_RNB_EVENTS,
+ "%s process %4.4x state changed (eEventProcessStateChanged): %s",
+ __FUNCTION__, pid, DNBStateAsString(pid_state));
- while (pid != INVALID_NUB_PROCESS)
- {
- // Wait for process to start up and hit entry point
- DNBLogThreadedIf (LOG_RNB_EVENTS, "%s DNBProcessWaitForEvent (%4.4x, eEventProcessRunningStateChanged | eEventProcessStoppedStateChanged, true, INFINITE)...", __FUNCTION__, pid);
- nub_event_t set_events = DNBProcessWaitForEvents (pid, eEventProcessRunningStateChanged | eEventProcessStoppedStateChanged, true, NULL);
- DNBLogThreadedIf (LOG_RNB_EVENTS, "%s DNBProcessWaitForEvent (%4.4x, eEventProcessRunningStateChanged | eEventProcessStoppedStateChanged, true, INFINITE) => 0x%8.8x", __FUNCTION__, pid, set_events);
-
- if (set_events == 0)
- {
- pid = INVALID_NUB_PROCESS;
- g_pid = pid;
- }
- else
- {
- if (set_events & (eEventProcessRunningStateChanged | eEventProcessStoppedStateChanged))
- {
- nub_state_t pid_state = DNBProcessGetState (pid);
- DNBLogThreadedIf (LOG_RNB_EVENTS, "%s process %4.4x state changed (eEventProcessStateChanged): %s", __FUNCTION__, pid, DNBStateAsString(pid_state));
-
- switch (pid_state)
- {
- case eStateInvalid:
- case eStateUnloaded:
- case eStateAttaching:
- case eStateLaunching:
- case eStateSuspended:
- break; // Ignore
-
- case eStateRunning:
- case eStateStepping:
- // Still waiting to stop at entry point...
- break;
-
- case eStateStopped:
- case eStateCrashed:
- ctx.SetProcessID(pid);
- return eRNBRunLoopModeInferiorExecuting;
-
- case eStateDetached:
- case eStateExited:
- pid = INVALID_NUB_PROCESS;
- g_pid = pid;
- return eRNBRunLoopModeExit;
- }
- }
+ switch (pid_state) {
+ case eStateInvalid:
+ case eStateUnloaded:
+ case eStateAttaching:
+ case eStateLaunching:
+ case eStateSuspended:
+ break; // Ignore
- DNBProcessResetEvents(pid, set_events);
+ case eStateRunning:
+ case eStateStepping:
+ // Still waiting to stop at entry point...
+ break;
+
+ case eStateStopped:
+ case eStateCrashed:
+ ctx.SetProcessID(pid);
+ return eRNBRunLoopModeInferiorExecuting;
+
+ case eStateDetached:
+ case eStateExited:
+ pid = INVALID_NUB_PROCESS;
+ g_pid = pid;
+ return eRNBRunLoopModeExit;
}
+ }
+
+ DNBProcessResetEvents(pid, set_events);
}
+ }
- return eRNBRunLoopModeExit;
+ return eRNBRunLoopModeExit;
}
-
//----------------------------------------------------------------------
// This run loop mode will wait for the process to launch and hit its
// entry point. It will currently ignore all events except for the
// process state changed event, where it watches for the process stopped
// or crash process state.
//----------------------------------------------------------------------
-RNBRunLoopMode
-RNBRunLoopLaunchAttaching (RNBRemote *remote, nub_process_t attach_pid, nub_process_t& pid)
-{
- RNBContext& ctx = remote->Context();
-
- DNBLogThreadedIf (LOG_RNB_MINIMAL, "%s Attaching to pid %i...", __FUNCTION__, attach_pid);
- char err_str[1024];
- pid = DNBProcessAttach (attach_pid, NULL, err_str, sizeof(err_str));
- g_pid = pid;
-
- if (pid == INVALID_NUB_PROCESS)
- {
- ctx.LaunchStatus().SetError(-1, DNBError::Generic);
- if (err_str[0])
- ctx.LaunchStatus().SetErrorString(err_str);
- return eRNBRunLoopModeExit;
- }
- else
- {
- ctx.SetProcessID(pid);
- return eRNBRunLoopModeInferiorExecuting;
- }
+RNBRunLoopMode RNBRunLoopLaunchAttaching(RNBRemote *remote,
+ nub_process_t attach_pid,
+ nub_process_t &pid) {
+ RNBContext &ctx = remote->Context();
+
+ DNBLogThreadedIf(LOG_RNB_MINIMAL, "%s Attaching to pid %i...", __FUNCTION__,
+ attach_pid);
+ char err_str[1024];
+ pid = DNBProcessAttach(attach_pid, NULL, err_str, sizeof(err_str));
+ g_pid = pid;
+
+ if (pid == INVALID_NUB_PROCESS) {
+ ctx.LaunchStatus().SetError(-1, DNBError::Generic);
+ if (err_str[0])
+ ctx.LaunchStatus().SetErrorString(err_str);
+ return eRNBRunLoopModeExit;
+ } else {
+ ctx.SetProcessID(pid);
+ return eRNBRunLoopModeInferiorExecuting;
+ }
}
//----------------------------------------------------------------------
@@ -390,284 +387,271 @@ RNBRunLoopLaunchAttaching (RNBRemote *re
//----------------------------------------------------------------------
int g_sigint_received = 0;
int g_sigpipe_received = 0;
-void
-signal_handler(int signo)
-{
- DNBLogThreadedIf (LOG_RNB_MINIMAL, "%s (%s)", __FUNCTION__, SysSignal::Name(signo));
-
- switch (signo)
- {
- case SIGINT:
- g_sigint_received++;
- if (g_pid != INVALID_NUB_PROCESS)
- {
- // Only send a SIGINT once...
- if (g_sigint_received == 1)
- {
- switch (DNBProcessGetState (g_pid))
- {
- case eStateRunning:
- case eStateStepping:
- DNBProcessSignal (g_pid, SIGSTOP);
- return;
- default:
- break;
- }
- }
- }
- exit (SIGINT);
- break;
-
- case SIGPIPE:
- g_sigpipe_received = 1;
- break;
- }
+void signal_handler(int signo) {
+ DNBLogThreadedIf(LOG_RNB_MINIMAL, "%s (%s)", __FUNCTION__,
+ SysSignal::Name(signo));
+
+ switch (signo) {
+ case SIGINT:
+ g_sigint_received++;
+ if (g_pid != INVALID_NUB_PROCESS) {
+ // Only send a SIGINT once...
+ if (g_sigint_received == 1) {
+ switch (DNBProcessGetState(g_pid)) {
+ case eStateRunning:
+ case eStateStepping:
+ DNBProcessSignal(g_pid, SIGSTOP);
+ return;
+ default:
+ break;
+ }
+ }
+ }
+ exit(SIGINT);
+ break;
+
+ case SIGPIPE:
+ g_sigpipe_received = 1;
+ break;
+ }
}
// Return the new run loop mode based off of the current process state
-RNBRunLoopMode
-HandleProcessStateChange (RNBRemote *remote, bool initialize)
-{
- RNBContext& ctx = remote->Context();
- nub_process_t pid = ctx.ProcessID();
-
- if (pid == INVALID_NUB_PROCESS)
- {
- DNBLogThreadedIf (LOG_RNB_MINIMAL, "#### %s error: pid invalid, exiting...", __FUNCTION__);
- return eRNBRunLoopModeExit;
- }
- nub_state_t pid_state = DNBProcessGetState (pid);
-
- DNBLogThreadedIf (LOG_RNB_MINIMAL, "%s (&remote, initialize=%i) pid_state = %s", __FUNCTION__, (int)initialize, DNBStateAsString (pid_state));
-
- switch (pid_state)
- {
- case eStateInvalid:
- case eStateUnloaded:
- // Something bad happened
- return eRNBRunLoopModeExit;
- break;
-
- case eStateAttaching:
- case eStateLaunching:
- return eRNBRunLoopModeInferiorExecuting;
-
- case eStateSuspended:
- case eStateCrashed:
- case eStateStopped:
- // If we stop due to a signal, so clear the fact that we got a SIGINT
- // so we can stop ourselves again (but only while our inferior
- // process is running..)
- g_sigint_received = 0;
- if (initialize == false)
- {
- // Compare the last stop count to our current notion of a stop count
- // to make sure we don't notify more than once for a given stop.
- nub_size_t prev_pid_stop_count = ctx.GetProcessStopCount();
- bool pid_stop_count_changed = ctx.SetProcessStopCount(DNBProcessGetStopCount(pid));
- if (pid_stop_count_changed)
- {
- remote->FlushSTDIO();
-
- if (ctx.GetProcessStopCount() == 1)
- {
- DNBLogThreadedIf (LOG_RNB_MINIMAL, "%s (&remote, initialize=%i) pid_state = %s pid_stop_count %llu (old %llu)) Notify??? no, first stop...", __FUNCTION__, (int)initialize, DNBStateAsString (pid_state), (uint64_t)ctx.GetProcessStopCount(), (uint64_t)prev_pid_stop_count);
- }
- else
- {
-
- DNBLogThreadedIf (LOG_RNB_MINIMAL, "%s (&remote, initialize=%i) pid_state = %s pid_stop_count %llu (old %llu)) Notify??? YES!!!", __FUNCTION__, (int)initialize, DNBStateAsString (pid_state), (uint64_t)ctx.GetProcessStopCount(), (uint64_t)prev_pid_stop_count);
- remote->NotifyThatProcessStopped ();
- }
- }
- else
- {
- DNBLogThreadedIf (LOG_RNB_MINIMAL, "%s (&remote, initialize=%i) pid_state = %s pid_stop_count %llu (old %llu)) Notify??? skipping...", __FUNCTION__, (int)initialize, DNBStateAsString (pid_state), (uint64_t)ctx.GetProcessStopCount(), (uint64_t)prev_pid_stop_count);
- }
- }
- return eRNBRunLoopModeInferiorExecuting;
-
- case eStateStepping:
- case eStateRunning:
- return eRNBRunLoopModeInferiorExecuting;
-
- case eStateExited:
- remote->HandlePacket_last_signal(NULL);
- case eStateDetached:
- return eRNBRunLoopModeExit;
+RNBRunLoopMode HandleProcessStateChange(RNBRemote *remote, bool initialize) {
+ RNBContext &ctx = remote->Context();
+ nub_process_t pid = ctx.ProcessID();
+
+ if (pid == INVALID_NUB_PROCESS) {
+ DNBLogThreadedIf(LOG_RNB_MINIMAL, "#### %s error: pid invalid, exiting...",
+ __FUNCTION__);
+ return eRNBRunLoopModeExit;
+ }
+ nub_state_t pid_state = DNBProcessGetState(pid);
- }
+ DNBLogThreadedIf(LOG_RNB_MINIMAL,
+ "%s (&remote, initialize=%i) pid_state = %s", __FUNCTION__,
+ (int)initialize, DNBStateAsString(pid_state));
+
+ switch (pid_state) {
+ case eStateInvalid:
+ case eStateUnloaded:
+ // Something bad happened
+ return eRNBRunLoopModeExit;
+ break;
- // Catch all...
+ case eStateAttaching:
+ case eStateLaunching:
+ return eRNBRunLoopModeInferiorExecuting;
+
+ case eStateSuspended:
+ case eStateCrashed:
+ case eStateStopped:
+ // If we stop due to a signal, so clear the fact that we got a SIGINT
+ // so we can stop ourselves again (but only while our inferior
+ // process is running..)
+ g_sigint_received = 0;
+ if (initialize == false) {
+ // Compare the last stop count to our current notion of a stop count
+ // to make sure we don't notify more than once for a given stop.
+ nub_size_t prev_pid_stop_count = ctx.GetProcessStopCount();
+ bool pid_stop_count_changed =
+ ctx.SetProcessStopCount(DNBProcessGetStopCount(pid));
+ if (pid_stop_count_changed) {
+ remote->FlushSTDIO();
+
+ if (ctx.GetProcessStopCount() == 1) {
+ DNBLogThreadedIf(
+ LOG_RNB_MINIMAL, "%s (&remote, initialize=%i) pid_state = %s "
+ "pid_stop_count %llu (old %llu)) Notify??? no, "
+ "first stop...",
+ __FUNCTION__, (int)initialize, DNBStateAsString(pid_state),
+ (uint64_t)ctx.GetProcessStopCount(),
+ (uint64_t)prev_pid_stop_count);
+ } else {
+
+ DNBLogThreadedIf(LOG_RNB_MINIMAL, "%s (&remote, initialize=%i) "
+ "pid_state = %s pid_stop_count "
+ "%llu (old %llu)) Notify??? YES!!!",
+ __FUNCTION__, (int)initialize,
+ DNBStateAsString(pid_state),
+ (uint64_t)ctx.GetProcessStopCount(),
+ (uint64_t)prev_pid_stop_count);
+ remote->NotifyThatProcessStopped();
+ }
+ } else {
+ DNBLogThreadedIf(
+ LOG_RNB_MINIMAL, "%s (&remote, initialize=%i) pid_state = %s "
+ "pid_stop_count %llu (old %llu)) Notify??? "
+ "skipping...",
+ __FUNCTION__, (int)initialize, DNBStateAsString(pid_state),
+ (uint64_t)ctx.GetProcessStopCount(), (uint64_t)prev_pid_stop_count);
+ }
+ }
+ return eRNBRunLoopModeInferiorExecuting;
+
+ case eStateStepping:
+ case eStateRunning:
+ return eRNBRunLoopModeInferiorExecuting;
+
+ case eStateExited:
+ remote->HandlePacket_last_signal(NULL);
+ case eStateDetached:
return eRNBRunLoopModeExit;
+ }
+
+ // Catch all...
+ return eRNBRunLoopModeExit;
}
// This function handles the case where our inferior program is stopped and
// we are waiting for gdb remote protocol packets. When a packet occurs that
// makes the inferior run, we need to leave this function with a new state
// as the return code.
-RNBRunLoopMode
-RNBRunLoopInferiorExecuting (RNBRemote *remote)
-{
- DNBLogThreadedIf (LOG_RNB_MINIMAL, "#### %s", __FUNCTION__);
- RNBContext& ctx = remote->Context();
-
- // Init our mode and set 'is_running' based on the current process state
- RNBRunLoopMode mode = HandleProcessStateChange (remote, true);
-
- while (ctx.ProcessID() != INVALID_NUB_PROCESS)
- {
-
- std::string set_events_str;
- uint32_t event_mask = ctx.NormalEventBits();
-
- if (!ctx.ProcessStateRunning())
- {
- // Clear some bits if we are not running so we don't send any async packets
- event_mask &= ~RNBContext::event_proc_stdio_available;
- event_mask &= ~RNBContext::event_proc_profile_data;
- // When we enable async structured data packets over another logical channel,
- // this can be relaxed.
- event_mask &= ~RNBContext::event_darwin_log_data_available;
- }
-
- // We want to make sure we consume all process state changes and have
- // whomever is notifying us to wait for us to reset the event bit before
- // continuing.
- //ctx.Events().SetResetAckMask (RNBContext::event_proc_state_changed);
-
- DNBLogThreadedIf (LOG_RNB_EVENTS, "%s ctx.Events().WaitForSetEvents(0x%08x) ...",__FUNCTION__, event_mask);
- nub_event_t set_events = ctx.Events().WaitForSetEvents(event_mask);
- DNBLogThreadedIf (LOG_RNB_EVENTS, "%s ctx.Events().WaitForSetEvents(0x%08x) => 0x%08x (%s)",__FUNCTION__, event_mask, set_events, ctx.EventsAsString(set_events, set_events_str));
-
- if (set_events)
- {
- if ((set_events & RNBContext::event_proc_thread_exiting) ||
- (set_events & RNBContext::event_proc_stdio_available))
- {
- remote->FlushSTDIO();
- }
+RNBRunLoopMode RNBRunLoopInferiorExecuting(RNBRemote *remote) {
+ DNBLogThreadedIf(LOG_RNB_MINIMAL, "#### %s", __FUNCTION__);
+ RNBContext &ctx = remote->Context();
+
+ // Init our mode and set 'is_running' based on the current process state
+ RNBRunLoopMode mode = HandleProcessStateChange(remote, true);
+
+ while (ctx.ProcessID() != INVALID_NUB_PROCESS) {
+
+ std::string set_events_str;
+ uint32_t event_mask = ctx.NormalEventBits();
+
+ if (!ctx.ProcessStateRunning()) {
+ // Clear some bits if we are not running so we don't send any async
+ // packets
+ event_mask &= ~RNBContext::event_proc_stdio_available;
+ event_mask &= ~RNBContext::event_proc_profile_data;
+ // When we enable async structured data packets over another logical
+ // channel,
+ // this can be relaxed.
+ event_mask &= ~RNBContext::event_darwin_log_data_available;
+ }
+
+ // We want to make sure we consume all process state changes and have
+ // whomever is notifying us to wait for us to reset the event bit before
+ // continuing.
+ // ctx.Events().SetResetAckMask (RNBContext::event_proc_state_changed);
+
+ DNBLogThreadedIf(LOG_RNB_EVENTS,
+ "%s ctx.Events().WaitForSetEvents(0x%08x) ...",
+ __FUNCTION__, event_mask);
+ nub_event_t set_events = ctx.Events().WaitForSetEvents(event_mask);
+ DNBLogThreadedIf(LOG_RNB_EVENTS,
+ "%s ctx.Events().WaitForSetEvents(0x%08x) => 0x%08x (%s)",
+ __FUNCTION__, event_mask, set_events,
+ ctx.EventsAsString(set_events, set_events_str));
+
+ if (set_events) {
+ if ((set_events & RNBContext::event_proc_thread_exiting) ||
+ (set_events & RNBContext::event_proc_stdio_available)) {
+ remote->FlushSTDIO();
+ }
+
+ if (set_events & RNBContext::event_proc_profile_data) {
+ remote->SendAsyncProfileData();
+ }
+
+ if (set_events & RNBContext::event_darwin_log_data_available) {
+ remote->SendAsyncDarwinLogData();
+ }
+
+ if (set_events & RNBContext::event_read_packet_available) {
+ // handleReceivedPacket will take care of resetting the
+ // event_read_packet_available events when there are no more...
+ set_events ^= RNBContext::event_read_packet_available;
+
+ if (ctx.ProcessStateRunning()) {
+ if (remote->HandleAsyncPacket() == rnb_not_connected) {
+ // TODO: connect again? Exit?
+ }
+ } else {
+ if (remote->HandleReceivedPacket() == rnb_not_connected) {
+ // TODO: connect again? Exit?
+ }
+ }
+ }
+
+ if (set_events & RNBContext::event_proc_state_changed) {
+ mode = HandleProcessStateChange(remote, false);
+ ctx.Events().ResetEvents(RNBContext::event_proc_state_changed);
+ set_events ^= RNBContext::event_proc_state_changed;
+ }
+
+ if (set_events & RNBContext::event_proc_thread_exiting) {
+ mode = eRNBRunLoopModeExit;
+ }
+
+ if (set_events & RNBContext::event_read_thread_exiting) {
+ // Out remote packet receiving thread exited, exit for now.
+ if (ctx.HasValidProcessID()) {
+ // TODO: We should add code that will leave the current process
+ // in its current state and listen for another connection...
+ if (ctx.ProcessStateRunning()) {
+ if (ctx.GetDetachOnError()) {
+ DNBLog("debugserver's event read thread is exiting, detaching "
+ "from the inferior process.");
+ DNBProcessDetach(ctx.ProcessID());
+ } else {
+ DNBLog("debugserver's event read thread is exiting, killing the "
+ "inferior process.");
+ DNBProcessKill(ctx.ProcessID());
+ }
+ } else {
+ if (ctx.GetDetachOnError()) {
+ DNBLog("debugserver's event read thread is exiting, detaching "
+ "from the inferior process.");
+ DNBProcessDetach(ctx.ProcessID());
+ }
+ }
+ }
+ mode = eRNBRunLoopModeExit;
+ }
+ }
+
+ // Reset all event bits that weren't reset for now...
+ if (set_events != 0)
+ ctx.Events().ResetEvents(set_events);
+
+ if (mode != eRNBRunLoopModeInferiorExecuting)
+ break;
+ }
- if (set_events & RNBContext::event_proc_profile_data)
- {
- remote->SendAsyncProfileData();
- }
-
- if (set_events & RNBContext::event_darwin_log_data_available)
- {
- remote->SendAsyncDarwinLogData();
- }
-
- if (set_events & RNBContext::event_read_packet_available)
- {
- // handleReceivedPacket will take care of resetting the
- // event_read_packet_available events when there are no more...
- set_events ^= RNBContext::event_read_packet_available;
-
- if (ctx.ProcessStateRunning())
- {
- if (remote->HandleAsyncPacket() == rnb_not_connected)
- {
- // TODO: connect again? Exit?
- }
- }
- else
- {
- if (remote->HandleReceivedPacket() == rnb_not_connected)
- {
- // TODO: connect again? Exit?
- }
- }
- }
-
- if (set_events & RNBContext::event_proc_state_changed)
- {
- mode = HandleProcessStateChange (remote, false);
- ctx.Events().ResetEvents(RNBContext::event_proc_state_changed);
- set_events ^= RNBContext::event_proc_state_changed;
- }
-
- if (set_events & RNBContext::event_proc_thread_exiting)
- {
- mode = eRNBRunLoopModeExit;
- }
-
- if (set_events & RNBContext::event_read_thread_exiting)
- {
- // Out remote packet receiving thread exited, exit for now.
- if (ctx.HasValidProcessID())
- {
- // TODO: We should add code that will leave the current process
- // in its current state and listen for another connection...
- if (ctx.ProcessStateRunning())
- {
- if (ctx.GetDetachOnError())
- {
- DNBLog ("debugserver's event read thread is exiting, detaching from the inferior process.");
- DNBProcessDetach (ctx.ProcessID());
- }
- else
- {
- DNBLog ("debugserver's event read thread is exiting, killing the inferior process.");
- DNBProcessKill (ctx.ProcessID());
- }
- }
- else
- {
- if (ctx.GetDetachOnError())
- {
- DNBLog ("debugserver's event read thread is exiting, detaching from the inferior process.");
- DNBProcessDetach (ctx.ProcessID());
- }
- }
- }
- mode = eRNBRunLoopModeExit;
- }
- }
-
- // Reset all event bits that weren't reset for now...
- if (set_events != 0)
- ctx.Events().ResetEvents(set_events);
-
- if (mode != eRNBRunLoopModeInferiorExecuting)
- break;
- }
-
- return mode;
+ return mode;
}
-
-RNBRunLoopMode
-RNBRunLoopPlatform (RNBRemote *remote)
-{
- RNBRunLoopMode mode = eRNBRunLoopModePlatformMode;
- RNBContext& ctx = remote->Context();
-
- while (mode == eRNBRunLoopModePlatformMode)
- {
- std::string set_events_str;
- const uint32_t event_mask = RNBContext::event_read_packet_available |
- RNBContext::event_read_thread_exiting;
-
- DNBLogThreadedIf (LOG_RNB_EVENTS, "%s ctx.Events().WaitForSetEvents(0x%08x) ...",__FUNCTION__, event_mask);
- nub_event_t set_events = ctx.Events().WaitForSetEvents(event_mask);
- DNBLogThreadedIf (LOG_RNB_EVENTS, "%s ctx.Events().WaitForSetEvents(0x%08x) => 0x%08x (%s)",__FUNCTION__, event_mask, set_events, ctx.EventsAsString(set_events, set_events_str));
-
- if (set_events)
- {
- if (set_events & RNBContext::event_read_packet_available)
- {
- if (remote->HandleReceivedPacket() == rnb_not_connected)
- mode = eRNBRunLoopModeExit;
- }
-
- if (set_events & RNBContext::event_read_thread_exiting)
- {
- mode = eRNBRunLoopModeExit;
- }
- ctx.Events().ResetEvents(set_events);
- }
+RNBRunLoopMode RNBRunLoopPlatform(RNBRemote *remote) {
+ RNBRunLoopMode mode = eRNBRunLoopModePlatformMode;
+ RNBContext &ctx = remote->Context();
+
+ while (mode == eRNBRunLoopModePlatformMode) {
+ std::string set_events_str;
+ const uint32_t event_mask = RNBContext::event_read_packet_available |
+ RNBContext::event_read_thread_exiting;
+
+ DNBLogThreadedIf(LOG_RNB_EVENTS,
+ "%s ctx.Events().WaitForSetEvents(0x%08x) ...",
+ __FUNCTION__, event_mask);
+ nub_event_t set_events = ctx.Events().WaitForSetEvents(event_mask);
+ DNBLogThreadedIf(LOG_RNB_EVENTS,
+ "%s ctx.Events().WaitForSetEvents(0x%08x) => 0x%08x (%s)",
+ __FUNCTION__, event_mask, set_events,
+ ctx.EventsAsString(set_events, set_events_str));
+
+ if (set_events) {
+ if (set_events & RNBContext::event_read_packet_available) {
+ if (remote->HandleReceivedPacket() == rnb_not_connected)
+ mode = eRNBRunLoopModeExit;
+ }
+
+ if (set_events & RNBContext::event_read_thread_exiting) {
+ mode = eRNBRunLoopModeExit;
+ }
+ ctx.Events().ResetEvents(set_events);
}
- return eRNBRunLoopModeExit;
+ }
+ return eRNBRunLoopModeExit;
}
//----------------------------------------------------------------------
@@ -675,1070 +659,1014 @@ RNBRunLoopPlatform (RNBRemote *remote)
// Returns 1 for success 0 for failure.
//----------------------------------------------------------------------
-static void
-PortWasBoundCallbackUnixSocket (const void *baton, in_port_t port)
-{
- //::printf ("PortWasBoundCallbackUnixSocket (baton = %p, port = %u)\n", baton, port);
+static void PortWasBoundCallbackUnixSocket(const void *baton, in_port_t port) {
+ //::printf ("PortWasBoundCallbackUnixSocket (baton = %p, port = %u)\n", baton,
+ //port);
- const char *unix_socket_name = (const char *)baton;
-
- if (unix_socket_name && unix_socket_name[0])
- {
- // We were given a unix socket name to use to communicate the port
- // that we ended up binding to back to our parent process
- struct sockaddr_un saddr_un;
- int s = ::socket (AF_UNIX, SOCK_STREAM, 0);
- if (s < 0)
- {
- perror("error: socket (AF_UNIX, SOCK_STREAM, 0)");
- exit(1);
- }
+ const char *unix_socket_name = (const char *)baton;
- saddr_un.sun_family = AF_UNIX;
- ::strncpy(saddr_un.sun_path, unix_socket_name, sizeof(saddr_un.sun_path) - 1);
- saddr_un.sun_path[sizeof(saddr_un.sun_path) - 1] = '\0';
- saddr_un.sun_len = SUN_LEN (&saddr_un);
+ if (unix_socket_name && unix_socket_name[0]) {
+ // We were given a unix socket name to use to communicate the port
+ // that we ended up binding to back to our parent process
+ struct sockaddr_un saddr_un;
+ int s = ::socket(AF_UNIX, SOCK_STREAM, 0);
+ if (s < 0) {
+ perror("error: socket (AF_UNIX, SOCK_STREAM, 0)");
+ exit(1);
+ }
- if (::connect (s, (struct sockaddr *)&saddr_un, static_cast<socklen_t>(SUN_LEN (&saddr_un))) < 0)
- {
- perror("error: connect (socket, &saddr_un, saddr_un_len)");
- exit(1);
- }
+ saddr_un.sun_family = AF_UNIX;
+ ::strncpy(saddr_un.sun_path, unix_socket_name,
+ sizeof(saddr_un.sun_path) - 1);
+ saddr_un.sun_path[sizeof(saddr_un.sun_path) - 1] = '\0';
+ saddr_un.sun_len = SUN_LEN(&saddr_un);
- //::printf ("connect () sucess!!\n");
+ if (::connect(s, (struct sockaddr *)&saddr_un,
+ static_cast<socklen_t>(SUN_LEN(&saddr_un))) < 0) {
+ perror("error: connect (socket, &saddr_un, saddr_un_len)");
+ exit(1);
+ }
+ //::printf ("connect () sucess!!\n");
- // We were able to connect to the socket, now write our PID so whomever
- // launched us will know this process's ID
- RNBLogSTDOUT ("Listening to port %i...\n", port);
+ // We were able to connect to the socket, now write our PID so whomever
+ // launched us will know this process's ID
+ RNBLogSTDOUT("Listening to port %i...\n", port);
- char pid_str[64];
- const int pid_str_len = ::snprintf (pid_str, sizeof(pid_str), "%u", port);
- const ssize_t bytes_sent = ::send (s, pid_str, pid_str_len, 0);
+ char pid_str[64];
+ const int pid_str_len = ::snprintf(pid_str, sizeof(pid_str), "%u", port);
+ const ssize_t bytes_sent = ::send(s, pid_str, pid_str_len, 0);
- if (pid_str_len != bytes_sent)
- {
- perror("error: send (s, pid_str, pid_str_len, 0)");
- exit (1);
- }
+ if (pid_str_len != bytes_sent) {
+ perror("error: send (s, pid_str, pid_str_len, 0)");
+ exit(1);
+ }
- //::printf ("send () sucess!!\n");
+ //::printf ("send () sucess!!\n");
- // We are done with the socket
- close (s);
- }
+ // We are done with the socket
+ close(s);
+ }
}
-static void
-PortWasBoundCallbackNamedPipe (const void *baton, uint16_t port)
-{
- const char *named_pipe = (const char *)baton;
- if (named_pipe && named_pipe[0])
- {
- int fd = ::open(named_pipe, O_WRONLY);
- if (fd > -1)
- {
- char port_str[64];
- const ssize_t port_str_len = ::snprintf (port_str, sizeof(port_str), "%u", port);
- // Write the port number as a C string with the NULL terminator
- ::write (fd, port_str, port_str_len + 1);
- close (fd);
- }
+static void PortWasBoundCallbackNamedPipe(const void *baton, uint16_t port) {
+ const char *named_pipe = (const char *)baton;
+ if (named_pipe && named_pipe[0]) {
+ int fd = ::open(named_pipe, O_WRONLY);
+ if (fd > -1) {
+ char port_str[64];
+ const ssize_t port_str_len =
+ ::snprintf(port_str, sizeof(port_str), "%u", port);
+ // Write the port number as a C string with the NULL terminator
+ ::write(fd, port_str, port_str_len + 1);
+ close(fd);
}
+ }
}
-static int
-ConnectRemote (RNBRemote *remote,
- const char *host,
- int port,
- bool reverse_connect,
- const char *named_pipe_path,
- const char *unix_socket_name)
-{
- if (!remote->Comm().IsConnected())
- {
- if (reverse_connect)
- {
- if (port == 0)
- {
- DNBLogThreaded("error: invalid port supplied for reverse connection: %i.\n", port);
- return 0;
- }
- if (remote->Comm().Connect(host, port) != rnb_success)
- {
- DNBLogThreaded("Failed to reverse connect to %s:%i.\n", host, port);
- return 0;
- }
- }
- else
- {
- if (port != 0)
- RNBLogSTDOUT ("Listening to port %i for a connection from %s...\n", port, host ? host : "127.0.0.1");
- if (unix_socket_name && unix_socket_name[0])
- {
- if (remote->Comm().Listen(host, port, PortWasBoundCallbackUnixSocket, unix_socket_name) != rnb_success)
- {
- RNBLogSTDERR ("Failed to get connection from a remote gdb process.\n");
- return 0;
- }
- }
- else
- {
- if (remote->Comm().Listen(host, port, PortWasBoundCallbackNamedPipe, named_pipe_path) != rnb_success)
- {
- RNBLogSTDERR ("Failed to get connection from a remote gdb process.\n");
- return 0;
- }
- }
- }
- remote->StartReadRemoteDataThread();
- }
- return 1;
+static int ConnectRemote(RNBRemote *remote, const char *host, int port,
+ bool reverse_connect, const char *named_pipe_path,
+ const char *unix_socket_name) {
+ if (!remote->Comm().IsConnected()) {
+ if (reverse_connect) {
+ if (port == 0) {
+ DNBLogThreaded(
+ "error: invalid port supplied for reverse connection: %i.\n", port);
+ return 0;
+ }
+ if (remote->Comm().Connect(host, port) != rnb_success) {
+ DNBLogThreaded("Failed to reverse connect to %s:%i.\n", host, port);
+ return 0;
+ }
+ } else {
+ if (port != 0)
+ RNBLogSTDOUT("Listening to port %i for a connection from %s...\n", port,
+ host ? host : "127.0.0.1");
+ if (unix_socket_name && unix_socket_name[0]) {
+ if (remote->Comm().Listen(host, port, PortWasBoundCallbackUnixSocket,
+ unix_socket_name) != rnb_success) {
+ RNBLogSTDERR("Failed to get connection from a remote gdb process.\n");
+ return 0;
+ }
+ } else {
+ if (remote->Comm().Listen(host, port, PortWasBoundCallbackNamedPipe,
+ named_pipe_path) != rnb_success) {
+ RNBLogSTDERR("Failed to get connection from a remote gdb process.\n");
+ return 0;
+ }
+ }
+ }
+ remote->StartReadRemoteDataThread();
+ }
+ return 1;
}
//----------------------------------------------------------------------
// ASL Logging callback that can be registered with DNBLogSetLogCallback
//----------------------------------------------------------------------
-void
-ASLLogCallback(void *baton, uint32_t flags, const char *format, va_list args)
-{
- if (format == NULL)
- return;
- static aslmsg g_aslmsg = NULL;
- if (g_aslmsg == NULL)
- {
- g_aslmsg = ::asl_new (ASL_TYPE_MSG);
- char asl_key_sender[PATH_MAX];
- snprintf(asl_key_sender, sizeof(asl_key_sender), "com.apple.%s-%s", DEBUGSERVER_PROGRAM_NAME, DEBUGSERVER_VERSION_STR);
- ::asl_set (g_aslmsg, ASL_KEY_SENDER, asl_key_sender);
- }
-
- int asl_level;
- if (flags & DNBLOG_FLAG_FATAL) asl_level = ASL_LEVEL_CRIT;
- else if (flags & DNBLOG_FLAG_ERROR) asl_level = ASL_LEVEL_ERR;
- else if (flags & DNBLOG_FLAG_WARNING) asl_level = ASL_LEVEL_WARNING;
- else if (flags & DNBLOG_FLAG_VERBOSE) asl_level = ASL_LEVEL_WARNING; //ASL_LEVEL_INFO;
- else asl_level = ASL_LEVEL_WARNING; //ASL_LEVEL_DEBUG;
+void ASLLogCallback(void *baton, uint32_t flags, const char *format,
+ va_list args) {
+ if (format == NULL)
+ return;
+ static aslmsg g_aslmsg = NULL;
+ if (g_aslmsg == NULL) {
+ g_aslmsg = ::asl_new(ASL_TYPE_MSG);
+ char asl_key_sender[PATH_MAX];
+ snprintf(asl_key_sender, sizeof(asl_key_sender), "com.apple.%s-%s",
+ DEBUGSERVER_PROGRAM_NAME, DEBUGSERVER_VERSION_STR);
+ ::asl_set(g_aslmsg, ASL_KEY_SENDER, asl_key_sender);
+ }
+
+ int asl_level;
+ if (flags & DNBLOG_FLAG_FATAL)
+ asl_level = ASL_LEVEL_CRIT;
+ else if (flags & DNBLOG_FLAG_ERROR)
+ asl_level = ASL_LEVEL_ERR;
+ else if (flags & DNBLOG_FLAG_WARNING)
+ asl_level = ASL_LEVEL_WARNING;
+ else if (flags & DNBLOG_FLAG_VERBOSE)
+ asl_level = ASL_LEVEL_WARNING; // ASL_LEVEL_INFO;
+ else
+ asl_level = ASL_LEVEL_WARNING; // ASL_LEVEL_DEBUG;
- ::asl_vlog (NULL, g_aslmsg, asl_level, format, args);
+ ::asl_vlog(NULL, g_aslmsg, asl_level, format, args);
}
//----------------------------------------------------------------------
// FILE based Logging callback that can be registered with
// DNBLogSetLogCallback
//----------------------------------------------------------------------
-void
-FileLogCallback(void *baton, uint32_t flags, const char *format, va_list args)
-{
- if (baton == NULL || format == NULL)
- return;
-
- ::vfprintf((FILE *)baton, format, args);
- ::fprintf((FILE *)baton, "\n");
- ::fflush((FILE *)baton);
+void FileLogCallback(void *baton, uint32_t flags, const char *format,
+ va_list args) {
+ if (baton == NULL || format == NULL)
+ return;
+
+ ::vfprintf((FILE *)baton, format, args);
+ ::fprintf((FILE *)baton, "\n");
+ ::fflush((FILE *)baton);
}
-
-void
-show_usage_and_exit (int exit_code)
-{
- RNBLogSTDERR ("Usage:\n %s host:port [program-name program-arg1 program-arg2 ...]\n", DEBUGSERVER_PROGRAM_NAME);
- RNBLogSTDERR (" %s /path/file [program-name program-arg1 program-arg2 ...]\n", DEBUGSERVER_PROGRAM_NAME);
- RNBLogSTDERR (" %s host:port --attach=<pid>\n", DEBUGSERVER_PROGRAM_NAME);
- RNBLogSTDERR (" %s /path/file --attach=<pid>\n", DEBUGSERVER_PROGRAM_NAME);
- RNBLogSTDERR (" %s host:port --attach=<process_name>\n", DEBUGSERVER_PROGRAM_NAME);
- RNBLogSTDERR (" %s /path/file --attach=<process_name>\n", DEBUGSERVER_PROGRAM_NAME);
- exit (exit_code);
+void show_usage_and_exit(int exit_code) {
+ RNBLogSTDERR(
+ "Usage:\n %s host:port [program-name program-arg1 program-arg2 ...]\n",
+ DEBUGSERVER_PROGRAM_NAME);
+ RNBLogSTDERR(" %s /path/file [program-name program-arg1 program-arg2 ...]\n",
+ DEBUGSERVER_PROGRAM_NAME);
+ RNBLogSTDERR(" %s host:port --attach=<pid>\n", DEBUGSERVER_PROGRAM_NAME);
+ RNBLogSTDERR(" %s /path/file --attach=<pid>\n", DEBUGSERVER_PROGRAM_NAME);
+ RNBLogSTDERR(" %s host:port --attach=<process_name>\n",
+ DEBUGSERVER_PROGRAM_NAME);
+ RNBLogSTDERR(" %s /path/file --attach=<process_name>\n",
+ DEBUGSERVER_PROGRAM_NAME);
+ exit(exit_code);
}
-
//----------------------------------------------------------------------
// option descriptors for getopt_long_only()
//----------------------------------------------------------------------
-static struct option g_long_options[] =
-{
- { "attach", required_argument, NULL, 'a' },
- { "arch", required_argument, NULL, 'A' },
- { "debug", no_argument, NULL, 'g' },
- { "kill-on-error", no_argument, NULL, 'K' },
- { "verbose", no_argument, NULL, 'v' },
- { "lockdown", no_argument, &g_lockdown_opt, 1 }, // short option "-k"
- { "applist", no_argument, &g_applist_opt, 1 }, // short option "-t"
- { "log-file", required_argument, NULL, 'l' },
- { "log-flags", required_argument, NULL, 'f' },
- { "launch", required_argument, NULL, 'x' }, // Valid values are "auto", "posix-spawn", "fork-exec", "springboard" (arm only)
- { "waitfor", required_argument, NULL, 'w' }, // Wait for a process whose name starts with ARG
- { "waitfor-interval", required_argument, NULL, 'i' }, // Time in usecs to wait between sampling the pid list when waiting for a process by name
- { "waitfor-duration", required_argument, NULL, 'd' }, // The time in seconds to wait for a process to show up by name
- { "native-regs", no_argument, NULL, 'r' }, // Specify to use the native registers instead of the gdb defaults for the architecture.
- { "stdio-path", required_argument, NULL, 's' }, // Set the STDIO path to be used when launching applications (STDIN, STDOUT and STDERR) (only if debugserver launches the process)
- { "stdin-path", required_argument, NULL, 'I' }, // Set the STDIN path to be used when launching applications (only if debugserver launches the process)
- { "stdout-path", required_argument, NULL, 'O' }, // Set the STDOUT path to be used when launching applications (only if debugserver launches the process)
- { "stderr-path", required_argument, NULL, 'E' }, // Set the STDERR path to be used when launching applications (only if debugserver launches the process)
- { "no-stdio", no_argument, NULL, 'n' }, // Do not set up any stdio (perhaps the program is a GUI program) (only if debugserver launches the process)
- { "setsid", no_argument, NULL, 'S' }, // call setsid() to make debugserver run in its own session
- { "disable-aslr", no_argument, NULL, 'D' }, // Use _POSIX_SPAWN_DISABLE_ASLR to avoid shared library randomization
- { "working-dir", required_argument, NULL, 'W' }, // The working directory that the inferior process should have (only if debugserver launches the process)
- { "platform", required_argument, NULL, 'p' }, // Put this executable into a remote platform mode
- { "unix-socket", required_argument, NULL, 'u' }, // If we need to handshake with our parent process, an option will be passed down that specifies a unix socket name to use
- { "fd", required_argument, NULL, 'FDSC' }, // A file descriptor was passed to this process when spawned that is already open and ready for communication
- { "named-pipe", required_argument, NULL, 'P' },
- { "reverse-connect", no_argument, NULL, 'R' },
- { "env", required_argument, NULL, 'e' }, // When debugserver launches the process, set a single environment entry as specified by the option value ("./debugserver -e FOO=1 -e BAR=2 localhost:1234 -- /bin/ls")
- { "forward-env", no_argument, NULL, 'F' }, // When debugserver launches the process, forward debugserver's current environment variables to the child process ("./debugserver -F localhost:1234 -- /bin/ls"
- { NULL, 0, NULL, 0 }
-};
-
+static struct option g_long_options[] = {
+ {"attach", required_argument, NULL, 'a'},
+ {"arch", required_argument, NULL, 'A'},
+ {"debug", no_argument, NULL, 'g'},
+ {"kill-on-error", no_argument, NULL, 'K'},
+ {"verbose", no_argument, NULL, 'v'},
+ {"lockdown", no_argument, &g_lockdown_opt, 1}, // short option "-k"
+ {"applist", no_argument, &g_applist_opt, 1}, // short option "-t"
+ {"log-file", required_argument, NULL, 'l'},
+ {"log-flags", required_argument, NULL, 'f'},
+ {"launch", required_argument, NULL, 'x'}, // Valid values are "auto",
+ // "posix-spawn", "fork-exec",
+ // "springboard" (arm only)
+ {"waitfor", required_argument, NULL,
+ 'w'}, // Wait for a process whose name starts with ARG
+ {"waitfor-interval", required_argument, NULL,
+ 'i'}, // Time in usecs to wait between sampling the pid list when waiting
+ // for a process by name
+ {"waitfor-duration", required_argument, NULL,
+ 'd'}, // The time in seconds to wait for a process to show up by name
+ {"native-regs", no_argument, NULL, 'r'}, // Specify to use the native
+ // registers instead of the gdb
+ // defaults for the architecture.
+ {"stdio-path", required_argument, NULL,
+ 's'}, // Set the STDIO path to be used when launching applications (STDIN,
+ // STDOUT and STDERR) (only if debugserver launches the process)
+ {"stdin-path", required_argument, NULL,
+ 'I'}, // Set the STDIN path to be used when launching applications (only if
+ // debugserver launches the process)
+ {"stdout-path", required_argument, NULL,
+ 'O'}, // Set the STDOUT path to be used when launching applications (only
+ // if debugserver launches the process)
+ {"stderr-path", required_argument, NULL,
+ 'E'}, // Set the STDERR path to be used when launching applications (only
+ // if debugserver launches the process)
+ {"no-stdio", no_argument, NULL,
+ 'n'}, // Do not set up any stdio (perhaps the program is a GUI program)
+ // (only if debugserver launches the process)
+ {"setsid", no_argument, NULL,
+ 'S'}, // call setsid() to make debugserver run in its own session
+ {"disable-aslr", no_argument, NULL, 'D'}, // Use _POSIX_SPAWN_DISABLE_ASLR
+ // to avoid shared library
+ // randomization
+ {"working-dir", required_argument, NULL,
+ 'W'}, // The working directory that the inferior process should have (only
+ // if debugserver launches the process)
+ {"platform", required_argument, NULL,
+ 'p'}, // Put this executable into a remote platform mode
+ {"unix-socket", required_argument, NULL,
+ 'u'}, // If we need to handshake with our parent process, an option will be
+ // passed down that specifies a unix socket name to use
+ {"fd", required_argument, NULL,
+ 'FDSC'}, // A file descriptor was passed to this process when spawned that
+ // is already open and ready for communication
+ {"named-pipe", required_argument, NULL, 'P'},
+ {"reverse-connect", no_argument, NULL, 'R'},
+ {"env", required_argument, NULL,
+ 'e'}, // When debugserver launches the process, set a single environment
+ // entry as specified by the option value ("./debugserver -e FOO=1 -e
+ // BAR=2 localhost:1234 -- /bin/ls")
+ {"forward-env", no_argument, NULL,
+ 'F'}, // When debugserver launches the process, forward debugserver's
+ // current environment variables to the child process ("./debugserver
+ // -F localhost:1234 -- /bin/ls"
+ {NULL, 0, NULL, 0}};
//----------------------------------------------------------------------
// main
//----------------------------------------------------------------------
-int
-main (int argc, char *argv[])
-{
- // If debugserver is launched with DYLD_INSERT_LIBRARIES, unset it so we
- // don't spawn child processes with this enabled.
- unsetenv("DYLD_INSERT_LIBRARIES");
-
- const char *argv_sub_zero = argv[0]; // save a copy of argv[0] for error reporting post-launch
-
-#if defined (__APPLE__)
- pthread_setname_np ("main thread");
-#if defined (__arm__) || defined (__arm64__) || defined (__aarch64__)
- struct sched_param thread_param;
- int thread_sched_policy;
- if (pthread_getschedparam(pthread_self(), &thread_sched_policy, &thread_param) == 0)
- {
- thread_param.sched_priority = 47;
- pthread_setschedparam(pthread_self(), thread_sched_policy, &thread_param);
- }
-
- ::proc_set_wakemon_params (getpid(), 500, 0); // Allow up to 500 wakeups/sec to avoid EXC_RESOURCE for normal use.
+int main(int argc, char *argv[]) {
+ // If debugserver is launched with DYLD_INSERT_LIBRARIES, unset it so we
+ // don't spawn child processes with this enabled.
+ unsetenv("DYLD_INSERT_LIBRARIES");
+
+ const char *argv_sub_zero =
+ argv[0]; // save a copy of argv[0] for error reporting post-launch
+
+#if defined(__APPLE__)
+ pthread_setname_np("main thread");
+#if defined(__arm__) || defined(__arm64__) || defined(__aarch64__)
+ struct sched_param thread_param;
+ int thread_sched_policy;
+ if (pthread_getschedparam(pthread_self(), &thread_sched_policy,
+ &thread_param) == 0) {
+ thread_param.sched_priority = 47;
+ pthread_setschedparam(pthread_self(), thread_sched_policy, &thread_param);
+ }
+
+ ::proc_set_wakemon_params(
+ getpid(), 500,
+ 0); // Allow up to 500 wakeups/sec to avoid EXC_RESOURCE for normal use.
#endif
#endif
- g_isatty = ::isatty (STDIN_FILENO);
+ g_isatty = ::isatty(STDIN_FILENO);
- // ::printf ("uid=%u euid=%u gid=%u egid=%u\n",
- // getuid(),
- // geteuid(),
- // getgid(),
- // getegid());
-
-
- // signal (SIGINT, signal_handler);
- signal (SIGPIPE, signal_handler);
- signal (SIGHUP, signal_handler);
-
- // We're always sitting in waitpid or kevent waiting on our target process' death,
- // we don't need no stinking SIGCHLD's...
-
- sigset_t sigset;
- sigemptyset(&sigset);
- sigaddset(&sigset, SIGCHLD);
- sigprocmask(SIG_BLOCK, &sigset, NULL);
-
- g_remoteSP.reset (new RNBRemote ());
-
-
- RNBRemote *remote = g_remoteSP.get();
- if (remote == NULL)
- {
- RNBLogSTDERR ("error: failed to create a remote connection class\n");
- return -1;
- }
-
- RNBContext& ctx = remote->Context();
-
- int i;
- int attach_pid = INVALID_NUB_PROCESS;
-
- FILE* log_file = NULL;
- uint32_t log_flags = 0;
- // Parse our options
- int ch;
- int long_option_index = 0;
- int debug = 0;
- int communication_fd = -1;
- std::string compile_options;
- std::string waitfor_pid_name; // Wait for a process that starts with this name
- std::string attach_pid_name;
- std::string arch_name;
- std::string working_dir; // The new working directory to use for the inferior
- std::string unix_socket_name; // If we need to handshake with our parent process, an option will be passed down that specifies a unix socket name to use
- std::string named_pipe_path; // If we need to handshake with our parent process, an option will be passed down that specifies a named pipe to use
- useconds_t waitfor_interval = 1000; // Time in usecs between process lists polls when waiting for a process by name, default 1 msec.
- useconds_t waitfor_duration = 0; // Time in seconds to wait for a process by name, 0 means wait forever.
- bool no_stdio = false;
- bool reverse_connect = false; // Set to true by an option to indicate we should reverse connect to the host:port supplied as the first debugserver argument
+ // ::printf ("uid=%u euid=%u gid=%u egid=%u\n",
+ // getuid(),
+ // geteuid(),
+ // getgid(),
+ // getegid());
+
+ // signal (SIGINT, signal_handler);
+ signal(SIGPIPE, signal_handler);
+ signal(SIGHUP, signal_handler);
+
+ // We're always sitting in waitpid or kevent waiting on our target process'
+ // death,
+ // we don't need no stinking SIGCHLD's...
+
+ sigset_t sigset;
+ sigemptyset(&sigset);
+ sigaddset(&sigset, SIGCHLD);
+ sigprocmask(SIG_BLOCK, &sigset, NULL);
+
+ g_remoteSP.reset(new RNBRemote());
+
+ RNBRemote *remote = g_remoteSP.get();
+ if (remote == NULL) {
+ RNBLogSTDERR("error: failed to create a remote connection class\n");
+ return -1;
+ }
+
+ RNBContext &ctx = remote->Context();
+
+ int i;
+ int attach_pid = INVALID_NUB_PROCESS;
+
+ FILE *log_file = NULL;
+ uint32_t log_flags = 0;
+ // Parse our options
+ int ch;
+ int long_option_index = 0;
+ int debug = 0;
+ int communication_fd = -1;
+ std::string compile_options;
+ std::string waitfor_pid_name; // Wait for a process that starts with this name
+ std::string attach_pid_name;
+ std::string arch_name;
+ std::string working_dir; // The new working directory to use for the inferior
+ std::string unix_socket_name; // If we need to handshake with our parent
+ // process, an option will be passed down that
+ // specifies a unix socket name to use
+ std::string named_pipe_path; // If we need to handshake with our parent
+ // process, an option will be passed down that
+ // specifies a named pipe to use
+ useconds_t waitfor_interval = 1000; // Time in usecs between process lists
+ // polls when waiting for a process by
+ // name, default 1 msec.
+ useconds_t waitfor_duration =
+ 0; // Time in seconds to wait for a process by name, 0 means wait forever.
+ bool no_stdio = false;
+ bool reverse_connect = false; // Set to true by an option to indicate we
+ // should reverse connect to the host:port
+ // supplied as the first debugserver argument
-#if !defined (DNBLOG_ENABLED)
- compile_options += "(no-logging) ";
+#if !defined(DNBLOG_ENABLED)
+ compile_options += "(no-logging) ";
#endif
- RNBRunLoopMode start_mode = eRNBRunLoopModeExit;
+ RNBRunLoopMode start_mode = eRNBRunLoopModeExit;
- char short_options[512];
- uint32_t short_options_idx = 0;
+ char short_options[512];
+ uint32_t short_options_idx = 0;
- // Handle the two case that don't have short options in g_long_options
- short_options[short_options_idx++] = 'k';
- short_options[short_options_idx++] = 't';
-
- for (i=0; g_long_options[i].name != NULL; ++i)
- {
- if (isalpha(g_long_options[i].val))
- {
- short_options[short_options_idx++] = g_long_options[i].val;
- switch (g_long_options[i].has_arg)
- {
- default:
- case no_argument:
- break;
-
- case optional_argument:
- short_options[short_options_idx++] = ':';
- // Fall through to required_argument case below...
- case required_argument:
- short_options[short_options_idx++] = ':';
- break;
- }
- }
- }
- // NULL terminate the short option string.
- short_options[short_options_idx++] = '\0';
+ // Handle the two case that don't have short options in g_long_options
+ short_options[short_options_idx++] = 'k';
+ short_options[short_options_idx++] = 't';
+
+ for (i = 0; g_long_options[i].name != NULL; ++i) {
+ if (isalpha(g_long_options[i].val)) {
+ short_options[short_options_idx++] = g_long_options[i].val;
+ switch (g_long_options[i].has_arg) {
+ default:
+ case no_argument:
+ break;
+
+ case optional_argument:
+ short_options[short_options_idx++] = ':';
+ // Fall through to required_argument case below...
+ case required_argument:
+ short_options[short_options_idx++] = ':';
+ break;
+ }
+ }
+ }
+ // NULL terminate the short option string.
+ short_options[short_options_idx++] = '\0';
#if __GLIBC__
- optind = 0;
+ optind = 0;
#else
- optreset = 1;
- optind = 1;
+ optreset = 1;
+ optind = 1;
#endif
- while ((ch = getopt_long_only(argc, argv, short_options, g_long_options, &long_option_index)) != -1)
- {
- DNBLogDebug("option: ch == %c (0x%2.2x) --%s%c%s\n",
- ch, (uint8_t)ch,
- g_long_options[long_option_index].name,
- g_long_options[long_option_index].has_arg ? '=' : ' ',
- optarg ? optarg : "");
- switch (ch)
- {
- case 0: // Any optional that auto set themselves will return 0
- break;
-
- case 'A':
- if (optarg && optarg[0])
- arch_name.assign(optarg);
- break;
-
- case 'a':
- if (optarg && optarg[0])
- {
- if (isdigit(optarg[0]))
- {
- char *end = NULL;
- attach_pid = static_cast<int>(strtoul(optarg, &end, 0));
- if (end == NULL || *end != '\0')
- {
- RNBLogSTDERR ("error: invalid pid option '%s'\n", optarg);
- exit (4);
- }
- }
- else
- {
- attach_pid_name = optarg;
- }
- start_mode = eRNBRunLoopModeInferiorAttaching;
- }
- break;
-
- // --waitfor=NAME
- case 'w':
- if (optarg && optarg[0])
- {
- waitfor_pid_name = optarg;
- start_mode = eRNBRunLoopModeInferiorAttaching;
- }
- break;
-
- // --waitfor-interval=USEC
- case 'i':
- if (optarg && optarg[0])
- {
- char *end = NULL;
- waitfor_interval = static_cast<useconds_t>(strtoul(optarg, &end, 0));
- if (end == NULL || *end != '\0')
- {
- RNBLogSTDERR ("error: invalid waitfor-interval option value '%s'.\n", optarg);
- exit (6);
- }
- }
- break;
-
- // --waitfor-duration=SEC
- case 'd':
- if (optarg && optarg[0])
- {
- char *end = NULL;
- waitfor_duration = static_cast<useconds_t>(strtoul(optarg, &end, 0));
- if (end == NULL || *end != '\0')
- {
- RNBLogSTDERR ("error: invalid waitfor-duration option value '%s'.\n", optarg);
- exit (7);
- }
- }
- break;
-
- case 'K':
- g_detach_on_error = false;
- break;
- case 'W':
- if (optarg && optarg[0])
- working_dir.assign(optarg);
- break;
-
- case 'x':
- if (optarg && optarg[0])
- {
- if (strcasecmp(optarg, "auto") == 0)
- g_launch_flavor = eLaunchFlavorDefault;
- else if (strcasestr(optarg, "posix") == optarg)
- g_launch_flavor = eLaunchFlavorPosixSpawn;
- else if (strcasestr(optarg, "fork") == optarg)
- g_launch_flavor = eLaunchFlavorForkExec;
+ while ((ch = getopt_long_only(argc, argv, short_options, g_long_options,
+ &long_option_index)) != -1) {
+ DNBLogDebug("option: ch == %c (0x%2.2x) --%s%c%s\n", ch, (uint8_t)ch,
+ g_long_options[long_option_index].name,
+ g_long_options[long_option_index].has_arg ? '=' : ' ',
+ optarg ? optarg : "");
+ switch (ch) {
+ case 0: // Any optional that auto set themselves will return 0
+ break;
+
+ case 'A':
+ if (optarg && optarg[0])
+ arch_name.assign(optarg);
+ break;
+
+ case 'a':
+ if (optarg && optarg[0]) {
+ if (isdigit(optarg[0])) {
+ char *end = NULL;
+ attach_pid = static_cast<int>(strtoul(optarg, &end, 0));
+ if (end == NULL || *end != '\0') {
+ RNBLogSTDERR("error: invalid pid option '%s'\n", optarg);
+ exit(4);
+ }
+ } else {
+ attach_pid_name = optarg;
+ }
+ start_mode = eRNBRunLoopModeInferiorAttaching;
+ }
+ break;
+
+ // --waitfor=NAME
+ case 'w':
+ if (optarg && optarg[0]) {
+ waitfor_pid_name = optarg;
+ start_mode = eRNBRunLoopModeInferiorAttaching;
+ }
+ break;
+
+ // --waitfor-interval=USEC
+ case 'i':
+ if (optarg && optarg[0]) {
+ char *end = NULL;
+ waitfor_interval = static_cast<useconds_t>(strtoul(optarg, &end, 0));
+ if (end == NULL || *end != '\0') {
+ RNBLogSTDERR("error: invalid waitfor-interval option value '%s'.\n",
+ optarg);
+ exit(6);
+ }
+ }
+ break;
+
+ // --waitfor-duration=SEC
+ case 'd':
+ if (optarg && optarg[0]) {
+ char *end = NULL;
+ waitfor_duration = static_cast<useconds_t>(strtoul(optarg, &end, 0));
+ if (end == NULL || *end != '\0') {
+ RNBLogSTDERR("error: invalid waitfor-duration option value '%s'.\n",
+ optarg);
+ exit(7);
+ }
+ }
+ break;
+
+ case 'K':
+ g_detach_on_error = false;
+ break;
+ case 'W':
+ if (optarg && optarg[0])
+ working_dir.assign(optarg);
+ break;
+
+ case 'x':
+ if (optarg && optarg[0]) {
+ if (strcasecmp(optarg, "auto") == 0)
+ g_launch_flavor = eLaunchFlavorDefault;
+ else if (strcasestr(optarg, "posix") == optarg)
+ g_launch_flavor = eLaunchFlavorPosixSpawn;
+ else if (strcasestr(optarg, "fork") == optarg)
+ g_launch_flavor = eLaunchFlavorForkExec;
#ifdef WITH_SPRINGBOARD
- else if (strcasestr(optarg, "spring") == optarg)
- g_launch_flavor = eLaunchFlavorSpringBoard;
+ else if (strcasestr(optarg, "spring") == optarg)
+ g_launch_flavor = eLaunchFlavorSpringBoard;
#endif
#ifdef WITH_BKS
- else if (strcasestr(optarg, "backboard") == optarg)
- g_launch_flavor = eLaunchFlavorBKS;
+ else if (strcasestr(optarg, "backboard") == optarg)
+ g_launch_flavor = eLaunchFlavorBKS;
#endif
#ifdef WITH_FBS
- else if (strcasestr(optarg, "frontboard") == optarg)
- g_launch_flavor = eLaunchFlavorFBS;
+ else if (strcasestr(optarg, "frontboard") == optarg)
+ g_launch_flavor = eLaunchFlavorFBS;
#endif
- else
- {
- RNBLogSTDERR ("error: invalid TYPE for the --launch=TYPE (-x TYPE) option: '%s'\n", optarg);
- RNBLogSTDERR ("Valid values TYPE are:\n");
- RNBLogSTDERR (" auto Auto-detect the best launch method to use.\n");
- RNBLogSTDERR (" posix Launch the executable using posix_spawn.\n");
- RNBLogSTDERR (" fork Launch the executable using fork and exec.\n");
+ else {
+ RNBLogSTDERR("error: invalid TYPE for the --launch=TYPE (-x TYPE) "
+ "option: '%s'\n",
+ optarg);
+ RNBLogSTDERR("Valid values TYPE are:\n");
+ RNBLogSTDERR(
+ " auto Auto-detect the best launch method to use.\n");
+ RNBLogSTDERR(
+ " posix Launch the executable using posix_spawn.\n");
+ RNBLogSTDERR(
+ " fork Launch the executable using fork and exec.\n");
#ifdef WITH_SPRINGBOARD
- RNBLogSTDERR (" spring Launch the executable through Springboard.\n");
+ RNBLogSTDERR(
+ " spring Launch the executable through Springboard.\n");
#endif
#ifdef WITH_BKS
- RNBLogSTDERR (" backboard Launch the executable through BackBoard Services.\n");
+ RNBLogSTDERR(" backboard Launch the executable through BackBoard "
+ "Services.\n");
#endif
#ifdef WITH_FBS
- RNBLogSTDERR (" frontboard Launch the executable through FrontBoard Services.\n");
-#endif
- exit (5);
- }
- }
- break;
-
- case 'l': // Set Log File
- if (optarg && optarg[0])
- {
- if (strcasecmp(optarg, "stdout") == 0)
- log_file = stdout;
- else if (strcasecmp(optarg, "stderr") == 0)
- log_file = stderr;
- else
- {
- log_file = fopen(optarg, "w");
- if (log_file != NULL)
- setlinebuf(log_file);
- }
-
- if (log_file == NULL)
- {
- const char *errno_str = strerror(errno);
- RNBLogSTDERR ("Failed to open log file '%s' for writing: errno = %i (%s)", optarg, errno, errno_str ? errno_str : "unknown error");
- }
- }
- break;
-
- case 'f': // Log Flags
- if (optarg && optarg[0])
- log_flags = static_cast<uint32_t>(strtoul(optarg, NULL, 0));
- break;
-
- case 'g':
- debug = 1;
- DNBLogSetDebug(debug);
- break;
-
- case 't':
- g_applist_opt = 1;
- break;
-
- case 'k':
- g_lockdown_opt = 1;
- break;
-
- case 'r':
- // Do nothing, native regs is the default these days
- break;
-
- case 'R':
- reverse_connect = true;
- break;
- case 'v':
- DNBLogSetVerbose(1);
- break;
-
- case 's':
- ctx.GetSTDIN().assign(optarg);
- ctx.GetSTDOUT().assign(optarg);
- ctx.GetSTDERR().assign(optarg);
- break;
-
- case 'I':
- ctx.GetSTDIN().assign(optarg);
- break;
-
- case 'O':
- ctx.GetSTDOUT().assign(optarg);
- break;
-
- case 'E':
- ctx.GetSTDERR().assign(optarg);
- break;
-
- case 'n':
- no_stdio = true;
- break;
-
- case 'S':
- // Put debugserver into a new session. Terminals group processes
- // into sessions and when a special terminal key sequences
- // (like control+c) are typed they can cause signals to go out to
- // all processes in a session. Using this --setsid (-S) option
- // will cause debugserver to run in its own sessions and be free
- // from such issues.
- //
- // This is useful when debugserver is spawned from a command
- // line application that uses debugserver to do the debugging,
- // yet that application doesn't want debugserver receiving the
- // signals sent to the session (i.e. dying when anyone hits ^C).
- setsid();
- break;
- case 'D':
- g_disable_aslr = 1;
- break;
-
- case 'p':
- start_mode = eRNBRunLoopModePlatformMode;
- break;
-
- case 'u':
- unix_socket_name.assign (optarg);
- break;
-
- case 'P':
- named_pipe_path.assign (optarg);
- break;
-
- case 'e':
- // Pass a single specified environment variable down to the process that gets launched
- remote->Context().PushEnvironment(optarg);
- break;
-
- case 'F':
- // Pass the current environment down to the process that gets launched
- {
- char **host_env = *_NSGetEnviron();
- char *env_entry;
- size_t i;
- for (i=0; (env_entry = host_env[i]) != NULL; ++i)
- remote->Context().PushEnvironment(env_entry);
- }
- break;
-
- case 'FDSC':
- // File descriptor passed to this process during fork/exec and is already
- // open and ready for communication.
- communication_fd = atoi(optarg);
- break;
- }
- }
-
- if (arch_name.empty())
- {
-#if defined (__arm__)
- arch_name.assign ("arm");
+ RNBLogSTDERR(" frontboard Launch the executable through FrontBoard "
+ "Services.\n");
#endif
- }
- else
- {
- DNBSetArchitecture (arch_name.c_str());
- }
-
-// if (arch_name.empty())
-// {
-// fprintf(stderr, "error: no architecture was specified\n");
-// exit (8);
-// }
- // Skip any options we consumed with getopt_long_only
- argc -= optind;
- argv += optind;
-
-
- if (!working_dir.empty())
- {
- if (remote->Context().SetWorkingDirectory (working_dir.c_str()) == false)
- {
- RNBLogSTDERR ("error: working directory doesn't exist '%s'.\n", working_dir.c_str());
- exit (8);
+ exit(5);
}
- }
-
- remote->Context().SetDetachOnError(g_detach_on_error);
-
- remote->Initialize();
+ }
+ break;
- // It is ok for us to set NULL as the logfile (this will disable any logging)
-
- if (log_file != NULL)
- {
- DNBLogSetLogCallback(FileLogCallback, log_file);
- // If our log file was set, yet we have no log flags, log everything!
- if (log_flags == 0)
- log_flags = LOG_ALL | LOG_RNB_ALL;
-
- DNBLogSetLogMask (log_flags);
- }
- else
- {
- // Enable DNB logging
-
- // if os_log() support is available, log through that.
- auto log_callback = OsLogger::GetLogFunction();
- if (log_callback)
- {
- DNBLogSetLogCallback(log_callback, nullptr);
- DNBLog("debugserver will use os_log for internal logging.");
+ case 'l': // Set Log File
+ if (optarg && optarg[0]) {
+ if (strcasecmp(optarg, "stdout") == 0)
+ log_file = stdout;
+ else if (strcasecmp(optarg, "stderr") == 0)
+ log_file = stderr;
+ else {
+ log_file = fopen(optarg, "w");
+ if (log_file != NULL)
+ setlinebuf(log_file);
+ }
+
+ if (log_file == NULL) {
+ const char *errno_str = strerror(errno);
+ RNBLogSTDERR(
+ "Failed to open log file '%s' for writing: errno = %i (%s)",
+ optarg, errno, errno_str ? errno_str : "unknown error");
+ }
+ }
+ break;
+
+ case 'f': // Log Flags
+ if (optarg && optarg[0])
+ log_flags = static_cast<uint32_t>(strtoul(optarg, NULL, 0));
+ break;
+
+ case 'g':
+ debug = 1;
+ DNBLogSetDebug(debug);
+ break;
+
+ case 't':
+ g_applist_opt = 1;
+ break;
+
+ case 'k':
+ g_lockdown_opt = 1;
+ break;
+
+ case 'r':
+ // Do nothing, native regs is the default these days
+ break;
+
+ case 'R':
+ reverse_connect = true;
+ break;
+ case 'v':
+ DNBLogSetVerbose(1);
+ break;
+
+ case 's':
+ ctx.GetSTDIN().assign(optarg);
+ ctx.GetSTDOUT().assign(optarg);
+ ctx.GetSTDERR().assign(optarg);
+ break;
+
+ case 'I':
+ ctx.GetSTDIN().assign(optarg);
+ break;
+
+ case 'O':
+ ctx.GetSTDOUT().assign(optarg);
+ break;
+
+ case 'E':
+ ctx.GetSTDERR().assign(optarg);
+ break;
+
+ case 'n':
+ no_stdio = true;
+ break;
+
+ case 'S':
+ // Put debugserver into a new session. Terminals group processes
+ // into sessions and when a special terminal key sequences
+ // (like control+c) are typed they can cause signals to go out to
+ // all processes in a session. Using this --setsid (-S) option
+ // will cause debugserver to run in its own sessions and be free
+ // from such issues.
+ //
+ // This is useful when debugserver is spawned from a command
+ // line application that uses debugserver to do the debugging,
+ // yet that application doesn't want debugserver receiving the
+ // signals sent to the session (i.e. dying when anyone hits ^C).
+ setsid();
+ break;
+ case 'D':
+ g_disable_aslr = 1;
+ break;
+
+ case 'p':
+ start_mode = eRNBRunLoopModePlatformMode;
+ break;
+
+ case 'u':
+ unix_socket_name.assign(optarg);
+ break;
+
+ case 'P':
+ named_pipe_path.assign(optarg);
+ break;
+
+ case 'e':
+ // Pass a single specified environment variable down to the process that
+ // gets launched
+ remote->Context().PushEnvironment(optarg);
+ break;
+
+ case 'F':
+ // Pass the current environment down to the process that gets launched
+ {
+ char **host_env = *_NSGetEnviron();
+ char *env_entry;
+ size_t i;
+ for (i = 0; (env_entry = host_env[i]) != NULL; ++i)
+ remote->Context().PushEnvironment(env_entry);
+ }
+ break;
+
+ case 'FDSC':
+ // File descriptor passed to this process during fork/exec and is already
+ // open and ready for communication.
+ communication_fd = atoi(optarg);
+ break;
+ }
+ }
+
+ if (arch_name.empty()) {
+#if defined(__arm__)
+ arch_name.assign("arm");
+#endif
+ } else {
+ DNBSetArchitecture(arch_name.c_str());
+ }
+
+ // if (arch_name.empty())
+ // {
+ // fprintf(stderr, "error: no architecture was specified\n");
+ // exit (8);
+ // }
+ // Skip any options we consumed with getopt_long_only
+ argc -= optind;
+ argv += optind;
+
+ if (!working_dir.empty()) {
+ if (remote->Context().SetWorkingDirectory(working_dir.c_str()) == false) {
+ RNBLogSTDERR("error: working directory doesn't exist '%s'.\n",
+ working_dir.c_str());
+ exit(8);
+ }
+ }
+
+ remote->Context().SetDetachOnError(g_detach_on_error);
+
+ remote->Initialize();
+
+ // It is ok for us to set NULL as the logfile (this will disable any logging)
+
+ if (log_file != NULL) {
+ DNBLogSetLogCallback(FileLogCallback, log_file);
+ // If our log file was set, yet we have no log flags, log everything!
+ if (log_flags == 0)
+ log_flags = LOG_ALL | LOG_RNB_ALL;
+
+ DNBLogSetLogMask(log_flags);
+ } else {
+ // Enable DNB logging
+
+ // if os_log() support is available, log through that.
+ auto log_callback = OsLogger::GetLogFunction();
+ if (log_callback) {
+ DNBLogSetLogCallback(log_callback, nullptr);
+ DNBLog("debugserver will use os_log for internal logging.");
+ } else {
+ // Fall back to ASL support.
+ DNBLogSetLogCallback(ASLLogCallback, NULL);
+ DNBLog("debugserver will use ASL for internal logging.");
+ }
+ DNBLogSetLogMask(log_flags);
+ }
+
+ if (DNBLogEnabled()) {
+ for (i = 0; i < argc; i++)
+ DNBLogDebug("argv[%i] = %s", i, argv[i]);
+ }
+
+ // as long as we're dropping remotenub in as a replacement for gdbserver,
+ // explicitly note that this is not gdbserver.
+
+ RNBLogSTDOUT("%s-%s %sfor %s.\n", DEBUGSERVER_PROGRAM_NAME,
+ DEBUGSERVER_VERSION_STR, compile_options.c_str(), RNB_ARCH);
+
+ std::string host;
+ int port = INT32_MAX;
+ char str[PATH_MAX];
+ str[0] = '\0';
+
+ if (g_lockdown_opt == 0 && g_applist_opt == 0 && communication_fd == -1) {
+ // Make sure we at least have port
+ if (argc < 1) {
+ show_usage_and_exit(1);
+ }
+ // accept 'localhost:' prefix on port number
+
+ int items_scanned = ::sscanf(argv[0], "%[^:]:%i", str, &port);
+ if (items_scanned == 2) {
+ host = str;
+ DNBLogDebug("host = '%s' port = %i", host.c_str(), port);
+ } else {
+ // No hostname means "localhost"
+ int items_scanned = ::sscanf(argv[0], "%i", &port);
+ if (items_scanned == 1) {
+ host = "127.0.0.1";
+ DNBLogDebug("host = '%s' port = %i", host.c_str(), port);
+ } else if (argv[0][0] == '/') {
+ port = INT32_MAX;
+ strncpy(str, argv[0], sizeof(str));
+ } else {
+ show_usage_and_exit(2);
+ }
+ }
+
+ // We just used the 'host:port' or the '/path/file' arg...
+ argc--;
+ argv++;
+ }
+
+ // If we know we're waiting to attach, we don't need any of this other info.
+ if (start_mode != eRNBRunLoopModeInferiorAttaching &&
+ start_mode != eRNBRunLoopModePlatformMode) {
+ if (argc == 0 || g_lockdown_opt) {
+ if (g_lockdown_opt != 0) {
+ // Work around for SIGPIPE crashes due to posix_spawn issue.
+ // We have to close STDOUT and STDERR, else the first time we
+ // try and do any, we get SIGPIPE and die as posix_spawn is
+ // doing bad things with our file descriptors at the moment.
+ int null = open("/dev/null", O_RDWR);
+ dup2(null, STDOUT_FILENO);
+ dup2(null, STDERR_FILENO);
+ } else if (g_applist_opt != 0) {
+ // List all applications we are able to see
+ std::string applist_plist;
+ int err = ListApplications(applist_plist, false, false);
+ if (err == 0) {
+ fputs(applist_plist.c_str(), stdout);
+ } else {
+ RNBLogSTDERR("error: ListApplications returned error %i\n", err);
+ }
+ // Exit with appropriate error if we were asked to list the applications
+ // with no other args were given (and we weren't trying to do this over
+ // lockdown)
+ return err;
+ }
+
+ DNBLogDebug("Get args from remote protocol...");
+ start_mode = eRNBRunLoopModeGetStartModeFromRemoteProtocol;
+ } else {
+ start_mode = eRNBRunLoopModeInferiorLaunching;
+ // Fill in the argv array in the context from the rest of our args.
+ // Skip the name of this executable and the port number
+ for (int i = 0; i < argc; i++) {
+ DNBLogDebug("inferior_argv[%i] = '%s'", i, argv[i]);
+ ctx.PushArgument(argv[i]);
+ }
+ }
+ }
+
+ if (start_mode == eRNBRunLoopModeExit)
+ return -1;
+
+ RNBRunLoopMode mode = start_mode;
+ char err_str[1024] = {'\0'};
+
+ while (mode != eRNBRunLoopModeExit) {
+ switch (mode) {
+ case eRNBRunLoopModeGetStartModeFromRemoteProtocol:
+#ifdef WITH_LOCKDOWN
+ if (g_lockdown_opt) {
+ if (!remote->Comm().IsConnected()) {
+ if (remote->Comm().ConnectToService() != rnb_success) {
+ RNBLogSTDERR(
+ "Failed to get connection from a remote gdb process.\n");
+ mode = eRNBRunLoopModeExit;
+ } else if (g_applist_opt != 0) {
+ // List all applications we are able to see
+ std::string applist_plist;
+ if (ListApplications(applist_plist, false, false) == 0) {
+ DNBLogDebug("Task list: %s", applist_plist.c_str());
+
+ remote->Comm().Write(applist_plist.c_str(), applist_plist.size());
+ // Issue a read that will never yield any data until the other
+ // side
+ // closes the socket so this process doesn't just exit and cause
+ // the
+ // socket to close prematurely on the other end and cause data
+ // loss.
+ std::string buf;
+ remote->Comm().Read(buf);
+ }
+ remote->Comm().Disconnect(false);
+ mode = eRNBRunLoopModeExit;
+ break;
+ } else {
+ // Start watching for remote packets
+ remote->StartReadRemoteDataThread();
+ }
}
+ } else
+#endif
+ if (port != INT32_MAX) {
+ if (!ConnectRemote(remote, host.c_str(), port, reverse_connect,
+ named_pipe_path.c_str(), unix_socket_name.c_str()))
+ mode = eRNBRunLoopModeExit;
+ } else if (str[0] == '/') {
+ if (remote->Comm().OpenFile(str))
+ mode = eRNBRunLoopModeExit;
+ } else if (communication_fd >= 0) {
+ // We were passed a file descriptor to use during fork/exec that is
+ // already open
+ // in our process, so lets just use it!
+ if (remote->Comm().useFD(communication_fd))
+ mode = eRNBRunLoopModeExit;
else
- {
- // Fall back to ASL support.
- DNBLogSetLogCallback(ASLLogCallback, NULL);
- DNBLog("debugserver will use ASL for internal logging.");
- }
- DNBLogSetLogMask (log_flags);
-
- }
-
- if (DNBLogEnabled())
- {
- for (i=0; i<argc; i++)
- DNBLogDebug("argv[%i] = %s", i, argv[i]);
- }
+ remote->StartReadRemoteDataThread();
+ }
- // as long as we're dropping remotenub in as a replacement for gdbserver,
- // explicitly note that this is not gdbserver.
+ if (mode != eRNBRunLoopModeExit) {
+ RNBLogSTDOUT("Got a connection, waiting for process information for "
+ "launching or attaching.\n");
+
+ mode = RNBRunLoopGetStartModeFromRemote(remote);
+ }
+ break;
+
+ case eRNBRunLoopModeInferiorAttaching:
+ if (!waitfor_pid_name.empty()) {
+ // Set our end wait time if we are using a waitfor-duration
+ // option that may have been specified
+ struct timespec attach_timeout_abstime, *timeout_ptr = NULL;
+ if (waitfor_duration != 0) {
+ DNBTimer::OffsetTimeOfDay(&attach_timeout_abstime, waitfor_duration,
+ 0);
+ timeout_ptr = &attach_timeout_abstime;
+ }
+ nub_launch_flavor_t launch_flavor = g_launch_flavor;
+ if (launch_flavor == eLaunchFlavorDefault) {
+ // Our default launch method is posix spawn
+ launch_flavor = eLaunchFlavorPosixSpawn;
- RNBLogSTDOUT ("%s-%s %sfor %s.\n",
- DEBUGSERVER_PROGRAM_NAME,
- DEBUGSERVER_VERSION_STR,
- compile_options.c_str(),
- RNB_ARCH);
-
- std::string host;
- int port = INT32_MAX;
- char str[PATH_MAX];
- str[0] = '\0';
-
- if (g_lockdown_opt == 0 && g_applist_opt == 0 && communication_fd == -1)
- {
- // Make sure we at least have port
- if (argc < 1)
- {
- show_usage_and_exit (1);
+#if defined WITH_FBS
+ // Check if we have an app bundle, if so launch using SpringBoard.
+ if (waitfor_pid_name.find(".app") != std::string::npos) {
+ launch_flavor = eLaunchFlavorFBS;
+ }
+#elif defined WITH_BKS
+ // Check if we have an app bundle, if so launch using SpringBoard.
+ if (waitfor_pid_name.find(".app") != std::string::npos) {
+ launch_flavor = eLaunchFlavorBKS;
+ }
+#elif defined WITH_SPRINGBOARD
+ // Check if we have an app bundle, if so launch using SpringBoard.
+ if (waitfor_pid_name.find(".app") != std::string::npos) {
+ launch_flavor = eLaunchFlavorSpringBoard;
+ }
+#endif
}
- // accept 'localhost:' prefix on port number
- int items_scanned = ::sscanf (argv[0], "%[^:]:%i", str, &port);
- if (items_scanned == 2)
- {
- host = str;
- DNBLogDebug("host = '%s' port = %i", host.c_str(), port);
- }
+ ctx.SetLaunchFlavor(launch_flavor);
+ bool ignore_existing = false;
+ RNBLogSTDOUT("Waiting to attach to process %s...\n",
+ waitfor_pid_name.c_str());
+ nub_process_t pid = DNBProcessAttachWait(
+ waitfor_pid_name.c_str(), launch_flavor, ignore_existing,
+ timeout_ptr, waitfor_interval, err_str, sizeof(err_str));
+ g_pid = pid;
+
+ if (pid == INVALID_NUB_PROCESS) {
+ ctx.LaunchStatus().SetError(-1, DNBError::Generic);
+ if (err_str[0])
+ ctx.LaunchStatus().SetErrorString(err_str);
+ RNBLogSTDERR("error: failed to attach to process named: \"%s\" %s\n",
+ waitfor_pid_name.c_str(), err_str);
+ mode = eRNBRunLoopModeExit;
+ } else {
+ ctx.SetProcessID(pid);
+ mode = eRNBRunLoopModeInferiorExecuting;
+ }
+ } else if (attach_pid != INVALID_NUB_PROCESS) {
+
+ RNBLogSTDOUT("Attaching to process %i...\n", attach_pid);
+ nub_process_t attached_pid;
+ mode = RNBRunLoopLaunchAttaching(remote, attach_pid, attached_pid);
+ if (mode != eRNBRunLoopModeInferiorExecuting) {
+ const char *error_str = remote->Context().LaunchStatus().AsString();
+ RNBLogSTDERR("error: failed to attach process %i: %s\n", attach_pid,
+ error_str ? error_str : "unknown error.");
+ mode = eRNBRunLoopModeExit;
+ }
+ } else if (!attach_pid_name.empty()) {
+ struct timespec attach_timeout_abstime, *timeout_ptr = NULL;
+ if (waitfor_duration != 0) {
+ DNBTimer::OffsetTimeOfDay(&attach_timeout_abstime, waitfor_duration,
+ 0);
+ timeout_ptr = &attach_timeout_abstime;
+ }
+
+ RNBLogSTDOUT("Attaching to process %s...\n", attach_pid_name.c_str());
+ nub_process_t pid = DNBProcessAttachByName(
+ attach_pid_name.c_str(), timeout_ptr, err_str, sizeof(err_str));
+ g_pid = pid;
+ if (pid == INVALID_NUB_PROCESS) {
+ ctx.LaunchStatus().SetError(-1, DNBError::Generic);
+ if (err_str[0])
+ ctx.LaunchStatus().SetErrorString(err_str);
+ RNBLogSTDERR("error: failed to attach to process named: \"%s\" %s\n",
+ waitfor_pid_name.c_str(), err_str);
+ mode = eRNBRunLoopModeExit;
+ } else {
+ ctx.SetProcessID(pid);
+ mode = eRNBRunLoopModeInferiorExecuting;
+ }
+
+ } else {
+ RNBLogSTDERR(
+ "error: asked to attach with empty name and invalid PID.\n");
+ mode = eRNBRunLoopModeExit;
+ }
+
+ if (mode != eRNBRunLoopModeExit) {
+ if (port != INT32_MAX) {
+ if (!ConnectRemote(remote, host.c_str(), port, reverse_connect,
+ named_pipe_path.c_str(), unix_socket_name.c_str()))
+ mode = eRNBRunLoopModeExit;
+ } else if (str[0] == '/') {
+ if (remote->Comm().OpenFile(str))
+ mode = eRNBRunLoopModeExit;
+ } else if (communication_fd >= 0) {
+ // We were passed a file descriptor to use during fork/exec that is
+ // already open
+ // in our process, so lets just use it!
+ if (remote->Comm().useFD(communication_fd))
+ mode = eRNBRunLoopModeExit;
+ else
+ remote->StartReadRemoteDataThread();
+ }
+
+ if (mode != eRNBRunLoopModeExit)
+ RNBLogSTDOUT("Waiting for debugger instructions for process %d.\n",
+ attach_pid);
+ }
+ break;
+
+ case eRNBRunLoopModeInferiorLaunching: {
+ mode = RNBRunLoopLaunchInferior(remote, ctx.GetSTDINPath(),
+ ctx.GetSTDOUTPath(), ctx.GetSTDERRPath(),
+ no_stdio);
+
+ if (mode == eRNBRunLoopModeInferiorExecuting) {
+ if (port != INT32_MAX) {
+ if (!ConnectRemote(remote, host.c_str(), port, reverse_connect,
+ named_pipe_path.c_str(), unix_socket_name.c_str()))
+ mode = eRNBRunLoopModeExit;
+ } else if (str[0] == '/') {
+ if (remote->Comm().OpenFile(str))
+ mode = eRNBRunLoopModeExit;
+ } else if (communication_fd >= 0) {
+ // We were passed a file descriptor to use during fork/exec that is
+ // already open
+ // in our process, so lets just use it!
+ if (remote->Comm().useFD(communication_fd))
+ mode = eRNBRunLoopModeExit;
+ else
+ remote->StartReadRemoteDataThread();
+ }
+
+ if (mode != eRNBRunLoopModeExit) {
+ const char *proc_name = "<unknown>";
+ if (ctx.ArgumentCount() > 0)
+ proc_name = ctx.ArgumentAtIndex(0);
+ RNBLogSTDOUT("Got a connection, launched process %s (pid = %d).\n",
+ proc_name, ctx.ProcessID());
+ }
+ } else {
+ const char *error_str = remote->Context().LaunchStatus().AsString();
+ RNBLogSTDERR("error: failed to launch process %s: %s\n", argv_sub_zero,
+ error_str ? error_str : "unknown error.");
+ }
+ } break;
+
+ case eRNBRunLoopModeInferiorExecuting:
+ mode = RNBRunLoopInferiorExecuting(remote);
+ break;
+
+ case eRNBRunLoopModePlatformMode:
+ if (port != INT32_MAX) {
+ if (!ConnectRemote(remote, host.c_str(), port, reverse_connect,
+ named_pipe_path.c_str(), unix_socket_name.c_str()))
+ mode = eRNBRunLoopModeExit;
+ } else if (str[0] == '/') {
+ if (remote->Comm().OpenFile(str))
+ mode = eRNBRunLoopModeExit;
+ } else if (communication_fd >= 0) {
+ // We were passed a file descriptor to use during fork/exec that is
+ // already open
+ // in our process, so lets just use it!
+ if (remote->Comm().useFD(communication_fd))
+ mode = eRNBRunLoopModeExit;
else
- {
- // No hostname means "localhost"
- int items_scanned = ::sscanf (argv[0], "%i", &port);
- if (items_scanned == 1)
- {
- host = "127.0.0.1";
- DNBLogDebug("host = '%s' port = %i", host.c_str(), port);
- }
- else if (argv[0][0] == '/')
- {
- port = INT32_MAX;
- strncpy(str, argv[0], sizeof(str));
- }
- else
- {
- show_usage_and_exit (2);
- }
- }
+ remote->StartReadRemoteDataThread();
+ }
- // We just used the 'host:port' or the '/path/file' arg...
- argc--;
- argv++;
-
- }
-
- // If we know we're waiting to attach, we don't need any of this other info.
- if (start_mode != eRNBRunLoopModeInferiorAttaching &&
- start_mode != eRNBRunLoopModePlatformMode)
- {
- if (argc == 0 || g_lockdown_opt)
- {
- if (g_lockdown_opt != 0)
- {
- // Work around for SIGPIPE crashes due to posix_spawn issue.
- // We have to close STDOUT and STDERR, else the first time we
- // try and do any, we get SIGPIPE and die as posix_spawn is
- // doing bad things with our file descriptors at the moment.
- int null = open("/dev/null", O_RDWR);
- dup2(null, STDOUT_FILENO);
- dup2(null, STDERR_FILENO);
- }
- else if (g_applist_opt != 0)
- {
- // List all applications we are able to see
- std::string applist_plist;
- int err = ListApplications(applist_plist, false, false);
- if (err == 0)
- {
- fputs (applist_plist.c_str(), stdout);
- }
- else
- {
- RNBLogSTDERR ("error: ListApplications returned error %i\n", err);
- }
- // Exit with appropriate error if we were asked to list the applications
- // with no other args were given (and we weren't trying to do this over
- // lockdown)
- return err;
- }
+ if (mode != eRNBRunLoopModeExit)
+ mode = RNBRunLoopPlatform(remote);
+ break;
- DNBLogDebug("Get args from remote protocol...");
- start_mode = eRNBRunLoopModeGetStartModeFromRemoteProtocol;
- }
- else
- {
- start_mode = eRNBRunLoopModeInferiorLaunching;
- // Fill in the argv array in the context from the rest of our args.
- // Skip the name of this executable and the port number
- for (int i = 0; i < argc; i++)
- {
- DNBLogDebug("inferior_argv[%i] = '%s'", i, argv[i]);
- ctx.PushArgument (argv[i]);
- }
- }
+ default:
+ mode = eRNBRunLoopModeExit;
+ case eRNBRunLoopModeExit:
+ break;
}
+ }
- if (start_mode == eRNBRunLoopModeExit)
- return -1;
-
- RNBRunLoopMode mode = start_mode;
- char err_str[1024] = {'\0'};
-
- while (mode != eRNBRunLoopModeExit)
- {
- switch (mode)
- {
- case eRNBRunLoopModeGetStartModeFromRemoteProtocol:
-#ifdef WITH_LOCKDOWN
- if (g_lockdown_opt)
- {
- if (!remote->Comm().IsConnected())
- {
- if (remote->Comm().ConnectToService () != rnb_success)
- {
- RNBLogSTDERR ("Failed to get connection from a remote gdb process.\n");
- mode = eRNBRunLoopModeExit;
- }
- else if (g_applist_opt != 0)
- {
- // List all applications we are able to see
- std::string applist_plist;
- if (ListApplications(applist_plist, false, false) == 0)
- {
- DNBLogDebug("Task list: %s", applist_plist.c_str());
-
- remote->Comm().Write(applist_plist.c_str(), applist_plist.size());
- // Issue a read that will never yield any data until the other side
- // closes the socket so this process doesn't just exit and cause the
- // socket to close prematurely on the other end and cause data loss.
- std::string buf;
- remote->Comm().Read(buf);
- }
- remote->Comm().Disconnect(false);
- mode = eRNBRunLoopModeExit;
- break;
- }
- else
- {
- // Start watching for remote packets
- remote->StartReadRemoteDataThread();
- }
- }
- }
- else
-#endif
- if (port != INT32_MAX)
- {
- if (!ConnectRemote (remote, host.c_str(), port, reverse_connect, named_pipe_path.c_str(), unix_socket_name.c_str()))
- mode = eRNBRunLoopModeExit;
- }
- else if (str[0] == '/')
- {
- if (remote->Comm().OpenFile (str))
- mode = eRNBRunLoopModeExit;
- }
- else if (communication_fd >= 0)
- {
- // We were passed a file descriptor to use during fork/exec that is already open
- // in our process, so lets just use it!
- if (remote->Comm().useFD(communication_fd))
- mode = eRNBRunLoopModeExit;
- else
- remote->StartReadRemoteDataThread();
- }
-
- if (mode != eRNBRunLoopModeExit)
- {
- RNBLogSTDOUT ("Got a connection, waiting for process information for launching or attaching.\n");
-
- mode = RNBRunLoopGetStartModeFromRemote (remote);
- }
- break;
-
- case eRNBRunLoopModeInferiorAttaching:
- if (!waitfor_pid_name.empty())
- {
- // Set our end wait time if we are using a waitfor-duration
- // option that may have been specified
- struct timespec attach_timeout_abstime, *timeout_ptr = NULL;
- if (waitfor_duration != 0)
- {
- DNBTimer::OffsetTimeOfDay(&attach_timeout_abstime, waitfor_duration, 0);
- timeout_ptr = &attach_timeout_abstime;
- }
- nub_launch_flavor_t launch_flavor = g_launch_flavor;
- if (launch_flavor == eLaunchFlavorDefault)
- {
- // Our default launch method is posix spawn
- launch_flavor = eLaunchFlavorPosixSpawn;
-
-#if defined WITH_FBS
- // Check if we have an app bundle, if so launch using SpringBoard.
- if (waitfor_pid_name.find (".app") != std::string::npos)
- {
- launch_flavor = eLaunchFlavorFBS;
- }
-#elif defined WITH_BKS
- // Check if we have an app bundle, if so launch using SpringBoard.
- if (waitfor_pid_name.find (".app") != std::string::npos)
- {
- launch_flavor = eLaunchFlavorBKS;
- }
-#elif defined WITH_SPRINGBOARD
- // Check if we have an app bundle, if so launch using SpringBoard.
- if (waitfor_pid_name.find (".app") != std::string::npos)
- {
- launch_flavor = eLaunchFlavorSpringBoard;
- }
-#endif
- }
-
- ctx.SetLaunchFlavor(launch_flavor);
- bool ignore_existing = false;
- RNBLogSTDOUT ("Waiting to attach to process %s...\n", waitfor_pid_name.c_str());
- nub_process_t pid = DNBProcessAttachWait (waitfor_pid_name.c_str(), launch_flavor, ignore_existing, timeout_ptr, waitfor_interval, err_str, sizeof(err_str));
- g_pid = pid;
-
- if (pid == INVALID_NUB_PROCESS)
- {
- ctx.LaunchStatus().SetError(-1, DNBError::Generic);
- if (err_str[0])
- ctx.LaunchStatus().SetErrorString(err_str);
- RNBLogSTDERR ("error: failed to attach to process named: \"%s\" %s\n", waitfor_pid_name.c_str(), err_str);
- mode = eRNBRunLoopModeExit;
- }
- else
- {
- ctx.SetProcessID(pid);
- mode = eRNBRunLoopModeInferiorExecuting;
- }
- }
- else if (attach_pid != INVALID_NUB_PROCESS)
- {
-
- RNBLogSTDOUT ("Attaching to process %i...\n", attach_pid);
- nub_process_t attached_pid;
- mode = RNBRunLoopLaunchAttaching (remote, attach_pid, attached_pid);
- if (mode != eRNBRunLoopModeInferiorExecuting)
- {
- const char *error_str = remote->Context().LaunchStatus().AsString();
- RNBLogSTDERR ("error: failed to attach process %i: %s\n", attach_pid, error_str ? error_str : "unknown error.");
- mode = eRNBRunLoopModeExit;
- }
- }
- else if (!attach_pid_name.empty ())
- {
- struct timespec attach_timeout_abstime, *timeout_ptr = NULL;
- if (waitfor_duration != 0)
- {
- DNBTimer::OffsetTimeOfDay(&attach_timeout_abstime, waitfor_duration, 0);
- timeout_ptr = &attach_timeout_abstime;
- }
-
- RNBLogSTDOUT ("Attaching to process %s...\n", attach_pid_name.c_str());
- nub_process_t pid = DNBProcessAttachByName (attach_pid_name.c_str(), timeout_ptr, err_str, sizeof(err_str));
- g_pid = pid;
- if (pid == INVALID_NUB_PROCESS)
- {
- ctx.LaunchStatus().SetError(-1, DNBError::Generic);
- if (err_str[0])
- ctx.LaunchStatus().SetErrorString(err_str);
- RNBLogSTDERR ("error: failed to attach to process named: \"%s\" %s\n", waitfor_pid_name.c_str(), err_str);
- mode = eRNBRunLoopModeExit;
- }
- else
- {
- ctx.SetProcessID(pid);
- mode = eRNBRunLoopModeInferiorExecuting;
- }
-
- }
- else
- {
- RNBLogSTDERR ("error: asked to attach with empty name and invalid PID.\n");
- mode = eRNBRunLoopModeExit;
- }
-
- if (mode != eRNBRunLoopModeExit)
- {
- if (port != INT32_MAX)
- {
- if (!ConnectRemote (remote, host.c_str(), port, reverse_connect, named_pipe_path.c_str(), unix_socket_name.c_str()))
- mode = eRNBRunLoopModeExit;
- }
- else if (str[0] == '/')
- {
- if (remote->Comm().OpenFile (str))
- mode = eRNBRunLoopModeExit;
- }
- else if (communication_fd >= 0)
- {
- // We were passed a file descriptor to use during fork/exec that is already open
- // in our process, so lets just use it!
- if (remote->Comm().useFD(communication_fd))
- mode = eRNBRunLoopModeExit;
- else
- remote->StartReadRemoteDataThread();
- }
-
- if (mode != eRNBRunLoopModeExit)
- RNBLogSTDOUT ("Waiting for debugger instructions for process %d.\n", attach_pid);
- }
- break;
-
- case eRNBRunLoopModeInferiorLaunching:
- {
- mode = RNBRunLoopLaunchInferior (remote,
- ctx.GetSTDINPath(),
- ctx.GetSTDOUTPath(),
- ctx.GetSTDERRPath(),
- no_stdio);
-
- if (mode == eRNBRunLoopModeInferiorExecuting)
- {
- if (port != INT32_MAX)
- {
- if (!ConnectRemote (remote, host.c_str(), port, reverse_connect, named_pipe_path.c_str(), unix_socket_name.c_str()))
- mode = eRNBRunLoopModeExit;
- }
- else if (str[0] == '/')
- {
- if (remote->Comm().OpenFile (str))
- mode = eRNBRunLoopModeExit;
- }
- else if (communication_fd >= 0)
- {
- // We were passed a file descriptor to use during fork/exec that is already open
- // in our process, so lets just use it!
- if (remote->Comm().useFD(communication_fd))
- mode = eRNBRunLoopModeExit;
- else
- remote->StartReadRemoteDataThread();
- }
-
- if (mode != eRNBRunLoopModeExit)
- {
- const char *proc_name = "<unknown>";
- if (ctx.ArgumentCount() > 0)
- proc_name = ctx.ArgumentAtIndex(0);
- RNBLogSTDOUT ("Got a connection, launched process %s (pid = %d).\n", proc_name, ctx.ProcessID());
- }
- }
- else
- {
- const char *error_str = remote->Context().LaunchStatus().AsString();
- RNBLogSTDERR ("error: failed to launch process %s: %s\n", argv_sub_zero, error_str ? error_str : "unknown error.");
- }
- }
- break;
-
- case eRNBRunLoopModeInferiorExecuting:
- mode = RNBRunLoopInferiorExecuting(remote);
- break;
-
- case eRNBRunLoopModePlatformMode:
- if (port != INT32_MAX)
- {
- if (!ConnectRemote (remote, host.c_str(), port, reverse_connect, named_pipe_path.c_str(), unix_socket_name.c_str()))
- mode = eRNBRunLoopModeExit;
- }
- else if (str[0] == '/')
- {
- if (remote->Comm().OpenFile (str))
- mode = eRNBRunLoopModeExit;
- }
- else if (communication_fd >= 0)
- {
- // We were passed a file descriptor to use during fork/exec that is already open
- // in our process, so lets just use it!
- if (remote->Comm().useFD(communication_fd))
- mode = eRNBRunLoopModeExit;
- else
- remote->StartReadRemoteDataThread();
- }
-
- if (mode != eRNBRunLoopModeExit)
- mode = RNBRunLoopPlatform (remote);
- break;
-
- default:
- mode = eRNBRunLoopModeExit;
- case eRNBRunLoopModeExit:
- break;
- }
- }
-
- remote->StopReadRemoteDataThread ();
- remote->Context().SetProcessID(INVALID_NUB_PROCESS);
- RNBLogSTDOUT ("Exiting.\n");
+ remote->StopReadRemoteDataThread();
+ remote->Context().SetProcessID(INVALID_NUB_PROCESS);
+ RNBLogSTDOUT("Exiting.\n");
- return 0;
+ return 0;
}
Modified: lldb/trunk/tools/debugserver/source/libdebugserver.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/debugserver/source/libdebugserver.cpp?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/tools/debugserver/source/libdebugserver.cpp (original)
+++ lldb/trunk/tools/debugserver/source/libdebugserver.cpp Tue Sep 6 15:57:50 2016
@@ -7,36 +7,34 @@
//
//===----------------------------------------------------------------------===//
-#include <sys/socket.h>
-#include <sys/types.h>
#include <errno.h>
#include <getopt.h>
#include <netinet/in.h>
#include <sys/select.h>
+#include <sys/socket.h>
#include <sys/sysctl.h>
+#include <sys/types.h>
#include "DNB.h"
#include "DNBLog.h"
#include "DNBTimer.h"
#include "PseudoTerminal.h"
#include "RNBContext.h"
+#include "RNBRemote.h"
#include "RNBServices.h"
#include "RNBSocket.h"
-#include "RNBRemote.h"
#include "SysSignal.h"
//----------------------------------------------------------------------
// Run loop modes which determine which run loop function will be called
//----------------------------------------------------------------------
-typedef enum
-{
- eRNBRunLoopModeInvalid = 0,
- eRNBRunLoopModeGetStartModeFromRemoteProtocol,
- eRNBRunLoopModeInferiorExecuting,
- eRNBRunLoopModeExit
+typedef enum {
+ eRNBRunLoopModeInvalid = 0,
+ eRNBRunLoopModeGetStartModeFromRemoteProtocol,
+ eRNBRunLoopModeInferiorExecuting,
+ eRNBRunLoopModeExit
} RNBRunLoopMode;
-
//----------------------------------------------------------------------
// Global Variables
//----------------------------------------------------------------------
@@ -44,9 +42,22 @@ RNBRemoteSP g_remoteSP;
int g_disable_aslr = 0;
int g_isatty = 0;
-#define RNBLogSTDOUT(fmt, ...) do { if (g_isatty) { fprintf(stdout, fmt, ## __VA_ARGS__); } else { _DNBLog(0, fmt, ## __VA_ARGS__); } } while (0)
-#define RNBLogSTDERR(fmt, ...) do { if (g_isatty) { fprintf(stderr, fmt, ## __VA_ARGS__); } else { _DNBLog(0, fmt, ## __VA_ARGS__); } } while (0)
-
+#define RNBLogSTDOUT(fmt, ...) \
+ do { \
+ if (g_isatty) { \
+ fprintf(stdout, fmt, ##__VA_ARGS__); \
+ } else { \
+ _DNBLog(0, fmt, ##__VA_ARGS__); \
+ } \
+ } while (0)
+#define RNBLogSTDERR(fmt, ...) \
+ do { \
+ if (g_isatty) { \
+ fprintf(stderr, fmt, ##__VA_ARGS__); \
+ } else { \
+ _DNBLog(0, fmt, ##__VA_ARGS__); \
+ } \
+ } while (0)
//----------------------------------------------------------------------
// Get our program path and arguments from the remote connection.
@@ -54,74 +65,65 @@ int g_isatty = 0;
// arguments, wait for the new process to finish launching and hit its
// entry point, and then return the run loop mode that should come next.
//----------------------------------------------------------------------
-RNBRunLoopMode
-RNBRunLoopGetStartModeFromRemote (RNBRemoteSP &remoteSP)
-{
- std::string packet;
-
- if (remoteSP.get() != NULL)
- {
- RNBRemote* remote = remoteSP.get();
- RNBContext& ctx = remote->Context();
- uint32_t event_mask = RNBContext::event_read_packet_available;
-
- // Spin waiting to get the A packet.
- while (1)
- {
- DNBLogThreadedIf (LOG_RNB_MAX, "%s ctx.Events().WaitForSetEvents( 0x%08x ) ...",__FUNCTION__, event_mask);
- nub_event_t set_events = ctx.Events().WaitForSetEvents(event_mask);
- DNBLogThreadedIf (LOG_RNB_MAX, "%s ctx.Events().WaitForSetEvents( 0x%08x ) => 0x%08x", __FUNCTION__, event_mask, set_events);
-
- if (set_events & RNBContext::event_read_packet_available)
- {
- rnb_err_t err = rnb_err;
- RNBRemote::PacketEnum type;
-
- err = remote->HandleReceivedPacket (&type);
-
- // check if we tried to attach to a process
- if (type == RNBRemote::vattach || type == RNBRemote::vattachwait)
- {
- if (err == rnb_success)
- return eRNBRunLoopModeInferiorExecuting;
- else
- {
- RNBLogSTDERR ("error: attach failed.");
- return eRNBRunLoopModeExit;
- }
- }
-
-
- if (err == rnb_success)
- {
- DNBLogThreadedIf (LOG_RNB_MINIMAL, "%s Got success...",__FUNCTION__);
- continue;
- }
- else if (err == rnb_not_connected)
- {
- RNBLogSTDERR ("error: connection lost.");
- return eRNBRunLoopModeExit;
- }
- else
- {
- // a catch all for any other gdb remote packets that failed
- DNBLogThreadedIf (LOG_RNB_MINIMAL, "%s Error getting packet.",__FUNCTION__);
- continue;
- }
-
- DNBLogThreadedIf (LOG_RNB_MINIMAL, "#### %s", __FUNCTION__);
- }
- else
- {
- DNBLogThreadedIf (LOG_RNB_MINIMAL, "%s Connection closed before getting \"A\" packet.", __FUNCTION__);
- return eRNBRunLoopModeExit;
- }
+RNBRunLoopMode RNBRunLoopGetStartModeFromRemote(RNBRemoteSP &remoteSP) {
+ std::string packet;
+
+ if (remoteSP.get() != NULL) {
+ RNBRemote *remote = remoteSP.get();
+ RNBContext &ctx = remote->Context();
+ uint32_t event_mask = RNBContext::event_read_packet_available;
+
+ // Spin waiting to get the A packet.
+ while (1) {
+ DNBLogThreadedIf(LOG_RNB_MAX,
+ "%s ctx.Events().WaitForSetEvents( 0x%08x ) ...",
+ __FUNCTION__, event_mask);
+ nub_event_t set_events = ctx.Events().WaitForSetEvents(event_mask);
+ DNBLogThreadedIf(LOG_RNB_MAX,
+ "%s ctx.Events().WaitForSetEvents( 0x%08x ) => 0x%08x",
+ __FUNCTION__, event_mask, set_events);
+
+ if (set_events & RNBContext::event_read_packet_available) {
+ rnb_err_t err = rnb_err;
+ RNBRemote::PacketEnum type;
+
+ err = remote->HandleReceivedPacket(&type);
+
+ // check if we tried to attach to a process
+ if (type == RNBRemote::vattach || type == RNBRemote::vattachwait) {
+ if (err == rnb_success)
+ return eRNBRunLoopModeInferiorExecuting;
+ else {
+ RNBLogSTDERR("error: attach failed.");
+ return eRNBRunLoopModeExit;
+ }
}
+
+ if (err == rnb_success) {
+ DNBLogThreadedIf(LOG_RNB_MINIMAL, "%s Got success...", __FUNCTION__);
+ continue;
+ } else if (err == rnb_not_connected) {
+ RNBLogSTDERR("error: connection lost.");
+ return eRNBRunLoopModeExit;
+ } else {
+ // a catch all for any other gdb remote packets that failed
+ DNBLogThreadedIf(LOG_RNB_MINIMAL, "%s Error getting packet.",
+ __FUNCTION__);
+ continue;
+ }
+
+ DNBLogThreadedIf(LOG_RNB_MINIMAL, "#### %s", __FUNCTION__);
+ } else {
+ DNBLogThreadedIf(LOG_RNB_MINIMAL,
+ "%s Connection closed before getting \"A\" packet.",
+ __FUNCTION__);
+ return eRNBRunLoopModeExit;
+ }
}
- return eRNBRunLoopModeExit;
+ }
+ return eRNBRunLoopModeExit;
}
-
//----------------------------------------------------------------------
// Watch for signals:
// SIGINT: so we can halt our inferior. (disabled for now)
@@ -129,269 +131,253 @@ RNBRunLoopGetStartModeFromRemote (RNBRem
//----------------------------------------------------------------------
nub_process_t g_pid;
int g_sigpipe_received = 0;
-void
-signal_handler(int signo)
-{
- DNBLogThreadedIf (LOG_RNB_MINIMAL, "%s (%s)", __FUNCTION__, SysSignal::Name(signo));
-
- switch (signo)
- {
- // case SIGINT:
- // DNBProcessKill (g_pid, signo);
- // break;
-
- case SIGPIPE:
- g_sigpipe_received = 1;
- break;
- }
+void signal_handler(int signo) {
+ DNBLogThreadedIf(LOG_RNB_MINIMAL, "%s (%s)", __FUNCTION__,
+ SysSignal::Name(signo));
+
+ switch (signo) {
+ // case SIGINT:
+ // DNBProcessKill (g_pid, signo);
+ // break;
+
+ case SIGPIPE:
+ g_sigpipe_received = 1;
+ break;
+ }
}
// Return the new run loop mode based off of the current process state
-RNBRunLoopMode
-HandleProcessStateChange (RNBRemoteSP &remote, bool initialize)
-{
- RNBContext& ctx = remote->Context();
- nub_process_t pid = ctx.ProcessID();
-
- if (pid == INVALID_NUB_PROCESS)
- {
- DNBLogThreadedIf (LOG_RNB_MINIMAL, "#### %s error: pid invalid, exiting...", __FUNCTION__);
- return eRNBRunLoopModeExit;
- }
- nub_state_t pid_state = DNBProcessGetState (pid);
-
- DNBLogThreadedIf (LOG_RNB_MINIMAL, "%s (&remote, initialize=%i) pid_state = %s", __FUNCTION__, (int)initialize, DNBStateAsString (pid_state));
-
- switch (pid_state)
- {
- case eStateInvalid:
- case eStateUnloaded:
- // Something bad happened
- return eRNBRunLoopModeExit;
- break;
-
- case eStateAttaching:
- case eStateLaunching:
- return eRNBRunLoopModeInferiorExecuting;
-
- case eStateSuspended:
- case eStateCrashed:
- case eStateStopped:
- if (initialize == false)
- {
- // Compare the last stop count to our current notion of a stop count
- // to make sure we don't notify more than once for a given stop.
- nub_size_t prev_pid_stop_count = ctx.GetProcessStopCount();
- bool pid_stop_count_changed = ctx.SetProcessStopCount(DNBProcessGetStopCount(pid));
- if (pid_stop_count_changed)
- {
- remote->FlushSTDIO();
-
- if (ctx.GetProcessStopCount() == 1)
- {
- DNBLogThreadedIf (LOG_RNB_MINIMAL, "%s (&remote, initialize=%i) pid_state = %s pid_stop_count %zu (old %zu)) Notify??? no, first stop...", __FUNCTION__, (int)initialize, DNBStateAsString (pid_state), ctx.GetProcessStopCount(), prev_pid_stop_count);
- }
- else
- {
-
- DNBLogThreadedIf (LOG_RNB_MINIMAL, "%s (&remote, initialize=%i) pid_state = %s pid_stop_count %zu (old %zu)) Notify??? YES!!!", __FUNCTION__, (int)initialize, DNBStateAsString (pid_state), ctx.GetProcessStopCount(), prev_pid_stop_count);
- remote->NotifyThatProcessStopped ();
- }
- }
- else
- {
- DNBLogThreadedIf (LOG_RNB_MINIMAL, "%s (&remote, initialize=%i) pid_state = %s pid_stop_count %zu (old %zu)) Notify??? skipping...", __FUNCTION__, (int)initialize, DNBStateAsString (pid_state), ctx.GetProcessStopCount(), prev_pid_stop_count);
- }
- }
- return eRNBRunLoopModeInferiorExecuting;
-
- case eStateStepping:
- case eStateRunning:
- return eRNBRunLoopModeInferiorExecuting;
-
- case eStateExited:
- remote->HandlePacket_last_signal(NULL);
- return eRNBRunLoopModeExit;
- case eStateDetached:
- return eRNBRunLoopModeExit;
-
+RNBRunLoopMode HandleProcessStateChange(RNBRemoteSP &remote, bool initialize) {
+ RNBContext &ctx = remote->Context();
+ nub_process_t pid = ctx.ProcessID();
+
+ if (pid == INVALID_NUB_PROCESS) {
+ DNBLogThreadedIf(LOG_RNB_MINIMAL, "#### %s error: pid invalid, exiting...",
+ __FUNCTION__);
+ return eRNBRunLoopModeExit;
+ }
+ nub_state_t pid_state = DNBProcessGetState(pid);
+
+ DNBLogThreadedIf(LOG_RNB_MINIMAL,
+ "%s (&remote, initialize=%i) pid_state = %s", __FUNCTION__,
+ (int)initialize, DNBStateAsString(pid_state));
+
+ switch (pid_state) {
+ case eStateInvalid:
+ case eStateUnloaded:
+ // Something bad happened
+ return eRNBRunLoopModeExit;
+ break;
+
+ case eStateAttaching:
+ case eStateLaunching:
+ return eRNBRunLoopModeInferiorExecuting;
+
+ case eStateSuspended:
+ case eStateCrashed:
+ case eStateStopped:
+ if (initialize == false) {
+ // Compare the last stop count to our current notion of a stop count
+ // to make sure we don't notify more than once for a given stop.
+ nub_size_t prev_pid_stop_count = ctx.GetProcessStopCount();
+ bool pid_stop_count_changed =
+ ctx.SetProcessStopCount(DNBProcessGetStopCount(pid));
+ if (pid_stop_count_changed) {
+ remote->FlushSTDIO();
+
+ if (ctx.GetProcessStopCount() == 1) {
+ DNBLogThreadedIf(
+ LOG_RNB_MINIMAL, "%s (&remote, initialize=%i) pid_state = %s "
+ "pid_stop_count %zu (old %zu)) Notify??? no, "
+ "first stop...",
+ __FUNCTION__, (int)initialize, DNBStateAsString(pid_state),
+ ctx.GetProcessStopCount(), prev_pid_stop_count);
+ } else {
+
+ DNBLogThreadedIf(
+ LOG_RNB_MINIMAL, "%s (&remote, initialize=%i) pid_state = %s "
+ "pid_stop_count %zu (old %zu)) Notify??? YES!!!",
+ __FUNCTION__, (int)initialize, DNBStateAsString(pid_state),
+ ctx.GetProcessStopCount(), prev_pid_stop_count);
+ remote->NotifyThatProcessStopped();
+ }
+ } else {
+ DNBLogThreadedIf(LOG_RNB_MINIMAL, "%s (&remote, initialize=%i) "
+ "pid_state = %s pid_stop_count %zu "
+ "(old %zu)) Notify??? skipping...",
+ __FUNCTION__, (int)initialize,
+ DNBStateAsString(pid_state), ctx.GetProcessStopCount(),
+ prev_pid_stop_count);
+ }
}
-
- // Catch all...
- return eRNBRunLoopModeExit;
+ return eRNBRunLoopModeInferiorExecuting;
+
+ case eStateStepping:
+ case eStateRunning:
+ return eRNBRunLoopModeInferiorExecuting;
+
+ case eStateExited:
+ remote->HandlePacket_last_signal(NULL);
+ return eRNBRunLoopModeExit;
+ case eStateDetached:
+ return eRNBRunLoopModeExit;
+ }
+
+ // Catch all...
+ return eRNBRunLoopModeExit;
}
// This function handles the case where our inferior program is stopped and
// we are waiting for gdb remote protocol packets. When a packet occurs that
// makes the inferior run, we need to leave this function with a new state
// as the return code.
-RNBRunLoopMode
-RNBRunLoopInferiorExecuting (RNBRemoteSP &remote)
-{
- DNBLogThreadedIf (LOG_RNB_MINIMAL, "#### %s", __FUNCTION__);
- RNBContext& ctx = remote->Context();
-
- // Init our mode and set 'is_running' based on the current process state
- RNBRunLoopMode mode = HandleProcessStateChange (remote, true);
-
- while (ctx.ProcessID() != INVALID_NUB_PROCESS)
- {
-
- std::string set_events_str;
- uint32_t event_mask = ctx.NormalEventBits();
-
- if (!ctx.ProcessStateRunning())
- {
- // Clear the stdio bits if we are not running so we don't send any async packets
- event_mask &= ~RNBContext::event_proc_stdio_available;
+RNBRunLoopMode RNBRunLoopInferiorExecuting(RNBRemoteSP &remote) {
+ DNBLogThreadedIf(LOG_RNB_MINIMAL, "#### %s", __FUNCTION__);
+ RNBContext &ctx = remote->Context();
+
+ // Init our mode and set 'is_running' based on the current process state
+ RNBRunLoopMode mode = HandleProcessStateChange(remote, true);
+
+ while (ctx.ProcessID() != INVALID_NUB_PROCESS) {
+
+ std::string set_events_str;
+ uint32_t event_mask = ctx.NormalEventBits();
+
+ if (!ctx.ProcessStateRunning()) {
+ // Clear the stdio bits if we are not running so we don't send any async
+ // packets
+ event_mask &= ~RNBContext::event_proc_stdio_available;
+ }
+
+ // We want to make sure we consume all process state changes and have
+ // whomever is notifying us to wait for us to reset the event bit before
+ // continuing.
+ // ctx.Events().SetResetAckMask (RNBContext::event_proc_state_changed);
+
+ DNBLogThreadedIf(LOG_RNB_EVENTS,
+ "%s ctx.Events().WaitForSetEvents(0x%08x) ...",
+ __FUNCTION__, event_mask);
+ nub_event_t set_events = ctx.Events().WaitForSetEvents(event_mask);
+ DNBLogThreadedIf(LOG_RNB_EVENTS,
+ "%s ctx.Events().WaitForSetEvents(0x%08x) => 0x%08x (%s)",
+ __FUNCTION__, event_mask, set_events,
+ ctx.EventsAsString(set_events, set_events_str));
+
+ if (set_events) {
+ if ((set_events & RNBContext::event_proc_thread_exiting) ||
+ (set_events & RNBContext::event_proc_stdio_available)) {
+ remote->FlushSTDIO();
+ }
+
+ if (set_events & RNBContext::event_read_packet_available) {
+ // handleReceivedPacket will take care of resetting the
+ // event_read_packet_available events when there are no more...
+ set_events ^= RNBContext::event_read_packet_available;
+
+ if (ctx.ProcessStateRunning()) {
+ if (remote->HandleAsyncPacket() == rnb_not_connected) {
+ // TODO: connect again? Exit?
+ }
+ } else {
+ if (remote->HandleReceivedPacket() == rnb_not_connected) {
+ // TODO: connect again? Exit?
+ }
}
-
- // We want to make sure we consume all process state changes and have
- // whomever is notifying us to wait for us to reset the event bit before
- // continuing.
- //ctx.Events().SetResetAckMask (RNBContext::event_proc_state_changed);
-
- DNBLogThreadedIf (LOG_RNB_EVENTS, "%s ctx.Events().WaitForSetEvents(0x%08x) ...",__FUNCTION__, event_mask);
- nub_event_t set_events = ctx.Events().WaitForSetEvents(event_mask);
- DNBLogThreadedIf (LOG_RNB_EVENTS, "%s ctx.Events().WaitForSetEvents(0x%08x) => 0x%08x (%s)",__FUNCTION__, event_mask, set_events, ctx.EventsAsString(set_events, set_events_str));
-
- if (set_events)
- {
- if ((set_events & RNBContext::event_proc_thread_exiting) ||
- (set_events & RNBContext::event_proc_stdio_available))
- {
- remote->FlushSTDIO();
- }
-
- if (set_events & RNBContext::event_read_packet_available)
- {
- // handleReceivedPacket will take care of resetting the
- // event_read_packet_available events when there are no more...
- set_events ^= RNBContext::event_read_packet_available;
-
- if (ctx.ProcessStateRunning())
- {
- if (remote->HandleAsyncPacket() == rnb_not_connected)
- {
- // TODO: connect again? Exit?
- }
- }
- else
- {
- if (remote->HandleReceivedPacket() == rnb_not_connected)
- {
- // TODO: connect again? Exit?
- }
- }
- }
-
- if (set_events & RNBContext::event_proc_state_changed)
- {
- mode = HandleProcessStateChange (remote, false);
- ctx.Events().ResetEvents(RNBContext::event_proc_state_changed);
- set_events ^= RNBContext::event_proc_state_changed;
- }
-
- if (set_events & RNBContext::event_proc_thread_exiting)
- {
- mode = eRNBRunLoopModeExit;
- }
-
- if (set_events & RNBContext::event_read_thread_exiting)
- {
- // Out remote packet receiving thread exited, exit for now.
- if (ctx.HasValidProcessID())
- {
- // TODO: We should add code that will leave the current process
- // in its current state and listen for another connection...
- if (ctx.ProcessStateRunning())
- {
- DNBProcessKill (ctx.ProcessID());
- }
- }
- mode = eRNBRunLoopModeExit;
- }
+ }
+
+ if (set_events & RNBContext::event_proc_state_changed) {
+ mode = HandleProcessStateChange(remote, false);
+ ctx.Events().ResetEvents(RNBContext::event_proc_state_changed);
+ set_events ^= RNBContext::event_proc_state_changed;
+ }
+
+ if (set_events & RNBContext::event_proc_thread_exiting) {
+ mode = eRNBRunLoopModeExit;
+ }
+
+ if (set_events & RNBContext::event_read_thread_exiting) {
+ // Out remote packet receiving thread exited, exit for now.
+ if (ctx.HasValidProcessID()) {
+ // TODO: We should add code that will leave the current process
+ // in its current state and listen for another connection...
+ if (ctx.ProcessStateRunning()) {
+ DNBProcessKill(ctx.ProcessID());
+ }
}
-
- // Reset all event bits that weren't reset for now...
- if (set_events != 0)
- ctx.Events().ResetEvents(set_events);
-
- if (mode != eRNBRunLoopModeInferiorExecuting)
- break;
+ mode = eRNBRunLoopModeExit;
+ }
}
-
- return mode;
+
+ // Reset all event bits that weren't reset for now...
+ if (set_events != 0)
+ ctx.Events().ResetEvents(set_events);
+
+ if (mode != eRNBRunLoopModeInferiorExecuting)
+ break;
+ }
+
+ return mode;
}
-void
-ASLLogCallback(void *baton, uint32_t flags, const char *format, va_list args)
-{
+void ASLLogCallback(void *baton, uint32_t flags, const char *format,
+ va_list args) {
#if 0
vprintf(format, args);
#endif
}
-extern "C" int
-debug_server_main(int fd)
-{
+extern "C" int debug_server_main(int fd) {
#if 1
- g_isatty = 0;
+ g_isatty = 0;
#else
- g_isatty = ::isatty (STDIN_FILENO);
+ g_isatty = ::isatty(STDIN_FILENO);
- DNBLogSetDebug(1);
- DNBLogSetVerbose(1);
- DNBLogSetLogMask(-1);
- DNBLogSetLogCallback(ASLLogCallback, NULL);
+ DNBLogSetDebug(1);
+ DNBLogSetVerbose(1);
+ DNBLogSetLogMask(-1);
+ DNBLogSetLogCallback(ASLLogCallback, NULL);
#endif
-
- signal (SIGPIPE, signal_handler);
-
- g_remoteSP.reset (new RNBRemote);
-
- RNBRemote *remote = g_remoteSP.get();
- if (remote == NULL)
- {
- RNBLogSTDERR ("error: failed to create a remote connection class\n");
- return -1;
- }
-
-
- RNBRunLoopMode mode = eRNBRunLoopModeGetStartModeFromRemoteProtocol;
-
- while (mode != eRNBRunLoopModeExit)
- {
- switch (mode)
- {
- case eRNBRunLoopModeGetStartModeFromRemoteProtocol:
- if (g_remoteSP->Comm().useFD(fd) == rnb_success) {
- RNBLogSTDOUT("Starting remote data thread.\n");
- g_remoteSP->StartReadRemoteDataThread();
-
- RNBLogSTDOUT("Waiting for start mode from remote.\n");
- mode = RNBRunLoopGetStartModeFromRemote(g_remoteSP);
- }
- else
- {
- mode = eRNBRunLoopModeExit;
- }
- break;
-
- case eRNBRunLoopModeInferiorExecuting:
- mode = RNBRunLoopInferiorExecuting(g_remoteSP);
- break;
-
- default:
- mode = eRNBRunLoopModeExit;
- break;
-
- case eRNBRunLoopModeExit:
- break;
- }
+
+ signal(SIGPIPE, signal_handler);
+
+ g_remoteSP.reset(new RNBRemote);
+
+ RNBRemote *remote = g_remoteSP.get();
+ if (remote == NULL) {
+ RNBLogSTDERR("error: failed to create a remote connection class\n");
+ return -1;
+ }
+
+ RNBRunLoopMode mode = eRNBRunLoopModeGetStartModeFromRemoteProtocol;
+
+ while (mode != eRNBRunLoopModeExit) {
+ switch (mode) {
+ case eRNBRunLoopModeGetStartModeFromRemoteProtocol:
+ if (g_remoteSP->Comm().useFD(fd) == rnb_success) {
+ RNBLogSTDOUT("Starting remote data thread.\n");
+ g_remoteSP->StartReadRemoteDataThread();
+
+ RNBLogSTDOUT("Waiting for start mode from remote.\n");
+ mode = RNBRunLoopGetStartModeFromRemote(g_remoteSP);
+ } else {
+ mode = eRNBRunLoopModeExit;
+ }
+ break;
+
+ case eRNBRunLoopModeInferiorExecuting:
+ mode = RNBRunLoopInferiorExecuting(g_remoteSP);
+ break;
+
+ default:
+ mode = eRNBRunLoopModeExit;
+ break;
+
+ case eRNBRunLoopModeExit:
+ break;
}
-
- g_remoteSP->StopReadRemoteDataThread ();
- g_remoteSP->Context().SetProcessID(INVALID_NUB_PROCESS);
-
- return 0;
+ }
+
+ g_remoteSP->StopReadRemoteDataThread();
+ g_remoteSP->Context().SetProcessID(INVALID_NUB_PROCESS);
+
+ return 0;
}
Modified: lldb/trunk/tools/driver/Driver.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/driver/Driver.cpp?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/tools/driver/Driver.cpp (original)
+++ lldb/trunk/tools/driver/Driver.cpp Tue Sep 6 15:57:50 2016
@@ -9,16 +9,16 @@
#include "Driver.h"
+#include <fcntl.h>
+#include <limits.h>
#include <stdio.h>
-#include <string.h>
#include <stdlib.h>
-#include <limits.h>
-#include <fcntl.h>
+#include <string.h>
// Includes for pipe()
#if defined(_WIN32)
-#include <io.h>
#include <fcntl.h>
+#include <io.h>
#elif defined(__ANDROID_NDK__)
#include <errno.h>
#else
@@ -50,7 +50,7 @@
using namespace lldb;
-static void reset_stdin_termios ();
+static void reset_stdin_termios();
static bool g_old_stdin_termios_is_valid = false;
static struct termios g_old_stdin_termios;
@@ -58,1253 +58,1155 @@ static Driver *g_driver = NULL;
// In the Driver::MainLoop, we change the terminal settings. This function is
// added as an atexit handler to make sure we clean them up.
-static void
-reset_stdin_termios ()
-{
- if (g_old_stdin_termios_is_valid)
- {
- g_old_stdin_termios_is_valid = false;
- ::tcsetattr (STDIN_FILENO, TCSANOW, &g_old_stdin_termios);
- }
-}
-
-typedef struct
-{
- uint32_t usage_mask; // Used to mark options that can be used together. If (1 << n & usage_mask) != 0
- // then this option belongs to option set n.
- bool required; // This option is required (in the current usage level)
- const char * long_option; // Full name for this option.
- int short_option; // Single character for this option.
- int option_has_arg; // no_argument, required_argument or optional_argument
- uint32_t completion_type; // Cookie the option class can use to do define the argument completion.
- lldb::CommandArgumentType argument_type; // Type of argument this option takes
- const char * usage_text; // Full text explaining what this options does and what (if any) argument to
- // pass it.
+static void reset_stdin_termios() {
+ if (g_old_stdin_termios_is_valid) {
+ g_old_stdin_termios_is_valid = false;
+ ::tcsetattr(STDIN_FILENO, TCSANOW, &g_old_stdin_termios);
+ }
+}
+
+typedef struct {
+ uint32_t usage_mask; // Used to mark options that can be used together. If (1
+ // << n & usage_mask) != 0
+ // then this option belongs to option set n.
+ bool required; // This option is required (in the current usage level)
+ const char *long_option; // Full name for this option.
+ int short_option; // Single character for this option.
+ int option_has_arg; // no_argument, required_argument or optional_argument
+ uint32_t completion_type; // Cookie the option class can use to do define the
+ // argument completion.
+ lldb::CommandArgumentType argument_type; // Type of argument this option takes
+ const char *usage_text; // Full text explaining what this options does and
+ // what (if any) argument to
+ // pass it.
} OptionDefinition;
-#define LLDB_3_TO_5 LLDB_OPT_SET_3|LLDB_OPT_SET_4|LLDB_OPT_SET_5
-#define LLDB_4_TO_5 LLDB_OPT_SET_4|LLDB_OPT_SET_5
+#define LLDB_3_TO_5 LLDB_OPT_SET_3 | LLDB_OPT_SET_4 | LLDB_OPT_SET_5
+#define LLDB_4_TO_5 LLDB_OPT_SET_4 | LLDB_OPT_SET_5
-static OptionDefinition g_options[] =
-{
- { LLDB_OPT_SET_1, true , "help" , 'h', no_argument , 0, eArgTypeNone,
- "Prints out the usage information for the LLDB debugger." },
- { LLDB_OPT_SET_2, true , "version" , 'v', no_argument , 0, eArgTypeNone,
- "Prints out the current version number of the LLDB debugger." },
- { LLDB_OPT_SET_3, true , "arch" , 'a', required_argument, 0, eArgTypeArchitecture,
- "Tells the debugger to use the specified architecture when starting and running the program. <architecture> must "
- "be one of the architectures for which the program was compiled." },
- { LLDB_OPT_SET_3, true , "file" , 'f', required_argument, 0, eArgTypeFilename,
- "Tells the debugger to use the file <filename> as the program to be debugged." },
- { LLDB_OPT_SET_3, false, "core" , 'c', required_argument, 0, eArgTypeFilename,
- "Tells the debugger to use the fullpath to <path> as the core file." },
- { LLDB_OPT_SET_5, true , "attach-pid" , 'p', required_argument, 0, eArgTypePid,
- "Tells the debugger to attach to a process with the given pid." },
- { LLDB_OPT_SET_4, true , "attach-name" , 'n', required_argument, 0, eArgTypeProcessName,
- "Tells the debugger to attach to a process with the given name." },
- { LLDB_OPT_SET_4, true , "wait-for" , 'w', no_argument , 0, eArgTypeNone,
- "Tells the debugger to wait for a process with the given pid or name to launch before attaching." },
- { LLDB_3_TO_5, false, "source" , 's', required_argument, 0, eArgTypeFilename,
- "Tells the debugger to read in and execute the lldb commands in the given file, after any file provided on the command line has been loaded." },
- { LLDB_3_TO_5, false, "one-line" , 'o', required_argument, 0, eArgTypeNone,
- "Tells the debugger to execute this one-line lldb command after any file provided on the command line has been loaded." },
- { LLDB_3_TO_5, false, "source-before-file" , 'S', required_argument, 0, eArgTypeFilename,
- "Tells the debugger to read in and execute the lldb commands in the given file, before any file provided on the command line has been loaded." },
- { LLDB_3_TO_5, false, "one-line-before-file" , 'O', required_argument, 0, eArgTypeNone,
- "Tells the debugger to execute this one-line lldb command before any file provided on the command line has been loaded." },
- { LLDB_3_TO_5, false, "one-line-on-crash" , 'k', required_argument, 0, eArgTypeNone,
- "When in batch mode, tells the debugger to execute this one-line lldb command if the target crashes." },
- { LLDB_3_TO_5, false, "source-on-crash" , 'K', required_argument, 0, eArgTypeFilename,
- "When in batch mode, tells the debugger to source this file of lldb commands if the target crashes." },
- { LLDB_3_TO_5, false, "source-quietly" , 'Q', no_argument , 0, eArgTypeNone,
- "Tells the debugger to execute this one-line lldb command before any file provided on the command line has been loaded." },
- { LLDB_3_TO_5, false, "batch" , 'b', no_argument , 0, eArgTypeNone,
- "Tells the debugger to running the commands from -s, -S, -o & -O, and then quit. However if any run command stopped due to a signal or crash, "
- "the debugger will return to the interactive prompt at the place of the crash." },
- { LLDB_3_TO_5, false, "editor" , 'e', no_argument , 0, eArgTypeNone,
- "Tells the debugger to open source files using the host's \"external editor\" mechanism." },
- { LLDB_3_TO_5, false, "no-lldbinit" , 'x', no_argument , 0, eArgTypeNone,
- "Do not automatically parse any '.lldbinit' files." },
- { LLDB_3_TO_5, false, "no-use-colors" , 'X', no_argument , 0, eArgTypeNone,
- "Do not use colors." },
- { LLDB_OPT_SET_6, true , "python-path" , 'P', no_argument , 0, eArgTypeNone,
- "Prints out the path to the lldb.py file for this version of lldb." },
- { LLDB_3_TO_5, false, "script-language", 'l', required_argument, 0, eArgTypeScriptLang,
- "Tells the debugger to use the specified scripting language for user-defined scripts, rather than the default. "
- "Valid scripting languages that can be specified include Python, Perl, Ruby and Tcl. Currently only the Python "
- "extensions have been implemented." },
- { LLDB_3_TO_5, false, "debug" , 'd', no_argument , 0, eArgTypeNone,
- "Tells the debugger to print out extra information for debugging itself." },
- { LLDB_OPT_SET_7, true , "repl" , 'r', optional_argument, 0, eArgTypeNone,
- "Runs lldb in REPL mode with a stub process." },
- { LLDB_OPT_SET_7, true , "repl-language" , 'R', required_argument, 0, eArgTypeNone,
- "Chooses the language for the REPL." },
- { 0, false, NULL , 0 , 0 , 0, eArgTypeNone, NULL }
-};
+static OptionDefinition g_options[] = {
+ {LLDB_OPT_SET_1, true, "help", 'h', no_argument, 0, eArgTypeNone,
+ "Prints out the usage information for the LLDB debugger."},
+ {LLDB_OPT_SET_2, true, "version", 'v', no_argument, 0, eArgTypeNone,
+ "Prints out the current version number of the LLDB debugger."},
+ {LLDB_OPT_SET_3, true, "arch", 'a', required_argument, 0,
+ eArgTypeArchitecture,
+ "Tells the debugger to use the specified architecture when starting and "
+ "running the program. <architecture> must "
+ "be one of the architectures for which the program was compiled."},
+ {LLDB_OPT_SET_3, true, "file", 'f', required_argument, 0, eArgTypeFilename,
+ "Tells the debugger to use the file <filename> as the program to be "
+ "debugged."},
+ {LLDB_OPT_SET_3, false, "core", 'c', required_argument, 0, eArgTypeFilename,
+ "Tells the debugger to use the fullpath to <path> as the core file."},
+ {LLDB_OPT_SET_5, true, "attach-pid", 'p', required_argument, 0, eArgTypePid,
+ "Tells the debugger to attach to a process with the given pid."},
+ {LLDB_OPT_SET_4, true, "attach-name", 'n', required_argument, 0,
+ eArgTypeProcessName,
+ "Tells the debugger to attach to a process with the given name."},
+ {LLDB_OPT_SET_4, true, "wait-for", 'w', no_argument, 0, eArgTypeNone,
+ "Tells the debugger to wait for a process with the given pid or name to "
+ "launch before attaching."},
+ {LLDB_3_TO_5, false, "source", 's', required_argument, 0, eArgTypeFilename,
+ "Tells the debugger to read in and execute the lldb commands in the given "
+ "file, after any file provided on the command line has been loaded."},
+ {LLDB_3_TO_5, false, "one-line", 'o', required_argument, 0, eArgTypeNone,
+ "Tells the debugger to execute this one-line lldb command after any file "
+ "provided on the command line has been loaded."},
+ {LLDB_3_TO_5, false, "source-before-file", 'S', required_argument, 0,
+ eArgTypeFilename, "Tells the debugger to read in and execute the lldb "
+ "commands in the given file, before any file provided "
+ "on the command line has been loaded."},
+ {LLDB_3_TO_5, false, "one-line-before-file", 'O', required_argument, 0,
+ eArgTypeNone, "Tells the debugger to execute this one-line lldb command "
+ "before any file provided on the command line has been "
+ "loaded."},
+ {LLDB_3_TO_5, false, "one-line-on-crash", 'k', required_argument, 0,
+ eArgTypeNone, "When in batch mode, tells the debugger to execute this "
+ "one-line lldb command if the target crashes."},
+ {LLDB_3_TO_5, false, "source-on-crash", 'K', required_argument, 0,
+ eArgTypeFilename, "When in batch mode, tells the debugger to source this "
+ "file of lldb commands if the target crashes."},
+ {LLDB_3_TO_5, false, "source-quietly", 'Q', no_argument, 0, eArgTypeNone,
+ "Tells the debugger to execute this one-line lldb command before any file "
+ "provided on the command line has been loaded."},
+ {LLDB_3_TO_5, false, "batch", 'b', no_argument, 0, eArgTypeNone,
+ "Tells the debugger to running the commands from -s, -S, -o & -O, and "
+ "then quit. However if any run command stopped due to a signal or crash, "
+ "the debugger will return to the interactive prompt at the place of the "
+ "crash."},
+ {LLDB_3_TO_5, false, "editor", 'e', no_argument, 0, eArgTypeNone,
+ "Tells the debugger to open source files using the host's \"external "
+ "editor\" mechanism."},
+ {LLDB_3_TO_5, false, "no-lldbinit", 'x', no_argument, 0, eArgTypeNone,
+ "Do not automatically parse any '.lldbinit' files."},
+ {LLDB_3_TO_5, false, "no-use-colors", 'X', no_argument, 0, eArgTypeNone,
+ "Do not use colors."},
+ {LLDB_OPT_SET_6, true, "python-path", 'P', no_argument, 0, eArgTypeNone,
+ "Prints out the path to the lldb.py file for this version of lldb."},
+ {LLDB_3_TO_5, false, "script-language", 'l', required_argument, 0,
+ eArgTypeScriptLang,
+ "Tells the debugger to use the specified scripting language for "
+ "user-defined scripts, rather than the default. "
+ "Valid scripting languages that can be specified include Python, Perl, "
+ "Ruby and Tcl. Currently only the Python "
+ "extensions have been implemented."},
+ {LLDB_3_TO_5, false, "debug", 'd', no_argument, 0, eArgTypeNone,
+ "Tells the debugger to print out extra information for debugging itself."},
+ {LLDB_OPT_SET_7, true, "repl", 'r', optional_argument, 0, eArgTypeNone,
+ "Runs lldb in REPL mode with a stub process."},
+ {LLDB_OPT_SET_7, true, "repl-language", 'R', required_argument, 0,
+ eArgTypeNone, "Chooses the language for the REPL."},
+ {0, false, NULL, 0, 0, 0, eArgTypeNone, NULL}};
static const uint32_t last_option_set_with_args = 2;
-Driver::Driver () :
- SBBroadcaster ("Driver"),
- m_debugger (SBDebugger::Create(false)),
- m_option_data ()
-{
- // We want to be able to handle CTRL+D in the terminal to have it terminate
- // certain input
- m_debugger.SetCloseInputOnEOF (false);
- g_driver = this;
-}
-
-Driver::~Driver ()
-{
- g_driver = NULL;
-}
-
-
-// This function takes INDENT, which tells how many spaces to output at the front
-// of each line; TEXT, which is the text that is to be output. It outputs the
-// text, on multiple lines if necessary, to RESULT, with INDENT spaces at the
-// front of each line. It breaks lines on spaces, tabs or newlines, shortening
-// the line if necessary to not break in the middle of a word. It assumes that
+Driver::Driver()
+ : SBBroadcaster("Driver"), m_debugger(SBDebugger::Create(false)),
+ m_option_data() {
+ // We want to be able to handle CTRL+D in the terminal to have it terminate
+ // certain input
+ m_debugger.SetCloseInputOnEOF(false);
+ g_driver = this;
+}
+
+Driver::~Driver() { g_driver = NULL; }
+
+// This function takes INDENT, which tells how many spaces to output at the
+// front
+// of each line; TEXT, which is the text that is to be output. It outputs the
+// text, on multiple lines if necessary, to RESULT, with INDENT spaces at the
+// front of each line. It breaks lines on spaces, tabs or newlines, shortening
+// the line if necessary to not break in the middle of a word. It assumes that
// each output line should contain a maximum of OUTPUT_MAX_COLUMNS characters.
-void
-OutputFormattedUsageText (FILE *out, int indent, const char *text, int output_max_columns)
-{
- int len = strlen (text);
- std::string text_string (text);
-
- // Force indentation to be reasonable.
- if (indent >= output_max_columns)
- indent = 0;
-
- // Will it all fit on one line?
-
- if (len + indent < output_max_columns)
- // Output as a single line
- fprintf (out, "%*s%s\n", indent, "", text);
- else
- {
- // We need to break it up into multiple lines.
- int text_width = output_max_columns - indent - 1;
- int start = 0;
- int end = start;
- int final_end = len;
- int sub_len;
-
- while (end < final_end)
- {
- // Dont start the 'text' on a space, since we're already outputting the indentation.
- while ((start < final_end) && (text[start] == ' '))
- start++;
-
- end = start + text_width;
- if (end > final_end)
- end = final_end;
- else
- {
- // If we're not at the end of the text, make sure we break the line on white space.
- while (end > start
- && text[end] != ' ' && text[end] != '\t' && text[end] != '\n')
- end--;
- }
- sub_len = end - start;
- std::string substring = text_string.substr (start, sub_len);
- fprintf (out, "%*s%s\n", indent, "", substring.c_str());
- start = end + 1;
- }
- }
-}
-
-void
-ShowUsage (FILE *out, OptionDefinition *option_table, Driver::OptionData data)
-{
- uint32_t screen_width = 80;
- uint32_t indent_level = 0;
- const char *name = "lldb";
-
- fprintf (out, "\nUsage:\n\n");
-
- indent_level += 2;
-
-
- // First, show each usage level set of options, e.g. <cmd> [options-for-level-0]
- // <cmd> [options-for-level-1]
- // etc.
-
- uint32_t num_options;
- uint32_t num_option_sets = 0;
-
- for (num_options = 0; option_table[num_options].long_option != NULL; ++num_options)
- {
- uint32_t this_usage_mask = option_table[num_options].usage_mask;
- if (this_usage_mask == LLDB_OPT_SET_ALL)
- {
- if (num_option_sets == 0)
- num_option_sets = 1;
- }
- else
- {
- for (uint32_t j = 0; j < LLDB_MAX_NUM_OPTION_SETS; j++)
- {
- if (this_usage_mask & 1 << j)
- {
- if (num_option_sets <= j)
- num_option_sets = j + 1;
- }
- }
- }
- }
-
- for (uint32_t opt_set = 0; opt_set < num_option_sets; opt_set++)
- {
- uint32_t opt_set_mask;
-
- opt_set_mask = 1 << opt_set;
-
- if (opt_set > 0)
- fprintf (out, "\n");
- fprintf (out, "%*s%s", indent_level, "", name);
- bool is_help_line = false;
-
- for (uint32_t i = 0; i < num_options; ++i)
- {
- if (option_table[i].usage_mask & opt_set_mask)
- {
- CommandArgumentType arg_type = option_table[i].argument_type;
- const char *arg_name = SBCommandInterpreter::GetArgumentTypeAsCString (arg_type);
- // This is a bit of a hack, but there's no way to say certain options don't have arguments yet...
- // so we do it by hand here.
- if (option_table[i].short_option == 'h')
- is_help_line = true;
-
- if (option_table[i].required)
- {
- if (option_table[i].option_has_arg == required_argument)
- fprintf (out, " -%c <%s>", option_table[i].short_option, arg_name);
- else if (option_table[i].option_has_arg == optional_argument)
- fprintf (out, " -%c [<%s>]", option_table[i].short_option, arg_name);
- else
- fprintf (out, " -%c", option_table[i].short_option);
- }
- else
- {
- if (option_table[i].option_has_arg == required_argument)
- fprintf (out, " [-%c <%s>]", option_table[i].short_option, arg_name);
- else if (option_table[i].option_has_arg == optional_argument)
- fprintf (out, " [-%c [<%s>]]", option_table[i].short_option, arg_name);
- else
- fprintf (out, " [-%c]", option_table[i].short_option);
- }
- }
- }
- if (!is_help_line && (opt_set <= last_option_set_with_args))
- fprintf (out, " [[--] <PROGRAM-ARG-1> [<PROGRAM_ARG-2> ...]]");
- }
-
- fprintf (out, "\n\n");
-
- // Now print out all the detailed information about the various options: long form, short form and help text:
- // -- long_name <argument>
- // - short <argument>
- // help text
-
- // This variable is used to keep track of which options' info we've printed out, because some options can be in
- // more than one usage level, but we only want to print the long form of its information once.
-
- Driver::OptionData::OptionSet options_seen;
- Driver::OptionData::OptionSet::iterator pos;
-
- indent_level += 5;
-
- for (uint32_t i = 0; i < num_options; ++i)
- {
- // Only print this option if we haven't already seen it.
- pos = options_seen.find (option_table[i].short_option);
- if (pos == options_seen.end())
- {
- CommandArgumentType arg_type = option_table[i].argument_type;
- const char *arg_name = SBCommandInterpreter::GetArgumentTypeAsCString (arg_type);
-
- options_seen.insert (option_table[i].short_option);
- fprintf (out, "%*s-%c ", indent_level, "", option_table[i].short_option);
- if (arg_type != eArgTypeNone)
- fprintf (out, "<%s>", arg_name);
- fprintf (out, "\n");
- fprintf (out, "%*s--%s ", indent_level, "", option_table[i].long_option);
- if (arg_type != eArgTypeNone)
- fprintf (out, "<%s>", arg_name);
- fprintf (out, "\n");
- indent_level += 5;
- OutputFormattedUsageText (out, indent_level, option_table[i].usage_text, screen_width);
- indent_level -= 5;
- fprintf (out, "\n");
- }
- }
-
- indent_level -= 5;
-
- fprintf (out, "\n%*sNotes:\n",
- indent_level, "");
- indent_level += 5;
-
- fprintf (out, "\n%*sMultiple \"-s\" and \"-o\" options can be provided. They will be processed"
- "\n%*sfrom left to right in order, with the source files and commands"
- "\n%*sinterleaved. The same is true of the \"-S\" and \"-O\" options. The before"
- "\n%*sfile and after file sets can intermixed freely, the command parser will"
- "\n%*ssort them out. The order of the file specifiers (\"-c\", \"-f\", etc.) is"
- "\n%*snot significant in this regard.\n\n",
- indent_level, "",
- indent_level, "",
- indent_level, "",
- indent_level, "",
- indent_level, "",
- indent_level, "");
-
- fprintf (out, "\n%*sIf you don't provide -f then the first argument will be the file to be"
- "\n%*sdebugged which means that '%s -- <filename> [<ARG1> [<ARG2>]]' also"
- "\n%*sworks. But remember to end the options with \"--\" if any of your"
- "\n%*sarguments have a \"-\" in them.\n\n",
- indent_level, "",
- indent_level, "",
- name,
- indent_level, "",
- indent_level, "");
-}
-
-void
-BuildGetOptTable (OptionDefinition *expanded_option_table, std::vector<struct option> &getopt_table,
- uint32_t num_options)
-{
- if (num_options == 0)
- return;
-
- uint32_t i;
- uint32_t j;
- std::bitset<256> option_seen;
-
- getopt_table.resize (num_options + 1);
-
- for (i = 0, j = 0; i < num_options; ++i)
- {
- char short_opt = expanded_option_table[i].short_option;
-
- if (option_seen.test(short_opt) == false)
- {
- getopt_table[j].name = expanded_option_table[i].long_option;
- getopt_table[j].has_arg = expanded_option_table[i].option_has_arg;
- getopt_table[j].flag = NULL;
- getopt_table[j].val = expanded_option_table[i].short_option;
- option_seen.set(short_opt);
- ++j;
- }
- }
-
- getopt_table[j].name = NULL;
- getopt_table[j].has_arg = 0;
- getopt_table[j].flag = NULL;
- getopt_table[j].val = 0;
-
-}
-
-Driver::OptionData::OptionData () :
- m_args(),
- m_script_lang (lldb::eScriptLanguageDefault),
- m_core_file (),
- m_crash_log (),
- m_initial_commands (),
- m_after_file_commands (),
- m_after_crash_commands(),
- m_debug_mode (false),
- m_source_quietly(false),
- m_print_version (false),
- m_print_python_path (false),
- m_print_help (false),
- m_wait_for(false),
- m_repl (false),
- m_repl_lang (eLanguageTypeUnknown),
- m_repl_options (),
- m_process_name(),
- m_process_pid(LLDB_INVALID_PROCESS_ID),
- m_use_external_editor(false),
- m_batch(false),
- m_seen_options()
-{
-}
-
-Driver::OptionData::~OptionData ()
-{
-}
-
-void
-Driver::OptionData::Clear ()
-{
- m_args.clear ();
- m_script_lang = lldb::eScriptLanguageDefault;
- m_initial_commands.clear ();
- m_after_file_commands.clear ();
-
- // If there is a local .lldbinit, add that to the
- // list of things to be sourced, if the settings
- // permit it.
- SBFileSpec local_lldbinit (".lldbinit", true);
-
- SBFileSpec homedir_dot_lldb = SBHostOS::GetUserHomeDirectory();
- homedir_dot_lldb.AppendPathComponent (".lldbinit");
-
- // Only read .lldbinit in the current working directory
- // if it's not the same as the .lldbinit in the home
- // directory (which is already being read in).
- if (local_lldbinit.Exists()
- && strcmp (local_lldbinit.GetDirectory(), homedir_dot_lldb.GetDirectory()) != 0)
- {
- char path[2048];
- local_lldbinit.GetPath(path, 2047);
- InitialCmdEntry entry(path, true, true, true);
- m_after_file_commands.push_back (entry);
- }
-
- m_debug_mode = false;
- m_source_quietly = false;
- m_print_help = false;
- m_print_version = false;
- m_print_python_path = false;
- m_use_external_editor = false;
- m_wait_for = false;
- m_process_name.erase();
- m_batch = false;
- m_after_crash_commands.clear();
-
- m_process_pid = LLDB_INVALID_PROCESS_ID;
-}
-
-void
-Driver::OptionData::AddInitialCommand (const char *command, CommandPlacement placement, bool is_file, SBError &error)
-{
- std::vector<InitialCmdEntry> *command_set;
- switch (placement)
- {
- case eCommandPlacementBeforeFile:
- command_set = &(m_initial_commands);
- break;
- case eCommandPlacementAfterFile:
- command_set = &(m_after_file_commands);
- break;
- case eCommandPlacementAfterCrash:
- command_set = &(m_after_crash_commands);
- break;
- }
+void OutputFormattedUsageText(FILE *out, int indent, const char *text,
+ int output_max_columns) {
+ int len = strlen(text);
+ std::string text_string(text);
+
+ // Force indentation to be reasonable.
+ if (indent >= output_max_columns)
+ indent = 0;
+
+ // Will it all fit on one line?
+
+ if (len + indent < output_max_columns)
+ // Output as a single line
+ fprintf(out, "%*s%s\n", indent, "", text);
+ else {
+ // We need to break it up into multiple lines.
+ int text_width = output_max_columns - indent - 1;
+ int start = 0;
+ int end = start;
+ int final_end = len;
+ int sub_len;
+
+ while (end < final_end) {
+ // Dont start the 'text' on a space, since we're already outputting the
+ // indentation.
+ while ((start < final_end) && (text[start] == ' '))
+ start++;
+
+ end = start + text_width;
+ if (end > final_end)
+ end = final_end;
+ else {
+ // If we're not at the end of the text, make sure we break the line on
+ // white space.
+ while (end > start && text[end] != ' ' && text[end] != '\t' &&
+ text[end] != '\n')
+ end--;
+ }
+ sub_len = end - start;
+ std::string substring = text_string.substr(start, sub_len);
+ fprintf(out, "%*s%s\n", indent, "", substring.c_str());
+ start = end + 1;
+ }
+ }
+}
+
+void ShowUsage(FILE *out, OptionDefinition *option_table,
+ Driver::OptionData data) {
+ uint32_t screen_width = 80;
+ uint32_t indent_level = 0;
+ const char *name = "lldb";
+
+ fprintf(out, "\nUsage:\n\n");
+
+ indent_level += 2;
+
+ // First, show each usage level set of options, e.g. <cmd>
+ // [options-for-level-0]
+ // <cmd>
+ // [options-for-level-1]
+ // etc.
+
+ uint32_t num_options;
+ uint32_t num_option_sets = 0;
+
+ for (num_options = 0; option_table[num_options].long_option != NULL;
+ ++num_options) {
+ uint32_t this_usage_mask = option_table[num_options].usage_mask;
+ if (this_usage_mask == LLDB_OPT_SET_ALL) {
+ if (num_option_sets == 0)
+ num_option_sets = 1;
+ } else {
+ for (uint32_t j = 0; j < LLDB_MAX_NUM_OPTION_SETS; j++) {
+ if (this_usage_mask & 1 << j) {
+ if (num_option_sets <= j)
+ num_option_sets = j + 1;
+ }
+ }
+ }
+ }
+
+ for (uint32_t opt_set = 0; opt_set < num_option_sets; opt_set++) {
+ uint32_t opt_set_mask;
+
+ opt_set_mask = 1 << opt_set;
+
+ if (opt_set > 0)
+ fprintf(out, "\n");
+ fprintf(out, "%*s%s", indent_level, "", name);
+ bool is_help_line = false;
+
+ for (uint32_t i = 0; i < num_options; ++i) {
+ if (option_table[i].usage_mask & opt_set_mask) {
+ CommandArgumentType arg_type = option_table[i].argument_type;
+ const char *arg_name =
+ SBCommandInterpreter::GetArgumentTypeAsCString(arg_type);
+ // This is a bit of a hack, but there's no way to say certain options
+ // don't have arguments yet...
+ // so we do it by hand here.
+ if (option_table[i].short_option == 'h')
+ is_help_line = true;
+
+ if (option_table[i].required) {
+ if (option_table[i].option_has_arg == required_argument)
+ fprintf(out, " -%c <%s>", option_table[i].short_option, arg_name);
+ else if (option_table[i].option_has_arg == optional_argument)
+ fprintf(out, " -%c [<%s>]", option_table[i].short_option, arg_name);
+ else
+ fprintf(out, " -%c", option_table[i].short_option);
+ } else {
+ if (option_table[i].option_has_arg == required_argument)
+ fprintf(out, " [-%c <%s>]", option_table[i].short_option, arg_name);
+ else if (option_table[i].option_has_arg == optional_argument)
+ fprintf(out, " [-%c [<%s>]]", option_table[i].short_option,
+ arg_name);
+ else
+ fprintf(out, " [-%c]", option_table[i].short_option);
+ }
+ }
+ }
+ if (!is_help_line && (opt_set <= last_option_set_with_args))
+ fprintf(out, " [[--] <PROGRAM-ARG-1> [<PROGRAM_ARG-2> ...]]");
+ }
+
+ fprintf(out, "\n\n");
+
+ // Now print out all the detailed information about the various options: long
+ // form, short form and help text:
+ // -- long_name <argument>
+ // - short <argument>
+ // help text
+
+ // This variable is used to keep track of which options' info we've printed
+ // out, because some options can be in
+ // more than one usage level, but we only want to print the long form of its
+ // information once.
+
+ Driver::OptionData::OptionSet options_seen;
+ Driver::OptionData::OptionSet::iterator pos;
+
+ indent_level += 5;
+
+ for (uint32_t i = 0; i < num_options; ++i) {
+ // Only print this option if we haven't already seen it.
+ pos = options_seen.find(option_table[i].short_option);
+ if (pos == options_seen.end()) {
+ CommandArgumentType arg_type = option_table[i].argument_type;
+ const char *arg_name =
+ SBCommandInterpreter::GetArgumentTypeAsCString(arg_type);
+
+ options_seen.insert(option_table[i].short_option);
+ fprintf(out, "%*s-%c ", indent_level, "", option_table[i].short_option);
+ if (arg_type != eArgTypeNone)
+ fprintf(out, "<%s>", arg_name);
+ fprintf(out, "\n");
+ fprintf(out, "%*s--%s ", indent_level, "", option_table[i].long_option);
+ if (arg_type != eArgTypeNone)
+ fprintf(out, "<%s>", arg_name);
+ fprintf(out, "\n");
+ indent_level += 5;
+ OutputFormattedUsageText(out, indent_level, option_table[i].usage_text,
+ screen_width);
+ indent_level -= 5;
+ fprintf(out, "\n");
+ }
+ }
+
+ indent_level -= 5;
+
+ fprintf(out, "\n%*sNotes:\n", indent_level, "");
+ indent_level += 5;
+
+ fprintf(out,
+ "\n%*sMultiple \"-s\" and \"-o\" options can be provided. They will "
+ "be processed"
+ "\n%*sfrom left to right in order, with the source files and commands"
+ "\n%*sinterleaved. The same is true of the \"-S\" and \"-O\" "
+ "options. The before"
+ "\n%*sfile and after file sets can intermixed freely, the command "
+ "parser will"
+ "\n%*ssort them out. The order of the file specifiers (\"-c\", "
+ "\"-f\", etc.) is"
+ "\n%*snot significant in this regard.\n\n",
+ indent_level, "", indent_level, "", indent_level, "", indent_level,
+ "", indent_level, "", indent_level, "");
+
+ fprintf(
+ out,
+ "\n%*sIf you don't provide -f then the first argument will be the file "
+ "to be"
+ "\n%*sdebugged which means that '%s -- <filename> [<ARG1> [<ARG2>]]' also"
+ "\n%*sworks. But remember to end the options with \"--\" if any of your"
+ "\n%*sarguments have a \"-\" in them.\n\n",
+ indent_level, "", indent_level, "", name, indent_level, "", indent_level,
+ "");
+}
+
+void BuildGetOptTable(OptionDefinition *expanded_option_table,
+ std::vector<struct option> &getopt_table,
+ uint32_t num_options) {
+ if (num_options == 0)
+ return;
+
+ uint32_t i;
+ uint32_t j;
+ std::bitset<256> option_seen;
+
+ getopt_table.resize(num_options + 1);
+
+ for (i = 0, j = 0; i < num_options; ++i) {
+ char short_opt = expanded_option_table[i].short_option;
+
+ if (option_seen.test(short_opt) == false) {
+ getopt_table[j].name = expanded_option_table[i].long_option;
+ getopt_table[j].has_arg = expanded_option_table[i].option_has_arg;
+ getopt_table[j].flag = NULL;
+ getopt_table[j].val = expanded_option_table[i].short_option;
+ option_seen.set(short_opt);
+ ++j;
+ }
+ }
+
+ getopt_table[j].name = NULL;
+ getopt_table[j].has_arg = 0;
+ getopt_table[j].flag = NULL;
+ getopt_table[j].val = 0;
+}
+
+Driver::OptionData::OptionData()
+ : m_args(), m_script_lang(lldb::eScriptLanguageDefault), m_core_file(),
+ m_crash_log(), m_initial_commands(), m_after_file_commands(),
+ m_after_crash_commands(), m_debug_mode(false), m_source_quietly(false),
+ m_print_version(false), m_print_python_path(false), m_print_help(false),
+ m_wait_for(false), m_repl(false), m_repl_lang(eLanguageTypeUnknown),
+ m_repl_options(), m_process_name(),
+ m_process_pid(LLDB_INVALID_PROCESS_ID), m_use_external_editor(false),
+ m_batch(false), m_seen_options() {}
+
+Driver::OptionData::~OptionData() {}
+
+void Driver::OptionData::Clear() {
+ m_args.clear();
+ m_script_lang = lldb::eScriptLanguageDefault;
+ m_initial_commands.clear();
+ m_after_file_commands.clear();
+
+ // If there is a local .lldbinit, add that to the
+ // list of things to be sourced, if the settings
+ // permit it.
+ SBFileSpec local_lldbinit(".lldbinit", true);
+
+ SBFileSpec homedir_dot_lldb = SBHostOS::GetUserHomeDirectory();
+ homedir_dot_lldb.AppendPathComponent(".lldbinit");
+
+ // Only read .lldbinit in the current working directory
+ // if it's not the same as the .lldbinit in the home
+ // directory (which is already being read in).
+ if (local_lldbinit.Exists() &&
+ strcmp(local_lldbinit.GetDirectory(), homedir_dot_lldb.GetDirectory()) !=
+ 0) {
+ char path[2048];
+ local_lldbinit.GetPath(path, 2047);
+ InitialCmdEntry entry(path, true, true, true);
+ m_after_file_commands.push_back(entry);
+ }
+
+ m_debug_mode = false;
+ m_source_quietly = false;
+ m_print_help = false;
+ m_print_version = false;
+ m_print_python_path = false;
+ m_use_external_editor = false;
+ m_wait_for = false;
+ m_process_name.erase();
+ m_batch = false;
+ m_after_crash_commands.clear();
+
+ m_process_pid = LLDB_INVALID_PROCESS_ID;
+}
+
+void Driver::OptionData::AddInitialCommand(const char *command,
+ CommandPlacement placement,
+ bool is_file, SBError &error) {
+ std::vector<InitialCmdEntry> *command_set;
+ switch (placement) {
+ case eCommandPlacementBeforeFile:
+ command_set = &(m_initial_commands);
+ break;
+ case eCommandPlacementAfterFile:
+ command_set = &(m_after_file_commands);
+ break;
+ case eCommandPlacementAfterCrash:
+ command_set = &(m_after_crash_commands);
+ break;
+ }
+
+ if (is_file) {
+ SBFileSpec file(command);
+ if (file.Exists())
+ command_set->push_back(InitialCmdEntry(command, is_file, false));
+ else if (file.ResolveExecutableLocation()) {
+ char final_path[PATH_MAX];
+ file.GetPath(final_path, sizeof(final_path));
+ command_set->push_back(InitialCmdEntry(final_path, is_file, false));
+ } else
+ error.SetErrorStringWithFormat(
+ "file specified in --source (-s) option doesn't exist: '%s'", optarg);
+ } else
+ command_set->push_back(InitialCmdEntry(command, is_file, false));
+}
+
+void Driver::ResetOptionValues() { m_option_data.Clear(); }
+
+const char *Driver::GetFilename() const {
+ if (m_option_data.m_args.empty())
+ return NULL;
+ return m_option_data.m_args.front().c_str();
+}
+
+const char *Driver::GetCrashLogFilename() const {
+ if (m_option_data.m_crash_log.empty())
+ return NULL;
+ return m_option_data.m_crash_log.c_str();
+}
+
+lldb::ScriptLanguage Driver::GetScriptLanguage() const {
+ return m_option_data.m_script_lang;
+}
+
+void Driver::WriteCommandsForSourcing(CommandPlacement placement,
+ SBStream &strm) {
+ std::vector<OptionData::InitialCmdEntry> *command_set;
+ switch (placement) {
+ case eCommandPlacementBeforeFile:
+ command_set = &m_option_data.m_initial_commands;
+ break;
+ case eCommandPlacementAfterFile:
+ command_set = &m_option_data.m_after_file_commands;
+ break;
+ case eCommandPlacementAfterCrash:
+ command_set = &m_option_data.m_after_crash_commands;
+ break;
+ }
+
+ for (const auto &command_entry : *command_set) {
+ const char *command = command_entry.contents.c_str();
+ if (command_entry.is_file) {
+ // If this command_entry is a file to be sourced, and it's the ./.lldbinit
+ // file (the .lldbinit
+ // file in the current working directory), only read it if
+ // target.load-cwd-lldbinit is 'true'.
+ if (command_entry.is_cwd_lldbinit_file_read) {
+ SBStringList strlist = m_debugger.GetInternalVariableValue(
+ "target.load-cwd-lldbinit", m_debugger.GetInstanceName());
+ if (strlist.GetSize() == 1 &&
+ strcmp(strlist.GetStringAtIndex(0), "warn") == 0) {
+ FILE *output = m_debugger.GetOutputFileHandle();
+ ::fprintf(
+ output,
+ "There is a .lldbinit file in the current directory which is not "
+ "being read.\n"
+ "To silence this warning without sourcing in the local "
+ ".lldbinit,\n"
+ "add the following to the lldbinit file in your home directory:\n"
+ " settings set target.load-cwd-lldbinit false\n"
+ "To allow lldb to source .lldbinit files in the current working "
+ "directory,\n"
+ "set the value of this variable to true. Only do so if you "
+ "understand and\n"
+ "accept the security risk.\n");
+ return;
+ }
+ if (strlist.GetSize() == 1 &&
+ strcmp(strlist.GetStringAtIndex(0), "false") == 0) {
+ return;
+ }
+ }
+ bool source_quietly =
+ m_option_data.m_source_quietly || command_entry.source_quietly;
+ strm.Printf("command source -s %i '%s'\n", source_quietly, command);
+ } else
+ strm.Printf("%s\n", command);
+ }
+}
+
+bool Driver::GetDebugMode() const { return m_option_data.m_debug_mode; }
+
+// Check the arguments that were passed to this program to make sure they are
+// valid and to get their
+// argument values (if any). Return a boolean value indicating whether or not
+// to start up the full
+// debugger (i.e. the Command Interpreter) or not. Return FALSE if the
+// arguments were invalid OR
+// if the user only wanted help or version information.
- if (is_file)
- {
- SBFileSpec file(command);
- if (file.Exists())
- command_set->push_back (InitialCmdEntry(command, is_file, false));
- else if (file.ResolveExecutableLocation())
- {
- char final_path[PATH_MAX];
- file.GetPath (final_path, sizeof(final_path));
- command_set->push_back (InitialCmdEntry(final_path, is_file, false));
- }
- else
- error.SetErrorStringWithFormat("file specified in --source (-s) option doesn't exist: '%s'", optarg);
- }
- else
- command_set->push_back (InitialCmdEntry(command, is_file, false));
-}
+SBError Driver::ParseArgs(int argc, const char *argv[], FILE *out_fh,
+ bool &exiting) {
+ ResetOptionValues();
+
+ SBCommandReturnObject result;
+
+ SBError error;
+ std::string option_string;
+ struct option *long_options = NULL;
+ std::vector<struct option> long_options_vector;
+ uint32_t num_options;
+
+ for (num_options = 0; g_options[num_options].long_option != NULL;
+ ++num_options)
+ /* Do Nothing. */;
+
+ if (num_options == 0) {
+ if (argc > 1)
+ error.SetErrorStringWithFormat("invalid number of options");
+ return error;
+ }
-void
-Driver::ResetOptionValues ()
-{
- m_option_data.Clear ();
-}
+ BuildGetOptTable(g_options, long_options_vector, num_options);
-const char *
-Driver::GetFilename() const
-{
- if (m_option_data.m_args.empty())
- return NULL;
- return m_option_data.m_args.front().c_str();
-}
+ if (long_options_vector.empty())
+ long_options = NULL;
+ else
+ long_options = &long_options_vector.front();
-const char *
-Driver::GetCrashLogFilename() const
-{
- if (m_option_data.m_crash_log.empty())
- return NULL;
- return m_option_data.m_crash_log.c_str();
-}
+ if (long_options == NULL) {
+ error.SetErrorStringWithFormat("invalid long options");
+ return error;
+ }
-lldb::ScriptLanguage
-Driver::GetScriptLanguage() const
-{
- return m_option_data.m_script_lang;
-}
+ // Build the option_string argument for call to getopt_long_only.
-void
-Driver::WriteCommandsForSourcing (CommandPlacement placement, SBStream &strm)
-{
- std::vector<OptionData::InitialCmdEntry> *command_set;
- switch (placement)
- {
- case eCommandPlacementBeforeFile:
- command_set = &m_option_data.m_initial_commands;
+ for (int i = 0; long_options[i].name != NULL; ++i) {
+ if (long_options[i].flag == NULL) {
+ option_string.push_back((char)long_options[i].val);
+ switch (long_options[i].has_arg) {
+ default:
+ case no_argument:
break;
- case eCommandPlacementAfterFile:
- command_set = &m_option_data.m_after_file_commands;
+ case required_argument:
+ option_string.push_back(':');
break;
- case eCommandPlacementAfterCrash:
- command_set = &m_option_data.m_after_crash_commands;
+ case optional_argument:
+ option_string.append("::");
break;
+ }
}
-
- for (const auto &command_entry : *command_set)
- {
- const char *command = command_entry.contents.c_str();
- if (command_entry.is_file)
- {
- // If this command_entry is a file to be sourced, and it's the ./.lldbinit file (the .lldbinit
- // file in the current working directory), only read it if target.load-cwd-lldbinit is 'true'.
- if (command_entry.is_cwd_lldbinit_file_read)
- {
- SBStringList strlist = m_debugger.GetInternalVariableValue ("target.load-cwd-lldbinit",
- m_debugger.GetInstanceName());
- if (strlist.GetSize() == 1 && strcmp (strlist.GetStringAtIndex(0), "warn") == 0)
- {
- FILE *output = m_debugger.GetOutputFileHandle ();
- ::fprintf (output,
- "There is a .lldbinit file in the current directory which is not being read.\n"
- "To silence this warning without sourcing in the local .lldbinit,\n"
- "add the following to the lldbinit file in your home directory:\n"
- " settings set target.load-cwd-lldbinit false\n"
- "To allow lldb to source .lldbinit files in the current working directory,\n"
- "set the value of this variable to true. Only do so if you understand and\n"
- "accept the security risk.\n");
- return;
- }
- if (strlist.GetSize() == 1 && strcmp (strlist.GetStringAtIndex(0), "false") == 0)
- {
- return;
- }
- }
- bool source_quietly = m_option_data.m_source_quietly || command_entry.source_quietly;
- strm.Printf("command source -s %i '%s'\n", source_quietly, command);
- }
- else
- strm.Printf("%s\n", command);
- }
-}
+ }
-bool
-Driver::GetDebugMode() const
-{
- return m_option_data.m_debug_mode;
-}
-
-
-// Check the arguments that were passed to this program to make sure they are valid and to get their
-// argument values (if any). Return a boolean value indicating whether or not to start up the full
-// debugger (i.e. the Command Interpreter) or not. Return FALSE if the arguments were invalid OR
-// if the user only wanted help or version information.
-
-SBError
-Driver::ParseArgs (int argc, const char *argv[], FILE *out_fh, bool &exiting)
-{
- ResetOptionValues ();
+ // This is kind of a pain, but since we make the debugger in the Driver's
+ // constructor, we can't
+ // know at that point whether we should read in init files yet. So we don't
+ // read them in in the
+ // Driver constructor, then set the flags back to "read them in" here, and
+ // then if we see the
+ // "-n" flag, we'll turn it off again. Finally we have to read them in by
+ // hand later in the
+ // main loop.
- SBCommandReturnObject result;
+ m_debugger.SkipLLDBInitFiles(false);
+ m_debugger.SkipAppInitFiles(false);
- SBError error;
- std::string option_string;
- struct option *long_options = NULL;
- std::vector<struct option> long_options_vector;
- uint32_t num_options;
-
- for (num_options = 0; g_options[num_options].long_option != NULL; ++num_options)
- /* Do Nothing. */;
-
- if (num_options == 0)
- {
- if (argc > 1)
- error.SetErrorStringWithFormat ("invalid number of options");
- return error;
- }
-
- BuildGetOptTable (g_options, long_options_vector, num_options);
-
- if (long_options_vector.empty())
- long_options = NULL;
- else
- long_options = &long_options_vector.front();
-
- if (long_options == NULL)
- {
- error.SetErrorStringWithFormat ("invalid long options");
- return error;
- }
-
- // Build the option_string argument for call to getopt_long_only.
-
- for (int i = 0; long_options[i].name != NULL; ++i)
- {
- if (long_options[i].flag == NULL)
- {
- option_string.push_back ((char) long_options[i].val);
- switch (long_options[i].has_arg)
- {
- default:
- case no_argument:
- break;
- case required_argument:
- option_string.push_back (':');
- break;
- case optional_argument:
- option_string.append ("::");
- break;
- }
- }
- }
-
- // This is kind of a pain, but since we make the debugger in the Driver's constructor, we can't
- // know at that point whether we should read in init files yet. So we don't read them in in the
- // Driver constructor, then set the flags back to "read them in" here, and then if we see the
- // "-n" flag, we'll turn it off again. Finally we have to read them in by hand later in the
- // main loop.
-
- m_debugger.SkipLLDBInitFiles (false);
- m_debugger.SkipAppInitFiles (false);
-
- // Prepare for & make calls to getopt_long_only.
+// Prepare for & make calls to getopt_long_only.
#if __GLIBC__
- optind = 0;
+ optind = 0;
#else
- optreset = 1;
- optind = 1;
+ optreset = 1;
+ optind = 1;
#endif
- int val;
- while (1)
- {
- int long_options_index = -1;
- val = ::getopt_long_only (argc, const_cast<char **>(argv), option_string.c_str(), long_options, &long_options_index);
-
- if (val == -1)
+ int val;
+ while (1) {
+ int long_options_index = -1;
+ val = ::getopt_long_only(argc, const_cast<char **>(argv),
+ option_string.c_str(), long_options,
+ &long_options_index);
+
+ if (val == -1)
+ break;
+ else if (val == '?') {
+ m_option_data.m_print_help = true;
+ error.SetErrorStringWithFormat("unknown or ambiguous option");
+ break;
+ } else if (val == 0)
+ continue;
+ else {
+ m_option_data.m_seen_options.insert((char)val);
+ if (long_options_index == -1) {
+ for (int i = 0; long_options[i].name || long_options[i].has_arg ||
+ long_options[i].flag || long_options[i].val;
+ ++i) {
+ if (long_options[i].val == val) {
+ long_options_index = i;
break;
- else if (val == '?')
- {
- m_option_data.m_print_help = true;
- error.SetErrorStringWithFormat ("unknown or ambiguous option");
- break;
- }
- else if (val == 0)
- continue;
- else
- {
- m_option_data.m_seen_options.insert ((char) val);
- if (long_options_index == -1)
- {
- for (int i = 0;
- long_options[i].name || long_options[i].has_arg || long_options[i].flag || long_options[i].val;
- ++i)
- {
- if (long_options[i].val == val)
- {
- long_options_index = i;
- break;
- }
- }
- }
-
- if (long_options_index >= 0)
- {
- const int short_option = g_options[long_options_index].short_option;
-
- switch (short_option)
- {
- case 'h':
- m_option_data.m_print_help = true;
- break;
-
- case 'v':
- m_option_data.m_print_version = true;
- break;
-
- case 'P':
- m_option_data.m_print_python_path = true;
- break;
-
- case 'b':
- m_option_data.m_batch = true;
- break;
-
- case 'c':
- {
- SBFileSpec file(optarg);
- if (file.Exists())
- {
- m_option_data.m_core_file = optarg;
- }
- else
- error.SetErrorStringWithFormat("file specified in --core (-c) option doesn't exist: '%s'", optarg);
- }
- break;
-
- case 'e':
- m_option_data.m_use_external_editor = true;
- break;
-
- case 'x':
- m_debugger.SkipLLDBInitFiles (true);
- m_debugger.SkipAppInitFiles (true);
- break;
-
- case 'X':
- m_debugger.SetUseColor (false);
- break;
-
- case 'f':
- {
- SBFileSpec file(optarg);
- if (file.Exists())
- {
- m_option_data.m_args.push_back (optarg);
- }
- else if (file.ResolveExecutableLocation())
- {
- char path[PATH_MAX];
- file.GetPath (path, sizeof(path));
- m_option_data.m_args.push_back (path);
- }
- else
- error.SetErrorStringWithFormat("file specified in --file (-f) option doesn't exist: '%s'", optarg);
- }
- break;
-
- case 'a':
- if (!m_debugger.SetDefaultArchitecture (optarg))
- error.SetErrorStringWithFormat("invalid architecture in the -a or --arch option: '%s'", optarg);
- break;
-
- case 'l':
- m_option_data.m_script_lang = m_debugger.GetScriptingLanguage (optarg);
- break;
-
- case 'd':
- m_option_data.m_debug_mode = true;
- break;
-
- case 'Q':
- m_option_data.m_source_quietly = true;
- break;
-
- case 'K':
- m_option_data.AddInitialCommand(optarg, eCommandPlacementAfterCrash, true, error);
- break;
- case 'k':
- m_option_data.AddInitialCommand(optarg, eCommandPlacementAfterCrash, false, error);
- break;
-
- case 'n':
- m_option_data.m_process_name = optarg;
- break;
-
- case 'w':
- m_option_data.m_wait_for = true;
- break;
-
- case 'p':
- {
- char *remainder;
- m_option_data.m_process_pid = strtol (optarg, &remainder, 0);
- if (remainder == optarg || *remainder != '\0')
- error.SetErrorStringWithFormat ("Could not convert process PID: \"%s\" into a pid.",
- optarg);
- }
- break;
-
- case 'r':
- m_option_data.m_repl = true;
- if (optarg && optarg[0])
- m_option_data.m_repl_options = optarg;
- else
- m_option_data.m_repl_options.clear();
- break;
-
- case 'R':
- m_option_data.m_repl_lang = SBLanguageRuntime::GetLanguageTypeFromString (optarg);
- if (m_option_data.m_repl_lang == eLanguageTypeUnknown)
- {
- error.SetErrorStringWithFormat ("Unrecognized language name: \"%s\"", optarg);
- }
- break;
-
- case 's':
- m_option_data.AddInitialCommand(optarg, eCommandPlacementAfterFile, true, error);
- break;
- case 'o':
- m_option_data.AddInitialCommand(optarg, eCommandPlacementAfterFile, false, error);
- break;
- case 'S':
- m_option_data.AddInitialCommand(optarg, eCommandPlacementBeforeFile, true, error);
- break;
- case 'O':
- m_option_data.AddInitialCommand(optarg, eCommandPlacementBeforeFile, false, error);
- break;
- default:
- m_option_data.m_print_help = true;
- error.SetErrorStringWithFormat ("unrecognized option %c", short_option);
- break;
- }
- }
- else
- {
- error.SetErrorStringWithFormat ("invalid option with value %i", val);
- }
- if (error.Fail())
- {
- return error;
- }
- }
- }
-
- if (error.Fail() || m_option_data.m_print_help)
- {
- ShowUsage (out_fh, g_options, m_option_data);
- exiting = true;
- }
- else if (m_option_data.m_print_version)
- {
- ::fprintf (out_fh, "%s\n", m_debugger.GetVersionString());
- exiting = true;
- }
- else if (m_option_data.m_print_python_path)
- {
- SBFileSpec python_file_spec = SBHostOS::GetLLDBPythonPath();
- if (python_file_spec.IsValid())
- {
- char python_path[PATH_MAX];
- size_t num_chars = python_file_spec.GetPath(python_path, PATH_MAX);
- if (num_chars < PATH_MAX)
- {
- ::fprintf (out_fh, "%s\n", python_path);
- }
- else
- ::fprintf (out_fh, "<PATH TOO LONG>\n");
- }
- else
- ::fprintf (out_fh, "<COULD NOT FIND PATH>\n");
- exiting = true;
- }
- else if (m_option_data.m_process_name.empty() && m_option_data.m_process_pid == LLDB_INVALID_PROCESS_ID)
- {
- // Any arguments that are left over after option parsing are for
- // the program. If a file was specified with -f then the filename
- // is already in the m_option_data.m_args array, and any remaining args
- // are arguments for the inferior program. If no file was specified with
- // -f, then what is left is the program name followed by any arguments.
-
- // Skip any options we consumed with getopt_long_only
- argc -= optind;
- argv += optind;
-
- if (argc > 0)
- {
- for (int arg_idx=0; arg_idx<argc; ++arg_idx)
- {
- const char *arg = argv[arg_idx];
- if (arg)
- m_option_data.m_args.push_back (arg);
- }
+ }
}
-
- }
- else
- {
- // Skip any options we consumed with getopt_long_only
- argc -= optind;
- //argv += optind; // Commented out to keep static analyzer happy
-
- if (argc > 0)
- ::fprintf (out_fh, "Warning: program arguments are ignored when attaching.\n");
- }
+ }
- return error;
-}
+ if (long_options_index >= 0) {
+ const int short_option = g_options[long_options_index].short_option;
-static ::FILE *
-PrepareCommandsForSourcing (const char *commands_data, size_t commands_size, int fds[2])
-{
- enum PIPES { READ, WRITE }; // Constants 0 and 1 for READ and WRITE
+ switch (short_option) {
+ case 'h':
+ m_option_data.m_print_help = true;
+ break;
+
+ case 'v':
+ m_option_data.m_print_version = true;
+ break;
+
+ case 'P':
+ m_option_data.m_print_python_path = true;
+ break;
+
+ case 'b':
+ m_option_data.m_batch = true;
+ break;
+
+ case 'c': {
+ SBFileSpec file(optarg);
+ if (file.Exists()) {
+ m_option_data.m_core_file = optarg;
+ } else
+ error.SetErrorStringWithFormat(
+ "file specified in --core (-c) option doesn't exist: '%s'",
+ optarg);
+ } break;
+
+ case 'e':
+ m_option_data.m_use_external_editor = true;
+ break;
+
+ case 'x':
+ m_debugger.SkipLLDBInitFiles(true);
+ m_debugger.SkipAppInitFiles(true);
+ break;
+
+ case 'X':
+ m_debugger.SetUseColor(false);
+ break;
+
+ case 'f': {
+ SBFileSpec file(optarg);
+ if (file.Exists()) {
+ m_option_data.m_args.push_back(optarg);
+ } else if (file.ResolveExecutableLocation()) {
+ char path[PATH_MAX];
+ file.GetPath(path, sizeof(path));
+ m_option_data.m_args.push_back(path);
+ } else
+ error.SetErrorStringWithFormat(
+ "file specified in --file (-f) option doesn't exist: '%s'",
+ optarg);
+ } break;
+
+ case 'a':
+ if (!m_debugger.SetDefaultArchitecture(optarg))
+ error.SetErrorStringWithFormat(
+ "invalid architecture in the -a or --arch option: '%s'",
+ optarg);
+ break;
+
+ case 'l':
+ m_option_data.m_script_lang = m_debugger.GetScriptingLanguage(optarg);
+ break;
+
+ case 'd':
+ m_option_data.m_debug_mode = true;
+ break;
+
+ case 'Q':
+ m_option_data.m_source_quietly = true;
+ break;
+
+ case 'K':
+ m_option_data.AddInitialCommand(optarg, eCommandPlacementAfterCrash,
+ true, error);
+ break;
+ case 'k':
+ m_option_data.AddInitialCommand(optarg, eCommandPlacementAfterCrash,
+ false, error);
+ break;
+
+ case 'n':
+ m_option_data.m_process_name = optarg;
+ break;
+
+ case 'w':
+ m_option_data.m_wait_for = true;
+ break;
+
+ case 'p': {
+ char *remainder;
+ m_option_data.m_process_pid = strtol(optarg, &remainder, 0);
+ if (remainder == optarg || *remainder != '\0')
+ error.SetErrorStringWithFormat(
+ "Could not convert process PID: \"%s\" into a pid.", optarg);
+ } break;
+
+ case 'r':
+ m_option_data.m_repl = true;
+ if (optarg && optarg[0])
+ m_option_data.m_repl_options = optarg;
+ else
+ m_option_data.m_repl_options.clear();
+ break;
+
+ case 'R':
+ m_option_data.m_repl_lang =
+ SBLanguageRuntime::GetLanguageTypeFromString(optarg);
+ if (m_option_data.m_repl_lang == eLanguageTypeUnknown) {
+ error.SetErrorStringWithFormat("Unrecognized language name: \"%s\"",
+ optarg);
+ }
+ break;
+
+ case 's':
+ m_option_data.AddInitialCommand(optarg, eCommandPlacementAfterFile,
+ true, error);
+ break;
+ case 'o':
+ m_option_data.AddInitialCommand(optarg, eCommandPlacementAfterFile,
+ false, error);
+ break;
+ case 'S':
+ m_option_data.AddInitialCommand(optarg, eCommandPlacementBeforeFile,
+ true, error);
+ break;
+ case 'O':
+ m_option_data.AddInitialCommand(optarg, eCommandPlacementBeforeFile,
+ false, error);
+ break;
+ default:
+ m_option_data.m_print_help = true;
+ error.SetErrorStringWithFormat("unrecognized option %c",
+ short_option);
+ break;
+ }
+ } else {
+ error.SetErrorStringWithFormat("invalid option with value %i", val);
+ }
+ if (error.Fail()) {
+ return error;
+ }
+ }
+ }
- ::FILE *commands_file = NULL;
- fds[0] = -1;
- fds[1] = -1;
- int err = 0;
+ if (error.Fail() || m_option_data.m_print_help) {
+ ShowUsage(out_fh, g_options, m_option_data);
+ exiting = true;
+ } else if (m_option_data.m_print_version) {
+ ::fprintf(out_fh, "%s\n", m_debugger.GetVersionString());
+ exiting = true;
+ } else if (m_option_data.m_print_python_path) {
+ SBFileSpec python_file_spec = SBHostOS::GetLLDBPythonPath();
+ if (python_file_spec.IsValid()) {
+ char python_path[PATH_MAX];
+ size_t num_chars = python_file_spec.GetPath(python_path, PATH_MAX);
+ if (num_chars < PATH_MAX) {
+ ::fprintf(out_fh, "%s\n", python_path);
+ } else
+ ::fprintf(out_fh, "<PATH TOO LONG>\n");
+ } else
+ ::fprintf(out_fh, "<COULD NOT FIND PATH>\n");
+ exiting = true;
+ } else if (m_option_data.m_process_name.empty() &&
+ m_option_data.m_process_pid == LLDB_INVALID_PROCESS_ID) {
+ // Any arguments that are left over after option parsing are for
+ // the program. If a file was specified with -f then the filename
+ // is already in the m_option_data.m_args array, and any remaining args
+ // are arguments for the inferior program. If no file was specified with
+ // -f, then what is left is the program name followed by any arguments.
+
+ // Skip any options we consumed with getopt_long_only
+ argc -= optind;
+ argv += optind;
+
+ if (argc > 0) {
+ for (int arg_idx = 0; arg_idx < argc; ++arg_idx) {
+ const char *arg = argv[arg_idx];
+ if (arg)
+ m_option_data.m_args.push_back(arg);
+ }
+ }
+
+ } else {
+ // Skip any options we consumed with getopt_long_only
+ argc -= optind;
+ // argv += optind; // Commented out to keep static analyzer happy
+
+ if (argc > 0)
+ ::fprintf(out_fh,
+ "Warning: program arguments are ignored when attaching.\n");
+ }
+
+ return error;
+}
+
+static ::FILE *PrepareCommandsForSourcing(const char *commands_data,
+ size_t commands_size, int fds[2]) {
+ enum PIPES { READ, WRITE }; // Constants 0 and 1 for READ and WRITE
+
+ ::FILE *commands_file = NULL;
+ fds[0] = -1;
+ fds[1] = -1;
+ int err = 0;
#ifdef _WIN32
- err = _pipe(fds, commands_size, O_BINARY);
+ err = _pipe(fds, commands_size, O_BINARY);
#else
- err = pipe(fds);
+ err = pipe(fds);
#endif
- if (err == 0)
- {
- ssize_t nrwr = write(fds[WRITE], commands_data, commands_size);
- if (nrwr < 0)
- {
- fprintf(stderr, "error: write(%i, %p, %" PRIu64 ") failed (errno = %i) "
- "when trying to open LLDB commands pipe\n",
- fds[WRITE], static_cast<const void *>(commands_data),
- static_cast<uint64_t>(commands_size), errno);
- }
- else if (static_cast<size_t>(nrwr) == commands_size)
- {
- // Close the write end of the pipe so when we give the read end to
- // the debugger/command interpreter it will exit when it consumes all
- // of the data
+ if (err == 0) {
+ ssize_t nrwr = write(fds[WRITE], commands_data, commands_size);
+ if (nrwr < 0) {
+ fprintf(stderr, "error: write(%i, %p, %" PRIu64 ") failed (errno = %i) "
+ "when trying to open LLDB commands pipe\n",
+ fds[WRITE], static_cast<const void *>(commands_data),
+ static_cast<uint64_t>(commands_size), errno);
+ } else if (static_cast<size_t>(nrwr) == commands_size) {
+// Close the write end of the pipe so when we give the read end to
+// the debugger/command interpreter it will exit when it consumes all
+// of the data
#ifdef _WIN32
- _close(fds[WRITE]); fds[WRITE] = -1;
+ _close(fds[WRITE]);
+ fds[WRITE] = -1;
#else
- close(fds[WRITE]); fds[WRITE] = -1;
+ close(fds[WRITE]);
+ fds[WRITE] = -1;
#endif
- // Now open the read file descriptor in a FILE * that we can give to
- // the debugger as an input handle
- commands_file = fdopen(fds[READ], "r");
- if (commands_file)
- {
- fds[READ] = -1; // The FILE * 'commands_file' now owns the read descriptor
- // Hand ownership if the FILE * over to the debugger for "commands_file".
- }
- else
- {
- fprintf(stderr,
- "error: fdopen(%i, \"r\") failed (errno = %i) when "
+ // Now open the read file descriptor in a FILE * that we can give to
+ // the debugger as an input handle
+ commands_file = fdopen(fds[READ], "r");
+ if (commands_file) {
+ fds[READ] =
+ -1; // The FILE * 'commands_file' now owns the read descriptor
+ // Hand ownership if the FILE * over to the debugger for
+ // "commands_file".
+ } else {
+ fprintf(stderr, "error: fdopen(%i, \"r\") failed (errno = %i) when "
"trying to open LLDB commands pipe\n",
- fds[READ], errno);
- }
- }
- }
- else
- {
- fprintf(stderr, "error: can't create pipe file descriptors for LLDB commands\n");
+ fds[READ], errno);
+ }
}
+ } else {
+ fprintf(stderr,
+ "error: can't create pipe file descriptors for LLDB commands\n");
+ }
- return commands_file;
+ return commands_file;
}
-void
-CleanupAfterCommandSourcing (int fds[2])
-{
- enum PIPES { READ, WRITE }; // Constants 0 and 1 for READ and WRITE
+void CleanupAfterCommandSourcing(int fds[2]) {
+ enum PIPES { READ, WRITE }; // Constants 0 and 1 for READ and WRITE
- // Close any pipes that we still have ownership of
- if ( fds[WRITE] != -1)
- {
+ // Close any pipes that we still have ownership of
+ if (fds[WRITE] != -1) {
#ifdef _WIN32
- _close(fds[WRITE]); fds[WRITE] = -1;
+ _close(fds[WRITE]);
+ fds[WRITE] = -1;
#else
- close(fds[WRITE]); fds[WRITE] = -1;
+ close(fds[WRITE]);
+ fds[WRITE] = -1;
#endif
-
- }
+ }
- if ( fds[READ] != -1)
- {
+ if (fds[READ] != -1) {
#ifdef _WIN32
- _close(fds[READ]); fds[READ] = -1;
+ _close(fds[READ]);
+ fds[READ] = -1;
#else
- close(fds[READ]); fds[READ] = -1;
+ close(fds[READ]);
+ fds[READ] = -1;
#endif
- }
-
+ }
}
-std::string
-EscapeString (std::string arg)
-{
- std::string::size_type pos = 0;
- while ((pos = arg.find_first_of("\"\\", pos)) != std::string::npos)
- {
- arg.insert (pos, 1, '\\');
- pos += 2;
- }
- return '"' + arg + '"';
-}
-
-void
-Driver::MainLoop ()
-{
- if (::tcgetattr(STDIN_FILENO, &g_old_stdin_termios) == 0)
- {
- g_old_stdin_termios_is_valid = true;
- atexit (reset_stdin_termios);
- }
+std::string EscapeString(std::string arg) {
+ std::string::size_type pos = 0;
+ while ((pos = arg.find_first_of("\"\\", pos)) != std::string::npos) {
+ arg.insert(pos, 1, '\\');
+ pos += 2;
+ }
+ return '"' + arg + '"';
+}
+
+void Driver::MainLoop() {
+ if (::tcgetattr(STDIN_FILENO, &g_old_stdin_termios) == 0) {
+ g_old_stdin_termios_is_valid = true;
+ atexit(reset_stdin_termios);
+ }
#ifndef _MSC_VER
- // Disabling stdin buffering with MSVC's 2015 CRT exposes a bug in fgets
- // which causes it to miss newlines depending on whether there have been an
- // odd or even number of characters. Bug has been reported to MS via Connect.
- ::setbuf (stdin, NULL);
+ // Disabling stdin buffering with MSVC's 2015 CRT exposes a bug in fgets
+ // which causes it to miss newlines depending on whether there have been an
+ // odd or even number of characters. Bug has been reported to MS via Connect.
+ ::setbuf(stdin, NULL);
#endif
- ::setbuf (stdout, NULL);
-
- m_debugger.SetErrorFileHandle (stderr, false);
- m_debugger.SetOutputFileHandle (stdout, false);
- m_debugger.SetInputFileHandle (stdin, false); // Don't take ownership of STDIN yet...
-
- m_debugger.SetUseExternalEditor(m_option_data.m_use_external_editor);
-
- struct winsize window_size;
- if (isatty (STDIN_FILENO)
- && ::ioctl (STDIN_FILENO, TIOCGWINSZ, &window_size) == 0)
- {
- if (window_size.ws_col > 0)
- m_debugger.SetTerminalWidth (window_size.ws_col);
- }
-
- SBCommandInterpreter sb_interpreter = m_debugger.GetCommandInterpreter();
-
- // Before we handle any options from the command line, we parse the
- // .lldbinit file in the user's home directory.
- SBCommandReturnObject result;
- sb_interpreter.SourceInitFileInHomeDirectory(result);
- if (GetDebugMode())
- {
- result.PutError (m_debugger.GetErrorFileHandle());
- result.PutOutput (m_debugger.GetOutputFileHandle());
- }
-
- // Now we handle options we got from the command line
- SBStream commands_stream;
-
- // First source in the commands specified to be run before the file arguments are processed.
- WriteCommandsForSourcing (eCommandPlacementBeforeFile, commands_stream);
-
- const size_t num_args = m_option_data.m_args.size();
- if (num_args > 0)
- {
- char arch_name[64];
- if (m_debugger.GetDefaultArchitecture (arch_name, sizeof (arch_name)))
- commands_stream.Printf("target create --arch=%s %s", arch_name, EscapeString(m_option_data.m_args[0]).c_str());
- else
- commands_stream.Printf("target create %s", EscapeString(m_option_data.m_args[0]).c_str());
-
- if (!m_option_data.m_core_file.empty())
- {
- commands_stream.Printf(" --core %s", EscapeString(m_option_data.m_core_file).c_str());
- }
- commands_stream.Printf("\n");
-
- if (num_args > 1)
- {
- commands_stream.Printf ("settings set -- target.run-args ");
- for (size_t arg_idx = 1; arg_idx < num_args; ++arg_idx)
- commands_stream.Printf(" %s", EscapeString(m_option_data.m_args[arg_idx]).c_str());
- commands_stream.Printf("\n");
- }
- }
- else if (!m_option_data.m_core_file.empty())
- {
- commands_stream.Printf("target create --core %s\n", EscapeString(m_option_data.m_core_file).c_str());
- }
- else if (!m_option_data.m_process_name.empty())
- {
- commands_stream.Printf ("process attach --name %s", EscapeString(m_option_data.m_process_name).c_str());
-
- if (m_option_data.m_wait_for)
- commands_stream.Printf(" --waitfor");
-
- commands_stream.Printf("\n");
+ ::setbuf(stdout, NULL);
- }
- else if (LLDB_INVALID_PROCESS_ID != m_option_data.m_process_pid)
- {
- commands_stream.Printf ("process attach --pid %" PRIu64 "\n", m_option_data.m_process_pid);
- }
-
- WriteCommandsForSourcing(eCommandPlacementAfterFile, commands_stream);
-
- if (GetDebugMode())
- {
- result.PutError(m_debugger.GetErrorFileHandle());
- result.PutOutput(m_debugger.GetOutputFileHandle());
- }
-
- bool handle_events = true;
- bool spawn_thread = false;
-
- if (m_option_data.m_repl)
- {
- const char *repl_options = NULL;
- if (!m_option_data.m_repl_options.empty())
- repl_options = m_option_data.m_repl_options.c_str();
- SBError error (m_debugger.RunREPL(m_option_data.m_repl_lang, repl_options));
- if (error.Fail())
- {
- const char *error_cstr = error.GetCString();
- if (error_cstr && error_cstr[0])
- fprintf (stderr, "error: %s\n", error_cstr);
- else
- fprintf (stderr, "error: %u\n", error.GetError());
- }
- }
+ m_debugger.SetErrorFileHandle(stderr, false);
+ m_debugger.SetOutputFileHandle(stdout, false);
+ m_debugger.SetInputFileHandle(stdin,
+ false); // Don't take ownership of STDIN yet...
+
+ m_debugger.SetUseExternalEditor(m_option_data.m_use_external_editor);
+
+ struct winsize window_size;
+ if (isatty(STDIN_FILENO) &&
+ ::ioctl(STDIN_FILENO, TIOCGWINSZ, &window_size) == 0) {
+ if (window_size.ws_col > 0)
+ m_debugger.SetTerminalWidth(window_size.ws_col);
+ }
+
+ SBCommandInterpreter sb_interpreter = m_debugger.GetCommandInterpreter();
+
+ // Before we handle any options from the command line, we parse the
+ // .lldbinit file in the user's home directory.
+ SBCommandReturnObject result;
+ sb_interpreter.SourceInitFileInHomeDirectory(result);
+ if (GetDebugMode()) {
+ result.PutError(m_debugger.GetErrorFileHandle());
+ result.PutOutput(m_debugger.GetOutputFileHandle());
+ }
+
+ // Now we handle options we got from the command line
+ SBStream commands_stream;
+
+ // First source in the commands specified to be run before the file arguments
+ // are processed.
+ WriteCommandsForSourcing(eCommandPlacementBeforeFile, commands_stream);
+
+ const size_t num_args = m_option_data.m_args.size();
+ if (num_args > 0) {
+ char arch_name[64];
+ if (m_debugger.GetDefaultArchitecture(arch_name, sizeof(arch_name)))
+ commands_stream.Printf("target create --arch=%s %s", arch_name,
+ EscapeString(m_option_data.m_args[0]).c_str());
else
- {
- // Check if we have any data in the commands stream, and if so, save it to a temp file
- // so we can then run the command interpreter using the file contents.
- const char *commands_data = commands_stream.GetData();
- const size_t commands_size = commands_stream.GetSize();
-
- // The command file might have requested that we quit, this variable will track that.
- bool quit_requested = false;
- bool stopped_for_crash = false;
- if (commands_data && commands_size)
- {
- int initial_commands_fds[2];
- bool success = true;
- FILE *commands_file = PrepareCommandsForSourcing (commands_data, commands_size, initial_commands_fds);
- if (commands_file)
- {
- m_debugger.SetInputFileHandle (commands_file, true);
-
- // Set the debugger into Sync mode when running the command file. Otherwise command files
- // that run the target won't run in a sensible way.
- bool old_async = m_debugger.GetAsync();
- m_debugger.SetAsync(false);
- int num_errors;
-
- SBCommandInterpreterRunOptions options;
- options.SetStopOnError (true);
- if (m_option_data.m_batch)
- options.SetStopOnCrash (true);
-
- m_debugger.RunCommandInterpreter(handle_events,
- spawn_thread,
- options,
- num_errors,
- quit_requested,
- stopped_for_crash);
-
- if (m_option_data.m_batch && stopped_for_crash && !m_option_data.m_after_crash_commands.empty())
- {
- int crash_command_fds[2];
- SBStream crash_commands_stream;
- WriteCommandsForSourcing (eCommandPlacementAfterCrash, crash_commands_stream);
- const char *crash_commands_data = crash_commands_stream.GetData();
- const size_t crash_commands_size = crash_commands_stream.GetSize();
- commands_file = PrepareCommandsForSourcing (crash_commands_data, crash_commands_size, crash_command_fds);
- if (commands_file)
- {
- bool local_quit_requested;
- bool local_stopped_for_crash;
- m_debugger.SetInputFileHandle (commands_file, true);
-
- m_debugger.RunCommandInterpreter(handle_events,
- spawn_thread,
- options,
- num_errors,
- local_quit_requested,
- local_stopped_for_crash);
- if (local_quit_requested)
- quit_requested = true;
-
- }
- }
- m_debugger.SetAsync(old_async);
- }
- else
- success = false;
-
- // Close any pipes that we still have ownership of
- CleanupAfterCommandSourcing(initial_commands_fds);
-
- // Something went wrong with command pipe
- if (!success)
- {
- exit(1);
- }
-
- }
-
- // Now set the input file handle to STDIN and run the command
- // interpreter again in interactive mode and let the debugger
- // take ownership of stdin
-
- bool go_interactive = true;
- if (quit_requested)
- go_interactive = false;
- else if (m_option_data.m_batch && !stopped_for_crash)
- go_interactive = false;
-
- if (go_interactive)
- {
- m_debugger.SetInputFileHandle (stdin, true);
- m_debugger.RunCommandInterpreter(handle_events, spawn_thread);
- }
- }
-
- reset_stdin_termios();
- fclose (stdin);
-
- SBDebugger::Destroy (m_debugger);
-}
-
-
-void
-Driver::ResizeWindow (unsigned short col)
-{
- GetDebugger().SetTerminalWidth (col);
-}
-
-void
-sigwinch_handler (int signo)
-{
- struct winsize window_size;
- if (isatty (STDIN_FILENO)
- && ::ioctl (STDIN_FILENO, TIOCGWINSZ, &window_size) == 0)
- {
- if ((window_size.ws_col > 0) && g_driver != NULL)
- {
- g_driver->ResizeWindow (window_size.ws_col);
- }
- }
-}
-
-void
-sigint_handler (int signo)
-{
- static bool g_interrupt_sent = false;
- if (g_driver)
- {
- if (!g_interrupt_sent)
- {
- g_interrupt_sent = true;
- g_driver->GetDebugger().DispatchInputInterrupt();
- g_interrupt_sent = false;
- return;
- }
- }
-
- exit (signo);
-}
-
-void
-sigtstp_handler (int signo)
-{
- if (g_driver)
- g_driver->GetDebugger().SaveInputTerminalState();
+ commands_stream.Printf("target create %s",
+ EscapeString(m_option_data.m_args[0]).c_str());
- signal (signo, SIG_DFL);
- kill (getpid(), signo);
- signal (signo, sigtstp_handler);
-}
-
-void
-sigcont_handler (int signo)
-{
- if (g_driver)
- g_driver->GetDebugger().RestoreInputTerminalState();
-
- signal (signo, SIG_DFL);
- kill (getpid(), signo);
- signal (signo, sigcont_handler);
+ if (!m_option_data.m_core_file.empty()) {
+ commands_stream.Printf(" --core %s",
+ EscapeString(m_option_data.m_core_file).c_str());
+ }
+ commands_stream.Printf("\n");
+
+ if (num_args > 1) {
+ commands_stream.Printf("settings set -- target.run-args ");
+ for (size_t arg_idx = 1; arg_idx < num_args; ++arg_idx)
+ commands_stream.Printf(
+ " %s", EscapeString(m_option_data.m_args[arg_idx]).c_str());
+ commands_stream.Printf("\n");
+ }
+ } else if (!m_option_data.m_core_file.empty()) {
+ commands_stream.Printf("target create --core %s\n",
+ EscapeString(m_option_data.m_core_file).c_str());
+ } else if (!m_option_data.m_process_name.empty()) {
+ commands_stream.Printf("process attach --name %s",
+ EscapeString(m_option_data.m_process_name).c_str());
+
+ if (m_option_data.m_wait_for)
+ commands_stream.Printf(" --waitfor");
+
+ commands_stream.Printf("\n");
+
+ } else if (LLDB_INVALID_PROCESS_ID != m_option_data.m_process_pid) {
+ commands_stream.Printf("process attach --pid %" PRIu64 "\n",
+ m_option_data.m_process_pid);
+ }
+
+ WriteCommandsForSourcing(eCommandPlacementAfterFile, commands_stream);
+
+ if (GetDebugMode()) {
+ result.PutError(m_debugger.GetErrorFileHandle());
+ result.PutOutput(m_debugger.GetOutputFileHandle());
+ }
+
+ bool handle_events = true;
+ bool spawn_thread = false;
+
+ if (m_option_data.m_repl) {
+ const char *repl_options = NULL;
+ if (!m_option_data.m_repl_options.empty())
+ repl_options = m_option_data.m_repl_options.c_str();
+ SBError error(m_debugger.RunREPL(m_option_data.m_repl_lang, repl_options));
+ if (error.Fail()) {
+ const char *error_cstr = error.GetCString();
+ if (error_cstr && error_cstr[0])
+ fprintf(stderr, "error: %s\n", error_cstr);
+ else
+ fprintf(stderr, "error: %u\n", error.GetError());
+ }
+ } else {
+ // Check if we have any data in the commands stream, and if so, save it to a
+ // temp file
+ // so we can then run the command interpreter using the file contents.
+ const char *commands_data = commands_stream.GetData();
+ const size_t commands_size = commands_stream.GetSize();
+
+ // The command file might have requested that we quit, this variable will
+ // track that.
+ bool quit_requested = false;
+ bool stopped_for_crash = false;
+ if (commands_data && commands_size) {
+ int initial_commands_fds[2];
+ bool success = true;
+ FILE *commands_file = PrepareCommandsForSourcing(
+ commands_data, commands_size, initial_commands_fds);
+ if (commands_file) {
+ m_debugger.SetInputFileHandle(commands_file, true);
+
+ // Set the debugger into Sync mode when running the command file.
+ // Otherwise command files
+ // that run the target won't run in a sensible way.
+ bool old_async = m_debugger.GetAsync();
+ m_debugger.SetAsync(false);
+ int num_errors;
+
+ SBCommandInterpreterRunOptions options;
+ options.SetStopOnError(true);
+ if (m_option_data.m_batch)
+ options.SetStopOnCrash(true);
+
+ m_debugger.RunCommandInterpreter(handle_events, spawn_thread, options,
+ num_errors, quit_requested,
+ stopped_for_crash);
+
+ if (m_option_data.m_batch && stopped_for_crash &&
+ !m_option_data.m_after_crash_commands.empty()) {
+ int crash_command_fds[2];
+ SBStream crash_commands_stream;
+ WriteCommandsForSourcing(eCommandPlacementAfterCrash,
+ crash_commands_stream);
+ const char *crash_commands_data = crash_commands_stream.GetData();
+ const size_t crash_commands_size = crash_commands_stream.GetSize();
+ commands_file = PrepareCommandsForSourcing(
+ crash_commands_data, crash_commands_size, crash_command_fds);
+ if (commands_file) {
+ bool local_quit_requested;
+ bool local_stopped_for_crash;
+ m_debugger.SetInputFileHandle(commands_file, true);
+
+ m_debugger.RunCommandInterpreter(
+ handle_events, spawn_thread, options, num_errors,
+ local_quit_requested, local_stopped_for_crash);
+ if (local_quit_requested)
+ quit_requested = true;
+ }
+ }
+ m_debugger.SetAsync(old_async);
+ } else
+ success = false;
+
+ // Close any pipes that we still have ownership of
+ CleanupAfterCommandSourcing(initial_commands_fds);
+
+ // Something went wrong with command pipe
+ if (!success) {
+ exit(1);
+ }
+ }
+
+ // Now set the input file handle to STDIN and run the command
+ // interpreter again in interactive mode and let the debugger
+ // take ownership of stdin
+
+ bool go_interactive = true;
+ if (quit_requested)
+ go_interactive = false;
+ else if (m_option_data.m_batch && !stopped_for_crash)
+ go_interactive = false;
+
+ if (go_interactive) {
+ m_debugger.SetInputFileHandle(stdin, true);
+ m_debugger.RunCommandInterpreter(handle_events, spawn_thread);
+ }
+ }
+
+ reset_stdin_termios();
+ fclose(stdin);
+
+ SBDebugger::Destroy(m_debugger);
+}
+
+void Driver::ResizeWindow(unsigned short col) {
+ GetDebugger().SetTerminalWidth(col);
+}
+
+void sigwinch_handler(int signo) {
+ struct winsize window_size;
+ if (isatty(STDIN_FILENO) &&
+ ::ioctl(STDIN_FILENO, TIOCGWINSZ, &window_size) == 0) {
+ if ((window_size.ws_col > 0) && g_driver != NULL) {
+ g_driver->ResizeWindow(window_size.ws_col);
+ }
+ }
+}
+
+void sigint_handler(int signo) {
+ static bool g_interrupt_sent = false;
+ if (g_driver) {
+ if (!g_interrupt_sent) {
+ g_interrupt_sent = true;
+ g_driver->GetDebugger().DispatchInputInterrupt();
+ g_interrupt_sent = false;
+ return;
+ }
+ }
+
+ exit(signo);
+}
+
+void sigtstp_handler(int signo) {
+ if (g_driver)
+ g_driver->GetDebugger().SaveInputTerminalState();
+
+ signal(signo, SIG_DFL);
+ kill(getpid(), signo);
+ signal(signo, sigtstp_handler);
+}
+
+void sigcont_handler(int signo) {
+ if (g_driver)
+ g_driver->GetDebugger().RestoreInputTerminalState();
+
+ signal(signo, SIG_DFL);
+ kill(getpid(), signo);
+ signal(signo, sigcont_handler);
}
int
@@ -1315,48 +1217,44 @@ main(int argc, char const *argv[])
#endif
{
#ifdef _WIN32
- // Convert wide arguments to UTF-8
- std::vector<std::string> argvStrings(argc);
- std::vector<const char *> argvPointers(argc);
- for (int i = 0; i != argc; ++i)
- {
- llvm::convertWideToUTF8(wargv[i], argvStrings[i]);
- argvPointers[i] = argvStrings[i].c_str();
- }
- const char **argv = argvPointers.data();
+ // Convert wide arguments to UTF-8
+ std::vector<std::string> argvStrings(argc);
+ std::vector<const char *> argvPointers(argc);
+ for (int i = 0; i != argc; ++i) {
+ llvm::convertWideToUTF8(wargv[i], argvStrings[i]);
+ argvPointers[i] = argvStrings[i].c_str();
+ }
+ const char **argv = argvPointers.data();
#endif
- SBDebugger::Initialize();
+ SBDebugger::Initialize();
- SBHostOS::ThreadCreated("<lldb.driver.main-thread>");
+ SBHostOS::ThreadCreated("<lldb.driver.main-thread>");
- signal(SIGINT, sigint_handler);
+ signal(SIGINT, sigint_handler);
#if !defined(_MSC_VER)
- signal(SIGPIPE, SIG_IGN);
- signal(SIGWINCH, sigwinch_handler);
- signal(SIGTSTP, sigtstp_handler);
- signal(SIGCONT, sigcont_handler);
+ signal(SIGPIPE, SIG_IGN);
+ signal(SIGWINCH, sigwinch_handler);
+ signal(SIGTSTP, sigtstp_handler);
+ signal(SIGCONT, sigcont_handler);
#endif
- // Create a scope for driver so that the driver object will destroy itself
- // before SBDebugger::Terminate() is called.
- {
- Driver driver;
-
- bool exiting = false;
- SBError error(driver.ParseArgs(argc, argv, stdout, exiting));
- if (error.Fail())
- {
- const char *error_cstr = error.GetCString();
- if (error_cstr)
- ::fprintf(stderr, "error: %s\n", error_cstr);
- }
- else if (!exiting)
- {
- driver.MainLoop();
- }
- }
+ // Create a scope for driver so that the driver object will destroy itself
+ // before SBDebugger::Terminate() is called.
+ {
+ Driver driver;
+
+ bool exiting = false;
+ SBError error(driver.ParseArgs(argc, argv, stdout, exiting));
+ if (error.Fail()) {
+ const char *error_cstr = error.GetCString();
+ if (error_cstr)
+ ::fprintf(stderr, "error: %s\n", error_cstr);
+ } else if (!exiting) {
+ driver.MainLoop();
+ }
+ }
- SBDebugger::Terminate();
- return 0;
+ SBDebugger::Terminate();
+ return 0;
}
Modified: lldb/trunk/tools/driver/Driver.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/driver/Driver.h?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/tools/driver/Driver.h (original)
+++ lldb/trunk/tools/driver/Driver.h Tue Sep 6 15:57:50 2016
@@ -13,136 +13,113 @@
#include "Platform.h"
#include "lldb/Utility/PseudoTerminal.h"
-#include <set>
#include <bitset>
+#include <set>
#include <string>
#include <vector>
-#include "lldb/API/SBDefines.h"
#include "lldb/API/SBBroadcaster.h"
#include "lldb/API/SBDebugger.h"
+#include "lldb/API/SBDefines.h"
#include "lldb/API/SBError.h"
class IOChannel;
-class Driver : public lldb::SBBroadcaster
-{
+class Driver : public lldb::SBBroadcaster {
public:
- typedef enum CommandPlacement
- {
- eCommandPlacementBeforeFile,
- eCommandPlacementAfterFile,
- eCommandPlacementAfterCrash,
- } CommandPlacement;
-
- Driver ();
-
- virtual
- ~Driver ();
-
- void
- MainLoop ();
-
- lldb::SBError
- ParseArgs (int argc, const char *argv[], FILE *out_fh, bool &do_exit);
-
- const char *
- GetFilename() const;
-
- const char *
- GetCrashLogFilename() const;
-
- const char *
- GetArchName() const;
-
- lldb::ScriptLanguage
- GetScriptLanguage() const;
-
- void
- WriteCommandsForSourcing (CommandPlacement placement, lldb::SBStream &strm);
-
- bool
- GetDebugMode() const;
-
-
- class OptionData
- {
- public:
- OptionData ();
- ~OptionData ();
-
- void
- Clear();
-
- void
- AddInitialCommand (const char *command, CommandPlacement placement, bool is_file, lldb::SBError &error);
-
- //static OptionDefinition m_cmd_option_table[];
-
- struct InitialCmdEntry
- {
- InitialCmdEntry (const char *in_contents, bool in_is_file, bool is_cwd_lldbinit_file_read, bool in_quiet = false) :
- contents (in_contents),
- is_file (in_is_file),
- is_cwd_lldbinit_file_read (is_cwd_lldbinit_file_read),
- source_quietly (in_quiet)
- {}
-
- std::string contents;
- bool is_file;
- bool is_cwd_lldbinit_file_read; // if this is reading ./.lldbinit - so we may skip if not permitted
- bool source_quietly;
- };
-
- std::vector<std::string> m_args;
- lldb::ScriptLanguage m_script_lang;
- std::string m_core_file;
- std::string m_crash_log;
- std::vector<InitialCmdEntry> m_initial_commands;
- std::vector<InitialCmdEntry> m_after_file_commands;
- std::vector<InitialCmdEntry> m_after_crash_commands;
- bool m_debug_mode;
- bool m_source_quietly;
- bool m_print_version;
- bool m_print_python_path;
- bool m_print_help;
- bool m_wait_for;
- bool m_repl;
- lldb::LanguageType m_repl_lang;
- std::string m_repl_options;
- std::string m_process_name;
- lldb::pid_t m_process_pid;
- bool m_use_external_editor; // FIXME: When we have set/show variables we can remove this from here.
- bool m_batch;
- typedef std::set<char> OptionSet;
- OptionSet m_seen_options;
+ typedef enum CommandPlacement {
+ eCommandPlacementBeforeFile,
+ eCommandPlacementAfterFile,
+ eCommandPlacementAfterCrash,
+ } CommandPlacement;
+
+ Driver();
+
+ virtual ~Driver();
+
+ void MainLoop();
+
+ lldb::SBError ParseArgs(int argc, const char *argv[], FILE *out_fh,
+ bool &do_exit);
+
+ const char *GetFilename() const;
+
+ const char *GetCrashLogFilename() const;
+
+ const char *GetArchName() const;
+
+ lldb::ScriptLanguage GetScriptLanguage() const;
+
+ void WriteCommandsForSourcing(CommandPlacement placement,
+ lldb::SBStream &strm);
+
+ bool GetDebugMode() const;
+
+ class OptionData {
+ public:
+ OptionData();
+ ~OptionData();
+
+ void Clear();
+
+ void AddInitialCommand(const char *command, CommandPlacement placement,
+ bool is_file, lldb::SBError &error);
+
+ // static OptionDefinition m_cmd_option_table[];
+
+ struct InitialCmdEntry {
+ InitialCmdEntry(const char *in_contents, bool in_is_file,
+ bool is_cwd_lldbinit_file_read, bool in_quiet = false)
+ : contents(in_contents), is_file(in_is_file),
+ is_cwd_lldbinit_file_read(is_cwd_lldbinit_file_read),
+ source_quietly(in_quiet) {}
+
+ std::string contents;
+ bool is_file;
+ bool is_cwd_lldbinit_file_read; // if this is reading ./.lldbinit - so we
+ // may skip if not permitted
+ bool source_quietly;
};
+ std::vector<std::string> m_args;
+ lldb::ScriptLanguage m_script_lang;
+ std::string m_core_file;
+ std::string m_crash_log;
+ std::vector<InitialCmdEntry> m_initial_commands;
+ std::vector<InitialCmdEntry> m_after_file_commands;
+ std::vector<InitialCmdEntry> m_after_crash_commands;
+ bool m_debug_mode;
+ bool m_source_quietly;
+ bool m_print_version;
+ bool m_print_python_path;
+ bool m_print_help;
+ bool m_wait_for;
+ bool m_repl;
+ lldb::LanguageType m_repl_lang;
+ std::string m_repl_options;
+ std::string m_process_name;
+ lldb::pid_t m_process_pid;
+ bool m_use_external_editor; // FIXME: When we have set/show variables we can
+ // remove this from here.
+ bool m_batch;
+ typedef std::set<char> OptionSet;
+ OptionSet m_seen_options;
+ };
- static lldb::SBError
- SetOptionValue (int option_idx,
- const char *option_arg,
- Driver::OptionData &data);
+ static lldb::SBError SetOptionValue(int option_idx, const char *option_arg,
+ Driver::OptionData &data);
+ lldb::SBDebugger &GetDebugger() { return m_debugger; }
- lldb::SBDebugger &
- GetDebugger()
- {
- return m_debugger;
- }
-
- void
- ResizeWindow (unsigned short col);
+ void ResizeWindow(unsigned short col);
private:
- lldb::SBDebugger m_debugger;
- OptionData m_option_data;
+ lldb::SBDebugger m_debugger;
+ OptionData m_option_data;
- void
- ResetOptionValues ();
+ void ResetOptionValues();
- void
- ReadyForCommand ();
+ void ReadyForCommand();
};
#endif // lldb_Driver_h_
Modified: lldb/trunk/tools/driver/Platform.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/driver/Platform.cpp?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/tools/driver/Platform.cpp (original)
+++ lldb/trunk/tools/driver/Platform.cpp Tue Sep 6 15:57:50 2016
@@ -8,65 +8,55 @@
//===----------------------------------------------------------------------===//
// this file is only relevant for Visual C++
-#if defined( _WIN32 )
+#if defined(_WIN32)
-#include <process.h>
#include <assert.h>
+#include <process.h>
#include <stdlib.h>
#include "Platform.h"
-int
-ioctl (int d, int request, ...)
-{
- switch ( request )
- {
- // request the console windows size
- case ( TIOCGWINSZ ):
- {
- va_list vl;
- va_start(vl,request);
- // locate the window size structure on stack
- winsize *ws = va_arg(vl, winsize*);
- // get screen buffer information
- CONSOLE_SCREEN_BUFFER_INFO info;
- if ( GetConsoleScreenBufferInfo( GetStdHandle( STD_OUTPUT_HANDLE ), &info ) == TRUE )
- // fill in the columns
- ws->ws_col = info.dwMaximumWindowSize.X;
- va_end(vl);
- return 0;
- }
- break;
- default:
- assert( !"Not implemented!" );
- }
- return -1;
+int ioctl(int d, int request, ...) {
+ switch (request) {
+ // request the console windows size
+ case (TIOCGWINSZ): {
+ va_list vl;
+ va_start(vl, request);
+ // locate the window size structure on stack
+ winsize *ws = va_arg(vl, winsize *);
+ // get screen buffer information
+ CONSOLE_SCREEN_BUFFER_INFO info;
+ if (GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE), &info) ==
+ TRUE)
+ // fill in the columns
+ ws->ws_col = info.dwMaximumWindowSize.X;
+ va_end(vl);
+ return 0;
+ } break;
+ default:
+ assert(!"Not implemented!");
+ }
+ return -1;
}
-int
-kill (pid_t pid, int sig)
-{
- // is the app trying to kill itself
- if ( pid == getpid( ) )
- exit( sig );
- //
- assert( !"Not implemented!" );
- return -1;
+int kill(pid_t pid, int sig) {
+ // is the app trying to kill itself
+ if (pid == getpid())
+ exit(sig);
+ //
+ assert(!"Not implemented!");
+ return -1;
}
-int
-tcsetattr (int fd, int optional_actions, const struct termios *termios_p)
-{
- assert( !"Not implemented!" );
- return -1;
+int tcsetattr(int fd, int optional_actions, const struct termios *termios_p) {
+ assert(!"Not implemented!");
+ return -1;
}
-int
-tcgetattr (int fildes, struct termios *termios_p)
-{
-// assert( !"Not implemented!" );
- // error return value (0=success)
- return -1;
+int tcgetattr(int fildes, struct termios *termios_p) {
+ // assert( !"Not implemented!" );
+ // error return value (0=success)
+ return -1;
}
#endif
Modified: lldb/trunk/tools/driver/Platform.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/driver/Platform.h?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/tools/driver/Platform.h (original)
+++ lldb/trunk/tools/driver/Platform.h Tue Sep 6 15:57:50 2016
@@ -10,85 +10,81 @@
#ifndef lldb_Platform_h_
#define lldb_Platform_h_
-#if defined( _WIN32 )
+#if defined(_WIN32)
- #include "lldb/Host/HostGetOpt.h"
- #include <io.h>
-#if defined( _MSC_VER )
- #include <eh.h>
- #include <signal.h>
+#include "lldb/Host/HostGetOpt.h"
+#include <io.h>
+#if defined(_MSC_VER)
+#include <eh.h>
+#include <signal.h>
#endif
- #include <inttypes.h>
- #include "lldb/Host/windows/windows.h"
-
- struct winsize
- {
- long ws_col;
- };
-
- typedef unsigned char cc_t;
- typedef unsigned int speed_t;
- typedef unsigned int tcflag_t;
-
- // fcntl.h
- #define O_NOCTTY 0400
-
- // ioctls.h
- #define TIOCGWINSZ 0x5413
-
- // signal.h
- #define SIGPIPE 13
- #define SIGCONT 18
- #define SIGTSTP 20
- #define SIGWINCH 28
-
- // tcsetattr arguments
- #define TCSANOW 0
-
- #define NCCS 32
- struct termios
- {
- tcflag_t c_iflag; // input mode flags
- tcflag_t c_oflag; // output mode flags
- tcflag_t c_cflag; // control mode flags
- tcflag_t c_lflag; // local mode flags
- cc_t c_line; // line discipline
- cc_t c_cc[NCCS]; // control characters
- speed_t c_ispeed; // input speed
- speed_t c_ospeed; // output speed
- };
-
+#include "lldb/Host/windows/windows.h"
+#include <inttypes.h>
+struct winsize {
+ long ws_col;
+};
+
+typedef unsigned char cc_t;
+typedef unsigned int speed_t;
+typedef unsigned int tcflag_t;
+
+// fcntl.h
+#define O_NOCTTY 0400
+
+// ioctls.h
+#define TIOCGWINSZ 0x5413
+
+// signal.h
+#define SIGPIPE 13
+#define SIGCONT 18
+#define SIGTSTP 20
+#define SIGWINCH 28
+
+// tcsetattr arguments
+#define TCSANOW 0
+
+#define NCCS 32
+struct termios {
+ tcflag_t c_iflag; // input mode flags
+ tcflag_t c_oflag; // output mode flags
+ tcflag_t c_cflag; // control mode flags
+ tcflag_t c_lflag; // local mode flags
+ cc_t c_line; // line discipline
+ cc_t c_cc[NCCS]; // control characters
+ speed_t c_ispeed; // input speed
+ speed_t c_ospeed; // output speed
+};
#ifdef _MSC_VER
- struct timeval
- {
- long tv_sec;
- long tv_usec;
- };
- typedef long pid_t;
- #define snprintf _snprintf
- #define PATH_MAX MAX_PATH
+struct timeval {
+ long tv_sec;
+ long tv_usec;
+};
+typedef long pid_t;
+#define snprintf _snprintf
+#define PATH_MAX MAX_PATH
#endif
- #define STDIN_FILENO 0
+#define STDIN_FILENO 0
- extern int ioctl( int d, int request, ... );
- extern int kill ( pid_t pid, int sig );
- extern int tcsetattr( int fd, int optional_actions, const struct termios *termios_p );
- extern int tcgetattr( int fildes, struct termios *termios_p );
+extern int ioctl(int d, int request, ...);
+extern int kill(pid_t pid, int sig);
+extern int tcsetattr(int fd, int optional_actions,
+ const struct termios *termios_p);
+extern int tcgetattr(int fildes, struct termios *termios_p);
#else
- #include "lldb/Host/HostGetOpt.h"
- #include <inttypes.h>
+#include "lldb/Host/HostGetOpt.h"
+#include <inttypes.h>
- #include <libgen.h>
- #include <sys/ioctl.h>
- #include <termios.h>
- #include <unistd.h>
+#include <libgen.h>
+#include <sys/ioctl.h>
+#include <termios.h>
+#include <unistd.h>
- #include <pthread.h>
- #include <sys/time.h>
+#include <pthread.h>
+#include <sys/time.h>
#endif
#endif // lldb_Platform_h_
Modified: lldb/trunk/tools/lldb-mi/MICmdArgContext.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/lldb-mi/MICmdArgContext.cpp?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/tools/lldb-mi/MICmdArgContext.cpp (original)
+++ lldb/trunk/tools/lldb-mi/MICmdArgContext.cpp Tue Sep 6 15:57:50 2016
@@ -10,68 +10,68 @@
// In-house headers:
#include "MICmdArgContext.h"
-//++ ------------------------------------------------------------------------------------
+//++
+//------------------------------------------------------------------------------------
// Details: CMICmdArgContext constructor.
// Type: Method.
// Args: None.
// Return: None.
// Throws: None.
//--
-CMICmdArgContext::CMICmdArgContext()
-{
-}
+CMICmdArgContext::CMICmdArgContext() {}
-//++ ------------------------------------------------------------------------------------
+//++
+//------------------------------------------------------------------------------------
// Details: CMICmdArgContext constructor.
// Type: Method.
-// Args: vrCmdLineArgsRaw - (R) The text description of the arguments options.
+// Args: vrCmdLineArgsRaw - (R) The text description of the arguments
+// options.
// Return: None.
// Throws: None.
//--
CMICmdArgContext::CMICmdArgContext(const CMIUtilString &vrCmdLineArgsRaw)
- : m_strCmdArgsAndOptions(vrCmdLineArgsRaw)
-{
-}
+ : m_strCmdArgsAndOptions(vrCmdLineArgsRaw) {}
-//++ ------------------------------------------------------------------------------------
+//++
+//------------------------------------------------------------------------------------
// Details: CMICmdArgContext destructor.
// Type: Method.
// Args: None.
// Return: None.
// Throws: None.
//--
-CMICmdArgContext::~CMICmdArgContext()
-{
-}
+CMICmdArgContext::~CMICmdArgContext() {}
-//++ ------------------------------------------------------------------------------------
-// Details: Retrieve the remainder of the command's argument options left to parse.
+//++
+//------------------------------------------------------------------------------------
+// Details: Retrieve the remainder of the command's argument options left to
+// parse.
// Type: Method.
// Args: None.
// Return: CMIUtilString & - Argument options text.
// Throws: None.
//--
-const CMIUtilString &
-CMICmdArgContext::GetArgsLeftToParse() const
-{
- return m_strCmdArgsAndOptions;
+const CMIUtilString &CMICmdArgContext::GetArgsLeftToParse() const {
+ return m_strCmdArgsAndOptions;
}
-//++ ------------------------------------------------------------------------------------
+//++
+//------------------------------------------------------------------------------------
// Details: Ask if this arguments string has any arguments.
// Type: Method.
// Args: None.
-// Return: bool - True = Has one or more arguments present, false = no arguments.
+// Return: bool - True = Has one or more arguments present, false = no
+// arguments.
// Throws: None.
//--
-bool
-CMICmdArgContext::IsEmpty() const
-{
- return m_strCmdArgsAndOptions.empty();
+bool CMICmdArgContext::IsEmpty() const {
+ return m_strCmdArgsAndOptions.empty();
}
-//++ ------------------------------------------------------------------------------------
-// Details: Remove the argument from the options text and any space after the argument
+//++
+//------------------------------------------------------------------------------------
+// Details: Remove the argument from the options text and any space after the
+// argument
// if applicable.
// Type: Method.
// Args: vArg - (R) The name of the argument.
@@ -79,167 +79,154 @@ CMICmdArgContext::IsEmpty() const
// MIstatus::failure - Functional failed.
// Throws: None.
//--
-bool
-CMICmdArgContext::RemoveArg(const CMIUtilString &vArg)
-{
- if (vArg.empty())
- return MIstatus::success;
-
- const size_t nLen = vArg.length();
- const size_t nLenCntxt = m_strCmdArgsAndOptions.length();
- if (nLen > nLenCntxt)
- return MIstatus::failure;
-
- size_t nExtraSpace = 0;
- size_t nPos = m_strCmdArgsAndOptions.find(vArg);
- while (1)
- {
- if (nPos == std::string::npos)
- return MIstatus::success;
-
- bool bPass1 = false;
- if (nPos != 0)
- {
- if (m_strCmdArgsAndOptions[nPos - 1] == ' ')
- bPass1 = true;
- }
- else
- bPass1 = true;
-
- const size_t nEnd = nPos + nLen;
-
- if (bPass1)
- {
- bool bPass2 = false;
- if (nEnd < nLenCntxt)
- {
- if (m_strCmdArgsAndOptions[nEnd] == ' ')
- {
- bPass2 = true;
- nExtraSpace = 1;
- }
- }
- else
- bPass2 = true;
+bool CMICmdArgContext::RemoveArg(const CMIUtilString &vArg) {
+ if (vArg.empty())
+ return MIstatus::success;
- if (bPass2)
- break;
+ const size_t nLen = vArg.length();
+ const size_t nLenCntxt = m_strCmdArgsAndOptions.length();
+ if (nLen > nLenCntxt)
+ return MIstatus::failure;
+
+ size_t nExtraSpace = 0;
+ size_t nPos = m_strCmdArgsAndOptions.find(vArg);
+ while (1) {
+ if (nPos == std::string::npos)
+ return MIstatus::success;
+
+ bool bPass1 = false;
+ if (nPos != 0) {
+ if (m_strCmdArgsAndOptions[nPos - 1] == ' ')
+ bPass1 = true;
+ } else
+ bPass1 = true;
+
+ const size_t nEnd = nPos + nLen;
+
+ if (bPass1) {
+ bool bPass2 = false;
+ if (nEnd < nLenCntxt) {
+ if (m_strCmdArgsAndOptions[nEnd] == ' ') {
+ bPass2 = true;
+ nExtraSpace = 1;
}
+ } else
+ bPass2 = true;
- nPos = m_strCmdArgsAndOptions.find(vArg, nEnd);
+ if (bPass2)
+ break;
}
- const size_t nPosEnd = nLen + nExtraSpace;
- m_strCmdArgsAndOptions = m_strCmdArgsAndOptions.replace(nPos, nPosEnd, "");
- m_strCmdArgsAndOptions = m_strCmdArgsAndOptions.Trim();
+ nPos = m_strCmdArgsAndOptions.find(vArg, nEnd);
+ }
- return MIstatus::success;
-}
-
-//++ ------------------------------------------------------------------------------------
-// Details: Remove the argument at the Nth word position along in the context string.
-// Any space after the argument is removed if applicable. A search is not
-// performed as there may be more than one vArg with the same 'name' in the
+ const size_t nPosEnd = nLen + nExtraSpace;
+ m_strCmdArgsAndOptions = m_strCmdArgsAndOptions.replace(nPos, nPosEnd, "");
+ m_strCmdArgsAndOptions = m_strCmdArgsAndOptions.Trim();
+
+ return MIstatus::success;
+}
+
+//++
+//------------------------------------------------------------------------------------
+// Details: Remove the argument at the Nth word position along in the context
+// string.
+// Any space after the argument is removed if applicable. A search is
+// not
+// performed as there may be more than one vArg with the same 'name' in
+// the
// context string.
// Type: Method.
// Args: vArg - (R) The name of the argument.
-// nArgIndex - (R) The word count position to which to remove the vArg word.
+// nArgIndex - (R) The word count position to which to remove the
+// vArg word.
// Return: MIstatus::success - Functional succeeded.
// MIstatus::failure - Functional failed.
// Throws: None.
//--
-bool
-CMICmdArgContext::RemoveArgAtPos(const CMIUtilString &vArg, size_t nArgIndex)
-{
- size_t nWordIndex = 0;
- CMIUtilString strBuildContextUp;
- const CMIUtilString::VecString_t vecWords(GetArgs());
- const bool bSpaceRequired(GetNumberArgsPresent() > 2);
-
- CMIUtilString::VecString_t::const_iterator it = vecWords.begin();
- const CMIUtilString::VecString_t::const_iterator itEnd = vecWords.end();
- while (it != itEnd)
- {
- const CMIUtilString &rWord(*it);
- if (nWordIndex++ != nArgIndex)
- {
- // Single words
- strBuildContextUp += rWord;
- if (bSpaceRequired)
- strBuildContextUp += " ";
+bool CMICmdArgContext::RemoveArgAtPos(const CMIUtilString &vArg,
+ size_t nArgIndex) {
+ size_t nWordIndex = 0;
+ CMIUtilString strBuildContextUp;
+ const CMIUtilString::VecString_t vecWords(GetArgs());
+ const bool bSpaceRequired(GetNumberArgsPresent() > 2);
+
+ CMIUtilString::VecString_t::const_iterator it = vecWords.begin();
+ const CMIUtilString::VecString_t::const_iterator itEnd = vecWords.end();
+ while (it != itEnd) {
+ const CMIUtilString &rWord(*it);
+ if (nWordIndex++ != nArgIndex) {
+ // Single words
+ strBuildContextUp += rWord;
+ if (bSpaceRequired)
+ strBuildContextUp += " ";
+ } else {
+ // If quoted loose quoted text
+ if (++it != itEnd) {
+ CMIUtilString words = rWord;
+ while (vArg != words) {
+ if (bSpaceRequired)
+ words += " ";
+ words += *it;
+ if (++it == itEnd)
+ break;
}
- else
- {
- // If quoted loose quoted text
- if (++it != itEnd)
- {
- CMIUtilString words = rWord;
- while (vArg != words)
- {
- if (bSpaceRequired)
- words += " ";
- words += *it;
- if (++it == itEnd)
- break;
- }
- if (it != itEnd)
- --it;
- }
- }
-
- // Next
if (it != itEnd)
- ++it;
+ --it;
+ }
}
- m_strCmdArgsAndOptions = strBuildContextUp;
- m_strCmdArgsAndOptions = m_strCmdArgsAndOptions.Trim();
+ // Next
+ if (it != itEnd)
+ ++it;
+ }
- return MIstatus::success;
+ m_strCmdArgsAndOptions = strBuildContextUp;
+ m_strCmdArgsAndOptions = m_strCmdArgsAndOptions.Trim();
+
+ return MIstatus::success;
}
-//++ ------------------------------------------------------------------------------------
-// Details: Retrieve number of arguments or options present in the command's option text.
+//++
+//------------------------------------------------------------------------------------
+// Details: Retrieve number of arguments or options present in the command's
+// option text.
// Type: Method.
// Args: None.
// Return: size_t - 0 to n arguments present.
// Throws: None.
//--
-size_t
-CMICmdArgContext::GetNumberArgsPresent() const
-{
- CMIUtilString::VecString_t vecOptions;
- return m_strCmdArgsAndOptions.SplitConsiderQuotes(" ", vecOptions);
+size_t CMICmdArgContext::GetNumberArgsPresent() const {
+ CMIUtilString::VecString_t vecOptions;
+ return m_strCmdArgsAndOptions.SplitConsiderQuotes(" ", vecOptions);
}
-//++ ------------------------------------------------------------------------------------
+//++
+//------------------------------------------------------------------------------------
// Details: Retrieve all the arguments or options remaining in *this context.
// Type: Method.
// Args: None.
// Return: MIUtilString::VecString_t - List of args remaining.
// Throws: None.
//--
-CMIUtilString::VecString_t
-CMICmdArgContext::GetArgs() const
-{
- CMIUtilString::VecString_t vecOptions;
- m_strCmdArgsAndOptions.SplitConsiderQuotes(" ", vecOptions);
- return vecOptions;
+CMIUtilString::VecString_t CMICmdArgContext::GetArgs() const {
+ CMIUtilString::VecString_t vecOptions;
+ m_strCmdArgsAndOptions.SplitConsiderQuotes(" ", vecOptions);
+ return vecOptions;
}
-//++ ------------------------------------------------------------------------------------
+//++
+//------------------------------------------------------------------------------------
// Details: Copy assignment operator.
// Type: Method.
// Args: vOther - (R) The variable to copy from.
// Return: CMIUtilString & - this object.
// Throws: None.
//--
-CMICmdArgContext &CMICmdArgContext::operator=(const CMICmdArgContext &vOther)
-{
- if (this != &vOther)
- {
- m_strCmdArgsAndOptions = vOther.m_strCmdArgsAndOptions;
- }
+CMICmdArgContext &CMICmdArgContext::operator=(const CMICmdArgContext &vOther) {
+ if (this != &vOther) {
+ m_strCmdArgsAndOptions = vOther.m_strCmdArgsAndOptions;
+ }
- return *this;
+ return *this;
}
Modified: lldb/trunk/tools/lldb-mi/MICmdArgContext.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/lldb-mi/MICmdArgContext.h?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/tools/lldb-mi/MICmdArgContext.h (original)
+++ lldb/trunk/tools/lldb-mi/MICmdArgContext.h Tue Sep 6 15:57:50 2016
@@ -12,33 +12,33 @@
// In-house headers:
#include "MIUtilString.h"
-//++ ============================================================================
+//++
+//============================================================================
// Details: MI common code class. Command arguments and options string. Holds
// the context string.
// Based on the Interpreter pattern.
//--
-class CMICmdArgContext
-{
- // Methods:
- public:
- /* ctor */ CMICmdArgContext();
- /* ctor */ CMICmdArgContext(const CMIUtilString &vrCmdLineArgsRaw);
- //
- const CMIUtilString &GetArgsLeftToParse() const;
- size_t GetNumberArgsPresent() const;
- CMIUtilString::VecString_t GetArgs() const;
- bool IsEmpty() const;
- bool RemoveArg(const CMIUtilString &vArg);
- bool RemoveArgAtPos(const CMIUtilString &vArg, size_t nArgIndex);
- //
- CMICmdArgContext &operator=(const CMICmdArgContext &vOther);
+class CMICmdArgContext {
+ // Methods:
+public:
+ /* ctor */ CMICmdArgContext();
+ /* ctor */ CMICmdArgContext(const CMIUtilString &vrCmdLineArgsRaw);
+ //
+ const CMIUtilString &GetArgsLeftToParse() const;
+ size_t GetNumberArgsPresent() const;
+ CMIUtilString::VecString_t GetArgs() const;
+ bool IsEmpty() const;
+ bool RemoveArg(const CMIUtilString &vArg);
+ bool RemoveArgAtPos(const CMIUtilString &vArg, size_t nArgIndex);
+ //
+ CMICmdArgContext &operator=(const CMICmdArgContext &vOther);
- // Overridden:
- public:
- // From CMIUtilString
- /* dtor */ virtual ~CMICmdArgContext();
+ // Overridden:
+public:
+ // From CMIUtilString
+ /* dtor */ virtual ~CMICmdArgContext();
- // Attributes:
- private:
- CMIUtilString m_strCmdArgsAndOptions;
+ // Attributes:
+private:
+ CMIUtilString m_strCmdArgsAndOptions;
};
Modified: lldb/trunk/tools/lldb-mi/MICmdArgSet.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/lldb-mi/MICmdArgSet.cpp?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/tools/lldb-mi/MICmdArgSet.cpp (original)
+++ lldb/trunk/tools/lldb-mi/MICmdArgSet.cpp Tue Sep 6 15:57:50 2016
@@ -10,10 +10,11 @@
// In-house headers:
#include "MICmdArgSet.h"
#include "MICmdArgValBase.h"
-#include "MICmnResources.h"
#include "MICmnLog.h"
+#include "MICmnResources.h"
-//++ ------------------------------------------------------------------------------------
+//++
+//------------------------------------------------------------------------------------
// Details: CMICmdArgSet constructor.
// Type: Method.
// Args: None.
@@ -21,136 +22,140 @@
// Throws: None.
//--
CMICmdArgSet::CMICmdArgSet()
- : m_bIsArgsPresentButNotHandledByCmd(false)
- , m_constStrCommaSpc(", ")
-{
-}
+ : m_bIsArgsPresentButNotHandledByCmd(false), m_constStrCommaSpc(", ") {}
-//++ ------------------------------------------------------------------------------------
+//++
+//------------------------------------------------------------------------------------
// Details: CMICmdArgSet destructor.
// Type: Method.
// Args: None.
// Return: None.
// Throws: None.
//--
-CMICmdArgSet::~CMICmdArgSet()
-{
- // Tidy up
- Destroy();
+CMICmdArgSet::~CMICmdArgSet() {
+ // Tidy up
+ Destroy();
}
-//++ ------------------------------------------------------------------------------------
+//++
+//------------------------------------------------------------------------------------
// Details: Release resources used by *this container object.
// Type: Method.
// Args: None.
// Return: None.
// Throws: None.
//--
-void
-CMICmdArgSet::Destroy()
-{
- // Delete command argument objects
- if (!m_setCmdArgs.empty())
- {
- SetCmdArgs_t::iterator it = m_setCmdArgs.begin();
- while (it != m_setCmdArgs.end())
- {
- CMICmdArgValBase *pArg(*it);
- delete pArg;
-
- // Next
- ++it;
- }
- m_setCmdArgs.clear();
- }
-
- m_setCmdArgsThatNotValid.clear();
- m_setCmdArgsThatAreMissing.clear();
- m_setCmdArgsNotHandledByCmd.clear();
- m_setCmdArgsMissingInfo.clear();
- m_bIsArgsPresentButNotHandledByCmd = false;
-}
-
-//++ ------------------------------------------------------------------------------------
-// Details: Retrieve the state flag indicating that the command set up ready to parse
-// command arguments or options found that one or more arguments was indeed
-// present but not handled. This is given as a warning in the MI log file.
+void CMICmdArgSet::Destroy() {
+ // Delete command argument objects
+ if (!m_setCmdArgs.empty()) {
+ SetCmdArgs_t::iterator it = m_setCmdArgs.begin();
+ while (it != m_setCmdArgs.end()) {
+ CMICmdArgValBase *pArg(*it);
+ delete pArg;
+
+ // Next
+ ++it;
+ }
+ m_setCmdArgs.clear();
+ }
+
+ m_setCmdArgsThatNotValid.clear();
+ m_setCmdArgsThatAreMissing.clear();
+ m_setCmdArgsNotHandledByCmd.clear();
+ m_setCmdArgsMissingInfo.clear();
+ m_bIsArgsPresentButNotHandledByCmd = false;
+}
+
+//++
+//------------------------------------------------------------------------------------
+// Details: Retrieve the state flag indicating that the command set up ready to
+// parse
+// command arguments or options found that one or more arguments was
+// indeed
+// present but not handled. This is given as a warning in the MI log
+// file.
// Type: Method.
// Args: None.
// Return: bool - True = one or more args not handled, false = all args handled
// Throws: None.
//--
-bool
-CMICmdArgSet::IsArgsPresentButNotHandledByCmd() const
-{
- return m_bIsArgsPresentButNotHandledByCmd;
+bool CMICmdArgSet::IsArgsPresentButNotHandledByCmd() const {
+ return m_bIsArgsPresentButNotHandledByCmd;
}
-//++ ------------------------------------------------------------------------------------
-// Details: Add the list of command's arguments to parse and validate another one.
+//++
+//------------------------------------------------------------------------------------
+// Details: Add the list of command's arguments to parse and validate another
+// one.
// Type: Method.
// Args: vArg - (R) A command argument object.
// Return: None.
// Throws: None.
//--
-void
-CMICmdArgSet::Add(CMICmdArgValBase *vArg)
-{
- m_setCmdArgs.push_back(vArg);
-}
+void CMICmdArgSet::Add(CMICmdArgValBase *vArg) { m_setCmdArgs.push_back(vArg); }
-//++ ------------------------------------------------------------------------------------
-// Details: After validating an options line of text (the context) and there is a failure,
-// it is likely a mandatory command argument that is required is missing. This
+//++
+//------------------------------------------------------------------------------------
+// Details: After validating an options line of text (the context) and there is
+// a failure,
+// it is likely a mandatory command argument that is required is
+// missing. This
// function returns the argument that should be present.
// Type: Method.
// Args: None.
// Return: SetCmdArgs_t & - Set of argument objects.
// Throws: None.
//--
-const CMICmdArgSet::SetCmdArgs_t &
-CMICmdArgSet::GetArgsThatAreMissing() const
-{
- return m_setCmdArgsThatAreMissing;
+const CMICmdArgSet::SetCmdArgs_t &CMICmdArgSet::GetArgsThatAreMissing() const {
+ return m_setCmdArgsThatAreMissing;
}
-//++ ------------------------------------------------------------------------------------
-// Details: After validating an options line of text (the context) and there is a failure,
-// it may be because one or more arguments were unable to extract a value. This
+//++
+//------------------------------------------------------------------------------------
+// Details: After validating an options line of text (the context) and there is
+// a failure,
+// it may be because one or more arguments were unable to extract a
+// value. This
// function returns the argument that were found to be invalid.
// Type: Method.
// Args: None.
// Return: SetCmdArgs_t & - Set of argument objects.
// Throws: None.
//--
-const CMICmdArgSet::SetCmdArgs_t &
-CMICmdArgSet::GetArgsThatInvalid() const
-{
- return m_setCmdArgsThatNotValid;
+const CMICmdArgSet::SetCmdArgs_t &CMICmdArgSet::GetArgsThatInvalid() const {
+ return m_setCmdArgsThatNotValid;
}
-//++ ------------------------------------------------------------------------------------
-// Details: The list of argument or option (objects) that were specified by the command
-// and so recognised when parsed but were not handled. Ideally the command
-// should handle all arguments and options presented to it. The command sends
-// warning to the MI log file to say that these options were not handled.
-// Used as one way to determine option that maybe should really be implemented
+//++
+//------------------------------------------------------------------------------------
+// Details: The list of argument or option (objects) that were specified by the
+// command
+// and so recognised when parsed but were not handled. Ideally the
+// command
+// should handle all arguments and options presented to it. The command
+// sends
+// warning to the MI log file to say that these options were not
+// handled.
+// Used as one way to determine option that maybe should really be
+// implemented
// and not just ignored.
// Type: Method.
// Args: None.
// Return: SetCmdArgs_t & - Set of argument objects.
// Throws: None.
//--
-const CMICmdArgSet::SetCmdArgs_t &
-CMICmdArgSet::GetArgsNotHandledByCmd() const
-{
- return m_setCmdArgsNotHandledByCmd;
+const CMICmdArgSet::SetCmdArgs_t &CMICmdArgSet::GetArgsNotHandledByCmd() const {
+ return m_setCmdArgsNotHandledByCmd;
}
-//++ ------------------------------------------------------------------------------------
-// Details: Given a set of command argument objects parse the context option string to
-// find those argument and retrieve their value. If the function fails call
-// GetArgsThatAreMissing() to see which commands that were mandatory were
+//++
+//------------------------------------------------------------------------------------
+// Details: Given a set of command argument objects parse the context option
+// string to
+// find those argument and retrieve their value. If the function fails
+// call
+// GetArgsThatAreMissing() to see which commands that were mandatory
+// were
// missing or failed to parse.
// Type: Method.
// Args: vStrMiCmd - (R) Command's name.
@@ -159,49 +164,45 @@ CMICmdArgSet::GetArgsNotHandledByCmd() c
// MIstatus::failure - Functional failed.
// Throws: None.
//--
-bool
-CMICmdArgSet::Validate(const CMIUtilString &vStrMiCmd, CMICmdArgContext &vwCmdArgsText)
-{
- m_cmdArgContext = vwCmdArgsText;
-
- // Iterate all the arguments or options required by a command
- SetCmdArgs_t::const_iterator it = m_setCmdArgs.begin();
- while (it != m_setCmdArgs.end())
- {
- CMICmdArgValBase *pArg = *it;
-
- if (!pArg->Validate(vwCmdArgsText))
- {
- if (pArg->GetFound())
- {
- if (pArg->GetIsMissingOptions())
- m_setCmdArgsMissingInfo.push_back(pArg);
- else if (!pArg->GetValid())
- m_setCmdArgsThatNotValid.push_back(pArg);
- }
- else if (pArg->GetIsMandatory())
- m_setCmdArgsThatAreMissing.push_back(pArg);
- }
-
- if (pArg->GetFound() && !pArg->GetIsHandledByCmd())
- {
- m_bIsArgsPresentButNotHandledByCmd = true;
- m_setCmdArgsNotHandledByCmd.push_back(pArg);
- }
+bool CMICmdArgSet::Validate(const CMIUtilString &vStrMiCmd,
+ CMICmdArgContext &vwCmdArgsText) {
+ m_cmdArgContext = vwCmdArgsText;
- // Next
- ++it;
+ // Iterate all the arguments or options required by a command
+ SetCmdArgs_t::const_iterator it = m_setCmdArgs.begin();
+ while (it != m_setCmdArgs.end()) {
+ CMICmdArgValBase *pArg = *it;
+
+ if (!pArg->Validate(vwCmdArgsText)) {
+ if (pArg->GetFound()) {
+ if (pArg->GetIsMissingOptions())
+ m_setCmdArgsMissingInfo.push_back(pArg);
+ else if (!pArg->GetValid())
+ m_setCmdArgsThatNotValid.push_back(pArg);
+ } else if (pArg->GetIsMandatory())
+ m_setCmdArgsThatAreMissing.push_back(pArg);
}
- // report any issues with arguments/options
- if (IsArgsPresentButNotHandledByCmd())
- WarningArgsNotHandledbyCmdLogFile(vStrMiCmd);
+ if (pArg->GetFound() && !pArg->GetIsHandledByCmd()) {
+ m_bIsArgsPresentButNotHandledByCmd = true;
+ m_setCmdArgsNotHandledByCmd.push_back(pArg);
+ }
- return ValidationFormErrorMessages(vwCmdArgsText);
+ // Next
+ ++it;
+ }
+
+ // report any issues with arguments/options
+ if (IsArgsPresentButNotHandledByCmd())
+ WarningArgsNotHandledbyCmdLogFile(vStrMiCmd);
+
+ return ValidationFormErrorMessages(vwCmdArgsText);
}
-//++ ------------------------------------------------------------------------------------
-// Details: Having validated the command's options text and failed for some reason form
+//++
+//------------------------------------------------------------------------------------
+// Details: Having validated the command's options text and failed for some
+// reason form
// the error message made up with the faults found.
// Type: Method.
// vCmdArgsText - (RW) A command's options or argument.
@@ -209,139 +210,134 @@ CMICmdArgSet::Validate(const CMIUtilStri
// MIstatus::failure - Functional failed.
// Throws: None.
//--
-bool
-CMICmdArgSet::ValidationFormErrorMessages(const CMICmdArgContext &vwCmdArgsText)
-{
- CMIUtilString strListMissing;
- CMIUtilString strListInvalid;
- CMIUtilString strListMissingInfo;
- const bool bArgsMissing = (m_setCmdArgsThatAreMissing.size() > 0);
- const bool bArgsInvalid = (m_setCmdArgsThatNotValid.size() > 0);
- const bool bArgsMissingInfo = (m_setCmdArgsMissingInfo.size() > 0);
- if (!(bArgsMissing || bArgsInvalid || bArgsMissingInfo))
- return MIstatus::success;
- if (bArgsMissing)
- {
- MIuint i = 0;
- SetCmdArgs_t::const_iterator it = m_setCmdArgsThatAreMissing.begin();
- while (it != m_setCmdArgsThatAreMissing.end())
- {
- if (i++ > 0)
- strListMissing += m_constStrCommaSpc;
-
- const CMICmdArgValBase *pArg(*it);
- strListMissing += pArg->GetName();
-
- // Next
- ++it;
- }
- }
- if (bArgsInvalid)
- {
- MIuint i = 0;
- SetCmdArgs_t::const_iterator it = m_setCmdArgsThatNotValid.begin();
- while (it != m_setCmdArgsThatNotValid.end())
- {
- if (i++ > 0)
- strListMissing += m_constStrCommaSpc;
-
- const CMICmdArgValBase *pArg(*it);
- strListInvalid += pArg->GetName();
-
- // Next
- ++it;
- }
- }
- if (bArgsMissingInfo)
- {
- MIuint i = 0;
- SetCmdArgs_t::const_iterator it = m_setCmdArgsMissingInfo.begin();
- while (it != m_setCmdArgsMissingInfo.end())
- {
- if (i++ > 0)
- strListMissingInfo += m_constStrCommaSpc;
-
- const CMICmdArgValBase *pArg(*it);
- strListMissingInfo += pArg->GetName();
-
- // Next
- ++it;
- }
- }
-
- bool bHaveOneError = false;
- CMIUtilString strError = MIRSRC(IDS_CMD_ARGS_ERR_PREFIX_MSG);
- if (bArgsMissing && bArgsInvalid)
- {
- bHaveOneError = true;
- strError += CMIUtilString::Format(MIRSRC(IDS_CMD_ARGS_ERR_VALIDATION_MAN_INVALID), strListMissing.c_str(), strListInvalid.c_str());
- }
- if (bArgsMissing)
- {
- if (bHaveOneError)
- strError += ". ";
- bHaveOneError = true;
- strError += CMIUtilString::Format(MIRSRC(IDS_CMD_ARGS_ERR_VALIDATION_MANDATORY), strListMissing.c_str());
- }
- if (bArgsMissingInfo)
- {
- if (bHaveOneError)
- strError += ". ";
- bHaveOneError = true;
- strError += CMIUtilString::Format(MIRSRC(IDS_CMD_ARGS_ERR_VALIDATION_MISSING_INF), strListMissingInfo.c_str());
- }
- if (bArgsInvalid)
- {
- if (bHaveOneError)
- strError += ". ";
- bHaveOneError = true;
- strError += CMIUtilString::Format(MIRSRC(IDS_CMD_ARGS_ERR_VALIDATION_INVALID), strListInvalid.c_str());
- }
- if (!vwCmdArgsText.IsEmpty())
- {
- if (bHaveOneError)
- strError += ". ";
- bHaveOneError = true;
- strError += CMIUtilString::Format(MIRSRC(IDS_CMD_ARGS_ERR_CONTEXT_NOT_ALL_EATTEN), vwCmdArgsText.GetArgsLeftToParse().c_str());
- }
-
+bool CMICmdArgSet::ValidationFormErrorMessages(
+ const CMICmdArgContext &vwCmdArgsText) {
+ CMIUtilString strListMissing;
+ CMIUtilString strListInvalid;
+ CMIUtilString strListMissingInfo;
+ const bool bArgsMissing = (m_setCmdArgsThatAreMissing.size() > 0);
+ const bool bArgsInvalid = (m_setCmdArgsThatNotValid.size() > 0);
+ const bool bArgsMissingInfo = (m_setCmdArgsMissingInfo.size() > 0);
+ if (!(bArgsMissing || bArgsInvalid || bArgsMissingInfo))
+ return MIstatus::success;
+ if (bArgsMissing) {
+ MIuint i = 0;
+ SetCmdArgs_t::const_iterator it = m_setCmdArgsThatAreMissing.begin();
+ while (it != m_setCmdArgsThatAreMissing.end()) {
+ if (i++ > 0)
+ strListMissing += m_constStrCommaSpc;
+
+ const CMICmdArgValBase *pArg(*it);
+ strListMissing += pArg->GetName();
+
+ // Next
+ ++it;
+ }
+ }
+ if (bArgsInvalid) {
+ MIuint i = 0;
+ SetCmdArgs_t::const_iterator it = m_setCmdArgsThatNotValid.begin();
+ while (it != m_setCmdArgsThatNotValid.end()) {
+ if (i++ > 0)
+ strListMissing += m_constStrCommaSpc;
+
+ const CMICmdArgValBase *pArg(*it);
+ strListInvalid += pArg->GetName();
+
+ // Next
+ ++it;
+ }
+ }
+ if (bArgsMissingInfo) {
+ MIuint i = 0;
+ SetCmdArgs_t::const_iterator it = m_setCmdArgsMissingInfo.begin();
+ while (it != m_setCmdArgsMissingInfo.end()) {
+ if (i++ > 0)
+ strListMissingInfo += m_constStrCommaSpc;
+
+ const CMICmdArgValBase *pArg(*it);
+ strListMissingInfo += pArg->GetName();
+
+ // Next
+ ++it;
+ }
+ }
+
+ bool bHaveOneError = false;
+ CMIUtilString strError = MIRSRC(IDS_CMD_ARGS_ERR_PREFIX_MSG);
+ if (bArgsMissing && bArgsInvalid) {
+ bHaveOneError = true;
+ strError +=
+ CMIUtilString::Format(MIRSRC(IDS_CMD_ARGS_ERR_VALIDATION_MAN_INVALID),
+ strListMissing.c_str(), strListInvalid.c_str());
+ }
+ if (bArgsMissing) {
if (bHaveOneError)
- {
- SetErrorDescription(strError);
- return MIstatus::failure;
- }
+ strError += ". ";
+ bHaveOneError = true;
+ strError += CMIUtilString::Format(
+ MIRSRC(IDS_CMD_ARGS_ERR_VALIDATION_MANDATORY), strListMissing.c_str());
+ }
+ if (bArgsMissingInfo) {
+ if (bHaveOneError)
+ strError += ". ";
+ bHaveOneError = true;
+ strError +=
+ CMIUtilString::Format(MIRSRC(IDS_CMD_ARGS_ERR_VALIDATION_MISSING_INF),
+ strListMissingInfo.c_str());
+ }
+ if (bArgsInvalid) {
+ if (bHaveOneError)
+ strError += ". ";
+ bHaveOneError = true;
+ strError += CMIUtilString::Format(
+ MIRSRC(IDS_CMD_ARGS_ERR_VALIDATION_INVALID), strListInvalid.c_str());
+ }
+ if (!vwCmdArgsText.IsEmpty()) {
+ if (bHaveOneError)
+ strError += ". ";
+ bHaveOneError = true;
+ strError +=
+ CMIUtilString::Format(MIRSRC(IDS_CMD_ARGS_ERR_CONTEXT_NOT_ALL_EATTEN),
+ vwCmdArgsText.GetArgsLeftToParse().c_str());
+ }
+
+ if (bHaveOneError) {
+ SetErrorDescription(strError);
+ return MIstatus::failure;
+ }
- return MIstatus::success;
+ return MIstatus::success;
}
-//++ ------------------------------------------------------------------------------------
+//++
+//------------------------------------------------------------------------------------
// Details: Ask if the command's argument options text had any arguments.
// Type: Method.
// Args: None.
-// Return: bool - True = Has one or more arguments present, false = no arguments.
+// Return: bool - True = Has one or more arguments present, false = no
+// arguments.
// Throws: None.
//--
-bool
-CMICmdArgSet::IsArgContextEmpty() const
-{
- return m_cmdArgContext.IsEmpty();
+bool CMICmdArgSet::IsArgContextEmpty() const {
+ return m_cmdArgContext.IsEmpty();
}
-//++ ------------------------------------------------------------------------------------
-// Details: Retrieve the number of arguments that are being used for the command.
+//++
+//------------------------------------------------------------------------------------
+// Details: Retrieve the number of arguments that are being used for the
+// command.
// Type: Method.
// Args: None.
// Return: size_t - Argument count.
// Throws: None.
//--
-size_t
-CMICmdArgSet::GetCount() const
-{
- return m_setCmdArgs.size();
-}
+size_t CMICmdArgSet::GetCount() const { return m_setCmdArgs.size(); }
-//++ ------------------------------------------------------------------------------------
-// Details: Given a set of command argument objects retrieve the argument with the
+//++
+//------------------------------------------------------------------------------------
+// Details: Given a set of command argument objects retrieve the argument with
+// the
// specified name.
// Type: Method.
// Args: vpArg - (W) A pointer to a command's argument object.
@@ -349,59 +345,57 @@ CMICmdArgSet::GetCount() const
// False - Argument not found.
// Throws: None.
//--
-bool
-CMICmdArgSet::GetArg(const CMIUtilString &vArgName, CMICmdArgValBase *&vpArg) const
-{
- bool bFound = false;
- SetCmdArgs_t::const_iterator it = m_setCmdArgs.begin();
- while (it != m_setCmdArgs.end())
- {
- CMICmdArgValBase *pArg(*it);
- if (pArg->GetName() == vArgName)
- {
- bFound = true;
- vpArg = pArg;
- break;
- }
-
- // Next
- ++it;
- }
-
- return bFound;
-}
-
-//++ ------------------------------------------------------------------------------------
-// Details: Write a warning message to the MI Log file about the command's arguments or
+bool CMICmdArgSet::GetArg(const CMIUtilString &vArgName,
+ CMICmdArgValBase *&vpArg) const {
+ bool bFound = false;
+ SetCmdArgs_t::const_iterator it = m_setCmdArgs.begin();
+ while (it != m_setCmdArgs.end()) {
+ CMICmdArgValBase *pArg(*it);
+ if (pArg->GetName() == vArgName) {
+ bFound = true;
+ vpArg = pArg;
+ break;
+ }
+
+ // Next
+ ++it;
+ }
+
+ return bFound;
+}
+
+//++
+//------------------------------------------------------------------------------------
+// Details: Write a warning message to the MI Log file about the command's
+// arguments or
// options that were found present but not handled.
// Type: Method.
// Args: vrCmdName - (R) The command's name.
// Return: None.
// Throws: None.
//--
-void
-CMICmdArgSet::WarningArgsNotHandledbyCmdLogFile(const CMIUtilString &vrCmdName)
-{
+void CMICmdArgSet::WarningArgsNotHandledbyCmdLogFile(
+ const CMIUtilString &vrCmdName) {
#if MICONFIG_GIVE_WARNING_CMD_ARGS_NOT_HANDLED
- CMIUtilString strArgsNotHandled;
- const CMICmdArgSet::SetCmdArgs_t &rSetArgs = GetArgsNotHandledByCmd();
- MIuint nCnt = 0;
- CMICmdArgSet::SetCmdArgs_t::const_iterator it = rSetArgs.begin();
- while (it != rSetArgs.end())
- {
- if (nCnt++ > 0)
- strArgsNotHandled += m_constStrCommaSpc;
- const CMICmdArgValBase *pArg = *it;
- strArgsNotHandled += pArg->GetName();
-
- // Next
- ++it;
- }
-
- const CMIUtilString strWarningMsg(
- CMIUtilString::Format(MIRSRC(IDS_CMD_WRN_ARGS_NOT_HANDLED), vrCmdName.c_str(), strArgsNotHandled.c_str()));
- m_pLog->WriteLog(strWarningMsg);
+ CMIUtilString strArgsNotHandled;
+ const CMICmdArgSet::SetCmdArgs_t &rSetArgs = GetArgsNotHandledByCmd();
+ MIuint nCnt = 0;
+ CMICmdArgSet::SetCmdArgs_t::const_iterator it = rSetArgs.begin();
+ while (it != rSetArgs.end()) {
+ if (nCnt++ > 0)
+ strArgsNotHandled += m_constStrCommaSpc;
+ const CMICmdArgValBase *pArg = *it;
+ strArgsNotHandled += pArg->GetName();
+
+ // Next
+ ++it;
+ }
+
+ const CMIUtilString strWarningMsg(
+ CMIUtilString::Format(MIRSRC(IDS_CMD_WRN_ARGS_NOT_HANDLED),
+ vrCmdName.c_str(), strArgsNotHandled.c_str()));
+ m_pLog->WriteLog(strWarningMsg);
#endif // MICONFIG_GIVE_WARNING_CMD_ARGS_NOT_HANDLED
}
Modified: lldb/trunk/tools/lldb-mi/MICmdArgSet.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/lldb-mi/MICmdArgSet.h?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/tools/lldb-mi/MICmdArgSet.h (original)
+++ lldb/trunk/tools/lldb-mi/MICmdArgSet.h Tue Sep 6 15:57:50 2016
@@ -15,81 +15,98 @@
// Other libraries and framework includes
// Project includes
-#include "MICmnBase.h"
#include "MICmdArgContext.h"
+#include "MICmnBase.h"
// Declarations:
class CMICmdArgValBase;
-//++ ============================================================================
+//++
+//============================================================================
// Details: MI common code class. Command arguments container class.
-// A command may have one or more arguments of which some may be optional.
+// A command may have one or more arguments of which some may be
+// optional.
// *this class contains a list of the command's arguments which are
-// validates against the commands argument options string (context string).
+// validates against the commands argument options string (context
+// string).
// Each argument tries to extract the value it is looking for.
-// Argument objects added to *this container are owned by this container
-// and are deleted when this container goes out of scope. Allocate argument
+// Argument objects added to *this container are owned by this
+// container
+// and are deleted when this container goes out of scope. Allocate
+// argument
// objects on the heap.
-// It is assumed the arguments to be parsed are read from left to right in
-// order. The order added to *this container is the order they will parsed.
+// It is assumed the arguments to be parsed are read from left to right
+// in
+// order. The order added to *this container is the order they will
+// parsed.
//--
-class CMICmdArgSet : public CMICmnBase
-{
- // Classes:
+class CMICmdArgSet : public CMICmnBase {
+ // Classes:
+public:
+ //++
+ // Description: ArgSet's interface for command arguments to implement.
+ //--
+ class IArg {
public:
- //++
- // Description: ArgSet's interface for command arguments to implement.
- //--
- class IArg
- {
- public:
- virtual bool GetFound() const = 0;
- virtual bool GetIsHandledByCmd() const = 0;
- virtual bool GetIsMandatory() const = 0;
- virtual bool GetIsMissingOptions() const = 0;
- virtual const CMIUtilString &GetName() const = 0;
- virtual bool GetValid() const = 0;
- virtual bool Validate(CMICmdArgContext &vwArgContext) = 0;
-
- virtual ~IArg() = default;
- };
-
- // Typedefs:
- typedef std::vector<CMICmdArgValBase *> SetCmdArgs_t;
-
- // Methods:
- CMICmdArgSet();
-
- void Add(CMICmdArgValBase *vArg);
- bool GetArg(const CMIUtilString &vArgName, CMICmdArgValBase *&vpArg) const;
- const SetCmdArgs_t &GetArgsThatAreMissing() const;
- const SetCmdArgs_t &GetArgsThatInvalid() const;
- size_t GetCount() const;
- bool IsArgContextEmpty() const;
- bool IsArgsPresentButNotHandledByCmd() const;
- void WarningArgsNotHandledbyCmdLogFile(const CMIUtilString &vrCmdName);
- bool Validate(const CMIUtilString &vStrMiCmd, CMICmdArgContext &vwCmdArgsText);
-
- // Overrideable:
- ~CMICmdArgSet() override;
-
- // Methods:
- private:
- const SetCmdArgs_t &GetArgsNotHandledByCmd() const;
- void
- Destroy(); // Release resources used by *this object
- bool ValidationFormErrorMessages(const CMICmdArgContext &vwCmdArgsText);
-
- // Attributes:
- bool m_bIsArgsPresentButNotHandledByCmd; // True = The driver's client presented the command with options recognised but not handled by
- // a command, false = all args handled
- SetCmdArgs_t m_setCmdArgs; // The set of arguments that are that the command is expecting to find in the options string
- SetCmdArgs_t m_setCmdArgsThatAreMissing; // The set of arguments that are required by the command but are missing
- SetCmdArgs_t m_setCmdArgsThatNotValid; // The set of arguments found in the text but for some reason unable to extract a value
- SetCmdArgs_t
- m_setCmdArgsNotHandledByCmd; // The set of arguments specified by the command which were present to the command but not handled
- SetCmdArgs_t m_setCmdArgsMissingInfo; // The set of arguments that were present but were found to be missing additional information i.e.
- // --thread 3 but 3 is missing
- CMICmdArgContext m_cmdArgContext; // Copy of the command's argument options text before validate takes place (empties it of content)
- const CMIUtilString m_constStrCommaSpc;
+ virtual bool GetFound() const = 0;
+ virtual bool GetIsHandledByCmd() const = 0;
+ virtual bool GetIsMandatory() const = 0;
+ virtual bool GetIsMissingOptions() const = 0;
+ virtual const CMIUtilString &GetName() const = 0;
+ virtual bool GetValid() const = 0;
+ virtual bool Validate(CMICmdArgContext &vwArgContext) = 0;
+
+ virtual ~IArg() = default;
+ };
+
+ // Typedefs:
+ typedef std::vector<CMICmdArgValBase *> SetCmdArgs_t;
+
+ // Methods:
+ CMICmdArgSet();
+
+ void Add(CMICmdArgValBase *vArg);
+ bool GetArg(const CMIUtilString &vArgName, CMICmdArgValBase *&vpArg) const;
+ const SetCmdArgs_t &GetArgsThatAreMissing() const;
+ const SetCmdArgs_t &GetArgsThatInvalid() const;
+ size_t GetCount() const;
+ bool IsArgContextEmpty() const;
+ bool IsArgsPresentButNotHandledByCmd() const;
+ void WarningArgsNotHandledbyCmdLogFile(const CMIUtilString &vrCmdName);
+ bool Validate(const CMIUtilString &vStrMiCmd,
+ CMICmdArgContext &vwCmdArgsText);
+
+ // Overrideable:
+ ~CMICmdArgSet() override;
+
+ // Methods:
+private:
+ const SetCmdArgs_t &GetArgsNotHandledByCmd() const;
+ void Destroy(); // Release resources used by *this object
+ bool ValidationFormErrorMessages(const CMICmdArgContext &vwCmdArgsText);
+
+ // Attributes:
+ bool m_bIsArgsPresentButNotHandledByCmd; // True = The driver's client
+ // presented the command with options
+ // recognised but not handled by
+ // a command, false = all args handled
+ SetCmdArgs_t m_setCmdArgs; // The set of arguments that are that the command
+ // is expecting to find in the options string
+ SetCmdArgs_t m_setCmdArgsThatAreMissing; // The set of arguments that are
+ // required by the command but are
+ // missing
+ SetCmdArgs_t m_setCmdArgsThatNotValid; // The set of arguments found in the
+ // text but for some reason unable to
+ // extract a value
+ SetCmdArgs_t m_setCmdArgsNotHandledByCmd; // The set of arguments specified by
+ // the command which were present to
+ // the command but not handled
+ SetCmdArgs_t m_setCmdArgsMissingInfo; // The set of arguments that were
+ // present but were found to be missing
+ // additional information i.e.
+ // --thread 3 but 3 is missing
+ CMICmdArgContext m_cmdArgContext; // Copy of the command's argument options
+ // text before validate takes place (empties
+ // it of content)
+ const CMIUtilString m_constStrCommaSpc;
};
Modified: lldb/trunk/tools/lldb-mi/MICmdArgValBase.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/lldb-mi/MICmdArgValBase.cpp?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/tools/lldb-mi/MICmdArgValBase.cpp (original)
+++ lldb/trunk/tools/lldb-mi/MICmdArgValBase.cpp Tue Sep 6 15:57:50 2016
@@ -12,10 +12,11 @@
// Other libraries and framework includes
// Project includes
#include "MICmdArgValBase.h"
-#include "MIUtilString.h"
#include "MICmdArgContext.h"
+#include "MIUtilString.h"
-//++ ------------------------------------------------------------------------------------
+//++
+//------------------------------------------------------------------------------------
// Details: CMICmdArgValBase constructor.
// Type: Method.
// Args: None.
@@ -23,35 +24,32 @@
// Throws: None.
//--
CMICmdArgValBase::CMICmdArgValBase()
- : m_bFound(false)
- , m_bValid(false)
- , m_bMandatory(false)
- , m_bHandled(false)
- , m_bIsMissingOptions(false)
-{
-}
+ : m_bFound(false), m_bValid(false), m_bMandatory(false), m_bHandled(false),
+ m_bIsMissingOptions(false) {}
-//++ ------------------------------------------------------------------------------------
+//++
+//------------------------------------------------------------------------------------
// Details: CMICmdArgValBase constructor.
// Type: Method.
// Args: vrArgName - (R) Argument's name to search by.
-// vbMandatory - (R) True = Yes must be present, false = optional argument.
-// vbHandleByCmd - (R) True = Command processes *this option, false = not handled.
+// vbMandatory - (R) True = Yes must be present, false = optional
+// argument.
+// vbHandleByCmd - (R) True = Command processes *this option, false =
+// not handled.
// Return: None.
// Throws: None.
//--
-CMICmdArgValBase::CMICmdArgValBase(const CMIUtilString &vrArgName, const bool vbMandatory, const bool vbHandleByCmd)
- : m_bFound(false)
- , m_bValid(false)
- , m_bMandatory(vbMandatory)
- , m_strArgName(vrArgName)
- , m_bHandled(vbHandleByCmd)
- , m_bIsMissingOptions(false)
-{
-}
-
-//++ ------------------------------------------------------------------------------------
-// Details: Retrieve the state flag of whether the argument is handled by the command or
+CMICmdArgValBase::CMICmdArgValBase(const CMIUtilString &vrArgName,
+ const bool vbMandatory,
+ const bool vbHandleByCmd)
+ : m_bFound(false), m_bValid(false), m_bMandatory(vbMandatory),
+ m_strArgName(vrArgName), m_bHandled(vbHandleByCmd),
+ m_bIsMissingOptions(false) {}
+
+//++
+//------------------------------------------------------------------------------------
+// Details: Retrieve the state flag of whether the argument is handled by the
+// command or
// not.
// Type: Method.
// Args: None.
@@ -59,14 +57,14 @@ CMICmdArgValBase::CMICmdArgValBase(const
// False - All information is present as expected.
// Throws: None.
//--
-bool
-CMICmdArgValBase::GetIsMissingOptions() const
-{
- return m_bIsMissingOptions;
+bool CMICmdArgValBase::GetIsMissingOptions() const {
+ return m_bIsMissingOptions;
}
-//++ ------------------------------------------------------------------------------------
-// Details: Retrieve the state flag of whether the argument is handled by the command or
+//++
+//------------------------------------------------------------------------------------
+// Details: Retrieve the state flag of whether the argument is handled by the
+// command or
// not.
// Type: Method.
// Args: None.
@@ -74,27 +72,22 @@ CMICmdArgValBase::GetIsMissingOptions()
// False - Not handled (argument specified but ignored).
// Throws: None.
//--
-bool
-CMICmdArgValBase::GetIsHandledByCmd() const
-{
- return m_bHandled;
-}
+bool CMICmdArgValBase::GetIsHandledByCmd() const { return m_bHandled; }
-//++ ------------------------------------------------------------------------------------
+//++
+//------------------------------------------------------------------------------------
// Details: Retrieve the name of *this argument.
// Type: Method.
// Args: None.
// Return: CMIUtilString & - Return the text name.
// Throws: None.
//--
-const CMIUtilString &
-CMICmdArgValBase::GetName() const
-{
- return m_strArgName;
-}
+const CMIUtilString &CMICmdArgValBase::GetName() const { return m_strArgName; }
-//++ ------------------------------------------------------------------------------------
-// Details: Retrieve the state flag of whether the argument was found in the command's
+//++
+//------------------------------------------------------------------------------------
+// Details: Retrieve the state flag of whether the argument was found in the
+// command's
// argument / options string.
// Type: Method.
// Args: None.
@@ -102,14 +95,12 @@ CMICmdArgValBase::GetName() const
// False - Argument not found.
// Throws: None.
//--
-bool
-CMICmdArgValBase::GetFound() const
-{
- return m_bFound;
-}
+bool CMICmdArgValBase::GetFound() const { return m_bFound; }
-//++ ------------------------------------------------------------------------------------
-// Details: Retrieve the state flag indicating whether the value was obtained from the
+//++
+//------------------------------------------------------------------------------------
+// Details: Retrieve the state flag indicating whether the value was obtained
+// from the
// text arguments string and is valid.
// Type: Method.
// Args: None.
@@ -117,14 +108,12 @@ CMICmdArgValBase::GetFound() const
// False - Argument not valid.
// Throws: None.
//--
-bool
-CMICmdArgValBase::GetValid() const
-{
- return m_bValid;
-}
+bool CMICmdArgValBase::GetValid() const { return m_bValid; }
-//++ ------------------------------------------------------------------------------------
-// Details: Retrieve the state flag indicating whether *this argument is a mandatory
+//++
+//------------------------------------------------------------------------------------
+// Details: Retrieve the state flag indicating whether *this argument is a
+// mandatory
// argument for the command or is optional to be present.
// Type: Method.
// Args: None.
@@ -132,14 +121,12 @@ CMICmdArgValBase::GetValid() const
// False - Optional.
// Throws: None.
//--
-bool
-CMICmdArgValBase::GetIsMandatory() const
-{
- return m_bMandatory;
-}
+bool CMICmdArgValBase::GetIsMandatory() const { return m_bMandatory; }
-//++ ------------------------------------------------------------------------------------
-// Details: Parse the command's argument options string and try to extract the value *this
+//++
+//------------------------------------------------------------------------------------
+// Details: Parse the command's argument options string and try to extract the
+// value *this
// argument is looking for.
// Type: Overrideable.
// Args: vArgContext - (RW) The command's argument options string.
@@ -147,12 +134,10 @@ CMICmdArgValBase::GetIsMandatory() const
// MIstatus::failure - Functional failed.
// Throws: None.
//--
-bool
-CMICmdArgValBase::Validate(CMICmdArgContext &vwArgContext)
-{
- MIunused(vwArgContext);
+bool CMICmdArgValBase::Validate(CMICmdArgContext &vwArgContext) {
+ MIunused(vwArgContext);
- // Override to implement
+ // Override to implement
- return MIstatus::failure;
+ return MIstatus::failure;
}
Modified: lldb/trunk/tools/lldb-mi/MICmdArgValBase.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/lldb-mi/MICmdArgValBase.h?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/tools/lldb-mi/MICmdArgValBase.h (original)
+++ lldb/trunk/tools/lldb-mi/MICmdArgValBase.h Tue Sep 6 15:57:50 2016
@@ -13,10 +13,11 @@
// C++ Includes
// Other libraries and framework includes
// Project includes
-#include "MIUtilString.h"
#include "MICmdArgSet.h"
+#include "MIUtilString.h"
-//++ ============================================================================
+//++
+//============================================================================
// Details: MI common code class. Command argument base class. Arguments objects
// needing specialization derived from *this class. An argument knows
// what type of argument it is and how it is to interpret the options
@@ -27,89 +28,95 @@
// deleted when the container goes out of scope. Allocate argument
// objects on the heap and pass in to the Add().
// Note the code is written such that a command will produce an error
-// should it be presented with arguments or options it does not understand.
+// should it be presented with arguments or options it does not
+// understand.
// A command can recognise an option or argument then ignore if it
// wishes (a warning is sent to the MI's Log file). This is so it is
// hardwired to fail and catch arguments or options that presented by
// different driver clients.
// Based on the Interpreter pattern.
//--
-class CMICmdArgValBase : public CMICmdArgSet::IArg
-{
- // Methods:
- public:
- CMICmdArgValBase();
- CMICmdArgValBase(const CMIUtilString &vrArgName, const bool vbMandatory, const bool vbHandleByCmd);
-
- // Overrideable:
- ~CMICmdArgValBase() override = default;
-
- // Overridden:
- // From CMICmdArgSet::IArg
- bool GetFound() const override;
- bool GetIsHandledByCmd() const override;
- bool GetIsMandatory() const override;
- bool GetIsMissingOptions() const override;
- const CMIUtilString &GetName() const override;
- bool GetValid() const override;
- bool Validate(CMICmdArgContext &vwArgContext) override;
-
- // Attributes:
- protected:
- bool m_bFound; // True = yes found in arguments options text, false = not found
- bool m_bValid; // True = yes argument parsed and valid, false = not valid
- bool m_bMandatory; // True = yes arg must be present, false = optional argument
- CMIUtilString m_strArgName;
- bool m_bHandled; // True = Command processes *this option, false = not handled
- bool m_bIsMissingOptions; // True = Command needs more information, false = ok
+class CMICmdArgValBase : public CMICmdArgSet::IArg {
+ // Methods:
+public:
+ CMICmdArgValBase();
+ CMICmdArgValBase(const CMIUtilString &vrArgName, const bool vbMandatory,
+ const bool vbHandleByCmd);
+
+ // Overrideable:
+ ~CMICmdArgValBase() override = default;
+
+ // Overridden:
+ // From CMICmdArgSet::IArg
+ bool GetFound() const override;
+ bool GetIsHandledByCmd() const override;
+ bool GetIsMandatory() const override;
+ bool GetIsMissingOptions() const override;
+ const CMIUtilString &GetName() const override;
+ bool GetValid() const override;
+ bool Validate(CMICmdArgContext &vwArgContext) override;
+
+ // Attributes:
+protected:
+ bool
+ m_bFound; // True = yes found in arguments options text, false = not found
+ bool m_bValid; // True = yes argument parsed and valid, false = not valid
+ bool
+ m_bMandatory; // True = yes arg must be present, false = optional argument
+ CMIUtilString m_strArgName;
+ bool m_bHandled; // True = Command processes *this option, false = not handled
+ bool m_bIsMissingOptions; // True = Command needs more information, false = ok
};
-//++ ============================================================================
+//++
+//============================================================================
// Details: MI common code class. Templated command argument base class.
//--
-template <class T> class CMICmdArgValBaseTemplate : public CMICmdArgValBase
-{
- // Methods:
- public:
- CMICmdArgValBaseTemplate() = default;
- CMICmdArgValBaseTemplate(const CMIUtilString &vrArgName, const bool vbMandatory, const bool vbHandleByCmd);
- //
- const T &GetValue() const;
-
- // Overrideable:
- ~CMICmdArgValBaseTemplate() override = default;
-
- // Attributes:
- protected:
- T m_argValue;
+template <class T> class CMICmdArgValBaseTemplate : public CMICmdArgValBase {
+ // Methods:
+public:
+ CMICmdArgValBaseTemplate() = default;
+ CMICmdArgValBaseTemplate(const CMIUtilString &vrArgName,
+ const bool vbMandatory, const bool vbHandleByCmd);
+ //
+ const T &GetValue() const;
+
+ // Overrideable:
+ ~CMICmdArgValBaseTemplate() override = default;
+
+ // Attributes:
+protected:
+ T m_argValue;
};
-//++ ------------------------------------------------------------------------------------
+//++
+//------------------------------------------------------------------------------------
// Details: CMICmdArgValBaseTemplate constructor.
// Type: Method.
// Args: vrArgName - (R) Argument's name to search by.
-// vbMandatory - (R) True = Yes must be present, false = optional argument.
-// vbHandleByCmd - (R) True = Command processes *this option, false = not handled.
+// vbMandatory - (R) True = Yes must be present, false = optional
+// argument.
+// vbHandleByCmd - (R) True = Command processes *this option, false =
+// not handled.
// Return: None.
// Throws: None.
//--
template <class T>
-CMICmdArgValBaseTemplate<T>::CMICmdArgValBaseTemplate(const CMIUtilString &vrArgName, const bool vbMandatory, const bool vbHandleByCmd)
- : CMICmdArgValBase(vrArgName, vbMandatory, vbHandleByCmd)
-{
-}
-
-//++ ------------------------------------------------------------------------------------
-// Details: Retrieve the value the argument parsed from the command's argument / options
+CMICmdArgValBaseTemplate<T>::CMICmdArgValBaseTemplate(
+ const CMIUtilString &vrArgName, const bool vbMandatory,
+ const bool vbHandleByCmd)
+ : CMICmdArgValBase(vrArgName, vbMandatory, vbHandleByCmd) {}
+
+//++
+//------------------------------------------------------------------------------------
+// Details: Retrieve the value the argument parsed from the command's argument /
+// options
// text string.
// Type: Method.
// Args: None.
// Return: Template type & - The arg value of *this object.
// Throws: None.
//--
-template <class T>
-const T &
-CMICmdArgValBaseTemplate<T>::GetValue() const
-{
- return m_argValue;
+template <class T> const T &CMICmdArgValBaseTemplate<T>::GetValue() const {
+ return m_argValue;
}
Modified: lldb/trunk/tools/lldb-mi/MICmdArgValConsume.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/lldb-mi/MICmdArgValConsume.cpp?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/tools/lldb-mi/MICmdArgValConsume.cpp (original)
+++ lldb/trunk/tools/lldb-mi/MICmdArgValConsume.cpp Tue Sep 6 15:57:50 2016
@@ -11,43 +11,44 @@
#include "MICmdArgValConsume.h"
#include "MICmdArgContext.h"
-//++ ------------------------------------------------------------------------------------
+//++
+//------------------------------------------------------------------------------------
// Details: CMICmdArgValConsume constructor.
// Type: Method.
// Args: None.
// Return: None.
// Throws: None.
//--
-CMICmdArgValConsume::CMICmdArgValConsume()
-{
-}
+CMICmdArgValConsume::CMICmdArgValConsume() {}
-//++ ------------------------------------------------------------------------------------
+//++
+//------------------------------------------------------------------------------------
// Details: CMICmdArgValConsume constructor.
// Type: Method.
// Args: vrArgName - (R) Argument's name to search by.
-// vbMandatory - (R) True = Yes must be present, false = optional argument.
+// vbMandatory - (R) True = Yes must be present, false = optional
+// argument.
// Return: None.
// Throws: None.
//--
-CMICmdArgValConsume::CMICmdArgValConsume(const CMIUtilString &vrArgName, const bool vbMandatory)
- : CMICmdArgValBaseTemplate(vrArgName, vbMandatory, true)
-{
-}
+CMICmdArgValConsume::CMICmdArgValConsume(const CMIUtilString &vrArgName,
+ const bool vbMandatory)
+ : CMICmdArgValBaseTemplate(vrArgName, vbMandatory, true) {}
-//++ ------------------------------------------------------------------------------------
+//++
+//------------------------------------------------------------------------------------
// Details: CMICmdArgValConsume destructor.
// Type: Overidden.
// Args: None.
// Return: None.
// Throws: None.
//--
-CMICmdArgValConsume::~CMICmdArgValConsume()
-{
-}
+CMICmdArgValConsume::~CMICmdArgValConsume() {}
-//++ ------------------------------------------------------------------------------------
-// Details: Parse the command's argument options string and try to extract the value *this
+//++
+//------------------------------------------------------------------------------------
+// Details: Parse the command's argument options string and try to extract the
+// value *this
// argument is looking for.
// Type: Overridden.
// Args: vwArgContext - (R) The command's argument options string.
@@ -55,44 +56,39 @@ CMICmdArgValConsume::~CMICmdArgValConsum
// MIstatus::failure - Functional failed.
// Throws: None.
//--
-bool
-CMICmdArgValConsume::Validate(CMICmdArgContext &vwArgContext)
-{
- if (vwArgContext.IsEmpty())
- return m_bMandatory ? MIstatus::failure : MIstatus::success;
-
- // Consume the optional file, line, linenum arguments till the mode '--' argument
- const CMIUtilString::VecString_t vecOptions(vwArgContext.GetArgs());
- CMIUtilString::VecString_t::const_iterator it = vecOptions.begin();
- while (it != vecOptions.end())
- {
- const CMIUtilString & rTxt( *it );
-
- if ( rTxt.compare( "--" ) == 0 )
- {
- m_bFound = true;
- m_bValid = true;
- if ( !vwArgContext.RemoveArg( rTxt ) )
- return MIstatus::failure;
- return MIstatus::success;
- }
- // Next
- ++it;
+bool CMICmdArgValConsume::Validate(CMICmdArgContext &vwArgContext) {
+ if (vwArgContext.IsEmpty())
+ return m_bMandatory ? MIstatus::failure : MIstatus::success;
+
+ // Consume the optional file, line, linenum arguments till the mode '--'
+ // argument
+ const CMIUtilString::VecString_t vecOptions(vwArgContext.GetArgs());
+ CMIUtilString::VecString_t::const_iterator it = vecOptions.begin();
+ while (it != vecOptions.end()) {
+ const CMIUtilString &rTxt(*it);
+
+ if (rTxt.compare("--") == 0) {
+ m_bFound = true;
+ m_bValid = true;
+ if (!vwArgContext.RemoveArg(rTxt))
+ return MIstatus::failure;
+ return MIstatus::success;
}
+ // Next
+ ++it;
+ }
- return MIstatus::failure;
+ return MIstatus::failure;
}
-//++ ------------------------------------------------------------------------------------
-// Details: Nothing to examine as we just want to consume the argument or option (ignore
+//++
+//------------------------------------------------------------------------------------
+// Details: Nothing to examine as we just want to consume the argument or option
+// (ignore
// it).
// Type: Method.
// Args: None.
// Return: bool - True = yes ok, false = not ok.
// Throws: None.
//--
-bool
-CMICmdArgValConsume::IsOk() const
-{
- return true;
-}
+bool CMICmdArgValConsume::IsOk() const { return true; }
Modified: lldb/trunk/tools/lldb-mi/MICmdArgValConsume.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/lldb-mi/MICmdArgValConsume.h?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/tools/lldb-mi/MICmdArgValConsume.h (original)
+++ lldb/trunk/tools/lldb-mi/MICmdArgValConsume.h Tue Sep 6 15:57:50 2016
@@ -15,34 +15,40 @@
// 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
+// 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
+// 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
+// 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.
//--
-class CMICmdArgValConsume : public CMICmdArgValBaseTemplate<CMIUtilString>
-{
- // Methods:
- public:
- /* ctor */ CMICmdArgValConsume();
- /* ctor */ CMICmdArgValConsume(const CMIUtilString &vrArgName, const bool vbMandatory);
- //
- bool IsOk() const;
+class CMICmdArgValConsume : public CMICmdArgValBaseTemplate<CMIUtilString> {
+ // Methods:
+public:
+ /* ctor */ CMICmdArgValConsume();
+ /* ctor */ CMICmdArgValConsume(const CMIUtilString &vrArgName,
+ const bool vbMandatory);
+ //
+ bool IsOk() const;
- // Overridden:
- public:
- // From CMICmdArgValBase
- /* dtor */ ~CMICmdArgValConsume() override;
- // From CMICmdArgSet::IArg
- bool Validate(CMICmdArgContext &vwArgContext) override;
+ // Overridden:
+public:
+ // From CMICmdArgValBase
+ /* dtor */ ~CMICmdArgValConsume() override;
+ // From CMICmdArgSet::IArg
+ bool Validate(CMICmdArgContext &vwArgContext) override;
};
Modified: lldb/trunk/tools/lldb-mi/MICmdArgValFile.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/lldb-mi/MICmdArgValFile.cpp?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/tools/lldb-mi/MICmdArgValFile.cpp (original)
+++ lldb/trunk/tools/lldb-mi/MICmdArgValFile.cpp Tue Sep 6 15:57:50 2016
@@ -11,44 +11,47 @@
#include "MICmdArgValFile.h"
#include "MICmdArgContext.h"
-//++ ------------------------------------------------------------------------------------
+//++
+//------------------------------------------------------------------------------------
// Details: CMICmdArgValFile constructor.
// Type: Method.
// Args: None.
// Return: None.
// Throws: None.
//--
-CMICmdArgValFile::CMICmdArgValFile()
-{
-}
+CMICmdArgValFile::CMICmdArgValFile() {}
-//++ ------------------------------------------------------------------------------------
+//++
+//------------------------------------------------------------------------------------
// Details: CMICmdArgValFile constructor.
// Type: Method.
// Args: vrArgName - (R) Argument's name to search by.
-// vbMandatory - (R) True = Yes must be present, false = optional argument.
-// vbHandleByCmd - (R) True = Command processes *this option, false = not handled.
+// vbMandatory - (R) True = Yes must be present, false = optional
+// argument.
+// vbHandleByCmd - (R) True = Command processes *this option, false =
+// not handled.
// Return: None.
// Throws: None.
//--
-CMICmdArgValFile::CMICmdArgValFile(const CMIUtilString &vrArgName, const bool vbMandatory, const bool vbHandleByCmd)
- : CMICmdArgValBaseTemplate(vrArgName, vbMandatory, vbHandleByCmd)
-{
-}
+CMICmdArgValFile::CMICmdArgValFile(const CMIUtilString &vrArgName,
+ const bool vbMandatory,
+ const bool vbHandleByCmd)
+ : CMICmdArgValBaseTemplate(vrArgName, vbMandatory, vbHandleByCmd) {}
-//++ ------------------------------------------------------------------------------------
+//++
+//------------------------------------------------------------------------------------
// Details: CMICmdArgValFile destructor.
// Type: Overridden.
// Args: None.
// Return: None.
// Throws: None.
//--
-CMICmdArgValFile::~CMICmdArgValFile()
-{
-}
+CMICmdArgValFile::~CMICmdArgValFile() {}
-//++ ------------------------------------------------------------------------------------
-// Details: Parse the command's argument options string and try to extract the value *this
+//++
+//------------------------------------------------------------------------------------
+// Details: Parse the command's argument options string and try to extract the
+// value *this
// argument is looking for.
// Type: Overridden.
// Args: vwArgContext - (R) The command's argument options string.
@@ -56,59 +59,52 @@ CMICmdArgValFile::~CMICmdArgValFile()
// MIstatus::failure - Functional failed.
// Throws: None.
//--
-bool
-CMICmdArgValFile::Validate(CMICmdArgContext &vwArgContext)
-{
- if (vwArgContext.IsEmpty())
- return m_bMandatory ? MIstatus::failure : MIstatus::success;
-
- // The GDB/MI spec suggests there is only parameter
-
- if (vwArgContext.GetNumberArgsPresent() == 1)
- {
- const CMIUtilString &rFile(vwArgContext.GetArgsLeftToParse());
- if (IsFilePath(rFile))
- {
- m_bFound = true;
- m_bValid = true;
- m_argValue = rFile.Trim('"');
- vwArgContext.RemoveArg(rFile);
- return MIstatus::success;
- }
- else
- return MIstatus::failure;
+bool CMICmdArgValFile::Validate(CMICmdArgContext &vwArgContext) {
+ if (vwArgContext.IsEmpty())
+ return m_bMandatory ? MIstatus::failure : MIstatus::success;
+
+ // The GDB/MI spec suggests there is only parameter
+
+ if (vwArgContext.GetNumberArgsPresent() == 1) {
+ const CMIUtilString &rFile(vwArgContext.GetArgsLeftToParse());
+ if (IsFilePath(rFile)) {
+ m_bFound = true;
+ m_bValid = true;
+ m_argValue = rFile.Trim('"');
+ vwArgContext.RemoveArg(rFile);
+ return MIstatus::success;
+ } else
+ return MIstatus::failure;
+ }
+
+ // In reality there are more than one option, if so the file option
+ // is the last one (don't handle that here - find the best looking one)
+ const CMIUtilString::VecString_t vecOptions(vwArgContext.GetArgs());
+ CMIUtilString::VecString_t::const_iterator it = vecOptions.begin();
+ while (it != vecOptions.end()) {
+ const CMIUtilString &rTxt(*it);
+ if (IsFilePath(rTxt)) {
+ m_bFound = true;
+
+ if (vwArgContext.RemoveArg(rTxt)) {
+ m_bValid = true;
+ m_argValue = rTxt.Trim('"');
+ return MIstatus::success;
+ } else
+ return MIstatus::success;
}
- // In reality there are more than one option, if so the file option
- // is the last one (don't handle that here - find the best looking one)
- const CMIUtilString::VecString_t vecOptions(vwArgContext.GetArgs());
- CMIUtilString::VecString_t::const_iterator it = vecOptions.begin();
- while (it != vecOptions.end())
- {
- const CMIUtilString &rTxt(*it);
- if (IsFilePath(rTxt))
- {
- m_bFound = true;
-
- if (vwArgContext.RemoveArg(rTxt))
- {
- m_bValid = true;
- m_argValue = rTxt.Trim('"');
- return MIstatus::success;
- }
- else
- return MIstatus::success;
- }
-
- // Next
- ++it;
- }
+ // Next
+ ++it;
+ }
- return MIstatus::failure;
+ return MIstatus::failure;
}
-//++ ------------------------------------------------------------------------------------
-// Details: Given some text extract the file name path from it. If a space is found in
+//++
+//------------------------------------------------------------------------------------
+// Details: Given some text extract the file name path from it. If a space is
+// found in
// path done return the path surrounded in quotes.
// Type: Method.
// Args: vrTxt - (R) The text to extract the file name path from.
@@ -116,82 +112,78 @@ CMICmdArgValFile::Validate(CMICmdArgCont
// Throws: None.
//--
CMIUtilString
-CMICmdArgValFile::GetFileNamePath(const CMIUtilString &vrTxt) const
-{
- CMIUtilString fileNamePath(vrTxt);
-
- // Look for a space in the path
- const char cSpace = ' ';
- const size_t nPos = fileNamePath.find(cSpace);
- if (nPos != std::string::npos)
- fileNamePath = CMIUtilString::Format("\"%s\"", fileNamePath.c_str());
+CMICmdArgValFile::GetFileNamePath(const CMIUtilString &vrTxt) const {
+ CMIUtilString fileNamePath(vrTxt);
- return fileNamePath;
+ // Look for a space in the path
+ const char cSpace = ' ';
+ const size_t nPos = fileNamePath.find(cSpace);
+ if (nPos != std::string::npos)
+ fileNamePath = CMIUtilString::Format("\"%s\"", fileNamePath.c_str());
+
+ return fileNamePath;
}
-//++ ------------------------------------------------------------------------------------
+//++
+//------------------------------------------------------------------------------------
// Details: Examine the string and determine if it is a valid file name path.
// Type: Method.
// Args: vrFileNamePath - (R) File's name and directory path.
// Return: bool - True = yes valid file path, false = no.
// Throws: None.
//--
-bool
-CMICmdArgValFile::IsFilePath(const CMIUtilString &vrFileNamePath) const
-{
- if (vrFileNamePath.empty())
- return false;
+bool CMICmdArgValFile::IsFilePath(const CMIUtilString &vrFileNamePath) const {
+ if (vrFileNamePath.empty())
+ return false;
- const bool bHavePosSlash = (vrFileNamePath.find('/') != std::string::npos);
- const bool bHaveBckSlash = (vrFileNamePath.find('\\') != std::string::npos);
+ const bool bHavePosSlash = (vrFileNamePath.find('/') != std::string::npos);
+ const bool bHaveBckSlash = (vrFileNamePath.find('\\') != std::string::npos);
- // Look for --someLongOption
- size_t nPos = vrFileNamePath.find("--");
- const bool bLong = (nPos == 0);
- if (bLong)
- return false;
+ // Look for --someLongOption
+ size_t nPos = vrFileNamePath.find("--");
+ const bool bLong = (nPos == 0);
+ if (bLong)
+ return false;
- // Look for -f type short parameters
- nPos = vrFileNamePath.find('-');
- const bool bShort = (nPos == 0);
- if (bShort)
- return false;
+ // Look for -f type short parameters
+ nPos = vrFileNamePath.find('-');
+ const bool bShort = (nPos == 0);
+ if (bShort)
+ return false;
- // Look for i1 i2 i3....
- nPos = vrFileNamePath.find('i');
- const bool bFoundI1 = ((nPos == 0) && (::isdigit(vrFileNamePath[1])));
- if (bFoundI1)
- return false;
+ // Look for i1 i2 i3....
+ nPos = vrFileNamePath.find('i');
+ const bool bFoundI1 = ((nPos == 0) && (::isdigit(vrFileNamePath[1])));
+ if (bFoundI1)
+ return false;
- const bool bValidChars = IsValidChars(vrFileNamePath);
- if (bValidChars || bHavePosSlash || bHaveBckSlash)
- return true;
+ const bool bValidChars = IsValidChars(vrFileNamePath);
+ if (bValidChars || bHavePosSlash || bHaveBckSlash)
+ return true;
- return false;
+ return false;
}
-//++ ------------------------------------------------------------------------------------
-// Details: Determine if the path contains valid characters for a file path. Letters can be
+//++
+//------------------------------------------------------------------------------------
+// Details: Determine if the path contains valid characters for a file path.
+// Letters can be
// either upper or lower case.
// Type: Method.
// Args: vrText - (R) The text data to examine.
// Return: bool - True = yes valid, false = one or more chars is valid.
// Throws: None.
//--
-bool
-CMICmdArgValFile::IsValidChars(const CMIUtilString &vrText) const
-{
- static CMIUtilString s_strSpecialCharacters(".'\"`@#$%^&*()_+-={}[]| ");
- const char *pPtr = vrText.c_str();
- for (MIuint i = 0; i < vrText.length(); i++, pPtr++)
- {
- const char c = *pPtr;
- if (::isalnum((int)c) == 0)
- {
- if (s_strSpecialCharacters.find(c) == CMIUtilString::npos)
- return false;
- }
+bool CMICmdArgValFile::IsValidChars(const CMIUtilString &vrText) const {
+ static CMIUtilString s_strSpecialCharacters(".'\"`@#$%^&*()_+-={}[]| ");
+ const char *pPtr = vrText.c_str();
+ for (MIuint i = 0; i < vrText.length(); i++, pPtr++) {
+ const char c = *pPtr;
+ if (::isalnum((int)c) == 0) {
+ if (s_strSpecialCharacters.find(c) == CMIUtilString::npos)
+ return false;
}
+ }
- return true;
+ return true;
}
Modified: lldb/trunk/tools/lldb-mi/MICmdArgValFile.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/lldb-mi/MICmdArgValFile.h?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/tools/lldb-mi/MICmdArgValFile.h (original)
+++ lldb/trunk/tools/lldb-mi/MICmdArgValFile.h Tue Sep 6 15:57:50 2016
@@ -15,32 +15,34 @@
// 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
+// interpret the options (context) string to find and validate a
+// matching
// argument and so extract a value from it .
// Based on the Interpreter pattern.
//--
-class CMICmdArgValFile : public CMICmdArgValBaseTemplate<CMIUtilString>
-{
- // Methods:
- public:
- /* ctor */ CMICmdArgValFile();
- /* ctor */ CMICmdArgValFile(const CMIUtilString &vrArgName, const bool vbMandatory, const bool vbHandleByCmd);
- //
- bool IsFilePath(const CMIUtilString &vrFileNamePath) const;
- CMIUtilString GetFileNamePath(const CMIUtilString &vrTxt) const;
+class CMICmdArgValFile : public CMICmdArgValBaseTemplate<CMIUtilString> {
+ // Methods:
+public:
+ /* ctor */ CMICmdArgValFile();
+ /* ctor */ CMICmdArgValFile(const CMIUtilString &vrArgName,
+ const bool vbMandatory, const bool vbHandleByCmd);
+ //
+ bool IsFilePath(const CMIUtilString &vrFileNamePath) const;
+ CMIUtilString GetFileNamePath(const CMIUtilString &vrTxt) const;
- // Overridden:
- public:
- // From CMICmdArgValBase
- /* dtor */ ~CMICmdArgValFile() override;
- // From CMICmdArgSet::IArg
- bool Validate(CMICmdArgContext &vwArgContext) override;
+ // Overridden:
+public:
+ // From CMICmdArgValBase
+ /* dtor */ ~CMICmdArgValFile() override;
+ // From CMICmdArgSet::IArg
+ bool Validate(CMICmdArgContext &vwArgContext) override;
- // Methods:
- private:
- bool IsValidChars(const CMIUtilString &vrText) const;
+ // Methods:
+private:
+ bool IsValidChars(const CMIUtilString &vrText) const;
};
Modified: lldb/trunk/tools/lldb-mi/MICmdArgValListBase.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/lldb-mi/MICmdArgValListBase.cpp?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/tools/lldb-mi/MICmdArgValListBase.cpp (original)
+++ lldb/trunk/tools/lldb-mi/MICmdArgValListBase.cpp Tue Sep 6 15:57:50 2016
@@ -10,15 +10,16 @@
// In-house headers:
#include "MICmdArgValListBase.h"
#include "MICmdArgContext.h"
+#include "MICmdArgValConsume.h"
#include "MICmdArgValFile.h"
#include "MICmdArgValNumber.h"
#include "MICmdArgValOptionLong.h"
#include "MICmdArgValOptionShort.h"
#include "MICmdArgValString.h"
#include "MICmdArgValThreadGrp.h"
-#include "MICmdArgValConsume.h"
-//++ ------------------------------------------------------------------------------------
+//++
+//------------------------------------------------------------------------------------
// Details: CMICmdArgValListBase constructor.
// Type: Method.
// Args: None.
@@ -26,80 +27,85 @@
// Throws: None.
//--
CMICmdArgValListBase::CMICmdArgValListBase()
- : m_eArgType(eArgValType_invalid)
-{
-}
+ : m_eArgType(eArgValType_invalid) {}
-//++ ------------------------------------------------------------------------------------
+//++
+//------------------------------------------------------------------------------------
// Details: CMICmdArgValListBase constructor.
// Type: Method.
// Args: vrArgName - (R) Argument's name to search by.
-// vbMandatory - (R) True = Yes must be present, false = optional argument.
-// vbHandleByCmd - (R) True = Command processes *this option, false = not handled.
+// vbMandatory - (R) True = Yes must be present, false = optional
+// argument.
+// vbHandleByCmd - (R) True = Command processes *this option, false =
+// not handled.
// Return: None.
// Throws: None.
//--
-CMICmdArgValListBase::CMICmdArgValListBase(const CMIUtilString &vrArgName, const bool vbMandatory, const bool vbHandleByCmd)
- : CMICmdArgValBaseTemplate(vrArgName, vbMandatory, vbHandleByCmd)
- , m_eArgType(eArgValType_invalid)
-{
-}
+CMICmdArgValListBase::CMICmdArgValListBase(const CMIUtilString &vrArgName,
+ const bool vbMandatory,
+ const bool vbHandleByCmd)
+ : CMICmdArgValBaseTemplate(vrArgName, vbMandatory, vbHandleByCmd),
+ m_eArgType(eArgValType_invalid) {}
-//++ ------------------------------------------------------------------------------------
+//++
+//------------------------------------------------------------------------------------
// Details: CMICmdArgValListBase constructor.
// Type: Method.
// Args: vrArgName - (R) Argument's name to search by.
-// vbMandatory - (R) True = Yes must be present, false = optional argument.
-// vbHandleByCmd - (R) True = Command processes *this option, false = not handled.
-// veType - (R) The type of argument to look for and create argument object of a certain type.
+// vbMandatory - (R) True = Yes must be present, false = optional
+// argument.
+// vbHandleByCmd - (R) True = Command processes *this option, false =
+// not handled.
+// veType - (R) The type of argument to look for and create
+// argument object of a certain type.
// Return: None.
// Throws: None.
//--
-CMICmdArgValListBase::CMICmdArgValListBase(const CMIUtilString &vrArgName, const bool vbMandatory, const bool vbHandleByCmd,
+CMICmdArgValListBase::CMICmdArgValListBase(const CMIUtilString &vrArgName,
+ const bool vbMandatory,
+ const bool vbHandleByCmd,
const ArgValType_e veType)
- : CMICmdArgValBaseTemplate(vrArgName, vbMandatory, vbHandleByCmd)
- , m_eArgType(veType)
-{
-}
+ : CMICmdArgValBaseTemplate(vrArgName, vbMandatory, vbHandleByCmd),
+ m_eArgType(veType) {}
-//++ ------------------------------------------------------------------------------------
+//++
+//------------------------------------------------------------------------------------
// Details: CMICmdArgValListBase destructor.
// Type: Overridden.
// Args: None.
// Return: None.
// Throws: None.
//--
-CMICmdArgValListBase::~CMICmdArgValListBase()
-{
- // Tidy up
- Destroy();
+CMICmdArgValListBase::~CMICmdArgValListBase() {
+ // Tidy up
+ Destroy();
}
-//++ ------------------------------------------------------------------------------------
+//++
+//------------------------------------------------------------------------------------
// Details: Tear down resources used by *this object.
// Type: Method.
// Args: None.
// Return: None.
// Throws: None.
//--
-void
-CMICmdArgValListBase::Destroy()
-{
- // Tidy up
- VecArgObjPtr_t::const_iterator it = m_argValue.begin();
- while (it != m_argValue.end())
- {
- CMICmdArgValBase *pArgObj = *it;
- delete pArgObj;
-
- // Next
- ++it;
- }
- m_argValue.clear();
-}
-
-//++ ------------------------------------------------------------------------------------
-// Details: Create an CMICmdArgValBase derived object matching the type specified
+void CMICmdArgValListBase::Destroy() {
+ // Tidy up
+ VecArgObjPtr_t::const_iterator it = m_argValue.begin();
+ while (it != m_argValue.end()) {
+ CMICmdArgValBase *pArgObj = *it;
+ delete pArgObj;
+
+ // Next
+ ++it;
+ }
+ m_argValue.clear();
+}
+
+//++
+//------------------------------------------------------------------------------------
+// Details: Create an CMICmdArgValBase derived object matching the type
+// specified
// and put the option or argument's value inside it.
// Type: Method.
// Args: vrTxt - (R) Text version the option or argument.
@@ -109,56 +115,56 @@ CMICmdArgValListBase::Destroy()
// Throws: None.
//--
CMICmdArgValBase *
-CMICmdArgValListBase::CreationObj(const CMIUtilString &vrTxt, const ArgValType_e veType) const
-{
- CMICmdArgValBase *pOptionObj = nullptr;
- switch (veType)
- {
- case eArgValType_File:
- pOptionObj = new CMICmdArgValFile();
- break;
- case eArgValType_Consume:
- pOptionObj = new CMICmdArgValConsume();
- break;
- case eArgValType_Number:
- pOptionObj = new CMICmdArgValNumber();
- break;
- case eArgValType_OptionLong:
- pOptionObj = new CMICmdArgValOptionLong();
- break;
- case eArgValType_OptionShort:
- pOptionObj = new CMICmdArgValOptionShort();
- break;
- case eArgValType_String:
- pOptionObj = new CMICmdArgValString();
- break;
- case eArgValType_StringQuoted:
- pOptionObj = new CMICmdArgValString(true, false, false);
- break;
- case eArgValType_StringQuotedNumber:
- pOptionObj = new CMICmdArgValString(true, true, false);
- break;
- case eArgValType_StringQuotedNumberPath:
- pOptionObj = new CMICmdArgValString(true, true, true);
- break;
- case eArgValType_StringAnything:
- pOptionObj = new CMICmdArgValString(true);
- break;
- case eArgValType_ThreadGrp:
- pOptionObj = new CMICmdArgValThreadGrp();
- break;
- default:
- return nullptr;
- }
-
- CMICmdArgContext argCntxt(vrTxt);
- if (!pOptionObj->Validate(argCntxt))
- return nullptr;
+CMICmdArgValListBase::CreationObj(const CMIUtilString &vrTxt,
+ const ArgValType_e veType) const {
+ CMICmdArgValBase *pOptionObj = nullptr;
+ switch (veType) {
+ case eArgValType_File:
+ pOptionObj = new CMICmdArgValFile();
+ break;
+ case eArgValType_Consume:
+ pOptionObj = new CMICmdArgValConsume();
+ break;
+ case eArgValType_Number:
+ pOptionObj = new CMICmdArgValNumber();
+ break;
+ case eArgValType_OptionLong:
+ pOptionObj = new CMICmdArgValOptionLong();
+ break;
+ case eArgValType_OptionShort:
+ pOptionObj = new CMICmdArgValOptionShort();
+ break;
+ case eArgValType_String:
+ pOptionObj = new CMICmdArgValString();
+ break;
+ case eArgValType_StringQuoted:
+ pOptionObj = new CMICmdArgValString(true, false, false);
+ break;
+ case eArgValType_StringQuotedNumber:
+ pOptionObj = new CMICmdArgValString(true, true, false);
+ break;
+ case eArgValType_StringQuotedNumberPath:
+ pOptionObj = new CMICmdArgValString(true, true, true);
+ break;
+ case eArgValType_StringAnything:
+ pOptionObj = new CMICmdArgValString(true);
+ break;
+ case eArgValType_ThreadGrp:
+ pOptionObj = new CMICmdArgValThreadGrp();
+ break;
+ default:
+ return nullptr;
+ }
+
+ CMICmdArgContext argCntxt(vrTxt);
+ if (!pOptionObj->Validate(argCntxt))
+ return nullptr;
- return pOptionObj;
+ return pOptionObj;
}
-//++ ------------------------------------------------------------------------------------
+//++
+//------------------------------------------------------------------------------------
// Details: Validate the option or argument is the correct type.
// Type: Method.
// Args: vrTxt - (R) Text version the option or argument.
@@ -166,48 +172,46 @@ CMICmdArgValListBase::CreationObj(const
// Return: bool - True = Yes expected type present, False = no.
// Throws: None.
//--
-bool
-CMICmdArgValListBase::IsExpectedCorrectType(const CMIUtilString &vrTxt, const ArgValType_e veType) const
-{
- bool bValid = false;
- switch (veType)
- {
- case eArgValType_File:
- bValid = CMICmdArgValFile().IsFilePath(vrTxt);
- break;
- case eArgValType_Consume:
- bValid = CMICmdArgValConsume().IsOk();
- break;
- case eArgValType_Number:
- bValid = CMICmdArgValNumber().IsArgNumber(vrTxt);
- break;
- case eArgValType_OptionLong:
- bValid = CMICmdArgValOptionLong().IsArgLongOption(vrTxt);
- break;
- case eArgValType_OptionShort:
- bValid = CMICmdArgValOptionShort().IsArgShortOption(vrTxt);
- break;
- case eArgValType_String:
- bValid = CMICmdArgValString().IsStringArg(vrTxt);
- break;
- case eArgValType_StringQuoted:
- bValid = CMICmdArgValString(true, false, false).IsStringArg(vrTxt);
- break;
- case eArgValType_StringQuotedNumber:
- bValid = CMICmdArgValString(true, true, false).IsStringArg(vrTxt);
- break;
- case eArgValType_StringQuotedNumberPath:
- bValid = CMICmdArgValString(true, true, true).IsStringArg(vrTxt);
- break;
- case eArgValType_StringAnything:
- bValid = CMICmdArgValString(true).IsStringArg(vrTxt);
- break;
- case eArgValType_ThreadGrp:
- bValid = CMICmdArgValThreadGrp().IsArgThreadGrp(vrTxt);
- break;
- default:
- return false;
- }
+bool CMICmdArgValListBase::IsExpectedCorrectType(
+ const CMIUtilString &vrTxt, const ArgValType_e veType) const {
+ bool bValid = false;
+ switch (veType) {
+ case eArgValType_File:
+ bValid = CMICmdArgValFile().IsFilePath(vrTxt);
+ break;
+ case eArgValType_Consume:
+ bValid = CMICmdArgValConsume().IsOk();
+ break;
+ case eArgValType_Number:
+ bValid = CMICmdArgValNumber().IsArgNumber(vrTxt);
+ break;
+ case eArgValType_OptionLong:
+ bValid = CMICmdArgValOptionLong().IsArgLongOption(vrTxt);
+ break;
+ case eArgValType_OptionShort:
+ bValid = CMICmdArgValOptionShort().IsArgShortOption(vrTxt);
+ break;
+ case eArgValType_String:
+ bValid = CMICmdArgValString().IsStringArg(vrTxt);
+ break;
+ case eArgValType_StringQuoted:
+ bValid = CMICmdArgValString(true, false, false).IsStringArg(vrTxt);
+ break;
+ case eArgValType_StringQuotedNumber:
+ bValid = CMICmdArgValString(true, true, false).IsStringArg(vrTxt);
+ break;
+ case eArgValType_StringQuotedNumberPath:
+ bValid = CMICmdArgValString(true, true, true).IsStringArg(vrTxt);
+ break;
+ case eArgValType_StringAnything:
+ bValid = CMICmdArgValString(true).IsStringArg(vrTxt);
+ break;
+ case eArgValType_ThreadGrp:
+ bValid = CMICmdArgValThreadGrp().IsArgThreadGrp(vrTxt);
+ break;
+ default:
+ return false;
+ }
- return bValid;
+ return bValid;
}
Modified: lldb/trunk/tools/lldb-mi/MICmdArgValListBase.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/lldb-mi/MICmdArgValListBase.h?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/tools/lldb-mi/MICmdArgValListBase.h (original)
+++ lldb/trunk/tools/lldb-mi/MICmdArgValListBase.h Tue Sep 6 15:57:50 2016
@@ -18,72 +18,86 @@
// Declarations:
class CMICmdArgContext;
-//++ ============================================================================
+//++
+//============================================================================
// Details: MI common code class. Command argument with addition options class.
// For example --recurse 1 2 4 [group ...]. Arguments object that
// require a list of options associated with them derive from the
-// CMICmdArgValListBase class. Additional options are also extracted from
+// CMICmdArgValListBase class. Additional options are also extracted
+// from
// the command arguments text string.
// 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
+// interpret the options (context) string to find and validate a
+// matching
// options and so extract a values from it .
-// The CMICmdArgValBase objects are added to the derived argument class's
-// container. The option arguments belong to that derived class and will
+// The CMICmdArgValBase objects are added to the derived argument
+// class's
+// container. The option arguments belong to that derived class and
+// will
// be deleted that object goes out of scope.
// Based on the Interpreter pattern.
//--
-class CMICmdArgValListBase : public CMICmdArgValBaseTemplate<std::vector<CMICmdArgValBase *>>
-{
- // Typedef:
- public:
- typedef std::vector<CMICmdArgValBase *> VecArgObjPtr_t;
-
- // Enums:
- public:
- //++ ---------------------------------------------------------------------------------
- // Details: CMICmdArgValListBase needs to know what type of argument to look for in
- // the command options text. It also needs to create argument objects of
- // a specific type.
- //--
- enum ArgValType_e
- {
- eArgValType_File = 0,
- eArgValType_Consume,
- eArgValType_Number,
- eArgValType_OptionLong,
- eArgValType_OptionShort,
- eArgValType_String,
- eArgValType_StringQuoted,
- eArgValType_StringQuotedNumber,
- eArgValType_StringQuotedNumberPath,
- eArgValType_StringAnything, // Accept any words for a string 'type' even if they look like --longOptions for example
- eArgValType_ThreadGrp,
- eArgValType_count, // Always the last one
- eArgValType_invalid
- };
-
- // Methods:
- public:
- /* ctor */ CMICmdArgValListBase();
- /* ctor */ CMICmdArgValListBase(const CMIUtilString &vrArgName, const bool vbMandatory, const bool vbHandleByCmd);
- /* ctor */ CMICmdArgValListBase(const CMIUtilString &vrArgName, const bool vbMandatory, const bool vbHandleByCmd,
- const ArgValType_e veType);
-
- // Overridden:
- public:
- // From CMICmdArgValBase
- /* dtor */ ~CMICmdArgValListBase() override;
-
- // Methods:
- protected:
- bool IsExpectedCorrectType(const CMIUtilString &vrTxt, const ArgValType_e veType) const;
- CMICmdArgValBase *CreationObj(const CMIUtilString &vrTxt, const ArgValType_e veType) const;
-
- // Attributes:
- protected:
- ArgValType_e m_eArgType;
-
- // Methods:
- private:
- void Destroy();
+class CMICmdArgValListBase
+ : public CMICmdArgValBaseTemplate<std::vector<CMICmdArgValBase *>> {
+ // Typedef:
+public:
+ typedef std::vector<CMICmdArgValBase *> VecArgObjPtr_t;
+
+ // Enums:
+public:
+ //++
+ //---------------------------------------------------------------------------------
+ // Details: CMICmdArgValListBase needs to know what type of argument to look
+ // for in
+ // the command options text. It also needs to create argument objects
+ // of
+ // a specific type.
+ //--
+ enum ArgValType_e {
+ eArgValType_File = 0,
+ eArgValType_Consume,
+ eArgValType_Number,
+ eArgValType_OptionLong,
+ eArgValType_OptionShort,
+ eArgValType_String,
+ eArgValType_StringQuoted,
+ eArgValType_StringQuotedNumber,
+ eArgValType_StringQuotedNumberPath,
+ eArgValType_StringAnything, // Accept any words for a string 'type' even if
+ // they look like --longOptions for example
+ eArgValType_ThreadGrp,
+ eArgValType_count, // Always the last one
+ eArgValType_invalid
+ };
+
+ // Methods:
+public:
+ /* ctor */ CMICmdArgValListBase();
+ /* ctor */ CMICmdArgValListBase(const CMIUtilString &vrArgName,
+ const bool vbMandatory,
+ const bool vbHandleByCmd);
+ /* ctor */ CMICmdArgValListBase(const CMIUtilString &vrArgName,
+ const bool vbMandatory,
+ const bool vbHandleByCmd,
+ const ArgValType_e veType);
+
+ // Overridden:
+public:
+ // From CMICmdArgValBase
+ /* dtor */ ~CMICmdArgValListBase() override;
+
+ // Methods:
+protected:
+ bool IsExpectedCorrectType(const CMIUtilString &vrTxt,
+ const ArgValType_e veType) const;
+ CMICmdArgValBase *CreationObj(const CMIUtilString &vrTxt,
+ const ArgValType_e veType) const;
+
+ // Attributes:
+protected:
+ ArgValType_e m_eArgType;
+
+ // Methods:
+private:
+ void Destroy();
};
Modified: lldb/trunk/tools/lldb-mi/MICmdArgValListOfN.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/lldb-mi/MICmdArgValListOfN.cpp?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/tools/lldb-mi/MICmdArgValListOfN.cpp (original)
+++ lldb/trunk/tools/lldb-mi/MICmdArgValListOfN.cpp Tue Sep 6 15:57:50 2016
@@ -17,46 +17,50 @@
#include "MICmdArgValString.h"
#include "MICmdArgValThreadGrp.h"
-//++ ------------------------------------------------------------------------------------
+//++
+//------------------------------------------------------------------------------------
// Details: CMICmdArgValListOfN constructor.
// Type: Method.
// Args: None.
// Return: None.
// Throws: None.
//--
-CMICmdArgValListOfN::CMICmdArgValListOfN()
-{
-}
+CMICmdArgValListOfN::CMICmdArgValListOfN() {}
-//++ ------------------------------------------------------------------------------------
+//++
+//------------------------------------------------------------------------------------
// Details: CMICmdArgValListOfN constructor.
// Type: Method.
// Args: vrArgName - (R) Argument's name to search by.
-// vbMandatory - (R) True = Yes must be present, false = optional argument.
-// vbHandleByCmd - (R) True = Command processes *this option, false = not handled.
-// veType - (R) The type of argument to look for and create argument object of a certain type.
+// vbMandatory - (R) True = Yes must be present, false = optional
+// argument.
+// vbHandleByCmd - (R) True = Command processes *this option, false =
+// not handled.
+// veType - (R) The type of argument to look for and create
+// argument object of a certain type.
// Return: None.
// Throws: None.
//--
-CMICmdArgValListOfN::CMICmdArgValListOfN(const CMIUtilString &vrArgName, const bool vbMandatory, const bool vbHandleByCmd,
+CMICmdArgValListOfN::CMICmdArgValListOfN(const CMIUtilString &vrArgName,
+ const bool vbMandatory,
+ const bool vbHandleByCmd,
const ArgValType_e veType)
- : CMICmdArgValListBase(vrArgName, vbMandatory, vbHandleByCmd, veType)
-{
-}
+ : CMICmdArgValListBase(vrArgName, vbMandatory, vbHandleByCmd, veType) {}
-//++ ------------------------------------------------------------------------------------
+//++
+//------------------------------------------------------------------------------------
// Details: CMICmdArgValListOfN destructor.
// Type: Overridden.
// Args: None.
// Return: None.
// Throws: None.
//--
-CMICmdArgValListOfN::~CMICmdArgValListOfN()
-{
-}
+CMICmdArgValListOfN::~CMICmdArgValListOfN() {}
-//++ ------------------------------------------------------------------------------------
-// Details: Parse the command's argument options string and try to extract the list of
+//++
+//------------------------------------------------------------------------------------
+// Details: Parse the command's argument options string and try to extract the
+// list of
// arguments based on the argument object type to look for.
// Type: Overridden.
// Args: vwArgContext - (RW) The command's argument options string.
@@ -64,105 +68,101 @@ CMICmdArgValListOfN::~CMICmdArgValListOf
// MIstatus::failure - Functional failed.
// Throws: None.
//--
-bool
-CMICmdArgValListOfN::Validate(CMICmdArgContext &vwArgContext)
-{
- if (m_eArgType >= eArgValType_count)
- {
- m_eArgType = eArgValType_invalid;
- return MIstatus::failure;
- }
-
- if (vwArgContext.IsEmpty())
- return m_bMandatory ? MIstatus::failure : MIstatus::success;
-
- const CMIUtilString &rArg(vwArgContext.GetArgsLeftToParse());
- if (IsListOfN(rArg) && CreateList(rArg))
- {
- m_bFound = true;
- m_bValid = true;
- vwArgContext.RemoveArg(rArg);
- return MIstatus::success;
- }
- else
- return MIstatus::failure;
+bool CMICmdArgValListOfN::Validate(CMICmdArgContext &vwArgContext) {
+ if (m_eArgType >= eArgValType_count) {
+ m_eArgType = eArgValType_invalid;
+ return MIstatus::failure;
+ }
+
+ if (vwArgContext.IsEmpty())
+ return m_bMandatory ? MIstatus::failure : MIstatus::success;
+
+ const CMIUtilString &rArg(vwArgContext.GetArgsLeftToParse());
+ if (IsListOfN(rArg) && CreateList(rArg)) {
+ m_bFound = true;
+ m_bValid = true;
+ vwArgContext.RemoveArg(rArg);
+ return MIstatus::success;
+ } else
+ return MIstatus::failure;
}
-//++ ------------------------------------------------------------------------------------
-// Details: Create list of argument objects each holding a value extract from the command
+//++
+//------------------------------------------------------------------------------------
+// Details: Create list of argument objects each holding a value extract from
+// the command
// options line.
// Type: Method.
// Args: vrTxt - (R) Some options text.
// Return: bool - True = yes valid arg, false = no.
// Throws: None.
//--
-bool
-CMICmdArgValListOfN::CreateList(const CMIUtilString &vrTxt)
-{
- CMIUtilString::VecString_t vecOptions;
- if ((m_eArgType == eArgValType_StringQuoted) || (m_eArgType == eArgValType_StringQuotedNumber) ||
- (m_eArgType == eArgValType_StringQuotedNumberPath) || (m_eArgType == eArgValType_StringAnything))
- {
- if (vrTxt.SplitConsiderQuotes(" ", vecOptions) == 0)
- return MIstatus::failure;
- }
- else if (vrTxt.Split(" ", vecOptions) == 0)
- return MIstatus::failure;
-
- CMIUtilString::VecString_t::const_iterator it = vecOptions.begin();
- while (it != vecOptions.end())
- {
- const CMIUtilString &rOption = *it;
- CMICmdArgValBase *pOption = CreationObj(rOption, m_eArgType);
- if (pOption != nullptr)
- m_argValue.push_back(pOption);
- else
- return MIstatus::failure;
-
- // Next
- ++it;
- }
+bool CMICmdArgValListOfN::CreateList(const CMIUtilString &vrTxt) {
+ CMIUtilString::VecString_t vecOptions;
+ if ((m_eArgType == eArgValType_StringQuoted) ||
+ (m_eArgType == eArgValType_StringQuotedNumber) ||
+ (m_eArgType == eArgValType_StringQuotedNumberPath) ||
+ (m_eArgType == eArgValType_StringAnything)) {
+ if (vrTxt.SplitConsiderQuotes(" ", vecOptions) == 0)
+ return MIstatus::failure;
+ } else if (vrTxt.Split(" ", vecOptions) == 0)
+ return MIstatus::failure;
+
+ CMIUtilString::VecString_t::const_iterator it = vecOptions.begin();
+ while (it != vecOptions.end()) {
+ const CMIUtilString &rOption = *it;
+ CMICmdArgValBase *pOption = CreationObj(rOption, m_eArgType);
+ if (pOption != nullptr)
+ m_argValue.push_back(pOption);
+ else
+ return MIstatus::failure;
- return MIstatus::success;
+ // Next
+ ++it;
+ }
+
+ return MIstatus::success;
}
-//++ ------------------------------------------------------------------------------------
-// Details: Examine the string and determine if it is a valid string type argument.
+//++
+//------------------------------------------------------------------------------------
+// Details: Examine the string and determine if it is a valid string type
+// argument.
// Type: Method.
// Args: vrTxt - (R) Some text.
// Return: bool - True = yes valid arg, false = no.
// Throws: None.
//--
-bool
-CMICmdArgValListOfN::IsListOfN(const CMIUtilString &vrTxt) const
-{
- CMIUtilString::VecString_t vecOptions;
- if ((m_eArgType == eArgValType_StringQuoted) || (m_eArgType == eArgValType_StringQuotedNumber) ||
- (m_eArgType == eArgValType_StringQuotedNumberPath) || (m_eArgType == eArgValType_StringAnything))
- {
- if (vrTxt.SplitConsiderQuotes(" ", vecOptions) == 0)
- return false;
- }
- else if (vrTxt.Split(" ", vecOptions) == 0)
- return false;
-
- CMIUtilString::VecString_t::const_iterator it = vecOptions.begin();
- while (it != vecOptions.end())
- {
- const CMIUtilString &rOption = *it;
- if (!IsExpectedCorrectType(rOption, m_eArgType))
- break;
-
- // Next
- ++it;
- }
-
- return true;
-}
-
-//++ ------------------------------------------------------------------------------------
-// Details: Retrieve the list of CMICmdArgValBase derived option objects found following
-// *this long option argument. For example "list-thread-groups [ --recurse 1 ]"
+bool CMICmdArgValListOfN::IsListOfN(const CMIUtilString &vrTxt) const {
+ CMIUtilString::VecString_t vecOptions;
+ if ((m_eArgType == eArgValType_StringQuoted) ||
+ (m_eArgType == eArgValType_StringQuotedNumber) ||
+ (m_eArgType == eArgValType_StringQuotedNumberPath) ||
+ (m_eArgType == eArgValType_StringAnything)) {
+ if (vrTxt.SplitConsiderQuotes(" ", vecOptions) == 0)
+ return false;
+ } else if (vrTxt.Split(" ", vecOptions) == 0)
+ return false;
+
+ CMIUtilString::VecString_t::const_iterator it = vecOptions.begin();
+ while (it != vecOptions.end()) {
+ const CMIUtilString &rOption = *it;
+ if (!IsExpectedCorrectType(rOption, m_eArgType))
+ break;
+
+ // Next
+ ++it;
+ }
+
+ return true;
+}
+
+//++
+//------------------------------------------------------------------------------------
+// Details: Retrieve the list of CMICmdArgValBase derived option objects found
+// following
+// *this long option argument. For example "list-thread-groups [
+// --recurse 1 ]"
// where 1 is the list of expected option to follow.
// Type: Method.
// Args: None.
@@ -170,7 +170,6 @@ CMICmdArgValListOfN::IsListOfN(const CMI
// Throws: None.
//--
const CMICmdArgValListBase::VecArgObjPtr_t &
-CMICmdArgValListOfN::GetExpectedOptions() const
-{
- return m_argValue;
+CMICmdArgValListOfN::GetExpectedOptions() const {
+ return m_argValue;
}
Modified: lldb/trunk/tools/lldb-mi/MICmdArgValListOfN.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/lldb-mi/MICmdArgValListOfN.h?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/tools/lldb-mi/MICmdArgValListOfN.h (original)
+++ lldb/trunk/tools/lldb-mi/MICmdArgValListOfN.h Tue Sep 6 15:57:50 2016
@@ -18,11 +18,13 @@
// 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
+// interpret the options (context) string to find and validate a
+// matching
// argument and so extract a value from it .
// The CMICmdArgValBase objects added to *this ListOfN container belong
// to this container and will be deleted when *this object goes out of
@@ -32,57 +34,61 @@ class CMICmdArgContext;
// otherwise assumed to be (...)* specification.
// Based on the Interpreter pattern.
//--
-class CMICmdArgValListOfN : public CMICmdArgValListBase
-{
- // Methods:
- public:
- /* ctor */ CMICmdArgValListOfN();
- /* ctor */ CMICmdArgValListOfN(const CMIUtilString &vrArgName, const bool vbMandatory, const bool vbHandleByCmd,
- const ArgValType_e veType);
- //
- const VecArgObjPtr_t &GetExpectedOptions() const;
- template <class T1, typename T2> bool GetExpectedOption(T2 &vrwValue, const VecArgObjPtr_t::size_type vnAt = 0) const;
-
- // Overridden:
- public:
- // From CMICmdArgValBase
- /* dtor */ ~CMICmdArgValListOfN() override;
- // From CMICmdArgSet::IArg
- bool Validate(CMICmdArgContext &vArgContext) override;
-
- // Methods:
- private:
- bool IsListOfN(const CMIUtilString &vrTxt) const;
- bool CreateList(const CMIUtilString &vrTxt);
+class CMICmdArgValListOfN : public CMICmdArgValListBase {
+ // Methods:
+public:
+ /* ctor */ CMICmdArgValListOfN();
+ /* ctor */ CMICmdArgValListOfN(const CMIUtilString &vrArgName,
+ const bool vbMandatory,
+ const bool vbHandleByCmd,
+ const ArgValType_e veType);
+ //
+ const VecArgObjPtr_t &GetExpectedOptions() const;
+ template <class T1, typename T2>
+ bool GetExpectedOption(T2 &vrwValue,
+ const VecArgObjPtr_t::size_type vnAt = 0) const;
+
+ // Overridden:
+public:
+ // From CMICmdArgValBase
+ /* dtor */ ~CMICmdArgValListOfN() override;
+ // From CMICmdArgSet::IArg
+ bool Validate(CMICmdArgContext &vArgContext) override;
+
+ // Methods:
+private:
+ bool IsListOfN(const CMIUtilString &vrTxt) const;
+ bool CreateList(const CMIUtilString &vrTxt);
};
-//++ ------------------------------------------------------------------------------------
-// Details: Retrieve the first argument or option value from the list of 1 or more options
+//++
+//------------------------------------------------------------------------------------
+// Details: Retrieve the first argument or option value from the list of 1 or
+// more options
// parsed from the command's options string.
// Type: Template method.
// Args: vrwValue - (W) Templated type return value.
// vnAt - (R) Value at the specific position.
-// T1 - The argument value's class type of the data hold in the list of options.
+// T1 - The argument value's class type of the data hold in
+// the list of options.
// T2 - The type pf the variable which holds the value wanted.
// Return: MIstatus::success - Functional succeeded.
// MIstatus::failure - Functional failed. List of object was empty.
// Throws: None.
//--
template <class T1, typename T2>
-bool
-CMICmdArgValListOfN::GetExpectedOption(T2 &vrwValue, const VecArgObjPtr_t::size_type vnAt) const
-{
- const VecArgObjPtr_t &rVecOptions(GetExpectedOptions());
- if (rVecOptions.size() <= vnAt)
- return MIstatus::failure;
-
- VecArgObjPtr_t::const_iterator it2 = rVecOptions.begin() + vnAt;
- if (it2 != rVecOptions.end())
- {
- const T1 *pOption = static_cast<T1 *>(*it2);
- vrwValue = pOption->GetValue();
- return MIstatus::success;
- }
-
+bool CMICmdArgValListOfN::GetExpectedOption(
+ T2 &vrwValue, const VecArgObjPtr_t::size_type vnAt) const {
+ const VecArgObjPtr_t &rVecOptions(GetExpectedOptions());
+ if (rVecOptions.size() <= vnAt)
return MIstatus::failure;
+
+ VecArgObjPtr_t::const_iterator it2 = rVecOptions.begin() + vnAt;
+ if (it2 != rVecOptions.end()) {
+ const T1 *pOption = static_cast<T1 *>(*it2);
+ vrwValue = pOption->GetValue();
+ return MIstatus::success;
+ }
+
+ return MIstatus::failure;
}
Modified: lldb/trunk/tools/lldb-mi/MICmdArgValNumber.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/lldb-mi/MICmdArgValNumber.cpp?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/tools/lldb-mi/MICmdArgValNumber.cpp (original)
+++ lldb/trunk/tools/lldb-mi/MICmdArgValNumber.cpp Tue Sep 6 15:57:50 2016
@@ -11,7 +11,8 @@
#include "MICmdArgValNumber.h"
#include "MICmdArgContext.h"
-//++ ------------------------------------------------------------------------------------
+//++
+//------------------------------------------------------------------------------------
// Details: CMICmdArgValNumber constructor.
// Type: Method.
// Args: None.
@@ -19,42 +20,45 @@
// Throws: None.
//--
CMICmdArgValNumber::CMICmdArgValNumber()
- : m_nNumberFormatMask(CMICmdArgValNumber::eArgValNumberFormat_Decimal)
- , m_nNumber(0)
-{
-}
+ : m_nNumberFormatMask(CMICmdArgValNumber::eArgValNumberFormat_Decimal),
+ m_nNumber(0) {}
-//++ ------------------------------------------------------------------------------------
+//++
+//------------------------------------------------------------------------------------
// Details: CMICmdArgValNumber constructor.
// Type: Method.
// Args: vrArgName - (R) Argument's name to search by.
-// vbMandatory - (R) True = Yes must be present, false = optional argument.
-// vbHandleByCmd - (R) True = Command processes *this option, false = not handled.
-// vnNumberFormatMask - (R) Mask of the number formats. (Dflt = CMICmdArgValNumber::eArgValNumberFormat_Decimal)
+// vbMandatory - (R) True = Yes must be present, false =
+// optional argument.
+// vbHandleByCmd - (R) True = Command processes *this option,
+// false = not handled.
+// vnNumberFormatMask - (R) Mask of the number formats. (Dflt =
+// CMICmdArgValNumber::eArgValNumberFormat_Decimal)
// Return: None.
// Throws: None.
//--
-CMICmdArgValNumber::CMICmdArgValNumber(const CMIUtilString &vrArgName, const bool vbMandatory, const bool vbHandleByCmd,
- const MIuint vnNumberFormatMask /* = CMICmdArgValNumber::eArgValNumberFormat_Decimal*/)
- : CMICmdArgValBaseTemplate(vrArgName, vbMandatory, vbHandleByCmd)
- , m_nNumberFormatMask(vnNumberFormatMask)
- , m_nNumber(0)
-{
-}
+CMICmdArgValNumber::CMICmdArgValNumber(
+ const CMIUtilString &vrArgName, const bool vbMandatory,
+ const bool vbHandleByCmd,
+ const MIuint
+ vnNumberFormatMask /* = CMICmdArgValNumber::eArgValNumberFormat_Decimal*/)
+ : CMICmdArgValBaseTemplate(vrArgName, vbMandatory, vbHandleByCmd),
+ m_nNumberFormatMask(vnNumberFormatMask), m_nNumber(0) {}
-//++ ------------------------------------------------------------------------------------
+//++
+//------------------------------------------------------------------------------------
// Details: CMICmdArgValNumber destructor.
// Type: Overridden.
// Args: None.
// Return: None.
// Throws: None.
//--
-CMICmdArgValNumber::~CMICmdArgValNumber()
-{
-}
+CMICmdArgValNumber::~CMICmdArgValNumber() {}
-//++ ------------------------------------------------------------------------------------
-// Details: Parse the command's argument options string and try to extract the value *this
+//++
+//------------------------------------------------------------------------------------
+// Details: Parse the command's argument options string and try to extract the
+// value *this
// argument is looking for.
// Type: Overridden.
// Args: vwArgContext - (RW) The command's argument options string.
@@ -62,81 +66,76 @@ CMICmdArgValNumber::~CMICmdArgValNumber(
// MIstatus::failure - Functional failed.
// Throws: None.
//--
-bool
-CMICmdArgValNumber::Validate(CMICmdArgContext &vwArgContext)
-{
- if (vwArgContext.IsEmpty())
- return m_bMandatory ? MIstatus::failure : MIstatus::success;
-
- if (vwArgContext.GetNumberArgsPresent() == 1)
- {
- const CMIUtilString &rArg(vwArgContext.GetArgsLeftToParse());
- if (IsArgNumber(rArg) && ExtractNumber(rArg))
- {
- m_bFound = true;
- m_bValid = true;
- m_argValue = GetNumber();
- vwArgContext.RemoveArg(rArg);
- return MIstatus::success;
- }
- else
- return MIstatus::failure;
+bool CMICmdArgValNumber::Validate(CMICmdArgContext &vwArgContext) {
+ if (vwArgContext.IsEmpty())
+ return m_bMandatory ? MIstatus::failure : MIstatus::success;
+
+ if (vwArgContext.GetNumberArgsPresent() == 1) {
+ const CMIUtilString &rArg(vwArgContext.GetArgsLeftToParse());
+ if (IsArgNumber(rArg) && ExtractNumber(rArg)) {
+ m_bFound = true;
+ m_bValid = true;
+ m_argValue = GetNumber();
+ vwArgContext.RemoveArg(rArg);
+ return MIstatus::success;
+ } else
+ return MIstatus::failure;
+ }
+
+ // More than one option...
+ const CMIUtilString::VecString_t vecOptions(vwArgContext.GetArgs());
+ CMIUtilString::VecString_t::const_iterator it = vecOptions.begin();
+ while (it != vecOptions.end()) {
+ const CMIUtilString &rArg(*it);
+ if (IsArgNumber(rArg) && ExtractNumber(rArg)) {
+ m_bFound = true;
+
+ if (vwArgContext.RemoveArg(rArg)) {
+ m_bValid = true;
+ m_argValue = GetNumber();
+ return MIstatus::success;
+ } else
+ return MIstatus::failure;
}
- // More than one option...
- const CMIUtilString::VecString_t vecOptions(vwArgContext.GetArgs());
- CMIUtilString::VecString_t::const_iterator it = vecOptions.begin();
- while (it != vecOptions.end())
- {
- const CMIUtilString &rArg(*it);
- if (IsArgNumber(rArg) && ExtractNumber(rArg))
- {
- m_bFound = true;
-
- if (vwArgContext.RemoveArg(rArg))
- {
- m_bValid = true;
- m_argValue = GetNumber();
- return MIstatus::success;
- }
- else
- return MIstatus::failure;
- }
-
- // Next
- ++it;
- }
+ // Next
+ ++it;
+ }
- return MIstatus::failure;
+ return MIstatus::failure;
}
-//++ ------------------------------------------------------------------------------------
-// Details: Examine the string and determine if it is a valid string type argument.
+//++
+//------------------------------------------------------------------------------------
+// Details: Examine the string and determine if it is a valid string type
+// argument.
// Type: Method.
// Args: vrTxt - (R) Some text.
// Return: bool - True = yes valid arg, false = no.
// Throws: None.
//--
-bool
-CMICmdArgValNumber::IsArgNumber(const CMIUtilString &vrTxt) const
-{
- const bool bFormatDecimal(m_nNumberFormatMask & CMICmdArgValNumber::eArgValNumberFormat_Decimal);
- const bool bFormatHexadecimal(m_nNumberFormatMask & CMICmdArgValNumber::eArgValNumberFormat_Hexadecimal);
-
- // Look for --someLongOption
- if (std::string::npos != vrTxt.find("--"))
- return false;
+bool CMICmdArgValNumber::IsArgNumber(const CMIUtilString &vrTxt) const {
+ const bool bFormatDecimal(m_nNumberFormatMask &
+ CMICmdArgValNumber::eArgValNumberFormat_Decimal);
+ const bool bFormatHexadecimal(
+ m_nNumberFormatMask &
+ CMICmdArgValNumber::eArgValNumberFormat_Hexadecimal);
- if (bFormatDecimal && vrTxt.IsNumber())
- return true;
+ // Look for --someLongOption
+ if (std::string::npos != vrTxt.find("--"))
+ return false;
- if (bFormatHexadecimal && vrTxt.IsHexadecimalNumber())
- return true;
+ if (bFormatDecimal && vrTxt.IsNumber())
+ return true;
- return false;
+ if (bFormatHexadecimal && vrTxt.IsHexadecimalNumber())
+ return true;
+
+ return false;
}
-//++ ------------------------------------------------------------------------------------
+//++
+//------------------------------------------------------------------------------------
// Details: Extract the thread group number from the thread group argument.
// Type: Method.
// Args: vrTxt - (R) Some text.
@@ -144,28 +143,22 @@ CMICmdArgValNumber::IsArgNumber(const CM
// MIstatus::failure - Functional failed.
// Throws: None.
//--
-bool
-CMICmdArgValNumber::ExtractNumber(const CMIUtilString &vrTxt)
-{
- MIint64 nNumber = 0;
- bool bOk = vrTxt.ExtractNumber(nNumber);
- if (bOk)
- {
- m_nNumber = static_cast<MIint64>(nNumber);
- }
+bool CMICmdArgValNumber::ExtractNumber(const CMIUtilString &vrTxt) {
+ MIint64 nNumber = 0;
+ bool bOk = vrTxt.ExtractNumber(nNumber);
+ if (bOk) {
+ m_nNumber = static_cast<MIint64>(nNumber);
+ }
- return bOk;
+ return bOk;
}
-//++ ------------------------------------------------------------------------------------
+//++
+//------------------------------------------------------------------------------------
// Details: Retrieve the thread group ID found in the argument.
// Type: Method.
// Args: None.
// Return: MIuint - Thread group ID.
// Throws: None.
//--
-MIint64
-CMICmdArgValNumber::GetNumber() const
-{
- return m_nNumber;
-}
+MIint64 CMICmdArgValNumber::GetNumber() const { return m_nNumber; }
Modified: lldb/trunk/tools/lldb-mi/MICmdArgValNumber.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/lldb-mi/MICmdArgValNumber.h?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/tools/lldb-mi/MICmdArgValNumber.h (original)
+++ lldb/trunk/tools/lldb-mi/MICmdArgValNumber.h Tue Sep 6 15:57:50 2016
@@ -15,51 +15,57 @@
// 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
+// interpret the options (context) string to find and validate a
+// matching
// argument and so extract a value from it .
// Based on the Interpreter pattern.
//--
-class CMICmdArgValNumber : public CMICmdArgValBaseTemplate<MIint64>
-{
- // Enums:
- public:
- //++ ---------------------------------------------------------------------------------
- // Details: CMICmdArgValNumber needs to know what format of argument to look for in
- // the command options text.
- //--
- enum ArgValNumberFormat_e
- {
- eArgValNumberFormat_Decimal = (1u << 0),
- eArgValNumberFormat_Hexadecimal = (1u << 1),
- eArgValNumberFormat_Auto = ((eArgValNumberFormat_Hexadecimal << 1) - 1u) ///< Indicates to try and lookup everything up during a query.
- };
+class CMICmdArgValNumber : public CMICmdArgValBaseTemplate<MIint64> {
+ // Enums:
+public:
+ //++
+ //---------------------------------------------------------------------------------
+ // Details: CMICmdArgValNumber needs to know what format of argument to look
+ // for in
+ // the command options text.
+ //--
+ enum ArgValNumberFormat_e {
+ eArgValNumberFormat_Decimal = (1u << 0),
+ eArgValNumberFormat_Hexadecimal = (1u << 1),
+ eArgValNumberFormat_Auto =
+ ((eArgValNumberFormat_Hexadecimal << 1) -
+ 1u) ///< Indicates to try and lookup everything up during a query.
+ };
- // Methods:
- public:
- /* ctor */ CMICmdArgValNumber();
- /* ctor */ CMICmdArgValNumber(const CMIUtilString &vrArgName, const bool vbMandatory, const bool vbHandleByCmd,
- const MIuint vnNumberFormatMask = eArgValNumberFormat_Decimal);
- //
- bool IsArgNumber(const CMIUtilString &vrTxt) const;
+ // Methods:
+public:
+ /* ctor */ CMICmdArgValNumber();
+ /* ctor */ CMICmdArgValNumber(
+ const CMIUtilString &vrArgName, const bool vbMandatory,
+ const bool vbHandleByCmd,
+ const MIuint vnNumberFormatMask = eArgValNumberFormat_Decimal);
+ //
+ bool IsArgNumber(const CMIUtilString &vrTxt) const;
- // Overridden:
- public:
- // From CMICmdArgValBase
- /* dtor */ ~CMICmdArgValNumber() override;
- // From CMICmdArgSet::IArg
- bool Validate(CMICmdArgContext &vwArgContext) override;
+ // Overridden:
+public:
+ // From CMICmdArgValBase
+ /* dtor */ ~CMICmdArgValNumber() override;
+ // From CMICmdArgSet::IArg
+ bool Validate(CMICmdArgContext &vwArgContext) override;
- // Methods:
- private:
- bool ExtractNumber(const CMIUtilString &vrTxt);
- MIint64 GetNumber() const;
+ // Methods:
+private:
+ bool ExtractNumber(const CMIUtilString &vrTxt);
+ MIint64 GetNumber() const;
- // Attributes:
- private:
- MIuint m_nNumberFormatMask;
- MIint64 m_nNumber;
+ // Attributes:
+private:
+ MIuint m_nNumberFormatMask;
+ MIint64 m_nNumber;
};
Modified: lldb/trunk/tools/lldb-mi/MICmdArgValOptionLong.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/lldb-mi/MICmdArgValOptionLong.cpp?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/tools/lldb-mi/MICmdArgValOptionLong.cpp (original)
+++ lldb/trunk/tools/lldb-mi/MICmdArgValOptionLong.cpp Tue Sep 6 15:57:50 2016
@@ -11,7 +11,8 @@
#include "MICmdArgValOptionLong.h"
#include "MICmdArgContext.h"
-//++ ------------------------------------------------------------------------------------
+//++
+//------------------------------------------------------------------------------------
// Details: CMICmdArgValOptionLong constructor.
// Type: Method.
// Args: None.
@@ -19,84 +20,89 @@
// Throws: None.
//--
CMICmdArgValOptionLong::CMICmdArgValOptionLong()
- : m_nExpectingNOptions(0)
- , m_eExpectingOptionType(eArgValType_invalid)
-{
-}
+ : m_nExpectingNOptions(0), m_eExpectingOptionType(eArgValType_invalid) {}
-//++ ------------------------------------------------------------------------------------
+//++
+//------------------------------------------------------------------------------------
// Details: CMICmdArgValOptionLong constructor.
// Type: Method.
// Args: vrArgName - (R) Argument's name to search by.
-// vbMandatory - (R) True = Yes must be present, false = optional argument.
-// vbHandleByCmd - (R) True = Command processes *this option, false = not handled.
+// vbMandatory - (R) True = Yes must be present, false = optional
+// argument.
+// vbHandleByCmd - (R) True = Command processes *this option, false =
+// not handled.
// Return: None.
// Throws: None.
//--
-CMICmdArgValOptionLong::CMICmdArgValOptionLong(const CMIUtilString &vrArgName, const bool vbMandatory, const bool vbHandleByCmd)
- : CMICmdArgValListBase(vrArgName, vbMandatory, vbHandleByCmd)
- , m_nExpectingNOptions(0)
- , m_eExpectingOptionType(eArgValType_invalid)
-{
-}
+CMICmdArgValOptionLong::CMICmdArgValOptionLong(const CMIUtilString &vrArgName,
+ const bool vbMandatory,
+ const bool vbHandleByCmd)
+ : CMICmdArgValListBase(vrArgName, vbMandatory, vbHandleByCmd),
+ m_nExpectingNOptions(0), m_eExpectingOptionType(eArgValType_invalid) {}
-//++ ------------------------------------------------------------------------------------
+//++
+//------------------------------------------------------------------------------------
// Details: CMICmdArgValOptionLong constructor.
// Type: Method.
// Args: vrArgName - (R) Argument's name to search by.
-// vbMandatory - (R) True = Yes must be present, false = optional argument.
-// vbHandleByCmd - (R) True = Command processes *this option, false = not handled.
-// veType - (R) The type of argument to look for and create argument object of a certain type.
-// vnExpectingNOptions - (R) The number of options expected to read following *this argument.
+// vbMandatory - (R) True = Yes must be present, false =
+// optional argument.
+// vbHandleByCmd - (R) True = Command processes *this option,
+// false = not handled.
+// veType - (R) The type of argument to look for and
+// create argument object of a certain type.
+// vnExpectingNOptions - (R) The number of options expected to read
+// following *this argument.
// Return: None.
// Throws: None.
//--
-CMICmdArgValOptionLong::CMICmdArgValOptionLong(const CMIUtilString &vrArgName, const bool vbMandatory, const bool vbHandleByCmd,
- const ArgValType_e veType, const MIuint vnExpectingNOptions)
- : CMICmdArgValListBase(vrArgName, vbMandatory, vbHandleByCmd)
- , m_nExpectingNOptions(vnExpectingNOptions)
- , m_eExpectingOptionType(veType)
-{
-}
+CMICmdArgValOptionLong::CMICmdArgValOptionLong(const CMIUtilString &vrArgName,
+ const bool vbMandatory,
+ const bool vbHandleByCmd,
+ const ArgValType_e veType,
+ const MIuint vnExpectingNOptions)
+ : CMICmdArgValListBase(vrArgName, vbMandatory, vbHandleByCmd),
+ m_nExpectingNOptions(vnExpectingNOptions),
+ m_eExpectingOptionType(veType) {}
-//++ ------------------------------------------------------------------------------------
+//++
+//------------------------------------------------------------------------------------
// Details: CMICmdArgValOptionLong destructor.
// Type: Overridden.
// Args: None.
// Return: None.
// Throws: None.
//--
-CMICmdArgValOptionLong::~CMICmdArgValOptionLong()
-{
- // Tidy up
- Destroy();
+CMICmdArgValOptionLong::~CMICmdArgValOptionLong() {
+ // Tidy up
+ Destroy();
}
-//++ ------------------------------------------------------------------------------------
+//++
+//------------------------------------------------------------------------------------
// Details: Tear down resources used by *this object.
// Type: Method.
// Args: None.
// Return: None.
// Throws: None.
//--
-void
-CMICmdArgValOptionLong::Destroy()
-{
- // Tidy up
- VecArgObjPtr_t::const_iterator it = m_vecArgsExpected.begin();
- while (it != m_vecArgsExpected.end())
- {
- CMICmdArgValBase *pOptionObj = *it;
- delete pOptionObj;
-
- // Next
- ++it;
- }
- m_vecArgsExpected.clear();
-}
-
-//++ ------------------------------------------------------------------------------------
-// Details: Parse the command's argument options string and try to extract the long
+void CMICmdArgValOptionLong::Destroy() {
+ // Tidy up
+ VecArgObjPtr_t::const_iterator it = m_vecArgsExpected.begin();
+ while (it != m_vecArgsExpected.end()) {
+ CMICmdArgValBase *pOptionObj = *it;
+ delete pOptionObj;
+
+ // Next
+ ++it;
+ }
+ m_vecArgsExpected.clear();
+}
+
+//++
+//------------------------------------------------------------------------------------
+// Details: Parse the command's argument options string and try to extract the
+// long
// argument *this argument type is looking for.
// Type: Overridden.
// Args: vwArgContext - (RW) The command's argument options string.
@@ -104,202 +110,198 @@ CMICmdArgValOptionLong::Destroy()
// MIstatus::failure - Functional failed.
// Throws: None.
//--
-bool
-CMICmdArgValOptionLong::Validate(CMICmdArgContext &vwArgContext)
-{
- if (vwArgContext.IsEmpty())
- return m_bMandatory ? MIstatus::failure : MIstatus::success;
-
- if (vwArgContext.GetNumberArgsPresent() == 1)
- {
- const CMIUtilString &rArg(vwArgContext.GetArgsLeftToParse());
- if (IsArgLongOption(rArg) && ArgNameMatch(rArg))
- {
- m_bFound = true;
-
- if (!vwArgContext.RemoveArg(rArg))
- return MIstatus::failure;
-
- if (m_nExpectingNOptions == 0)
- {
- m_bValid = true;
- return MIstatus::success;
- }
+bool CMICmdArgValOptionLong::Validate(CMICmdArgContext &vwArgContext) {
+ if (vwArgContext.IsEmpty())
+ return m_bMandatory ? MIstatus::failure : MIstatus::success;
+
+ if (vwArgContext.GetNumberArgsPresent() == 1) {
+ const CMIUtilString &rArg(vwArgContext.GetArgsLeftToParse());
+ if (IsArgLongOption(rArg) && ArgNameMatch(rArg)) {
+ m_bFound = true;
- m_bIsMissingOptions = true;
- return MIstatus::failure;
- }
- else
- return MIstatus::failure;
- }
+ if (!vwArgContext.RemoveArg(rArg))
+ return MIstatus::failure;
+
+ if (m_nExpectingNOptions == 0) {
+ m_bValid = true;
+ return MIstatus::success;
+ }
+
+ m_bIsMissingOptions = true;
+ return MIstatus::failure;
+ } else
+ return MIstatus::failure;
+ }
+
+ // More than one option...
+ MIuint nArgIndex = 0;
+ const CMIUtilString::VecString_t vecOptions(vwArgContext.GetArgs());
+ CMIUtilString::VecString_t::const_iterator it = vecOptions.begin();
+ while (it != vecOptions.end()) {
+ const CMIUtilString &rArg(*it);
+ if (IsArgOptionCorrect(rArg) && ArgNameMatch(rArg)) {
+ m_bFound = true;
+
+ if (!vwArgContext.RemoveArg(rArg))
+ return MIstatus::failure;
- // More than one option...
- MIuint nArgIndex = 0;
- const CMIUtilString::VecString_t vecOptions(vwArgContext.GetArgs());
- CMIUtilString::VecString_t::const_iterator it = vecOptions.begin();
- while (it != vecOptions.end())
- {
- const CMIUtilString &rArg(*it);
- if (IsArgOptionCorrect(rArg) && ArgNameMatch(rArg))
- {
- m_bFound = true;
-
- if (!vwArgContext.RemoveArg(rArg))
- return MIstatus::failure;
-
- if (m_nExpectingNOptions != 0)
- {
- if (ExtractExpectedOptions(vwArgContext, nArgIndex))
- {
- m_bValid = true;
- return MIstatus::success;
- }
-
- m_bIsMissingOptions = true;
- return MIstatus::failure;
- }
- else
- {
- m_bValid = true;
- return MIstatus::success;
- }
+ if (m_nExpectingNOptions != 0) {
+ if (ExtractExpectedOptions(vwArgContext, nArgIndex)) {
+ m_bValid = true;
+ return MIstatus::success;
}
- // Next
- ++it;
- ++nArgIndex;
+ m_bIsMissingOptions = true;
+ return MIstatus::failure;
+ } else {
+ m_bValid = true;
+ return MIstatus::success;
+ }
}
- return MIstatus::failure;
+ // Next
+ ++it;
+ ++nArgIndex;
+ }
+
+ return MIstatus::failure;
}
-//++ ------------------------------------------------------------------------------------
-// Details: Parse the text following *this argument and extract the options the values of
-// CMICmdArgValListBase::m_eArgType forming argument objects for each of those
+//++
+//------------------------------------------------------------------------------------
+// Details: Parse the text following *this argument and extract the options the
+// values of
+// CMICmdArgValListBase::m_eArgType forming argument objects for each
+// of those
// options extracted.
// Type: Method.
// Args: vrwTxt - (RW) The command's argument options string.
-// nArgIndex - (R) The Nth arg position in argument context from the left.
+// nArgIndex - (R) The Nth arg position in argument context from
+// the left.
// Return: MIstatus::success - Functional succeeded.
// MIstatus::failure - Functional failed.
// Throws: None.
//--
-bool
-CMICmdArgValOptionLong::ExtractExpectedOptions(CMICmdArgContext &vrwTxt, const MIuint nArgIndex)
-{
- CMIUtilString::VecString_t vecOptions;
- MIuint nOptionsPresent = 0;
- if ((m_eExpectingOptionType != eArgValType_StringQuoted) && (m_eExpectingOptionType != eArgValType_StringQuotedNumber) &&
- (m_eExpectingOptionType != eArgValType_StringQuotedNumberPath))
- nOptionsPresent = vrwTxt.GetArgsLeftToParse().Split(" ", vecOptions);
- else
- nOptionsPresent = vrwTxt.GetArgsLeftToParse().SplitConsiderQuotes(" ", vecOptions);
- if (nOptionsPresent == 0)
- return MIstatus::failure;
-
- MIuint nArgIndexCnt = 0;
- MIuint nTypeCnt = 0;
- MIuint nTypeCnt2 = 0;
- MIuint nFoundNOptionsCnt = 0;
- CMIUtilString::VecString_t::const_iterator it = vecOptions.begin();
- while (it != vecOptions.end())
- {
- // Move to the Nth argument position from left before do validation/checking
- if (nArgIndexCnt++ == nArgIndex)
- {
- nTypeCnt++;
- const CMIUtilString &rOption(*it);
- if (IsExpectedCorrectType(rOption, m_eExpectingOptionType))
- {
- nTypeCnt2++;
- CMICmdArgValBase *pOptionObj = CreationObj(rOption, m_eExpectingOptionType);
- if ((pOptionObj != nullptr) && vrwTxt.RemoveArgAtPos(rOption, nArgIndex))
- {
- nFoundNOptionsCnt++;
- m_vecArgsExpected.push_back(pOptionObj);
- }
- }
-
- // Is the sequence 'options' of same type broken. Expecting the same type until the
- // next argument.
- if (nTypeCnt != nTypeCnt2)
- return MIstatus::failure;
+bool CMICmdArgValOptionLong::ExtractExpectedOptions(CMICmdArgContext &vrwTxt,
+ const MIuint nArgIndex) {
+ CMIUtilString::VecString_t vecOptions;
+ MIuint nOptionsPresent = 0;
+ if ((m_eExpectingOptionType != eArgValType_StringQuoted) &&
+ (m_eExpectingOptionType != eArgValType_StringQuotedNumber) &&
+ (m_eExpectingOptionType != eArgValType_StringQuotedNumberPath))
+ nOptionsPresent = vrwTxt.GetArgsLeftToParse().Split(" ", vecOptions);
+ else
+ nOptionsPresent =
+ vrwTxt.GetArgsLeftToParse().SplitConsiderQuotes(" ", vecOptions);
+ if (nOptionsPresent == 0)
+ return MIstatus::failure;
- if (nFoundNOptionsCnt == m_nExpectingNOptions)
- return MIstatus::success;
+ MIuint nArgIndexCnt = 0;
+ MIuint nTypeCnt = 0;
+ MIuint nTypeCnt2 = 0;
+ MIuint nFoundNOptionsCnt = 0;
+ CMIUtilString::VecString_t::const_iterator it = vecOptions.begin();
+ while (it != vecOptions.end()) {
+ // Move to the Nth argument position from left before do validation/checking
+ if (nArgIndexCnt++ == nArgIndex) {
+ nTypeCnt++;
+ const CMIUtilString &rOption(*it);
+ if (IsExpectedCorrectType(rOption, m_eExpectingOptionType)) {
+ nTypeCnt2++;
+ CMICmdArgValBase *pOptionObj =
+ CreationObj(rOption, m_eExpectingOptionType);
+ if ((pOptionObj != nullptr) &&
+ vrwTxt.RemoveArgAtPos(rOption, nArgIndex)) {
+ nFoundNOptionsCnt++;
+ m_vecArgsExpected.push_back(pOptionObj);
}
+ }
- // Next
- ++it;
- }
- if (nFoundNOptionsCnt != m_nExpectingNOptions)
+ // Is the sequence 'options' of same type broken. Expecting the same type
+ // until the
+ // next argument.
+ if (nTypeCnt != nTypeCnt2)
return MIstatus::failure;
- return MIstatus::success;
+ if (nFoundNOptionsCnt == m_nExpectingNOptions)
+ return MIstatus::success;
+ }
+
+ // Next
+ ++it;
+ }
+ if (nFoundNOptionsCnt != m_nExpectingNOptions)
+ return MIstatus::failure;
+
+ return MIstatus::success;
}
-//++ ------------------------------------------------------------------------------------
-// Details: Examine the string and determine if it is a valid long type option argument.
+//++
+//------------------------------------------------------------------------------------
+// Details: Examine the string and determine if it is a valid long type option
+// argument.
// Long type argument looks like --someLongOption.
// Type: Method.
// Args: vrTxt - (R) Some text.
// Return: bool - True = yes valid arg, false = no.
// Throws: None.
//--
-bool
-CMICmdArgValOptionLong::IsArgLongOption(const CMIUtilString &vrTxt) const
-{
- const bool bHavePosSlash = (vrTxt.find('/') != std::string::npos);
- const bool bHaveBckSlash = (vrTxt.find('\\') != std::string::npos);
- if (bHavePosSlash || bHaveBckSlash)
- return false;
-
- const size_t nPos = vrTxt.find("--");
- if (nPos != 0)
- return false;
-
- if (vrTxt.length() < 3)
- return false;
-
- const CMIUtilString strArg = vrTxt.substr(2);
- if (strArg.IsNumber())
- return false;
-
- return true;
-}
-
-//++ ------------------------------------------------------------------------------------
-// Details: Examine the string and determine if it is a valid long type option argument.
+bool CMICmdArgValOptionLong::IsArgLongOption(const CMIUtilString &vrTxt) const {
+ const bool bHavePosSlash = (vrTxt.find('/') != std::string::npos);
+ const bool bHaveBckSlash = (vrTxt.find('\\') != std::string::npos);
+ if (bHavePosSlash || bHaveBckSlash)
+ return false;
+
+ const size_t nPos = vrTxt.find("--");
+ if (nPos != 0)
+ return false;
+
+ if (vrTxt.length() < 3)
+ return false;
+
+ const CMIUtilString strArg = vrTxt.substr(2);
+ if (strArg.IsNumber())
+ return false;
+
+ return true;
+}
+
+//++
+//------------------------------------------------------------------------------------
+// Details: Examine the string and determine if it is a valid long type option
+// argument.
// Long type argument looks like --someLongOption.
// Type: Overideable.
// Args: vrTxt - (R) Some text.
// Return: bool - True = yes valid arg, false = no.
// Throws: None.
//--
-bool
-CMICmdArgValOptionLong::IsArgOptionCorrect(const CMIUtilString &vrTxt) const
-{
- return IsArgLongOption(vrTxt);
+bool CMICmdArgValOptionLong::IsArgOptionCorrect(
+ const CMIUtilString &vrTxt) const {
+ return IsArgLongOption(vrTxt);
}
-//++ ------------------------------------------------------------------------------------
-// Details: Does the argument name of the argument being parsed ATM match the name of
+//++
+//------------------------------------------------------------------------------------
+// Details: Does the argument name of the argument being parsed ATM match the
+// name of
// *this argument object.
// Type: Method.
// Args: vrTxt - (R) Some text.
// Return: bool - True = yes arg name matched, false = no.
// Throws: None.
//--
-bool
-CMICmdArgValOptionLong::ArgNameMatch(const CMIUtilString &vrTxt) const
-{
- const CMIUtilString strArg = vrTxt.substr(2);
- return (strArg == GetName());
+bool CMICmdArgValOptionLong::ArgNameMatch(const CMIUtilString &vrTxt) const {
+ const CMIUtilString strArg = vrTxt.substr(2);
+ return (strArg == GetName());
}
-//++ ------------------------------------------------------------------------------------
-// Details: Retrieve the list of CMICmdArgValBase derived option objects found following
-// *this long option argument. For example "list-thread-groups [ --recurse 1 ]"
+//++
+//------------------------------------------------------------------------------------
+// Details: Retrieve the list of CMICmdArgValBase derived option objects found
+// following
+// *this long option argument. For example "list-thread-groups [
+// --recurse 1 ]"
// where 1 is the list of expected option to follow.
// Type: Method.
// Args: None.
@@ -307,7 +309,6 @@ CMICmdArgValOptionLong::ArgNameMatch(con
// Throws: None.
//--
const CMICmdArgValListBase::VecArgObjPtr_t &
-CMICmdArgValOptionLong::GetExpectedOptions() const
-{
- return m_vecArgsExpected;
+CMICmdArgValOptionLong::GetExpectedOptions() const {
+ return m_vecArgsExpected;
}
Modified: lldb/trunk/tools/lldb-mi/MICmdArgValOptionLong.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/lldb-mi/MICmdArgValOptionLong.h?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/tools/lldb-mi/MICmdArgValOptionLong.h (original)
+++ lldb/trunk/tools/lldb-mi/MICmdArgValOptionLong.h Tue Sep 6 15:57:50 2016
@@ -16,80 +16,91 @@
class CMICmdArgContext;
class CMIUtilString;
-//++ ============================================================================
+//++
+//============================================================================
// 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
+// interpret the options (context) string to find and validate a
+// matching
// argument and so extract a value from it.
-// If *this argument has expected options following it the option objects
-// created to hold each of those option's values belong to *this argument
+// If *this argument has expected options following it the option
+// objects
+// created to hold each of those option's values belong to *this
+// argument
// object and so are deleted when *this object goes out of scope.
// Based on the Interpreter pattern.
//--
-class CMICmdArgValOptionLong : public CMICmdArgValListBase
-{
- // Methods:
- public:
- /* ctor */ CMICmdArgValOptionLong();
- /* ctor */ CMICmdArgValOptionLong(const CMIUtilString &vrArgName, const bool vbMandatory, const bool vbHandleByCmd);
- /* ctor */ CMICmdArgValOptionLong(const CMIUtilString &vrArgName, const bool vbMandatory, const bool vbHandleByCmd,
- const ArgValType_e veType, const MIuint vnExpectingNOptions);
- //
- bool IsArgLongOption(const CMIUtilString &vrTxt) const;
- const VecArgObjPtr_t &GetExpectedOptions() const;
- template <class T1, typename T2> bool GetExpectedOption(T2 &vrwValue) const;
-
- // Overridden:
- public:
- // From CMICmdArgValBase
- /* dtor */ ~CMICmdArgValOptionLong() override;
- // From CMICmdArgSet::IArg
- bool Validate(CMICmdArgContext &vArgContext) override;
-
- // Methods:
- protected:
- bool ExtractExpectedOptions(CMICmdArgContext &vrwTxt, const MIuint nArgIndex);
-
- // Overrideable:
- protected:
- virtual bool IsArgOptionCorrect(const CMIUtilString &vrTxt) const;
- virtual bool ArgNameMatch(const CMIUtilString &vrTxt) const;
-
- // Methods:
- private:
- void Destroy();
-
- // Attributes:
- private:
- MIuint m_nExpectingNOptions; // The number of options expected to read following *this argument
- VecArgObjPtr_t m_vecArgsExpected; // The option objects holding the value extracted following *this argument
- ArgValType_e m_eExpectingOptionType; // The type of options expected to read following *this argument
+class CMICmdArgValOptionLong : public CMICmdArgValListBase {
+ // Methods:
+public:
+ /* ctor */ CMICmdArgValOptionLong();
+ /* ctor */ CMICmdArgValOptionLong(const CMIUtilString &vrArgName,
+ const bool vbMandatory,
+ const bool vbHandleByCmd);
+ /* ctor */ CMICmdArgValOptionLong(const CMIUtilString &vrArgName,
+ const bool vbMandatory,
+ const bool vbHandleByCmd,
+ const ArgValType_e veType,
+ const MIuint vnExpectingNOptions);
+ //
+ bool IsArgLongOption(const CMIUtilString &vrTxt) const;
+ const VecArgObjPtr_t &GetExpectedOptions() const;
+ template <class T1, typename T2> bool GetExpectedOption(T2 &vrwValue) const;
+
+ // Overridden:
+public:
+ // From CMICmdArgValBase
+ /* dtor */ ~CMICmdArgValOptionLong() override;
+ // From CMICmdArgSet::IArg
+ bool Validate(CMICmdArgContext &vArgContext) override;
+
+ // Methods:
+protected:
+ bool ExtractExpectedOptions(CMICmdArgContext &vrwTxt, const MIuint nArgIndex);
+
+ // Overrideable:
+protected:
+ virtual bool IsArgOptionCorrect(const CMIUtilString &vrTxt) const;
+ virtual bool ArgNameMatch(const CMIUtilString &vrTxt) const;
+
+ // Methods:
+private:
+ void Destroy();
+
+ // Attributes:
+private:
+ MIuint m_nExpectingNOptions; // The number of options expected to read
+ // following *this argument
+ VecArgObjPtr_t m_vecArgsExpected; // The option objects holding the value
+ // extracted following *this argument
+ ArgValType_e m_eExpectingOptionType; // The type of options expected to read
+ // following *this argument
};
-//++ ------------------------------------------------------------------------------------
-// Details: Retrieve the first argument or option value from the list of 1 or more options
+//++
+//------------------------------------------------------------------------------------
+// Details: Retrieve the first argument or option value from the list of 1 or
+// more options
// parsed from the command's options string.
// Type: Template method.
// Args: vrwValue - (W) Templated type return value.
-// T1 - The argument value's class type of the data hold in the list of options.
+// T1 - The argument value's class type of the data hold in
+// the list of options.
// T2 - The type pf the variable which holds the value wanted.
// Return: MIstatus::success - Functional succeeded.
// MIstatus::failure - Functional failed. List of object was empty.
// Throws: None.
//--
template <class T1, typename T2>
-bool
-CMICmdArgValOptionLong::GetExpectedOption(T2 &vrwValue) const
-{
- const VecArgObjPtr_t &rVecOptions(GetExpectedOptions());
- VecArgObjPtr_t::const_iterator it2 = rVecOptions.begin();
- if (it2 != rVecOptions.end())
- {
- const T1 *pOption = static_cast<T1 *>(*it2);
- vrwValue = pOption->GetValue();
- return MIstatus::success;
- }
+bool CMICmdArgValOptionLong::GetExpectedOption(T2 &vrwValue) const {
+ const VecArgObjPtr_t &rVecOptions(GetExpectedOptions());
+ VecArgObjPtr_t::const_iterator it2 = rVecOptions.begin();
+ if (it2 != rVecOptions.end()) {
+ const T1 *pOption = static_cast<T1 *>(*it2);
+ vrwValue = pOption->GetValue();
+ return MIstatus::success;
+ }
- return MIstatus::failure;
+ return MIstatus::failure;
}
Modified: lldb/trunk/tools/lldb-mi/MICmdArgValOptionShort.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/lldb-mi/MICmdArgValOptionShort.cpp?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/tools/lldb-mi/MICmdArgValOptionShort.cpp (original)
+++ lldb/trunk/tools/lldb-mi/MICmdArgValOptionShort.cpp Tue Sep 6 15:57:50 2016
@@ -11,110 +11,119 @@
#include "MICmdArgValOptionShort.h"
#include "MICmdArgContext.h"
-//++ ------------------------------------------------------------------------------------
+//++
+//------------------------------------------------------------------------------------
// Details: CMICmdArgValOptionShort constructor.
// Type: Method.
// Args: None.
// Return: None.
// Throws: None.
//--
-CMICmdArgValOptionShort::CMICmdArgValOptionShort()
-{
-}
+CMICmdArgValOptionShort::CMICmdArgValOptionShort() {}
-//++ ------------------------------------------------------------------------------------
+//++
+//------------------------------------------------------------------------------------
// Details: CMICmdArgValOptionShort constructor.
// Type: Method.
// Args: vrArgName - (R) Argument's name to search by.
-// vbMandatory - (R) True = Yes must be present, false = optional argument.
-// vbHandleByCmd - (R) True = Command processes *this option, false = not handled.
+// vbMandatory - (R) True = Yes must be present, false = optional
+// argument.
+// vbHandleByCmd - (R) True = Command processes *this option, false =
+// not handled.
// Return: None.
// Throws: None.
//--
-CMICmdArgValOptionShort::CMICmdArgValOptionShort(const CMIUtilString &vrArgName, const bool vbMandatory, const bool vbHandleByCmd)
- : CMICmdArgValOptionLong(vrArgName, vbMandatory, vbHandleByCmd)
-{
-}
+CMICmdArgValOptionShort::CMICmdArgValOptionShort(const CMIUtilString &vrArgName,
+ const bool vbMandatory,
+ const bool vbHandleByCmd)
+ : CMICmdArgValOptionLong(vrArgName, vbMandatory, vbHandleByCmd) {}
-//++ ------------------------------------------------------------------------------------
+//++
+//------------------------------------------------------------------------------------
// Details: CMICmdArgValOptionLong constructor.
// Type: Method.
// Args: vrArgName - (R) Argument's name to search by.
-// vbMandatory - (R) True = Yes must be present, false = optional argument.
-// vbHandleByCmd - (R) True = Command processes *this option, false = not handled.
-// veType - (R) The type of argument to look for and create argument object of a certain type.
-// vnExpectingNOptions - (R) The number of options expected to read following *this argument.
+// vbMandatory - (R) True = Yes must be present, false =
+// optional argument.
+// vbHandleByCmd - (R) True = Command processes *this option,
+// false = not handled.
+// veType - (R) The type of argument to look for and
+// create argument object of a certain type.
+// vnExpectingNOptions - (R) The number of options expected to read
+// following *this argument.
// Return: None.
// Throws: None.
//--
-CMICmdArgValOptionShort::CMICmdArgValOptionShort(const CMIUtilString &vrArgName, const bool vbMandatory, const bool vbHandleByCmd,
- const ArgValType_e veType, const MIuint vnExpectingNOptions)
- : CMICmdArgValOptionLong(vrArgName, vbMandatory, vbHandleByCmd, veType, vnExpectingNOptions)
-{
-}
+CMICmdArgValOptionShort::CMICmdArgValOptionShort(
+ const CMIUtilString &vrArgName, const bool vbMandatory,
+ const bool vbHandleByCmd, const ArgValType_e veType,
+ const MIuint vnExpectingNOptions)
+ : CMICmdArgValOptionLong(vrArgName, vbMandatory, vbHandleByCmd, veType,
+ vnExpectingNOptions) {}
-//++ ------------------------------------------------------------------------------------
+//++
+//------------------------------------------------------------------------------------
// Details: CMICmdArgValOptionShort destructor.
// Type: Overridden.
// Args: None.
// Return: None.
// Throws: None.
//--
-CMICmdArgValOptionShort::~CMICmdArgValOptionShort()
-{
-}
+CMICmdArgValOptionShort::~CMICmdArgValOptionShort() {}
-//++ ------------------------------------------------------------------------------------
-// Details: Examine the string and determine if it is a valid short type option argument.
+//++
+//------------------------------------------------------------------------------------
+// Details: Examine the string and determine if it is a valid short type option
+// argument.
// Type: Method.
// Args: vrTxt - (R) Some text.
// Return: bool - True = yes valid arg, false = no.
// Throws: None.
//--
-bool
-CMICmdArgValOptionShort::IsArgShortOption(const CMIUtilString &vrTxt) const
-{
- // Look for --someLongOption
- MIint nPos = vrTxt.find("--");
- if (nPos == 0)
- return false;
-
- // Look for -f short option
- nPos = vrTxt.find('-');
- if (nPos != 0)
- return false;
-
- if (vrTxt.length() > 2)
- return false;
-
- return true;
-}
-
-//++ ------------------------------------------------------------------------------------
-// Details: Examine the string and determine if it is a valid short type option argument.
+bool CMICmdArgValOptionShort::IsArgShortOption(
+ const CMIUtilString &vrTxt) const {
+ // Look for --someLongOption
+ MIint nPos = vrTxt.find("--");
+ if (nPos == 0)
+ return false;
+
+ // Look for -f short option
+ nPos = vrTxt.find('-');
+ if (nPos != 0)
+ return false;
+
+ if (vrTxt.length() > 2)
+ return false;
+
+ return true;
+}
+
+//++
+//------------------------------------------------------------------------------------
+// Details: Examine the string and determine if it is a valid short type option
+// argument.
// Long type argument looks like -f some short option.
// Type: Overridden.
// Args: vrTxt - (R) Some text.
// Return: bool - True = yes valid arg, false = no.
// Throws: None.
//--
-bool
-CMICmdArgValOptionShort::IsArgOptionCorrect(const CMIUtilString &vrTxt) const
-{
- return IsArgShortOption(vrTxt);
+bool CMICmdArgValOptionShort::IsArgOptionCorrect(
+ const CMIUtilString &vrTxt) const {
+ return IsArgShortOption(vrTxt);
}
-//++ ------------------------------------------------------------------------------------
-// Details: Does the argument name of the argument being parsed ATM match the name of
+//++
+//------------------------------------------------------------------------------------
+// Details: Does the argument name of the argument being parsed ATM match the
+// name of
// *this argument object.
// Type: Overridden.
// Args: vrTxt - (R) Some text.
// Return: bool - True = yes arg name matched, false = no.
// Throws: None.
//--
-bool
-CMICmdArgValOptionShort::ArgNameMatch(const CMIUtilString &vrTxt) const
-{
- const CMIUtilString strArg = vrTxt.substr(1);
- return (strArg == GetName());
+bool CMICmdArgValOptionShort::ArgNameMatch(const CMIUtilString &vrTxt) const {
+ const CMIUtilString strArg = vrTxt.substr(1);
+ return (strArg == GetName());
}
Modified: lldb/trunk/tools/lldb-mi/MICmdArgValOptionShort.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/lldb-mi/MICmdArgValOptionShort.h?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/tools/lldb-mi/MICmdArgValOptionShort.h (original)
+++ lldb/trunk/tools/lldb-mi/MICmdArgValOptionShort.h Tue Sep 6 15:57:50 2016
@@ -16,36 +16,45 @@
class CMICmdArgContext;
class CMIUtilString;
-//++ ============================================================================
+//++
+//============================================================================
// Details: MI common code class. Command argument class. Arguments object
-// needing specialization derived from the CMICmdArgValOptionLong class.
+// needing specialization derived from the CMICmdArgValOptionLong
+// 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
+// interpret the options (context) string to find and validate a
+// matching
// argument and so extract a value from it.
-// If *this argument has expected options following it the option objects
-// created to hold each of those option's values belong to *this argument
+// If *this argument has expected options following it the option
+// objects
+// created to hold each of those option's values belong to *this
+// argument
// object and so are deleted when *this object goes out of scope.
// Based on the Interpreter pattern.
//--
-class CMICmdArgValOptionShort : public CMICmdArgValOptionLong
-{
- // Methods:
- public:
- /* ctor */ CMICmdArgValOptionShort();
- /* ctor */ CMICmdArgValOptionShort(const CMIUtilString &vrArgName, const bool vbMandatory, const bool vbHandleByCmd);
- /* ctor */ CMICmdArgValOptionShort(const CMIUtilString &vrArgName, const bool vbMandatory, const bool vbHandleByCmd,
- const ArgValType_e veType, const MIuint vnExpectingNOptions);
- //
- bool IsArgShortOption(const CMIUtilString &vrTxt) const;
+class CMICmdArgValOptionShort : public CMICmdArgValOptionLong {
+ // Methods:
+public:
+ /* ctor */ CMICmdArgValOptionShort();
+ /* ctor */ CMICmdArgValOptionShort(const CMIUtilString &vrArgName,
+ const bool vbMandatory,
+ const bool vbHandleByCmd);
+ /* ctor */ CMICmdArgValOptionShort(const CMIUtilString &vrArgName,
+ const bool vbMandatory,
+ const bool vbHandleByCmd,
+ const ArgValType_e veType,
+ const MIuint vnExpectingNOptions);
+ //
+ bool IsArgShortOption(const CMIUtilString &vrTxt) const;
- // Overridden:
- public:
- // From CMICmdArgValBase
- /* dtor */ ~CMICmdArgValOptionShort() override;
+ // Overridden:
+public:
+ // From CMICmdArgValBase
+ /* dtor */ ~CMICmdArgValOptionShort() override;
- // Overridden:
- private:
- // From CMICmdArgValOptionLong
- bool IsArgOptionCorrect(const CMIUtilString &vrTxt) const override;
- bool ArgNameMatch(const CMIUtilString &vrTxt) const override;
+ // Overridden:
+private:
+ // From CMICmdArgValOptionLong
+ bool IsArgOptionCorrect(const CMIUtilString &vrTxt) const override;
+ bool ArgNameMatch(const CMIUtilString &vrTxt) const override;
};
Modified: lldb/trunk/tools/lldb-mi/MICmdArgValPrintValues.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/lldb-mi/MICmdArgValPrintValues.cpp?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/tools/lldb-mi/MICmdArgValPrintValues.cpp (original)
+++ lldb/trunk/tools/lldb-mi/MICmdArgValPrintValues.cpp Tue Sep 6 15:57:50 2016
@@ -11,46 +11,48 @@
#include "MICmdArgValPrintValues.h"
#include "MICmdArgContext.h"
-//++ ------------------------------------------------------------------------------------
+//++
+//------------------------------------------------------------------------------------
// Details: CMICmdArgValPrintValues constructor.
// Type: Method.
// Args: None.
// Return: None.
// Throws: None.
//--
-CMICmdArgValPrintValues::CMICmdArgValPrintValues()
- : m_nPrintValues(0)
-{
-}
+CMICmdArgValPrintValues::CMICmdArgValPrintValues() : m_nPrintValues(0) {}
-//++ ------------------------------------------------------------------------------------
+//++
+//------------------------------------------------------------------------------------
// Details: CMICmdArgValPrintValues constructor.
// Type: Method.
// Args: vrArgName - (R) Argument's name to search by.
-// vbMandatory - (R) True = Yes must be present, false = optional argument.
-// vbHandleByCmd - (R) True = Command processes *this option, false = not handled.
+// vbMandatory - (R) True = Yes must be present, false = optional
+// argument.
+// vbHandleByCmd - (R) True = Command processes *this option, false =
+// not handled.
// Return: None.
// Throws: None.
//--
-CMICmdArgValPrintValues::CMICmdArgValPrintValues(const CMIUtilString &vrArgName, const bool vbMandatory, const bool vbHandleByCmd)
- : CMICmdArgValBaseTemplate(vrArgName, vbMandatory, vbHandleByCmd)
- , m_nPrintValues(0)
-{
-}
+CMICmdArgValPrintValues::CMICmdArgValPrintValues(const CMIUtilString &vrArgName,
+ const bool vbMandatory,
+ const bool vbHandleByCmd)
+ : CMICmdArgValBaseTemplate(vrArgName, vbMandatory, vbHandleByCmd),
+ m_nPrintValues(0) {}
-//++ ------------------------------------------------------------------------------------
+//++
+//------------------------------------------------------------------------------------
// Details: CMICmdArgValPrintValues destructor.
// Type: Overridden.
// Args: None.
// Return: None.
// Throws: None.
//--
-CMICmdArgValPrintValues::~CMICmdArgValPrintValues()
-{
-}
+CMICmdArgValPrintValues::~CMICmdArgValPrintValues() {}
-//++ ------------------------------------------------------------------------------------
-// Details: Parse the command's argument options string and try to extract the value *this
+//++
+//------------------------------------------------------------------------------------
+// Details: Parse the command's argument options string and try to extract the
+// value *this
// argument is looking for.
// Type: Overridden.
// Args: vwArgContext - (RW) The command's argument options string.
@@ -58,41 +60,43 @@ CMICmdArgValPrintValues::~CMICmdArgValPr
// MIstatus::failure - Functional failed.
// Throws: None.
//--
-bool
-CMICmdArgValPrintValues::Validate(CMICmdArgContext &vwArgContext)
-{
- if (vwArgContext.IsEmpty())
- return m_bMandatory ? MIstatus::failure : MIstatus::success;
-
- const CMIUtilString strArg(vwArgContext.GetArgs()[0]);
- if (IsArgPrintValues(strArg) && ExtractPrintValues(strArg))
- {
- m_bFound = true;
- m_bValid = true;
- m_argValue = GetPrintValues();
- vwArgContext.RemoveArg(strArg);
- return MIstatus::success;
- }
+bool CMICmdArgValPrintValues::Validate(CMICmdArgContext &vwArgContext) {
+ if (vwArgContext.IsEmpty())
+ return m_bMandatory ? MIstatus::failure : MIstatus::success;
+
+ const CMIUtilString strArg(vwArgContext.GetArgs()[0]);
+ if (IsArgPrintValues(strArg) && ExtractPrintValues(strArg)) {
+ m_bFound = true;
+ m_bValid = true;
+ m_argValue = GetPrintValues();
+ vwArgContext.RemoveArg(strArg);
+ return MIstatus::success;
+ }
- return MIstatus::failure;
+ return MIstatus::failure;
}
-//++ ------------------------------------------------------------------------------------
-// Details: Examine the string and determine if it is a valid string type argument.
+//++
+//------------------------------------------------------------------------------------
+// Details: Examine the string and determine if it is a valid string type
+// argument.
// Type: Method.
// Args: vrTxt - (R) Some text.
// Return: bool - True = yes valid arg, false = no.
// Throws: None.
//--
-bool
-CMICmdArgValPrintValues::IsArgPrintValues(const CMIUtilString &vrTxt) const
-{
- return (CMIUtilString::Compare(vrTxt, "0") || CMIUtilString::Compare(vrTxt, "--no-values") ||
- CMIUtilString::Compare(vrTxt, "1") || CMIUtilString::Compare(vrTxt, "--all-values") ||
- CMIUtilString::Compare(vrTxt, "2") || CMIUtilString::Compare(vrTxt, "--simple-values"));
+bool CMICmdArgValPrintValues::IsArgPrintValues(
+ const CMIUtilString &vrTxt) const {
+ return (CMIUtilString::Compare(vrTxt, "0") ||
+ CMIUtilString::Compare(vrTxt, "--no-values") ||
+ CMIUtilString::Compare(vrTxt, "1") ||
+ CMIUtilString::Compare(vrTxt, "--all-values") ||
+ CMIUtilString::Compare(vrTxt, "2") ||
+ CMIUtilString::Compare(vrTxt, "--simple-values"));
}
-//++ ------------------------------------------------------------------------------------
+//++
+//------------------------------------------------------------------------------------
// Details: Extract the print-values from the print-values argument.
// Type: Method.
// Args: vrTxt - (R) Some text.
@@ -100,30 +104,30 @@ CMICmdArgValPrintValues::IsArgPrintValue
// MIstatus::failure - Functional failed.
// Throws: None.
//--
-bool
-CMICmdArgValPrintValues::ExtractPrintValues(const CMIUtilString &vrTxt)
-{
- if (CMIUtilString::Compare(vrTxt, "0") || CMIUtilString::Compare(vrTxt, "--no-values"))
- m_nPrintValues = 0;
- else if (CMIUtilString::Compare(vrTxt, "1") || CMIUtilString::Compare(vrTxt, "--all-values"))
- m_nPrintValues = 1;
- else if (CMIUtilString::Compare(vrTxt, "2") || CMIUtilString::Compare(vrTxt, "--simple-values"))
- m_nPrintValues = 2;
- else
- return MIstatus::failure;
+bool CMICmdArgValPrintValues::ExtractPrintValues(const CMIUtilString &vrTxt) {
+ if (CMIUtilString::Compare(vrTxt, "0") ||
+ CMIUtilString::Compare(vrTxt, "--no-values"))
+ m_nPrintValues = 0;
+ else if (CMIUtilString::Compare(vrTxt, "1") ||
+ CMIUtilString::Compare(vrTxt, "--all-values"))
+ m_nPrintValues = 1;
+ else if (CMIUtilString::Compare(vrTxt, "2") ||
+ CMIUtilString::Compare(vrTxt, "--simple-values"))
+ m_nPrintValues = 2;
+ else
+ return MIstatus::failure;
- return MIstatus::success;
+ return MIstatus::success;
}
-//++ ------------------------------------------------------------------------------------
+//++
+//------------------------------------------------------------------------------------
// Details: Retrieve the print-values found in the argument.
// Type: Method.
// Args: None.
// Return: MIuint - The print-values.
// Throws: None.
//--
-MIuint
-CMICmdArgValPrintValues::GetPrintValues() const
-{
- return m_nPrintValues;
+MIuint CMICmdArgValPrintValues::GetPrintValues() const {
+ return m_nPrintValues;
}
Modified: lldb/trunk/tools/lldb-mi/MICmdArgValPrintValues.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/lldb-mi/MICmdArgValPrintValues.h?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/tools/lldb-mi/MICmdArgValPrintValues.h (original)
+++ lldb/trunk/tools/lldb-mi/MICmdArgValPrintValues.h Tue Sep 6 15:57:50 2016
@@ -15,39 +15,43 @@
// 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 and so extract a value from it. The print-values looks like:
+// interpret the options (context) string to find and validate a
+// matching
+// argument and so extract a value from it. The print-values looks
+// like:
// 0 or --no-values
// 1 or --all-values
// 2 or --simple-values
// Based on the Interpreter pattern.
//--
-class CMICmdArgValPrintValues : public CMICmdArgValBaseTemplate<MIuint>
-{
- // Methods:
- public:
- /* ctor */ CMICmdArgValPrintValues();
- /* ctor */ CMICmdArgValPrintValues(const CMIUtilString &vrArgName, const bool vbMandatory, const bool vbHandleByCmd);
- //
- bool IsArgPrintValues(const CMIUtilString &vrTxt) const;
+class CMICmdArgValPrintValues : public CMICmdArgValBaseTemplate<MIuint> {
+ // Methods:
+public:
+ /* ctor */ CMICmdArgValPrintValues();
+ /* ctor */ CMICmdArgValPrintValues(const CMIUtilString &vrArgName,
+ const bool vbMandatory,
+ const bool vbHandleByCmd);
+ //
+ bool IsArgPrintValues(const CMIUtilString &vrTxt) const;
- // Overridden:
- public:
- // From CMICmdArgValBase
- /* dtor */ ~CMICmdArgValPrintValues() override;
- // From CMICmdArgSet::IArg
- bool Validate(CMICmdArgContext &vArgContext) override;
+ // Overridden:
+public:
+ // From CMICmdArgValBase
+ /* dtor */ ~CMICmdArgValPrintValues() override;
+ // From CMICmdArgSet::IArg
+ bool Validate(CMICmdArgContext &vArgContext) override;
- // Methods:
- private:
- bool ExtractPrintValues(const CMIUtilString &vrTxt);
- MIuint GetPrintValues() const;
+ // Methods:
+private:
+ bool ExtractPrintValues(const CMIUtilString &vrTxt);
+ MIuint GetPrintValues() const;
- // Attributes:
- private:
- MIuint m_nPrintValues;
+ // Attributes:
+private:
+ MIuint m_nPrintValues;
};
Modified: lldb/trunk/tools/lldb-mi/MICmdArgValString.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/lldb-mi/MICmdArgValString.cpp?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/tools/lldb-mi/MICmdArgValString.cpp (original)
+++ lldb/trunk/tools/lldb-mi/MICmdArgValString.cpp Tue Sep 6 15:57:50 2016
@@ -11,7 +11,8 @@
#include "MICmdArgValString.h"
#include "MICmdArgContext.h"
-//++ ------------------------------------------------------------------------------------
+//++
+//------------------------------------------------------------------------------------
// Details: CMICmdArgValString constructor.
// Type: Method.
// Args: None.
@@ -19,108 +20,115 @@
// Throws: None.
//--
CMICmdArgValString::CMICmdArgValString()
- : m_bHandleQuotedString(false)
- , m_bAcceptNumbers(false)
- , m_bHandleDirPaths(false)
- , m_bHandleAnything(false)
-{
-}
+ : m_bHandleQuotedString(false), m_bAcceptNumbers(false),
+ m_bHandleDirPaths(false), m_bHandleAnything(false) {}
-//++ ------------------------------------------------------------------------------------
+//++
+//------------------------------------------------------------------------------------
// Details: CMICmdArgValString constructor.
// Type: Method.
-// Args: vbAnything - (R) True = Parse a string and accept anything, false = do not accept anything.
+// Args: vbAnything - (R) True = Parse a string and accept anything, false =
+// do not accept anything.
// Return: None.
// Throws: None.
//--
CMICmdArgValString::CMICmdArgValString(const bool vbAnything)
- : m_bHandleQuotedString(vbAnything ? true : false)
- , m_bAcceptNumbers(false)
- , m_bHandleDirPaths(false)
- , m_bHandleAnything(vbAnything)
-{
-}
+ : m_bHandleQuotedString(vbAnything ? true : false), m_bAcceptNumbers(false),
+ m_bHandleDirPaths(false), m_bHandleAnything(vbAnything) {}
-//++ ------------------------------------------------------------------------------------
+//++
+//------------------------------------------------------------------------------------
// Details: CMICmdArgValString constructor.
// Type: Method.
-// Args: vbHandleQuotes - (R) True = Parse a string surrounded by quotes spaces are not delimiters, false = only text up to
+// Args: vbHandleQuotes - (R) True = Parse a string surrounded by quotes
+// spaces are not delimiters, false = only text up to
// next delimiting space character.
-// vbAcceptNumbers - (R) True = Parse a string and accept as a number if number, false = numbers not recognised
+// vbAcceptNumbers - (R) True = Parse a string and accept as a
+// number if number, false = numbers not recognised
// as string types.
-// vbHandleDirPaths - (R) True = Parse a string and accept as a file path if a path, false = file paths are not
+// vbHandleDirPaths - (R) True = Parse a string and accept as a file
+// path if a path, false = file paths are not
// recognised as string types.
// Return: None.
// Throws: None.
//--
-CMICmdArgValString::CMICmdArgValString(const bool vbHandleQuotes, const bool vbAcceptNumbers, const bool vbHandleDirPaths)
- : m_bHandleQuotedString(vbHandleQuotes)
- , m_bAcceptNumbers(vbAcceptNumbers)
- , m_bHandleDirPaths(vbHandleDirPaths)
- , m_bHandleAnything(false)
-{
-}
+CMICmdArgValString::CMICmdArgValString(const bool vbHandleQuotes,
+ const bool vbAcceptNumbers,
+ const bool vbHandleDirPaths)
+ : m_bHandleQuotedString(vbHandleQuotes), m_bAcceptNumbers(vbAcceptNumbers),
+ m_bHandleDirPaths(vbHandleDirPaths), m_bHandleAnything(false) {}
-//++ ------------------------------------------------------------------------------------
+//++
+//------------------------------------------------------------------------------------
// Details: CMICmdArgValString constructor.
// Type: Method.
// Args: vrArgName - (R) Argument's name to search by.
-// vbMandatory - (R) True = Yes must be present, false = optional argument.
-// vbHandleByCmd - (R) True = Command processes *this option, false = not handled.
-// vbHandleQuotes - (R) True = Parse a string surrounded by quotes spaces are not delimiters, false = only text up to
+// vbMandatory - (R) True = Yes must be present, false = optional
+// argument.
+// vbHandleByCmd - (R) True = Command processes *this option, false =
+// not handled.
+// vbHandleQuotes - (R) True = Parse a string surrounded by quotes
+// spaces are not delimiters, false = only text up to
// next delimiting space character. (Dflt = false)
-// vbAcceptNumbers - (R) True = Parse a string and accept as a number if number, false = numbers not recognised as
+// vbAcceptNumbers - (R) True = Parse a string and accept as a number
+// if number, false = numbers not recognised as
// string types. (Dflt = false)
// Return: None.
// Throws: None.
//--
-CMICmdArgValString::CMICmdArgValString(const CMIUtilString &vrArgName, const bool vbMandatory, const bool vbHandleByCmd,
- const bool vbHandleQuotes /* = false */, const bool vbAcceptNumbers /* = false */)
- : CMICmdArgValBaseTemplate(vrArgName, vbMandatory, vbHandleByCmd)
- , m_bHandleQuotedString(vbHandleQuotes)
- , m_bAcceptNumbers(vbAcceptNumbers)
- , m_bHandleDirPaths(false)
- , m_bHandleAnything(false)
-{
-}
+CMICmdArgValString::CMICmdArgValString(const CMIUtilString &vrArgName,
+ const bool vbMandatory,
+ const bool vbHandleByCmd,
+ const bool vbHandleQuotes /* = false */,
+ const bool vbAcceptNumbers /* = false */)
+ : CMICmdArgValBaseTemplate(vrArgName, vbMandatory, vbHandleByCmd),
+ m_bHandleQuotedString(vbHandleQuotes), m_bAcceptNumbers(vbAcceptNumbers),
+ m_bHandleDirPaths(false), m_bHandleAnything(false) {}
-//++ ------------------------------------------------------------------------------------
+//++
+//------------------------------------------------------------------------------------
// Details: CMICmdArgValString constructor.
// Type: Method.
// Args: vrArgName - (R) Argument's name to search by.
-// vbMandatory - (R) True = Yes must be present, false = optional argument.
-// vbHandleByCmd - (R) True = Command processes *this option, false = not handled.
-// vbHandleQuotes - (R) True = Parse a string surrounded by quotes spaces are not delimiters, false = only text up to
+// vbMandatory - (R) True = Yes must be present, false = optional
+// argument.
+// vbHandleByCmd - (R) True = Command processes *this option, false =
+// not handled.
+// vbHandleQuotes - (R) True = Parse a string surrounded by quotes
+// spaces are not delimiters, false = only text up to
// next delimiting space character.
-// vbAcceptNumbers - (R) True = Parse a string and accept as a number if number, false = numbers not recognised as
-// vbHandleDirPaths - (R) True = Parse a string and accept as a file path if a path, false = file paths are not
+// vbAcceptNumbers - (R) True = Parse a string and accept as a number
+// if number, false = numbers not recognised as
+// vbHandleDirPaths - (R) True = Parse a string and accept as a file
+// path if a path, false = file paths are not
// string types.
// Return: None.
// Throws: None.
//--
-CMICmdArgValString::CMICmdArgValString(const CMIUtilString &vrArgName, const bool vbMandatory, const bool vbHandleByCmd,
- const bool vbHandleQuotes, const bool vbAcceptNumbers, const bool vbHandleDirPaths)
- : CMICmdArgValBaseTemplate(vrArgName, vbMandatory, vbHandleByCmd)
- , m_bHandleQuotedString(vbHandleQuotes)
- , m_bAcceptNumbers(vbAcceptNumbers)
- , m_bHandleDirPaths(vbHandleDirPaths)
- , m_bHandleAnything(false)
-{
-}
+CMICmdArgValString::CMICmdArgValString(const CMIUtilString &vrArgName,
+ const bool vbMandatory,
+ const bool vbHandleByCmd,
+ const bool vbHandleQuotes,
+ const bool vbAcceptNumbers,
+ const bool vbHandleDirPaths)
+ : CMICmdArgValBaseTemplate(vrArgName, vbMandatory, vbHandleByCmd),
+ m_bHandleQuotedString(vbHandleQuotes), m_bAcceptNumbers(vbAcceptNumbers),
+ m_bHandleDirPaths(vbHandleDirPaths), m_bHandleAnything(false) {}
-//++ ------------------------------------------------------------------------------------
+//++
+//------------------------------------------------------------------------------------
// Details: CMICmdArgValString destructor.
// Type: Overridden.
// Args: None.
// Return: None.
// Throws: None.
//--
-CMICmdArgValString::~CMICmdArgValString()
-{
-}
+CMICmdArgValString::~CMICmdArgValString() {}
-//++ ------------------------------------------------------------------------------------
-// Details: Parse the command's argument options string and try to extract the value *this
+//++
+//------------------------------------------------------------------------------------
+// Details: Parse the command's argument options string and try to extract the
+// value *this
// argument is looking for.
// Type: Overridden.
// Args: vrwArgContext - (RW) The command's argument options string.
@@ -128,20 +136,20 @@ CMICmdArgValString::~CMICmdArgValString(
// MIstatus::failure - Functional failed.
// Throws: None.
//--
-bool
-CMICmdArgValString::Validate(CMICmdArgContext &vrwArgContext)
-{
- if (vrwArgContext.IsEmpty())
- return m_bMandatory ? MIstatus::failure : MIstatus::success;
+bool CMICmdArgValString::Validate(CMICmdArgContext &vrwArgContext) {
+ if (vrwArgContext.IsEmpty())
+ return m_bMandatory ? MIstatus::failure : MIstatus::success;
- if (m_bHandleQuotedString)
- return ValidateQuotedText(vrwArgContext);
+ if (m_bHandleQuotedString)
+ return ValidateQuotedText(vrwArgContext);
- return ValidateSingleText(vrwArgContext);
+ return ValidateSingleText(vrwArgContext);
}
-//++ ------------------------------------------------------------------------------------
-// Details: Parse the command's argument options string and try to extract only the next
+//++
+//------------------------------------------------------------------------------------
+// Details: Parse the command's argument options string and try to extract only
+// the next
// word delimited by the next space.
// Type: Method.
// Args: vrwArgContext - (RW) The command's argument options string.
@@ -149,37 +157,33 @@ CMICmdArgValString::Validate(CMICmdArgCo
// MIstatus::failure - Functional failed.
// Throws: None.
//--
-bool
-CMICmdArgValString::ValidateSingleText(CMICmdArgContext &vrwArgContext)
-{
- const CMIUtilString::VecString_t vecOptions(vrwArgContext.GetArgs());
- CMIUtilString::VecString_t::const_iterator it = vecOptions.begin();
- while (it != vecOptions.end())
- {
- const CMIUtilString &rArg(*it);
- if (IsStringArg(rArg))
- {
- m_bFound = true;
-
- if (vrwArgContext.RemoveArg(rArg))
- {
- m_bValid = true;
- m_argValue = rArg.StripSlashes();
- return MIstatus::success;
- }
- else
- return MIstatus::failure;
- }
+bool CMICmdArgValString::ValidateSingleText(CMICmdArgContext &vrwArgContext) {
+ const CMIUtilString::VecString_t vecOptions(vrwArgContext.GetArgs());
+ CMIUtilString::VecString_t::const_iterator it = vecOptions.begin();
+ while (it != vecOptions.end()) {
+ const CMIUtilString &rArg(*it);
+ if (IsStringArg(rArg)) {
+ m_bFound = true;
- // Next
- ++it;
+ if (vrwArgContext.RemoveArg(rArg)) {
+ m_bValid = true;
+ m_argValue = rArg.StripSlashes();
+ return MIstatus::success;
+ } else
+ return MIstatus::failure;
}
- return MIstatus::failure;
+ // Next
+ ++it;
+ }
+
+ return MIstatus::failure;
}
-//++ ------------------------------------------------------------------------------------
-// Details: Parse the command's argument options string and try to extract all the words
+//++
+//------------------------------------------------------------------------------------
+// Details: Parse the command's argument options string and try to extract all
+// the words
// between quotes then delimited by the next space.
// Type: Method.
// Args: vrwArgContext - (RW) The command's argument options string.
@@ -187,197 +191,208 @@ CMICmdArgValString::ValidateSingleText(C
// MIstatus::failure - Functional failed.
// Throws: None.
//--
-bool
-CMICmdArgValString::ValidateQuotedText(CMICmdArgContext &vrwArgContext)
-{
- const CMIUtilString::VecString_t vecOptions(vrwArgContext.GetArgs());
- if (vecOptions.size() == 0)
- return MIstatus::failure;
+bool CMICmdArgValString::ValidateQuotedText(CMICmdArgContext &vrwArgContext) {
+ const CMIUtilString::VecString_t vecOptions(vrwArgContext.GetArgs());
+ if (vecOptions.size() == 0)
+ return MIstatus::failure;
- const CMIUtilString &rArg(vecOptions[0]);
- if (!IsStringArg(rArg))
- return MIstatus::failure;
+ const CMIUtilString &rArg(vecOptions[0]);
+ if (!IsStringArg(rArg))
+ return MIstatus::failure;
- m_bFound = true;
+ m_bFound = true;
- if (vrwArgContext.RemoveArg(rArg))
- {
- m_bValid = true;
- const char cQuote = '"';
- m_argValue = rArg.Trim(cQuote).StripSlashes();
- return MIstatus::success;
- }
+ if (vrwArgContext.RemoveArg(rArg)) {
+ m_bValid = true;
+ const char cQuote = '"';
+ m_argValue = rArg.Trim(cQuote).StripSlashes();
+ return MIstatus::success;
+ }
- return MIstatus::failure;
+ return MIstatus::failure;
}
-//++ ------------------------------------------------------------------------------------
-// Details: Examine the string and determine if it is a valid string type argument.
+//++
+//------------------------------------------------------------------------------------
+// Details: Examine the string and determine if it is a valid string type
+// argument.
// Type: Method.
// Args: vrTxt - (R) Some text.
// Return: bool - True = yes valid arg, false = no.
// Throws: None.
//--
-bool
-CMICmdArgValString::IsStringArg(const CMIUtilString &vrTxt) const
-{
- if (m_bHandleQuotedString)
- return (IsStringArgQuotedText(vrTxt) || IsStringArgQuotedTextEmbedded(vrTxt) || IsStringArgQuotedQuotedTextEmbedded(vrTxt) ||
- IsStringArgSingleText(vrTxt)); // Still test for this as could just be one word still
-
- return IsStringArgSingleText(vrTxt);
-}
-
-//++ ------------------------------------------------------------------------------------
-// Details: Examine the string and determine if it is a valid string type argument or
-// option value. If the string looks like a long option, short option, a thread
-// group ID or just a number it is rejected as a string type value. There is an
+bool CMICmdArgValString::IsStringArg(const CMIUtilString &vrTxt) const {
+ if (m_bHandleQuotedString)
+ return (IsStringArgQuotedText(vrTxt) ||
+ IsStringArgQuotedTextEmbedded(vrTxt) ||
+ IsStringArgQuotedQuotedTextEmbedded(vrTxt) ||
+ IsStringArgSingleText(
+ vrTxt)); // Still test for this as could just be one word still
+
+ return IsStringArgSingleText(vrTxt);
+}
+
+//++
+//------------------------------------------------------------------------------------
+// Details: Examine the string and determine if it is a valid string type
+// argument or
+// option value. If the string looks like a long option, short option,
+// a thread
+// group ID or just a number it is rejected as a string type value.
+// There is an
// option to allow the string to accept a number as a string type.
// Type: Method.
// Args: vrTxt - (R) Some text.
// Return: bool - True = yes valid argument value, false = something else.
// Throws: None.
//--
-bool
-CMICmdArgValString::IsStringArgSingleText(const CMIUtilString &vrTxt) const
-{
- if (!m_bHandleDirPaths)
- {
- // Look for directory file paths, if found reject
- const bool bHavePosSlash = (vrTxt.find('/') != std::string::npos);
- const bool bHaveBckSlash = (vrTxt.find('\\') != std::string::npos);
- if (bHavePosSlash || bHaveBckSlash)
- return false;
- }
+bool CMICmdArgValString::IsStringArgSingleText(
+ const CMIUtilString &vrTxt) const {
+ if (!m_bHandleDirPaths) {
+ // Look for directory file paths, if found reject
+ const bool bHavePosSlash = (vrTxt.find('/') != std::string::npos);
+ const bool bHaveBckSlash = (vrTxt.find('\\') != std::string::npos);
+ if (bHavePosSlash || bHaveBckSlash)
+ return false;
+ }
- // Look for --someLongOption, if found reject
- if (0 == vrTxt.find("--"))
- return false;
-
- // Look for -f type short options, if found reject
- if ((0 == vrTxt.find('-')) && (vrTxt.length() == 2))
- return false;
-
- // Look for thread group i1 i2 i3...., if found reject
- if ((vrTxt.find('i') == 0) && ::isdigit(vrTxt[1]))
- return false;
-
- // Look for numbers, if found reject
- if (!m_bAcceptNumbers && vrTxt.IsNumber())
- return false;
+ // Look for --someLongOption, if found reject
+ if (0 == vrTxt.find("--"))
+ return false;
- return true;
+ // Look for -f type short options, if found reject
+ if ((0 == vrTxt.find('-')) && (vrTxt.length() == 2))
+ return false;
+
+ // Look for thread group i1 i2 i3...., if found reject
+ if ((vrTxt.find('i') == 0) && ::isdigit(vrTxt[1]))
+ return false;
+
+ // Look for numbers, if found reject
+ if (!m_bAcceptNumbers && vrTxt.IsNumber())
+ return false;
+
+ return true;
}
-//++ ------------------------------------------------------------------------------------
-// Details: Examine the string and determine if it is a valid string type argument.
-// Take into account quotes surrounding the text. Note this function falls
+//++
+//------------------------------------------------------------------------------------
+// Details: Examine the string and determine if it is a valid string type
+// argument.
+// Take into account quotes surrounding the text. Note this function
+// falls
// through to IsStringArgSingleText() should the criteria match fail.
// Type: Method.
// Args: vrTxt - (R) Some text.
// Return: bool - True = yes valid arg, false = no.
// Throws: None.
//--
-bool
-CMICmdArgValString::IsStringArgQuotedText(const CMIUtilString &vrTxt) const
-{
- // Accept anything as string word
- if (m_bHandleAnything)
- return true;
+bool CMICmdArgValString::IsStringArgQuotedText(
+ const CMIUtilString &vrTxt) const {
+ // Accept anything as string word
+ if (m_bHandleAnything)
+ return true;
- // CODETAG_QUOTEDTEXT_SIMILAR_CODE
- const char cQuote = '"';
- const size_t nPos = vrTxt.find(cQuote);
- if (nPos == std::string::npos)
- return false;
-
- // Is one and only quote at end of the string
- if (nPos == (vrTxt.length() - 1))
- return false;
-
- // Quote must be the first character in the string or be preceded by a space
- // Also check for embedded string formating quote
- const char cBckSlash = '\\';
- const char cSpace = ' ';
- if ((nPos > 1) && (vrTxt[nPos - 1] == cBckSlash) && (vrTxt[nPos - 2] != cSpace))
- {
- return false;
- }
- if ((nPos > 0) && (vrTxt[nPos - 1] != cSpace))
- return false;
+ // CODETAG_QUOTEDTEXT_SIMILAR_CODE
+ const char cQuote = '"';
+ const size_t nPos = vrTxt.find(cQuote);
+ if (nPos == std::string::npos)
+ return false;
- // Need to find the other quote
- const size_t nPos2 = vrTxt.rfind(cQuote);
- if (nPos2 == std::string::npos)
- return false;
+ // Is one and only quote at end of the string
+ if (nPos == (vrTxt.length() - 1))
+ return false;
- // Make sure not same quote, need two quotes
- if (nPos == nPos2)
- return MIstatus::failure;
+ // Quote must be the first character in the string or be preceded by a space
+ // Also check for embedded string formating quote
+ const char cBckSlash = '\\';
+ const char cSpace = ' ';
+ if ((nPos > 1) && (vrTxt[nPos - 1] == cBckSlash) &&
+ (vrTxt[nPos - 2] != cSpace)) {
+ return false;
+ }
+ if ((nPos > 0) && (vrTxt[nPos - 1] != cSpace))
+ return false;
- return true;
+ // Need to find the other quote
+ const size_t nPos2 = vrTxt.rfind(cQuote);
+ if (nPos2 == std::string::npos)
+ return false;
+
+ // Make sure not same quote, need two quotes
+ if (nPos == nPos2)
+ return MIstatus::failure;
+
+ return true;
}
-//++ ------------------------------------------------------------------------------------
-// Details: Examine the string and determine if it is a valid string type argument.
-// Take into account quotes surrounding the text. Take into account string format
-// embedded quotes surrounding the text i.e. "\\\"%5d\\\"". Note this function falls
+//++
+//------------------------------------------------------------------------------------
+// Details: Examine the string and determine if it is a valid string type
+// argument.
+// Take into account quotes surrounding the text. Take into account
+// string format
+// embedded quotes surrounding the text i.e. "\\\"%5d\\\"". Note this
+// function falls
// through to IsStringArgQuotedText() should the criteria match fail.
// Type: Method.
// Args: vrTxt - (R) Some text.
// Return: bool - True = yes valid arg, false = no.
// Throws: None.
//--
-bool
-CMICmdArgValString::IsStringArgQuotedTextEmbedded(const CMIUtilString &vrTxt) const
-{
- // CODETAG_QUOTEDTEXT_SIMILAR_CODE
- const char cBckSlash = '\\';
- const size_t nPos = vrTxt.find(cBckSlash);
- if (nPos == std::string::npos)
- return false;
-
- // Slash must be the first character in the string or be preceded by a space
- const char cSpace = ' ';
- if ((nPos > 0) && (vrTxt[nPos - 1] != cSpace))
- return false;
-
- // Need to find the other matching slash
- const size_t nPos2 = vrTxt.rfind(cBckSlash);
- if (nPos2 == std::string::npos)
- return false;
+bool CMICmdArgValString::IsStringArgQuotedTextEmbedded(
+ const CMIUtilString &vrTxt) const {
+ // CODETAG_QUOTEDTEXT_SIMILAR_CODE
+ const char cBckSlash = '\\';
+ const size_t nPos = vrTxt.find(cBckSlash);
+ if (nPos == std::string::npos)
+ return false;
- // Make sure not same back slash, need two slashes
- if (nPos == nPos2)
- return MIstatus::failure;
+ // Slash must be the first character in the string or be preceded by a space
+ const char cSpace = ' ';
+ if ((nPos > 0) && (vrTxt[nPos - 1] != cSpace))
+ return false;
+ // Need to find the other matching slash
+ const size_t nPos2 = vrTxt.rfind(cBckSlash);
+ if (nPos2 == std::string::npos)
return false;
+
+ // Make sure not same back slash, need two slashes
+ if (nPos == nPos2)
+ return MIstatus::failure;
+
+ return false;
}
-//++ ------------------------------------------------------------------------------------
-// Details: Examine the string and determine if it is a valid string type argument.
-// Take into account quotes surrounding the text. Take into account string format
-// embedded quotes surrounding the text i.e. "\\\"%5d\\\"". Note this function falls
-// through to IsStringArgQuotedTextEmbedded() should the criteria match fail.
+//++
+//------------------------------------------------------------------------------------
+// Details: Examine the string and determine if it is a valid string type
+// argument.
+// Take into account quotes surrounding the text. Take into account
+// string format
+// embedded quotes surrounding the text i.e. "\\\"%5d\\\"". Note this
+// function falls
+// through to IsStringArgQuotedTextEmbedded() should the criteria match
+// fail.
// Type: Method.
// Args: vrTxt - (R) Some text.
// Return: bool - True = yes valid arg, false = no.
// Throws: None.
//--
-bool
-CMICmdArgValString::IsStringArgQuotedQuotedTextEmbedded(const CMIUtilString &vrTxt) const
-{
- const size_t nPos = vrTxt.find("\"\\\"");
- if (nPos == std::string::npos)
- return false;
-
- const size_t nPos2 = vrTxt.rfind("\\\"\"");
- if (nPos2 == std::string::npos)
- return false;
-
- const size_t nLen = vrTxt.length();
- if ((nLen > 5) && ((nPos + 2) == (nPos2 - 2)))
- return false;
+bool CMICmdArgValString::IsStringArgQuotedQuotedTextEmbedded(
+ const CMIUtilString &vrTxt) const {
+ const size_t nPos = vrTxt.find("\"\\\"");
+ if (nPos == std::string::npos)
+ return false;
- return true;
+ const size_t nPos2 = vrTxt.rfind("\\\"\"");
+ if (nPos2 == std::string::npos)
+ return false;
+
+ const size_t nLen = vrTxt.length();
+ if ((nLen > 5) && ((nPos + 2) == (nPos2 - 2)))
+ return false;
+
+ return true;
}
Modified: lldb/trunk/tools/lldb-mi/MICmdArgValString.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/lldb-mi/MICmdArgValString.h?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/tools/lldb-mi/MICmdArgValString.h (original)
+++ lldb/trunk/tools/lldb-mi/MICmdArgValString.h Tue Sep 6 15:57:50 2016
@@ -15,52 +15,69 @@
// 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
+// interpret the options (context) string to find and validate a
+// matching
// argument and so extract a value from it .
// Based on the Interpreter pattern.
//--
-class CMICmdArgValString : public CMICmdArgValBaseTemplate<CMIUtilString>
-{
- // Methods:
- public:
- /* ctor */ CMICmdArgValString();
- /* ctor */ CMICmdArgValString(const bool vbAnything);
- /* ctor */ CMICmdArgValString(const bool vbHandleQuotes, const bool vbAcceptNumbers, const bool vbHandleDirPaths);
- /* ctor */ CMICmdArgValString(const CMIUtilString &vrArgName, const bool vbMandatory, const bool vbHandleByCmd,
- const bool vbHandleQuotes = false, const bool vbAcceptNumbers = false);
- /* ctor */ CMICmdArgValString(const CMIUtilString &vrArgName, const bool vbMandatory, const bool vbHandleByCmd,
- const bool vbHandleQuotes, const bool vbAcceptNumbers, const bool vbHandleDirPaths);
- //
- bool IsStringArg(const CMIUtilString &vrTxt) const;
+class CMICmdArgValString : public CMICmdArgValBaseTemplate<CMIUtilString> {
+ // Methods:
+public:
+ /* ctor */ CMICmdArgValString();
+ /* ctor */ CMICmdArgValString(const bool vbAnything);
+ /* ctor */ CMICmdArgValString(const bool vbHandleQuotes,
+ const bool vbAcceptNumbers,
+ const bool vbHandleDirPaths);
+ /* ctor */ CMICmdArgValString(const CMIUtilString &vrArgName,
+ const bool vbMandatory,
+ const bool vbHandleByCmd,
+ const bool vbHandleQuotes = false,
+ const bool vbAcceptNumbers = false);
+ /* ctor */ CMICmdArgValString(const CMIUtilString &vrArgName,
+ const bool vbMandatory,
+ const bool vbHandleByCmd,
+ const bool vbHandleQuotes,
+ const bool vbAcceptNumbers,
+ const bool vbHandleDirPaths);
+ //
+ bool IsStringArg(const CMIUtilString &vrTxt) const;
- // Overridden:
- public:
- // From CMICmdArgValBase
- /* dtor */ ~CMICmdArgValString() override;
- // From CMICmdArgSet::IArg
- bool Validate(CMICmdArgContext &vrwArgContext) override;
+ // Overridden:
+public:
+ // From CMICmdArgValBase
+ /* dtor */ ~CMICmdArgValString() override;
+ // From CMICmdArgSet::IArg
+ bool Validate(CMICmdArgContext &vrwArgContext) override;
- // Methods:
- private:
- bool ValidateSingleText(CMICmdArgContext &vrwArgContext);
- bool ValidateQuotedText(CMICmdArgContext &vrwArgContext);
- bool ValidateQuotedTextEmbedded(CMICmdArgContext &vrwArgContext);
- bool ValidateQuotedQuotedTextEmbedded(CMICmdArgContext &vrwArgContext);
- bool IsStringArgSingleText(const CMIUtilString &vrTxt) const;
- bool IsStringArgQuotedText(const CMIUtilString &vrTxt) const;
- bool IsStringArgQuotedTextEmbedded(const CMIUtilString &vrTxt) const;
- bool IsStringArgQuotedQuotedTextEmbedded(const CMIUtilString &vrTxt) const;
+ // Methods:
+private:
+ bool ValidateSingleText(CMICmdArgContext &vrwArgContext);
+ bool ValidateQuotedText(CMICmdArgContext &vrwArgContext);
+ bool ValidateQuotedTextEmbedded(CMICmdArgContext &vrwArgContext);
+ bool ValidateQuotedQuotedTextEmbedded(CMICmdArgContext &vrwArgContext);
+ bool IsStringArgSingleText(const CMIUtilString &vrTxt) const;
+ bool IsStringArgQuotedText(const CMIUtilString &vrTxt) const;
+ bool IsStringArgQuotedTextEmbedded(const CMIUtilString &vrTxt) const;
+ bool IsStringArgQuotedQuotedTextEmbedded(const CMIUtilString &vrTxt) const;
- // Attribute:
- private:
- bool m_bHandleQuotedString; // True = Parse a string surrounded by quotes spaces are not delimiters, false = only text up to next
- // delimiting space character
- bool m_bAcceptNumbers; // True = Parse a string and accept as a number if number, false = numbers not recognised as string types
- bool m_bHandleDirPaths; // True = Parse a string and accept directory file style string if present, false = directory file path not
- // accepted
- bool m_bHandleAnything; // True = Parse a string and accept anything if present, false = validate for criteria matches
+ // Attribute:
+private:
+ bool m_bHandleQuotedString; // True = Parse a string surrounded by quotes
+ // spaces are not delimiters, false = only text up
+ // to next
+ // delimiting space character
+ bool m_bAcceptNumbers; // True = Parse a string and accept as a number if
+ // number, false = numbers not recognised as string
+ // types
+ bool m_bHandleDirPaths; // True = Parse a string and accept directory file
+ // style string if present, false = directory file
+ // path not
+ // accepted
+ bool m_bHandleAnything; // True = Parse a string and accept anything if
+ // present, false = validate for criteria matches
};
Modified: lldb/trunk/tools/lldb-mi/MICmdArgValThreadGrp.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/lldb-mi/MICmdArgValThreadGrp.cpp?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/tools/lldb-mi/MICmdArgValThreadGrp.cpp (original)
+++ lldb/trunk/tools/lldb-mi/MICmdArgValThreadGrp.cpp Tue Sep 6 15:57:50 2016
@@ -11,46 +11,48 @@
#include "MICmdArgValThreadGrp.h"
#include "MICmdArgContext.h"
-//++ ------------------------------------------------------------------------------------
+//++
+//------------------------------------------------------------------------------------
// Details: CMICmdArgValThreadGrp constructor.
// Type: Method.
// Args: None.
// Return: None.
// Throws: None.
//--
-CMICmdArgValThreadGrp::CMICmdArgValThreadGrp()
- : m_nThreadGrp(0)
-{
-}
+CMICmdArgValThreadGrp::CMICmdArgValThreadGrp() : m_nThreadGrp(0) {}
-//++ ------------------------------------------------------------------------------------
+//++
+//------------------------------------------------------------------------------------
// Details: CMICmdArgValThreadGrp constructor.
// Type: Method.
// Args: vrArgName - (R) Argument's name to search by.
-// vbMandatory - (R) True = Yes must be present, false = optional argument.
-// vbHandleByCmd - (R) True = Command processes *this option, false = not handled.
+// vbMandatory - (R) True = Yes must be present, false = optional
+// argument.
+// vbHandleByCmd - (R) True = Command processes *this option, false =
+// not handled.
// Return: None.
// Throws: None.
//--
-CMICmdArgValThreadGrp::CMICmdArgValThreadGrp(const CMIUtilString &vrArgName, const bool vbMandatory, const bool vbHandleByCmd)
- : CMICmdArgValBaseTemplate(vrArgName, vbMandatory, vbHandleByCmd)
- , m_nThreadGrp(0)
-{
-}
+CMICmdArgValThreadGrp::CMICmdArgValThreadGrp(const CMIUtilString &vrArgName,
+ const bool vbMandatory,
+ const bool vbHandleByCmd)
+ : CMICmdArgValBaseTemplate(vrArgName, vbMandatory, vbHandleByCmd),
+ m_nThreadGrp(0) {}
-//++ ------------------------------------------------------------------------------------
+//++
+//------------------------------------------------------------------------------------
// Details: CMICmdArgValThreadGrp destructor.
// Type: Overridden.
// Args: None.
// Return: None.
// Throws: None.
//--
-CMICmdArgValThreadGrp::~CMICmdArgValThreadGrp()
-{
-}
+CMICmdArgValThreadGrp::~CMICmdArgValThreadGrp() {}
-//++ ------------------------------------------------------------------------------------
-// Details: Parse the command's argument options string and try to extract the value *this
+//++
+//------------------------------------------------------------------------------------
+// Details: Parse the command's argument options string and try to extract the
+// value *this
// argument is looking for.
// Type: Overridden.
// Args: vwArgContext - (RW) The command's argument options string.
@@ -58,77 +60,69 @@ CMICmdArgValThreadGrp::~CMICmdArgValThre
// MIstatus::failure - Functional failed.
// Throws: None.
//--
-bool
-CMICmdArgValThreadGrp::Validate(CMICmdArgContext &vwArgContext)
-{
- if (vwArgContext.IsEmpty())
- return m_bMandatory ? MIstatus::failure : MIstatus::success;
-
- if (vwArgContext.GetNumberArgsPresent() == 1)
- {
- const CMIUtilString &rArg(vwArgContext.GetArgsLeftToParse());
- if (IsArgThreadGrp(rArg) && ExtractNumber(rArg))
- {
- m_bFound = true;
- m_bValid = true;
- m_argValue = GetNumber();
- vwArgContext.RemoveArg(rArg);
- return MIstatus::success;
- }
- else
- return MIstatus::failure;
+bool CMICmdArgValThreadGrp::Validate(CMICmdArgContext &vwArgContext) {
+ if (vwArgContext.IsEmpty())
+ return m_bMandatory ? MIstatus::failure : MIstatus::success;
+
+ if (vwArgContext.GetNumberArgsPresent() == 1) {
+ const CMIUtilString &rArg(vwArgContext.GetArgsLeftToParse());
+ if (IsArgThreadGrp(rArg) && ExtractNumber(rArg)) {
+ m_bFound = true;
+ m_bValid = true;
+ m_argValue = GetNumber();
+ vwArgContext.RemoveArg(rArg);
+ return MIstatus::success;
+ } else
+ return MIstatus::failure;
+ }
+
+ // More than one option...
+ const CMIUtilString::VecString_t vecOptions(vwArgContext.GetArgs());
+ CMIUtilString::VecString_t::const_iterator it = vecOptions.begin();
+ while (it != vecOptions.end()) {
+ const CMIUtilString &rArg(*it);
+ if (IsArgThreadGrp(rArg) && ExtractNumber(rArg)) {
+ m_bFound = true;
+
+ if (vwArgContext.RemoveArg(rArg)) {
+ m_bValid = true;
+ m_argValue = GetNumber();
+ return MIstatus::success;
+ } else
+ return MIstatus::failure;
}
- // More than one option...
- const CMIUtilString::VecString_t vecOptions(vwArgContext.GetArgs());
- CMIUtilString::VecString_t::const_iterator it = vecOptions.begin();
- while (it != vecOptions.end())
- {
- const CMIUtilString &rArg(*it);
- if (IsArgThreadGrp(rArg) && ExtractNumber(rArg))
- {
- m_bFound = true;
-
- if (vwArgContext.RemoveArg(rArg))
- {
- m_bValid = true;
- m_argValue = GetNumber();
- return MIstatus::success;
- }
- else
- return MIstatus::failure;
- }
-
- // Next
- ++it;
- }
+ // Next
+ ++it;
+ }
- return MIstatus::failure;
+ return MIstatus::failure;
}
-//++ ------------------------------------------------------------------------------------
-// Details: Examine the string and determine if it is a valid string type argument.
+//++
+//------------------------------------------------------------------------------------
+// Details: Examine the string and determine if it is a valid string type
+// argument.
// Type: Method.
// Args: vrTxt - (R) Some text.
// Return: bool - True = yes valid arg, false = no.
// Throws: None.
//--
-bool
-CMICmdArgValThreadGrp::IsArgThreadGrp(const CMIUtilString &vrTxt) const
-{
- // Look for i1 i2 i3....
- const MIint nPos = vrTxt.find('i');
- if (nPos != 0)
- return false;
-
- const CMIUtilString strNum = vrTxt.substr(1);
- if (!strNum.IsNumber())
- return false;
+bool CMICmdArgValThreadGrp::IsArgThreadGrp(const CMIUtilString &vrTxt) const {
+ // Look for i1 i2 i3....
+ const MIint nPos = vrTxt.find('i');
+ if (nPos != 0)
+ return false;
+
+ const CMIUtilString strNum = vrTxt.substr(1);
+ if (!strNum.IsNumber())
+ return false;
- return true;
+ return true;
}
-//++ ------------------------------------------------------------------------------------
+//++
+//------------------------------------------------------------------------------------
// Details: Extract the thread group number from the thread group argument.
// Type: Method.
// Args: vrTxt - (R) Some text.
@@ -136,29 +130,23 @@ CMICmdArgValThreadGrp::IsArgThreadGrp(co
// MIstatus::failure - Functional failed.
// Throws: None.
//--
-bool
-CMICmdArgValThreadGrp::ExtractNumber(const CMIUtilString &vrTxt)
-{
- const CMIUtilString strNum = vrTxt.substr(1);
- MIint64 nNumber = 0;
- bool bOk = strNum.ExtractNumber(nNumber);
- if (bOk)
- {
- m_nThreadGrp = static_cast<MIuint>(nNumber);
- }
+bool CMICmdArgValThreadGrp::ExtractNumber(const CMIUtilString &vrTxt) {
+ const CMIUtilString strNum = vrTxt.substr(1);
+ MIint64 nNumber = 0;
+ bool bOk = strNum.ExtractNumber(nNumber);
+ if (bOk) {
+ m_nThreadGrp = static_cast<MIuint>(nNumber);
+ }
- return bOk;
+ return bOk;
}
-//++ ------------------------------------------------------------------------------------
+//++
+//------------------------------------------------------------------------------------
// Details: Retrieve the thread group ID found in the argument.
// Type: Method.
// Args: None.
// Return: MIuint - Thread group ID.
// Throws: None.
//--
-MIuint
-CMICmdArgValThreadGrp::GetNumber() const
-{
- return m_nThreadGrp;
-}
+MIuint CMICmdArgValThreadGrp::GetNumber() const { return m_nThreadGrp; }
Modified: lldb/trunk/tools/lldb-mi/MICmdArgValThreadGrp.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/lldb-mi/MICmdArgValThreadGrp.h?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/tools/lldb-mi/MICmdArgValThreadGrp.h (original)
+++ lldb/trunk/tools/lldb-mi/MICmdArgValThreadGrp.h Tue Sep 6 15:57:50 2016
@@ -15,37 +15,40 @@
// 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
+// interpret the options (context) string to find and validate a
+// matching
// argument and so extract a value from it. Thread group looks like
// "i1" in the options text.
// Based on the Interpreter pattern.
//--
-class CMICmdArgValThreadGrp : public CMICmdArgValBaseTemplate<MIuint>
-{
- // Methods:
- public:
- /* ctor */ CMICmdArgValThreadGrp();
- /* ctor */ CMICmdArgValThreadGrp(const CMIUtilString &vrArgName, const bool vbMandatory, const bool vbHandleByCmd);
- //
- bool IsArgThreadGrp(const CMIUtilString &vrTxt) const;
+class CMICmdArgValThreadGrp : public CMICmdArgValBaseTemplate<MIuint> {
+ // Methods:
+public:
+ /* ctor */ CMICmdArgValThreadGrp();
+ /* ctor */ CMICmdArgValThreadGrp(const CMIUtilString &vrArgName,
+ const bool vbMandatory,
+ const bool vbHandleByCmd);
+ //
+ bool IsArgThreadGrp(const CMIUtilString &vrTxt) const;
- // Overridden:
- public:
- // From CMICmdArgValBase
- /* dtor */ ~CMICmdArgValThreadGrp() override;
- // From CMICmdArgSet::IArg
- bool Validate(CMICmdArgContext &vArgContext) override;
+ // Overridden:
+public:
+ // From CMICmdArgValBase
+ /* dtor */ ~CMICmdArgValThreadGrp() override;
+ // From CMICmdArgSet::IArg
+ bool Validate(CMICmdArgContext &vArgContext) override;
- // Methods:
- private:
- bool ExtractNumber(const CMIUtilString &vrTxt);
- MIuint GetNumber() const;
+ // Methods:
+private:
+ bool ExtractNumber(const CMIUtilString &vrTxt);
+ MIuint GetNumber() const;
- // Attributes:
- private:
- MIuint m_nThreadGrp;
+ // Attributes:
+private:
+ MIuint m_nThreadGrp;
};
Modified: lldb/trunk/tools/lldb-mi/MICmdBase.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/lldb-mi/MICmdBase.cpp?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/tools/lldb-mi/MICmdBase.cpp (original)
+++ lldb/trunk/tools/lldb-mi/MICmdBase.cpp Tue Sep 6 15:57:50 2016
@@ -9,12 +9,13 @@
// In-house headers:
#include "MICmdBase.h"
-#include "MICmnMIValueConst.h"
-#include "MICmnLLDBDebugSessionInfo.h"
-#include "MICmdArgValOptionLong.h"
#include "MICmdArgValConsume.h"
+#include "MICmdArgValOptionLong.h"
+#include "MICmnLLDBDebugSessionInfo.h"
+#include "MICmnMIValueConst.h"
-//++ ------------------------------------------------------------------------------------
+//++
+//------------------------------------------------------------------------------------
// Details: CMICmdBase constructor.
// Type: Method.
// Args: None.
@@ -22,44 +23,35 @@
// Throws: None.
//--
CMICmdBase::CMICmdBase()
- : m_pSelfCreatorFn(nullptr)
- , m_rLLDBDebugSessionInfo(CMICmnLLDBDebugSessionInfo::Instance())
- , m_bHasResultRecordExtra(false)
- , m_constStrArgThreadGroup("thread-group")
- , m_constStrArgThread("thread")
- , m_constStrArgFrame("frame")
- , m_constStrArgConsume("--")
- , m_ThreadGrpArgMandatory(false)
- , m_ThreadArgMandatory(false)
- , m_FrameArgMandatory(false)
-{
-}
+ : m_pSelfCreatorFn(nullptr),
+ m_rLLDBDebugSessionInfo(CMICmnLLDBDebugSessionInfo::Instance()),
+ m_bHasResultRecordExtra(false), m_constStrArgThreadGroup("thread-group"),
+ m_constStrArgThread("thread"), m_constStrArgFrame("frame"),
+ m_constStrArgConsume("--"), m_ThreadGrpArgMandatory(false),
+ m_ThreadArgMandatory(false), m_FrameArgMandatory(false) {}
-//++ ------------------------------------------------------------------------------------
+//++
+//------------------------------------------------------------------------------------
// Details: CMICmdBase destructor.
// Type: Overrideable.
// Args: None.
// Return: None.
// Throws: None.
//--
-CMICmdBase::~CMICmdBase()
-{
-}
+CMICmdBase::~CMICmdBase() {}
-//++ ------------------------------------------------------------------------------------
+//++
+//------------------------------------------------------------------------------------
// Details: The invoker requires this function.
// Type: Overridden.
// Args: None.
// Return: SMICmdData & - *this command's present status/data/information.
// Throws: None.
//--
-const SMICmdData &
-CMICmdBase::GetCmdData() const
-{
- return m_cmdData;
-}
+const SMICmdData &CMICmdBase::GetCmdData() const { return m_cmdData; }
-//++ ------------------------------------------------------------------------------------
+//++
+//------------------------------------------------------------------------------------
// Details: The invoker requires this function.
// Type: Overridden.
// Args: None.
@@ -67,169 +59,179 @@ CMICmdBase::GetCmdData() const
// Empty string indicates command status ok.
// Throws: None.
//--
-const CMIUtilString &
-CMICmdBase::GetErrorDescription() const
-{
- return m_strCurrentErrDescription;
+const CMIUtilString &CMICmdBase::GetErrorDescription() const {
+ return m_strCurrentErrDescription;
}
-//++ ------------------------------------------------------------------------------------
-// Details: The CMICmdFactory requires this function. Retrieve the command and argument
+//++
+//------------------------------------------------------------------------------------
+// Details: The CMICmdFactory requires this function. Retrieve the command and
+// argument
// options description string.
// Type: Overridden.
// Args: None.
// Return: CMIUtilString & - Command description.
// Throws: None.
//--
-const CMIUtilString &
-CMICmdBase::GetMiCmd() const
-{
- return m_strMiCmd;
-}
+const CMIUtilString &CMICmdBase::GetMiCmd() const { return m_strMiCmd; }
-//++ ------------------------------------------------------------------------------------
+//++
+//------------------------------------------------------------------------------------
// Details: Help parse the arguments that are common to all commands.
// Args: None.
// Return: None
// Throws: None.
//--
-void
-CMICmdBase::AddCommonArgs()
-{
- m_setCmdArgs.Add(new CMICmdArgValOptionLong(m_constStrArgThreadGroup, m_ThreadGrpArgMandatory, true, CMICmdArgValListBase::eArgValType_ThreadGrp, 1));
- m_setCmdArgs.Add(new CMICmdArgValOptionLong(m_constStrArgThread, m_ThreadArgMandatory, true, CMICmdArgValListBase::eArgValType_Number, 1));
- m_setCmdArgs.Add(new CMICmdArgValOptionLong(m_constStrArgFrame, m_FrameArgMandatory, true, CMICmdArgValListBase::eArgValType_Number, 1));
- m_setCmdArgs.Add(new CMICmdArgValConsume(m_constStrArgConsume, false));
-}
-
-//++ ------------------------------------------------------------------------------------
-// Details: The invoker requires this function. A command must be given working data and
-// provide data about its status or provide information to other objects.
+void CMICmdBase::AddCommonArgs() {
+ m_setCmdArgs.Add(new CMICmdArgValOptionLong(
+ m_constStrArgThreadGroup, m_ThreadGrpArgMandatory, true,
+ CMICmdArgValListBase::eArgValType_ThreadGrp, 1));
+ m_setCmdArgs.Add(new CMICmdArgValOptionLong(
+ m_constStrArgThread, m_ThreadArgMandatory, true,
+ CMICmdArgValListBase::eArgValType_Number, 1));
+ m_setCmdArgs.Add(
+ new CMICmdArgValOptionLong(m_constStrArgFrame, m_FrameArgMandatory, true,
+ CMICmdArgValListBase::eArgValType_Number, 1));
+ m_setCmdArgs.Add(new CMICmdArgValConsume(m_constStrArgConsume, false));
+}
+
+//++
+//------------------------------------------------------------------------------------
+// Details: The invoker requires this function. A command must be given working
+// data and
+// provide data about its status or provide information to other
+// objects.
// Type: Overridden.
// Args: None.
// Return: None.
// Throws: None.
//--
-void
-CMICmdBase::SetCmdData(const SMICmdData &vCmdData)
-{
- m_cmdData = vCmdData;
+void CMICmdBase::SetCmdData(const SMICmdData &vCmdData) {
+ m_cmdData = vCmdData;
}
-//++ ------------------------------------------------------------------------------------
-// Details: The command factory requires this function. The factory calls this function
+//++
+//------------------------------------------------------------------------------------
+// Details: The command factory requires this function. The factory calls this
+// function
// so it can obtain *this command's creation function.
// Type: Overridden.
// Args: None.
// Return: CMICmdFactory::CmdCreatorFnPtr - Function pointer.
// Throws: None.
//--
-CMICmdFactory::CmdCreatorFnPtr
-CMICmdBase::GetCmdCreatorFn() const
-{
- return m_pSelfCreatorFn;
+CMICmdFactory::CmdCreatorFnPtr CMICmdBase::GetCmdCreatorFn() const {
+ return m_pSelfCreatorFn;
}
-//++ ------------------------------------------------------------------------------------
-// Details: If a command is an event type (has callbacks registered with SBListener) it
-// needs to inform the Invoker that it has finished its work so that the
-// Invoker can tidy up and call the commands Acknowledge function (yes the
-// command itself could call the Acknowledge itself but not doing that way).
+//++
+//------------------------------------------------------------------------------------
+// Details: If a command is an event type (has callbacks registered with
+// SBListener) it
+// needs to inform the Invoker that it has finished its work so that
+// the
+// Invoker can tidy up and call the commands Acknowledge function (yes
+// the
+// command itself could call the Acknowledge itself but not doing that
+// way).
// Type: Overridden.
// Args: None.
// Return: None.
// Throws: None.
//--
-void
-CMICmdBase::CmdFinishedTellInvoker() const
-{
- CMICmdInvoker::Instance().CmdExecuteFinished(const_cast<CMICmdBase &>(*this));
+void CMICmdBase::CmdFinishedTellInvoker() const {
+ CMICmdInvoker::Instance().CmdExecuteFinished(const_cast<CMICmdBase &>(*this));
}
-//++ ------------------------------------------------------------------------------------
-// Details: Returns the final version of the MI result record built up in the command's
+//++
+//------------------------------------------------------------------------------------
+// Details: Returns the final version of the MI result record built up in the
+// command's
// Acknowledge function. The one line text of MI result.
// Type: Overridden.
// Args: None.
// Return: CMIUtilString & - MI text version of the MI result record.
// Throws: None.
//--
-const CMIUtilString &
-CMICmdBase::GetMIResultRecord() const
-{
- return m_miResultRecord.GetString();
+const CMIUtilString &CMICmdBase::GetMIResultRecord() const {
+ return m_miResultRecord.GetString();
}
-//++ ------------------------------------------------------------------------------------
-// Details: Retrieve from the command additional MI result to its 1 line response.
-// Because of using LLDB additional 'fake'/hack output is sometimes required to
+//++
+//------------------------------------------------------------------------------------
+// Details: Retrieve from the command additional MI result to its 1 line
+// response.
+// Because of using LLDB additional 'fake'/hack output is sometimes
+// required to
// help the driver client operate i.e. Eclipse.
// Type: Overridden.
// Args: None.
// Return: CMIUtilString & - MI text version of the MI result record.
// Throws: None.
//--
-const CMIUtilString &
-CMICmdBase::GetMIResultRecordExtra() const
-{
- return m_miResultRecordExtra;
+const CMIUtilString &CMICmdBase::GetMIResultRecordExtra() const {
+ return m_miResultRecordExtra;
}
-//++ ------------------------------------------------------------------------------------
+//++
+//------------------------------------------------------------------------------------
// Details: Hss *this command got additional MI result to its 1 line response.
-// Because of using LLDB additional 'fake'/hack output is sometimes required to
+// Because of using LLDB additional 'fake'/hack output is sometimes
+// required to
// help the driver client operate i.e. Eclipse.
// Type: Overridden.
// Args: None.
-// Return: bool - True = Yes have additional MI output, false = no nothing extra.
+// Return: bool - True = Yes have additional MI output, false = no nothing
+// extra.
// Throws: None.
//--
-bool
-CMICmdBase::HasMIResultRecordExtra() const
-{
- return m_bHasResultRecordExtra;
+bool CMICmdBase::HasMIResultRecordExtra() const {
+ return m_bHasResultRecordExtra;
}
-//++ ------------------------------------------------------------------------------------
-// Details: Short cut function to enter error information into the command's metadata
+//++
+//------------------------------------------------------------------------------------
+// Details: Short cut function to enter error information into the command's
+// metadata
// object and set the command's error status.
// Type: Method.
// Args: rErrMsg - (R) Error description.
// Return: None.
// Throws: None.
//--
-void
-CMICmdBase::SetError(const CMIUtilString &rErrMsg)
-{
- m_cmdData.bCmdValid = false;
- m_cmdData.strErrorDescription = rErrMsg;
- m_cmdData.bCmdExecutedSuccessfully = false;
-
- const CMICmnMIValueResult valueResult("msg", CMICmnMIValueConst(rErrMsg));
- const CMICmnMIResultRecord miResultRecord(m_cmdData.strMiCmdToken, CMICmnMIResultRecord::eResultClass_Error, valueResult);
- m_miResultRecord = miResultRecord;
- m_cmdData.strMiCmdResultRecord = miResultRecord.GetString();
+void CMICmdBase::SetError(const CMIUtilString &rErrMsg) {
+ m_cmdData.bCmdValid = false;
+ m_cmdData.strErrorDescription = rErrMsg;
+ m_cmdData.bCmdExecutedSuccessfully = false;
+
+ const CMICmnMIValueResult valueResult("msg", CMICmnMIValueConst(rErrMsg));
+ const CMICmnMIResultRecord miResultRecord(
+ m_cmdData.strMiCmdToken, CMICmnMIResultRecord::eResultClass_Error,
+ valueResult);
+ m_miResultRecord = miResultRecord;
+ m_cmdData.strMiCmdResultRecord = miResultRecord.GetString();
}
-//++ ------------------------------------------------------------------------------------
+//++
+//------------------------------------------------------------------------------------
// Details: Ask a command to provide its unique identifier.
// Type: Method.
// Args: A unique identifier for this command class.
// Return: None.
// Throws: None.
//--
-MIuint
-CMICmdBase::GetGUID()
-{
- MIuint64 vptr = reinterpret_cast<MIuint64>(this);
- MIuint id = (vptr)&0xFFFFFFFF;
- id ^= (vptr >> 32) & 0xFFFFFFFF;
-
- return id;
+MIuint CMICmdBase::GetGUID() {
+ MIuint64 vptr = reinterpret_cast<MIuint64>(this);
+ MIuint id = (vptr)&0xFFFFFFFF;
+ id ^= (vptr >> 32) & 0xFFFFFFFF;
+
+ return id;
}
-//++ ------------------------------------------------------------------------------------
-// Details: The invoker requires this function. The parses the command line options
+//++
+//------------------------------------------------------------------------------------
+// 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.
@@ -237,18 +239,20 @@ CMICmdBase::GetGUID()
// MIstatus::failure - Functional failed.
// Throws: None.
//--
-bool
-CMICmdBase::ParseArgs()
-{
- // Do nothing - override to implement
+bool CMICmdBase::ParseArgs() {
+ // Do nothing - override to implement
- return MIstatus::success;
+ return MIstatus::success;
}
-//++ ------------------------------------------------------------------------------------
-// Details: Having previously given CMICmdArgSet m_setCmdArgs all the argument or option
-// definitions for the command to handle proceed to parse and validate the
-// command's options text for those arguments and extract the values for each if
+//++
+//------------------------------------------------------------------------------------
+// Details: Having previously given CMICmdArgSet m_setCmdArgs all the argument
+// or option
+// definitions for the command to handle proceed to parse and validate
+// the
+// command's options text for those arguments and extract the values
+// for each if
// any.
// Type: Method.
// Args: None.
@@ -256,31 +260,33 @@ CMICmdBase::ParseArgs()
// MIstatus::failure - Functional failed.
// Throws: None.
//--
-bool
-CMICmdBase::ParseValidateCmdOptions()
-{
- CMICmdArgContext argCntxt(m_cmdData.strMiCmdOption);
- if (m_setCmdArgs.Validate(m_cmdData.strMiCmd, argCntxt))
- return MIstatus::success;
-
- SetError(CMIUtilString::Format(MIRSRC(IDS_CMD_ERR_ARGS), m_cmdData.strMiCmd.c_str(), m_setCmdArgs.GetErrorDescription().c_str()));
-
- return MIstatus::failure;
-}
-
-//++ ------------------------------------------------------------------------------------
-// Details: If the MI Driver is not operating via a client i.e. Eclipse but say operating
-// on a executable passed in as a argument to the drive then what should the driver
-// do on a command failing? Either continue operating or exit the application.
-// Override this function where a command failure cannot allow the driver to
+bool CMICmdBase::ParseValidateCmdOptions() {
+ CMICmdArgContext argCntxt(m_cmdData.strMiCmdOption);
+ if (m_setCmdArgs.Validate(m_cmdData.strMiCmd, argCntxt))
+ return MIstatus::success;
+
+ SetError(CMIUtilString::Format(MIRSRC(IDS_CMD_ERR_ARGS),
+ m_cmdData.strMiCmd.c_str(),
+ m_setCmdArgs.GetErrorDescription().c_str()));
+
+ return MIstatus::failure;
+}
+
+//++
+//------------------------------------------------------------------------------------
+// Details: If the MI Driver is not operating via a client i.e. Eclipse but say
+// operating
+// on a executable passed in as a argument to the drive then what
+// should the driver
+// do on a command failing? Either continue operating or exit the
+// application.
+// Override this function where a command failure cannot allow the
+// driver to
// continue operating.
// Type: Overrideable.
// Args: None.
-// Return: bool - True = Fatal if command fails, false = can continue if command fails.
+// Return: bool - True = Fatal if command fails, false = can continue if
+// command fails.
// Throws: None.
//--
-bool
-CMICmdBase::GetExitAppOnCommandFailure() const
-{
- return false;
-}
+bool CMICmdBase::GetExitAppOnCommandFailure() const { return false; }
Modified: lldb/trunk/tools/lldb-mi/MICmdBase.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/lldb-mi/MICmdBase.h?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/tools/lldb-mi/MICmdBase.h (original)
+++ lldb/trunk/tools/lldb-mi/MICmdBase.h Tue Sep 6 15:57:50 2016
@@ -13,19 +13,20 @@
// C++ Includes
// Other libraries and framework includes
// Project includes
-#include "MIUtilString.h"
-#include "MICmnBase.h"
-#include "MICmnResources.h"
-#include "MICmdInvoker.h"
-#include "MICmdFactory.h"
+#include "MICmdArgSet.h"
#include "MICmdData.h"
+#include "MICmdFactory.h"
+#include "MICmdInvoker.h"
+#include "MICmnBase.h"
#include "MICmnMIResultRecord.h"
-#include "MICmdArgSet.h"
+#include "MICmnResources.h"
+#include "MIUtilString.h"
// Declarations:
class CMICmnLLDBDebugSessionInfo;
-//++ ============================================================================
+//++
+//============================================================================
// Details: MI command base class. MI commands derive from this base class.
// The Command Factory creates command objects and passes them to the
// Command Invoker. The Invoker takes ownership of any commands created
@@ -39,116 +40,149 @@ class CMICmnLLDBDebugSessionInfo;
// function. The other type of command is one that just does some work,
// ends, then the Invoker calls the command's Acknowledge function. No
// events set up.
-// A command's Execute(), Acknowledge() and event callback functions are
+// A command's Execute(), Acknowledge() and event callback functions
+// are
// carried out in the main thread.
-// A command may use the argument derived object classes (CMICmdArgValBase)
+// A command may use the argument derived object classes
+// (CMICmdArgValBase)
// to factor handling and parsing of different types of arguments
// presented to a command. A command will produce an error should it
// be presented with arguments or options it does not understand.
//--
-class CMICmdBase : public CMICmnBase, public CMICmdInvoker::ICmd, public CMICmdFactory::ICmd
-{
- // Methods:
- public:
- CMICmdBase();
-
- // Overridden:
- // From CMICmdInvoker::ICmd
- const SMICmdData &GetCmdData() const override;
- const CMIUtilString &GetErrorDescription() const override;
- void SetCmdData(const SMICmdData &vCmdData) override;
- void CmdFinishedTellInvoker() const override;
- const CMIUtilString &GetMIResultRecord() const override;
- const CMIUtilString &GetMIResultRecordExtra() const override;
- bool HasMIResultRecordExtra() const override;
- bool ParseArgs() override;
- // From CMICmdFactory::ICmd
- const CMIUtilString &GetMiCmd() const override;
- CMICmdFactory::CmdCreatorFnPtr GetCmdCreatorFn() const override;
-
- virtual MIuint GetGUID();
- void AddCommonArgs();
-
- // Overrideable:
- ~CMICmdBase() override;
- virtual bool GetExitAppOnCommandFailure() const;
-
- // Methods:
- protected:
- void SetError(const CMIUtilString &rErrMsg);
- template <class T> T *GetOption(const CMIUtilString &vStrOptionName);
- bool ParseValidateCmdOptions();
-
- // Attributes:
- CMICmdFactory::CmdCreatorFnPtr m_pSelfCreatorFn;
- CMIUtilString m_strCurrentErrDescription; // Reason for Execute or Acknowledge function failure
- SMICmdData m_cmdData; // Holds information/status of *this command. Used by other MI code to report or determine state of a command.
- bool m_bWaitForEventFromSBDebugger; // True = yes event type command wait, false = command calls Acknowledge() straight after Execute()
- // no waiting
- CMIUtilString m_strMiCmd; // The MI text identifying *this command i.e. 'break-insert'
- CMICmnMIResultRecord m_miResultRecord; // This is completed in the Acknowledge() function and returned to the Command Invoker to proceed
- // stdout output. Each command forms 1 response to its input.
- CMIUtilString m_miResultRecordExtra; // This is completed in the Acknowledge() function and returned to the Command Invoker to proceed
- // stdout output. Hack command produce more response text to help the client because of using LLDB
- CMICmnLLDBDebugSessionInfo &
- m_rLLDBDebugSessionInfo; // Access to command sharing information or data across any and all command based derived classes.
- bool m_bHasResultRecordExtra; // True = Yes command produced additional MI output to its 1 line response, false = no extra MI output
- // formed.
- CMICmdArgSet m_setCmdArgs; // The list of arguments *this command needs to parse from the options string to carry out work.
- const CMIUtilString m_constStrArgThreadGroup;
- const CMIUtilString m_constStrArgThread;
- const CMIUtilString m_constStrArgFrame;
- const CMIUtilString m_constStrArgConsume;
-
- // These 3 members can be used by the derived classes to make any of
- // "thread", "frame" or "thread-group" mandatory.
- bool m_ThreadGrpArgMandatory;
- bool m_ThreadArgMandatory;
- bool m_FrameArgMandatory;
+class CMICmdBase : public CMICmnBase,
+ public CMICmdInvoker::ICmd,
+ public CMICmdFactory::ICmd {
+ // Methods:
+public:
+ CMICmdBase();
+
+ // Overridden:
+ // From CMICmdInvoker::ICmd
+ const SMICmdData &GetCmdData() const override;
+ const CMIUtilString &GetErrorDescription() const override;
+ void SetCmdData(const SMICmdData &vCmdData) override;
+ void CmdFinishedTellInvoker() const override;
+ const CMIUtilString &GetMIResultRecord() const override;
+ const CMIUtilString &GetMIResultRecordExtra() const override;
+ bool HasMIResultRecordExtra() const override;
+ bool ParseArgs() override;
+ // From CMICmdFactory::ICmd
+ const CMIUtilString &GetMiCmd() const override;
+ CMICmdFactory::CmdCreatorFnPtr GetCmdCreatorFn() const override;
+
+ virtual MIuint GetGUID();
+ void AddCommonArgs();
+
+ // Overrideable:
+ ~CMICmdBase() override;
+ virtual bool GetExitAppOnCommandFailure() const;
+
+ // Methods:
+protected:
+ void SetError(const CMIUtilString &rErrMsg);
+ template <class T> T *GetOption(const CMIUtilString &vStrOptionName);
+ bool ParseValidateCmdOptions();
+
+ // Attributes:
+ CMICmdFactory::CmdCreatorFnPtr m_pSelfCreatorFn;
+ CMIUtilString m_strCurrentErrDescription; // Reason for Execute or Acknowledge
+ // function failure
+ SMICmdData m_cmdData; // Holds information/status of *this command. Used by
+ // other MI code to report or determine state of a
+ // command.
+ bool m_bWaitForEventFromSBDebugger; // True = yes event type command wait,
+ // false = command calls Acknowledge()
+ // straight after Execute()
+ // no waiting
+ CMIUtilString
+ m_strMiCmd; // The MI text identifying *this command i.e. 'break-insert'
+ CMICmnMIResultRecord m_miResultRecord; // This is completed in the
+ // Acknowledge() function and returned
+ // to the Command Invoker to proceed
+ // stdout output. Each command forms 1 response to its input.
+ CMIUtilString m_miResultRecordExtra; // This is completed in the Acknowledge()
+ // function and returned to the Command
+ // Invoker to proceed
+ // stdout output. Hack command produce more response text to help the client
+ // because of using LLDB
+ CMICmnLLDBDebugSessionInfo &m_rLLDBDebugSessionInfo; // Access to command
+ // sharing information or
+ // data across any and
+ // all command based
+ // derived classes.
+ bool m_bHasResultRecordExtra; // True = Yes command produced additional MI
+ // output to its 1 line response, false = no
+ // extra MI output
+ // formed.
+ CMICmdArgSet m_setCmdArgs; // The list of arguments *this command needs to
+ // parse from the options string to carry out work.
+ const CMIUtilString m_constStrArgThreadGroup;
+ const CMIUtilString m_constStrArgThread;
+ const CMIUtilString m_constStrArgFrame;
+ const CMIUtilString m_constStrArgConsume;
+
+ // These 3 members can be used by the derived classes to make any of
+ // "thread", "frame" or "thread-group" mandatory.
+ bool m_ThreadGrpArgMandatory;
+ bool m_ThreadArgMandatory;
+ bool m_FrameArgMandatory;
};
-//++ ------------------------------------------------------------------------------------
-// Details: Retrieve the command argument or option object pointer so that it can be
-// examined. If the option found and valid get the value (number, string or list
-// - see CMICmdArgValBase class) from it to use with the command's decision
-// making. If the argument is not found the command's error description is set
+//++
+//------------------------------------------------------------------------------------
+// Details: Retrieve the command argument or option object pointer so that it
+// can be
+// examined. If the option found and valid get the value (number,
+// string or list
+// - see CMICmdArgValBase class) from it to use with the command's
+// decision
+// making. If the argument is not found the command's error description
+// is set
// describing the error condition.
// Type: Template method.
-// Args: vStrOptionName - (R) The text name of the argument or option to search for in
-// the list of the command's possible arguments or options.
+// Args: vStrOptionName - (R) The text name of the argument or option to
+// search for in
+// the list of the command's possible arguments
+// or options.
// Return: T * - CMICmdArgValBase derived object.
-// - nullptr = function has failed, unable to retrieve the option/arg object.
+// - nullptr = function has failed, unable to retrieve the
+// option/arg object.
// Throws: None.
//--
template <class T>
-T *
-CMICmdBase::GetOption(const CMIUtilString &vStrOptionName)
-{
- CMICmdArgValBase *pPtrBase = nullptr;
- if (!m_setCmdArgs.GetArg(vStrOptionName, pPtrBase))
- {
- SetError(CMIUtilString::Format(MIRSRC(IDS_CMD_ERR_OPTION_NOT_FOUND), m_cmdData.strMiCmd.c_str(), vStrOptionName.c_str()));
- return nullptr;
- }
+T *CMICmdBase::GetOption(const CMIUtilString &vStrOptionName) {
+ CMICmdArgValBase *pPtrBase = nullptr;
+ if (!m_setCmdArgs.GetArg(vStrOptionName, pPtrBase)) {
+ SetError(CMIUtilString::Format(MIRSRC(IDS_CMD_ERR_OPTION_NOT_FOUND),
+ m_cmdData.strMiCmd.c_str(),
+ vStrOptionName.c_str()));
+ return nullptr;
+ }
- return static_cast<T *>(pPtrBase);
+ return static_cast<T *>(pPtrBase);
}
-//++ ------------------------------------------------------------------------------------
-// Details: Retrieve the command argument or option object pointer using template function
-// CMICmdBase::GetOption(). Should the argument (by name) not be found the
+//++
+//------------------------------------------------------------------------------------
+// Details: Retrieve the command argument or option object pointer using
+// template function
+// CMICmdBase::GetOption(). Should the argument (by name) not be found
+// the
// command will exit with a failure (set in GetOption()).
// Type: Preprocessor macro.
// Args: a - (R) The actual variable's name.
-// b - (R) The type of variable (appended to CMICmdArgVal i.e. CMICmdArgValString).
-// c - (R) The text name of the argument or option to search for in the list of
+// b - (R) The type of variable (appended to CMICmdArgVal i.e.
+// CMICmdArgValString).
+// c - (R) The text name of the argument or option to search for in
+// the list of
// the command's possible arguments or options.
// Return: T * - CMICmdArgValBase derived object.
-// - nullptr = function has failed, unable to retrieve the option/arg object.
+// - nullptr = function has failed, unable to retrieve the
+// option/arg object.
// Throws: None.
//--
-#define CMICMDBASE_GETOPTION(a, b, c) \
- CMICmdArgVal##b *a = CMICmdBase::GetOption<CMICmdArgVal##b>(c); \
- if (a == nullptr) \
- return MIstatus::failure;
+#define CMICMDBASE_GETOPTION(a, b, c) \
+ CMICmdArgVal##b *a = CMICmdBase::GetOption<CMICmdArgVal##b>(c); \
+ if (a == nullptr) \
+ return MIstatus::failure;
// This comment is to stop compile warning for #define
Modified: lldb/trunk/tools/lldb-mi/MICmdCmd.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/lldb-mi/MICmdCmd.cpp?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/tools/lldb-mi/MICmdCmd.cpp (original)
+++ lldb/trunk/tools/lldb-mi/MICmdCmd.cpp Tue Sep 6 15:57:50 2016
@@ -11,55 +11,56 @@
// CMICmdCmdSource implementation.
//
-
// In-house headers:
#include "MICmdCmd.h"
-//++ ------------------------------------------------------------------------------------
+//++
+//------------------------------------------------------------------------------------
// Details: CMICmdCmdEnablePrettyPrinting constructor.
// Type: Method.
// Args: None.
// Return: None.
// Throws: None.
//--
-CMICmdCmdEnablePrettyPrinting::CMICmdCmdEnablePrettyPrinting()
-{
- // Command factory matches this name with that received from the stdin stream
- m_strMiCmd = "enable-pretty-printing";
+CMICmdCmdEnablePrettyPrinting::CMICmdCmdEnablePrettyPrinting() {
+ // Command factory matches this name with that received from the stdin stream
+ m_strMiCmd = "enable-pretty-printing";
- // Required by the CMICmdFactory when registering *this command
- m_pSelfCreatorFn = &CMICmdCmdEnablePrettyPrinting::CreateSelf;
+ // Required by the CMICmdFactory when registering *this command
+ m_pSelfCreatorFn = &CMICmdCmdEnablePrettyPrinting::CreateSelf;
}
-//++ ------------------------------------------------------------------------------------
+//++
+//------------------------------------------------------------------------------------
// Details: CMICmdCmdEnablePrettyPrinting destructor.
// Type: Overrideable.
// Args: None.
// Return: None.
// Throws: None.
//--
-CMICmdCmdEnablePrettyPrinting::~CMICmdCmdEnablePrettyPrinting()
-{
-}
+CMICmdCmdEnablePrettyPrinting::~CMICmdCmdEnablePrettyPrinting() {}
-//++ ------------------------------------------------------------------------------------
-// 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.
+//++
+//------------------------------------------------------------------------------------
+// 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
-CMICmdCmdEnablePrettyPrinting::Execute()
-{
- // Do nothing
- return MIstatus::success;
+bool CMICmdCmdEnablePrettyPrinting::Execute() {
+ // Do nothing
+ return MIstatus::success;
}
-//++ ------------------------------------------------------------------------------------
-// Details: The invoker requires this function. The command prepares a MI Record Result
+//++
+//------------------------------------------------------------------------------------
+// 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.
@@ -67,80 +68,82 @@ CMICmdCmdEnablePrettyPrinting::Execute()
// MIstatus::failure - Functional failed.
// Throws: None.
//--
-bool
-CMICmdCmdEnablePrettyPrinting::Acknowledge()
-{
- const CMICmnMIValueConst miValueConst("0");
- const CMICmnMIValueResult miValueResult("supported", miValueConst);
- const CMICmnMIResultRecord miRecordResult(m_cmdData.strMiCmdToken, CMICmnMIResultRecord::eResultClass_Done, miValueResult);
- m_miResultRecord = miRecordResult;
-
- return MIstatus::success;
+bool CMICmdCmdEnablePrettyPrinting::Acknowledge() {
+ const CMICmnMIValueConst miValueConst("0");
+ const CMICmnMIValueResult miValueResult("supported", miValueConst);
+ const CMICmnMIResultRecord miRecordResult(
+ m_cmdData.strMiCmdToken, CMICmnMIResultRecord::eResultClass_Done,
+ miValueResult);
+ m_miResultRecord = miRecordResult;
+
+ return MIstatus::success;
}
-//++ ------------------------------------------------------------------------------------
-// Details: Required by the CMICmdFactory when registering *this command. The factory
+//++
+//------------------------------------------------------------------------------------
+// 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 *
-CMICmdCmdEnablePrettyPrinting::CreateSelf()
-{
- return new CMICmdCmdEnablePrettyPrinting();
+CMICmdBase *CMICmdCmdEnablePrettyPrinting::CreateSelf() {
+ return new CMICmdCmdEnablePrettyPrinting();
}
//---------------------------------------------------------------------------------------
//---------------------------------------------------------------------------------------
//---------------------------------------------------------------------------------------
-//++ ------------------------------------------------------------------------------------
+//++
+//------------------------------------------------------------------------------------
// Details: CMICmdCmdSource constructor.
// Type: Method.
// Args: None.
// Return: None.
// Throws: None.
//--
-CMICmdCmdSource::CMICmdCmdSource()
-{
- // Command factory matches this name with that received from the stdin stream
- m_strMiCmd = "source";
+CMICmdCmdSource::CMICmdCmdSource() {
+ // Command factory matches this name with that received from the stdin stream
+ m_strMiCmd = "source";
- // Required by the CMICmdFactory when registering *this command
- m_pSelfCreatorFn = &CMICmdCmdSource::CreateSelf;
+ // Required by the CMICmdFactory when registering *this command
+ m_pSelfCreatorFn = &CMICmdCmdSource::CreateSelf;
}
-//++ ------------------------------------------------------------------------------------
+//++
+//------------------------------------------------------------------------------------
// Details: CMICmdCmdSource destructor.
// Type: Overrideable.
// Args: None.
// Return: None.
// Throws: None.
//--
-CMICmdCmdSource::~CMICmdCmdSource()
-{
-}
+CMICmdCmdSource::~CMICmdCmdSource() {}
-//++ ------------------------------------------------------------------------------------
-// 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.
+//++
+//------------------------------------------------------------------------------------
+// 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
-CMICmdCmdSource::Execute()
-{
- // Do nothing
- return MIstatus::success;
+bool CMICmdCmdSource::Execute() {
+ // Do nothing
+ return MIstatus::success;
}
-//++ ------------------------------------------------------------------------------------
-// Details: The invoker requires this function. The command prepares a MI Record Result
+//++
+//------------------------------------------------------------------------------------
+// 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.
@@ -148,25 +151,22 @@ CMICmdCmdSource::Execute()
// MIstatus::failure - Functional failed.
// Throws: None.
//--
-bool
-CMICmdCmdSource::Acknowledge()
-{
- const CMICmnMIResultRecord miRecordResult(m_cmdData.strMiCmdToken, CMICmnMIResultRecord::eResultClass_Done);
- m_miResultRecord = miRecordResult;
-
- return MIstatus::success;
+bool CMICmdCmdSource::Acknowledge() {
+ const CMICmnMIResultRecord miRecordResult(
+ m_cmdData.strMiCmdToken, CMICmnMIResultRecord::eResultClass_Done);
+ m_miResultRecord = miRecordResult;
+
+ return MIstatus::success;
}
-//++ ------------------------------------------------------------------------------------
-// Details: Required by the CMICmdFactory when registering *this command. The factory
+//++
+//------------------------------------------------------------------------------------
+// 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 *
-CMICmdCmdSource::CreateSelf()
-{
- return new CMICmdCmdSource();
-}
+CMICmdBase *CMICmdCmdSource::CreateSelf() { return new CMICmdCmdSource(); }
Modified: lldb/trunk/tools/lldb-mi/MICmdCmd.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/lldb-mi/MICmdCmd.h?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/tools/lldb-mi/MICmdCmd.h (original)
+++ lldb/trunk/tools/lldb-mi/MICmdCmd.h Tue Sep 6 15:57:50 2016
@@ -10,13 +10,16 @@
// Overview: CMICmdCmdEnablePrettyPrinting interface.
// CMICmdCmdSource 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 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
+// For an introduction to adding a new command see
+// CMICmdCmdSupportInfoMiCmdQuery
// command class as an example.
/*
@@ -27,61 +30,62 @@ MI commands implemented are:
#pragma once
// Third party headers:
-#include <vector>
#include "lldb/API/SBBreakpoint.h"
#include "lldb/API/SBCommandReturnObject.h"
+#include <vector>
// In-house headers:
#include "MICmdBase.h"
-#include "MICmnMIValueTuple.h"
#include "MICmnMIValueList.h"
+#include "MICmnMIValueTuple.h"
-//++ ============================================================================
+//++
+//============================================================================
// Details: MI command class. MI commands derived from the command base class.
// *this class implements MI command "enable-pretty-printing".
// Enables Python base pretty printing.
-// Ref: http://sourceware.org/gdb/onlinedocs/gdb/GDB_002fMI-Variable-Objects.html
+// Ref:
+// http://sourceware.org/gdb/onlinedocs/gdb/GDB_002fMI-Variable-Objects.html
//--
-class CMICmdCmdEnablePrettyPrinting : public CMICmdBase
-{
- // Statics:
- public:
- // Required by the CMICmdFactory when registering *this command
- static CMICmdBase *CreateSelf();
-
- // Methods:
- public:
- /* ctor */ CMICmdCmdEnablePrettyPrinting();
-
- // Overridden:
- public:
- // From CMICmdInvoker::ICmd
- bool Execute() override;
- bool Acknowledge() override;
- // From CMICmnBase
- /* dtor */ ~CMICmdCmdEnablePrettyPrinting() override;
+class CMICmdCmdEnablePrettyPrinting : public CMICmdBase {
+ // Statics:
+public:
+ // Required by the CMICmdFactory when registering *this command
+ static CMICmdBase *CreateSelf();
+
+ // Methods:
+public:
+ /* ctor */ CMICmdCmdEnablePrettyPrinting();
+
+ // Overridden:
+public:
+ // From CMICmdInvoker::ICmd
+ bool Execute() override;
+ bool Acknowledge() override;
+ // From CMICmnBase
+ /* dtor */ ~CMICmdCmdEnablePrettyPrinting() override;
};
-//++ ============================================================================
+//++
+//============================================================================
// Details: MI command class. MI commands derived from the command base class.
// *this class implements MI command "source".
//--
-class CMICmdCmdSource : public CMICmdBase
-{
- // Statics:
- public:
- // Required by the CMICmdFactory when registering *this command
- static CMICmdBase *CreateSelf();
-
- // Methods:
- public:
- /* ctor */ CMICmdCmdSource();
-
- // Overridden:
- public:
- // From CMICmdInvoker::ICmd
- bool Execute() override;
- bool Acknowledge() override;
- // From CMICmnBase
- /* dtor */ ~CMICmdCmdSource() override;
+class CMICmdCmdSource : public CMICmdBase {
+ // Statics:
+public:
+ // Required by the CMICmdFactory when registering *this command
+ static CMICmdBase *CreateSelf();
+
+ // Methods:
+public:
+ /* ctor */ CMICmdCmdSource();
+
+ // Overridden:
+public:
+ // From CMICmdInvoker::ICmd
+ bool Execute() override;
+ bool Acknowledge() override;
+ // From CMICmnBase
+ /* dtor */ ~CMICmdCmdSource() override;
};
Modified: lldb/trunk/tools/lldb-mi/MICmdCmdBreak.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/lldb-mi/MICmdCmdBreak.cpp?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/tools/lldb-mi/MICmdCmdBreak.cpp (original)
+++ lldb/trunk/tools/lldb-mi/MICmdCmdBreak.cpp Tue Sep 6 15:57:50 2016
@@ -18,22 +18,23 @@
#include "lldb/API/SBBreakpointLocation.h"
// In-house headers:
-#include "MICmdCmdBreak.h"
-#include "MICmnMIResultRecord.h"
-#include "MICmnMIValueConst.h"
-#include "MICmnMIOutOfBandRecord.h"
-#include "MICmnLLDBDebugger.h"
-#include "MICmnLLDBDebugSessionInfo.h"
#include "MICmdArgValFile.h"
+#include "MICmdArgValListOfN.h"
#include "MICmdArgValNumber.h"
-#include "MICmdArgValString.h"
-#include "MICmdArgValThreadGrp.h"
#include "MICmdArgValOptionLong.h"
#include "MICmdArgValOptionShort.h"
-#include "MICmdArgValListOfN.h"
+#include "MICmdArgValString.h"
+#include "MICmdArgValThreadGrp.h"
+#include "MICmdCmdBreak.h"
+#include "MICmnLLDBDebugSessionInfo.h"
+#include "MICmnLLDBDebugger.h"
+#include "MICmnMIOutOfBandRecord.h"
+#include "MICmnMIResultRecord.h"
+#include "MICmnMIValueConst.h"
#include "MICmnStreamStdout.h"
-//++ ------------------------------------------------------------------------------------
+//++
+//------------------------------------------------------------------------------------
// Details: CMICmdCmdBreakInsert constructor.
// Type: Method.
// Args: None.
@@ -41,43 +42,35 @@
// Throws: None.
//--
CMICmdCmdBreakInsert::CMICmdCmdBreakInsert()
- : m_bBrkPtIsTemp(false)
- , m_bBrkPtIsPending(false)
- , m_nBrkPtIgnoreCount(0)
- , m_bBrkPtEnabled(false)
- , m_bBrkPtCondition(false)
- , m_bBrkPtThreadId(false)
- , m_nBrkPtThreadId(0)
- , m_constStrArgNamedTempBrkPt("t")
- , m_constStrArgNamedHWBrkPt("h")
- , m_constStrArgNamedPendinfBrkPt("f")
- , m_constStrArgNamedDisableBrkPt("d")
- , m_constStrArgNamedTracePt("a")
- , m_constStrArgNamedConditionalBrkPt("c")
- , m_constStrArgNamedInoreCnt("i")
- , m_constStrArgNamedRestrictBrkPtToThreadId("p")
- , m_constStrArgNamedLocation("location")
-{
- // Command factory matches this name with that received from the stdin stream
- m_strMiCmd = "break-insert";
+ : m_bBrkPtIsTemp(false), m_bBrkPtIsPending(false), m_nBrkPtIgnoreCount(0),
+ m_bBrkPtEnabled(false), m_bBrkPtCondition(false), m_bBrkPtThreadId(false),
+ m_nBrkPtThreadId(0), m_constStrArgNamedTempBrkPt("t"),
+ m_constStrArgNamedHWBrkPt("h"), m_constStrArgNamedPendinfBrkPt("f"),
+ m_constStrArgNamedDisableBrkPt("d"), m_constStrArgNamedTracePt("a"),
+ m_constStrArgNamedConditionalBrkPt("c"), m_constStrArgNamedInoreCnt("i"),
+ m_constStrArgNamedRestrictBrkPtToThreadId("p"),
+ m_constStrArgNamedLocation("location") {
+ // Command factory matches this name with that received from the stdin stream
+ m_strMiCmd = "break-insert";
- // Required by the CMICmdFactory when registering *this command
- m_pSelfCreatorFn = &CMICmdCmdBreakInsert::CreateSelf;
+ // Required by the CMICmdFactory when registering *this command
+ m_pSelfCreatorFn = &CMICmdCmdBreakInsert::CreateSelf;
}
-//++ ------------------------------------------------------------------------------------
+//++
+//------------------------------------------------------------------------------------
// Details: CMICmdCmdBreakInsert destructor.
// Type: Overrideable.
// Args: None.
// Return: None.
// Throws: None.
//--
-CMICmdCmdBreakInsert::~CMICmdCmdBreakInsert()
-{
-}
+CMICmdCmdBreakInsert::~CMICmdCmdBreakInsert() {}
-//++ ------------------------------------------------------------------------------------
-// Details: The invoker requires this function. The parses the command line options
+//++
+//------------------------------------------------------------------------------------
+// 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.
@@ -85,234 +78,241 @@ CMICmdCmdBreakInsert::~CMICmdCmdBreakIns
// MIstatus::failure - Functional failed.
// Throws: None.
//--
-bool
-CMICmdCmdBreakInsert::ParseArgs()
-{
- m_setCmdArgs.Add(new CMICmdArgValOptionShort(m_constStrArgNamedTempBrkPt, false, true));
- // Not implemented m_setCmdArgs.Add(new CMICmdArgValOptionShort( m_constStrArgNamedHWBrkPt, false, false));
- m_setCmdArgs.Add(new CMICmdArgValOptionShort(m_constStrArgNamedPendinfBrkPt, false, true,
- CMICmdArgValListBase::eArgValType_StringQuotedNumberPath, 1));
- m_setCmdArgs.Add(new CMICmdArgValOptionShort(m_constStrArgNamedDisableBrkPt, false, false));
- // Not implemented m_setCmdArgs.Add(new CMICmdArgValOptionShort( m_constStrArgNamedTracePt, false, false));
- m_setCmdArgs.Add(new CMICmdArgValOptionShort(m_constStrArgNamedConditionalBrkPt, false, true,
- CMICmdArgValListBase::eArgValType_StringQuoted, 1));
- m_setCmdArgs.Add(
- new CMICmdArgValOptionShort(m_constStrArgNamedInoreCnt, false, true, CMICmdArgValListBase::eArgValType_Number, 1));
- m_setCmdArgs.Add(new CMICmdArgValOptionShort(m_constStrArgNamedRestrictBrkPtToThreadId, false, true,
- CMICmdArgValListBase::eArgValType_Number, 1));
- m_setCmdArgs.Add(new CMICmdArgValString(m_constStrArgNamedLocation, false, true, false, false, true));
- return ParseValidateCmdOptions();
+bool CMICmdCmdBreakInsert::ParseArgs() {
+ m_setCmdArgs.Add(
+ new CMICmdArgValOptionShort(m_constStrArgNamedTempBrkPt, false, true));
+ // Not implemented m_setCmdArgs.Add(new CMICmdArgValOptionShort(
+ // m_constStrArgNamedHWBrkPt, false, false));
+ m_setCmdArgs.Add(new CMICmdArgValOptionShort(
+ m_constStrArgNamedPendinfBrkPt, false, true,
+ CMICmdArgValListBase::eArgValType_StringQuotedNumberPath, 1));
+ m_setCmdArgs.Add(new CMICmdArgValOptionShort(m_constStrArgNamedDisableBrkPt,
+ false, false));
+ // Not implemented m_setCmdArgs.Add(new CMICmdArgValOptionShort(
+ // m_constStrArgNamedTracePt, false, false));
+ m_setCmdArgs.Add(new CMICmdArgValOptionShort(
+ m_constStrArgNamedConditionalBrkPt, false, true,
+ CMICmdArgValListBase::eArgValType_StringQuoted, 1));
+ m_setCmdArgs.Add(
+ new CMICmdArgValOptionShort(m_constStrArgNamedInoreCnt, false, true,
+ CMICmdArgValListBase::eArgValType_Number, 1));
+ m_setCmdArgs.Add(new CMICmdArgValOptionShort(
+ m_constStrArgNamedRestrictBrkPtToThreadId, false, true,
+ CMICmdArgValListBase::eArgValType_Number, 1));
+ m_setCmdArgs.Add(new CMICmdArgValString(m_constStrArgNamedLocation, false,
+ true, false, false, true));
+ return ParseValidateCmdOptions();
}
-//++ ------------------------------------------------------------------------------------
+//++
+//------------------------------------------------------------------------------------
// Helper function for CMICmdCmdBreakInsert::Execute().
//
// Given a string, return the position of the ':' separator in 'file:func'
// or 'file:line', if any. If not found, return npos. For example, return
// 5 for 'foo.c:std::string'.
//--
-static size_t findFileSeparatorPos(const std::string& x)
-{
- // Full paths in windows can have ':' after a drive letter, so we
- // search backwards, taking care to skip C++ namespace tokens '::'.
- size_t n = x.rfind(':');
- while (n != std::string::npos && n > 1 && x[n-1] == ':')
- {
- n = x.rfind(':', n - 2);
- }
- return n;
-}
-
-//++ ------------------------------------------------------------------------------------
-// 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.
+static size_t findFileSeparatorPos(const std::string &x) {
+ // Full paths in windows can have ':' after a drive letter, so we
+ // search backwards, taking care to skip C++ namespace tokens '::'.
+ size_t n = x.rfind(':');
+ while (n != std::string::npos && n > 1 && x[n - 1] == ':') {
+ n = x.rfind(':', n - 2);
+ }
+ return n;
+}
+
+//++
+//------------------------------------------------------------------------------------
+// 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
-CMICmdCmdBreakInsert::Execute()
-{
- CMICMDBASE_GETOPTION(pArgTempBrkPt, OptionShort, m_constStrArgNamedTempBrkPt);
- CMICMDBASE_GETOPTION(pArgThreadGroup, OptionLong, m_constStrArgThreadGroup);
- CMICMDBASE_GETOPTION(pArgLocation, String, m_constStrArgNamedLocation);
- CMICMDBASE_GETOPTION(pArgIgnoreCnt, OptionShort, m_constStrArgNamedInoreCnt);
- CMICMDBASE_GETOPTION(pArgPendingBrkPt, OptionShort, m_constStrArgNamedPendinfBrkPt);
- CMICMDBASE_GETOPTION(pArgDisableBrkPt, OptionShort, m_constStrArgNamedDisableBrkPt);
- CMICMDBASE_GETOPTION(pArgConditionalBrkPt, OptionShort, m_constStrArgNamedConditionalBrkPt);
- CMICMDBASE_GETOPTION(pArgRestrictBrkPtToThreadId, OptionShort, m_constStrArgNamedRestrictBrkPtToThreadId);
-
- m_bBrkPtEnabled = !pArgDisableBrkPt->GetFound();
- m_bBrkPtIsTemp = pArgTempBrkPt->GetFound();
- m_bHaveArgOptionThreadGrp = pArgThreadGroup->GetFound();
- if (m_bHaveArgOptionThreadGrp)
- {
- MIuint nThreadGrp = 0;
- pArgThreadGroup->GetExpectedOption<CMICmdArgValThreadGrp, MIuint>(nThreadGrp);
- m_strArgOptionThreadGrp = CMIUtilString::Format("i%d", nThreadGrp);
- }
- m_bBrkPtIsPending = pArgPendingBrkPt->GetFound();
- if (pArgLocation->GetFound())
- m_brkName = pArgLocation->GetValue();
- else if (m_bBrkPtIsPending)
- {
- pArgPendingBrkPt->GetExpectedOption<CMICmdArgValString, CMIUtilString>(m_brkName);
- }
- if (pArgIgnoreCnt->GetFound())
- {
- pArgIgnoreCnt->GetExpectedOption<CMICmdArgValNumber, MIuint>(m_nBrkPtIgnoreCount);
- }
- m_bBrkPtCondition = pArgConditionalBrkPt->GetFound();
- if (m_bBrkPtCondition)
- {
- pArgConditionalBrkPt->GetExpectedOption<CMICmdArgValString, CMIUtilString>(m_brkPtCondition);
- }
- m_bBrkPtThreadId = pArgRestrictBrkPtToThreadId->GetFound();
- if (m_bBrkPtCondition)
- {
- pArgRestrictBrkPtToThreadId->GetExpectedOption<CMICmdArgValNumber, MIuint>(m_nBrkPtThreadId);
- }
-
- // Determine if break on a file line or at a function
- BreakPoint_e eBrkPtType = eBreakPoint_NotDefineYet;
- CMIUtilString fileName;
- MIuint nFileLine = 0;
- CMIUtilString strFileFn;
- CMIUtilString rStrLineOrFn;
- // Is the string in the form 'file:func' or 'file:line'?
- // If so, find the position of the ':' separator.
- const size_t nPosColon = findFileSeparatorPos(m_brkName);
- if (nPosColon != std::string::npos)
- {
- // Extract file name and line number from it
- fileName = m_brkName.substr(0, nPosColon);
- rStrLineOrFn = m_brkName.substr(nPosColon + 1, m_brkName.size() - nPosColon - 1);
-
- if (rStrLineOrFn.empty())
- eBrkPtType = eBreakPoint_ByName;
- else
- {
- MIint64 nValue = 0;
- if (rStrLineOrFn.ExtractNumber(nValue))
- {
- nFileLine = static_cast<MIuint>(nValue);
- eBrkPtType = eBreakPoint_ByFileLine;
- }
- else
- {
- strFileFn = rStrLineOrFn;
- eBrkPtType = eBreakPoint_ByFileFn;
- }
- }
- }
-
- // Determine if break defined as an address
- lldb::addr_t nAddress = 0;
- if (eBrkPtType == eBreakPoint_NotDefineYet)
- {
- MIint64 nValue = 0;
- if (m_brkName.ExtractNumber(nValue))
- {
- nAddress = static_cast<lldb::addr_t>(nValue);
- eBrkPtType = eBreakPoint_ByAddress;
- }
- }
-
- // Break defined as an function
- if (eBrkPtType == eBreakPoint_NotDefineYet)
- {
- eBrkPtType = eBreakPoint_ByName;
- }
-
- // Ask LLDB to create a breakpoint
- bool bOk = MIstatus::success;
- CMICmnLLDBDebugSessionInfo &rSessionInfo(CMICmnLLDBDebugSessionInfo::Instance());
- lldb::SBTarget sbTarget = rSessionInfo.GetTarget();
- switch (eBrkPtType)
- {
- case eBreakPoint_ByAddress:
- m_brkPt = sbTarget.BreakpointCreateByAddress(nAddress);
- break;
- case eBreakPoint_ByFileFn:
- {
- lldb::SBFileSpecList module; // search in all modules
- lldb::SBFileSpecList compUnit;
- compUnit.Append (lldb::SBFileSpec(fileName.c_str()));
- m_brkPt = sbTarget.BreakpointCreateByName(strFileFn.c_str(), module, compUnit);
- break;
- }
- case eBreakPoint_ByFileLine:
- m_brkPt = sbTarget.BreakpointCreateByLocation(fileName.c_str(), nFileLine);
- break;
- case eBreakPoint_ByName:
- m_brkPt = sbTarget.BreakpointCreateByName(m_brkName.c_str(), nullptr);
- break;
- case eBreakPoint_count:
- case eBreakPoint_NotDefineYet:
- case eBreakPoint_Invalid:
- bOk = MIstatus::failure;
- break;
+bool CMICmdCmdBreakInsert::Execute() {
+ CMICMDBASE_GETOPTION(pArgTempBrkPt, OptionShort, m_constStrArgNamedTempBrkPt);
+ CMICMDBASE_GETOPTION(pArgThreadGroup, OptionLong, m_constStrArgThreadGroup);
+ CMICMDBASE_GETOPTION(pArgLocation, String, m_constStrArgNamedLocation);
+ CMICMDBASE_GETOPTION(pArgIgnoreCnt, OptionShort, m_constStrArgNamedInoreCnt);
+ CMICMDBASE_GETOPTION(pArgPendingBrkPt, OptionShort,
+ m_constStrArgNamedPendinfBrkPt);
+ CMICMDBASE_GETOPTION(pArgDisableBrkPt, OptionShort,
+ m_constStrArgNamedDisableBrkPt);
+ CMICMDBASE_GETOPTION(pArgConditionalBrkPt, OptionShort,
+ m_constStrArgNamedConditionalBrkPt);
+ CMICMDBASE_GETOPTION(pArgRestrictBrkPtToThreadId, OptionShort,
+ m_constStrArgNamedRestrictBrkPtToThreadId);
+
+ m_bBrkPtEnabled = !pArgDisableBrkPt->GetFound();
+ m_bBrkPtIsTemp = pArgTempBrkPt->GetFound();
+ m_bHaveArgOptionThreadGrp = pArgThreadGroup->GetFound();
+ if (m_bHaveArgOptionThreadGrp) {
+ MIuint nThreadGrp = 0;
+ pArgThreadGroup->GetExpectedOption<CMICmdArgValThreadGrp, MIuint>(
+ nThreadGrp);
+ m_strArgOptionThreadGrp = CMIUtilString::Format("i%d", nThreadGrp);
+ }
+ m_bBrkPtIsPending = pArgPendingBrkPt->GetFound();
+ if (pArgLocation->GetFound())
+ m_brkName = pArgLocation->GetValue();
+ else if (m_bBrkPtIsPending) {
+ pArgPendingBrkPt->GetExpectedOption<CMICmdArgValString, CMIUtilString>(
+ m_brkName);
+ }
+ if (pArgIgnoreCnt->GetFound()) {
+ pArgIgnoreCnt->GetExpectedOption<CMICmdArgValNumber, MIuint>(
+ m_nBrkPtIgnoreCount);
+ }
+ m_bBrkPtCondition = pArgConditionalBrkPt->GetFound();
+ if (m_bBrkPtCondition) {
+ pArgConditionalBrkPt->GetExpectedOption<CMICmdArgValString, CMIUtilString>(
+ m_brkPtCondition);
+ }
+ m_bBrkPtThreadId = pArgRestrictBrkPtToThreadId->GetFound();
+ if (m_bBrkPtCondition) {
+ pArgRestrictBrkPtToThreadId->GetExpectedOption<CMICmdArgValNumber, MIuint>(
+ m_nBrkPtThreadId);
+ }
+
+ // Determine if break on a file line or at a function
+ BreakPoint_e eBrkPtType = eBreakPoint_NotDefineYet;
+ CMIUtilString fileName;
+ MIuint nFileLine = 0;
+ CMIUtilString strFileFn;
+ CMIUtilString rStrLineOrFn;
+ // Is the string in the form 'file:func' or 'file:line'?
+ // If so, find the position of the ':' separator.
+ const size_t nPosColon = findFileSeparatorPos(m_brkName);
+ if (nPosColon != std::string::npos) {
+ // Extract file name and line number from it
+ fileName = m_brkName.substr(0, nPosColon);
+ rStrLineOrFn =
+ m_brkName.substr(nPosColon + 1, m_brkName.size() - nPosColon - 1);
+
+ if (rStrLineOrFn.empty())
+ eBrkPtType = eBreakPoint_ByName;
+ else {
+ MIint64 nValue = 0;
+ if (rStrLineOrFn.ExtractNumber(nValue)) {
+ nFileLine = static_cast<MIuint>(nValue);
+ eBrkPtType = eBreakPoint_ByFileLine;
+ } else {
+ strFileFn = rStrLineOrFn;
+ eBrkPtType = eBreakPoint_ByFileFn;
+ }
+ }
+ }
+
+ // Determine if break defined as an address
+ lldb::addr_t nAddress = 0;
+ if (eBrkPtType == eBreakPoint_NotDefineYet) {
+ MIint64 nValue = 0;
+ if (m_brkName.ExtractNumber(nValue)) {
+ nAddress = static_cast<lldb::addr_t>(nValue);
+ eBrkPtType = eBreakPoint_ByAddress;
+ }
+ }
+
+ // Break defined as an function
+ if (eBrkPtType == eBreakPoint_NotDefineYet) {
+ eBrkPtType = eBreakPoint_ByName;
+ }
+
+ // Ask LLDB to create a breakpoint
+ bool bOk = MIstatus::success;
+ CMICmnLLDBDebugSessionInfo &rSessionInfo(
+ CMICmnLLDBDebugSessionInfo::Instance());
+ lldb::SBTarget sbTarget = rSessionInfo.GetTarget();
+ switch (eBrkPtType) {
+ case eBreakPoint_ByAddress:
+ m_brkPt = sbTarget.BreakpointCreateByAddress(nAddress);
+ break;
+ case eBreakPoint_ByFileFn: {
+ lldb::SBFileSpecList module; // search in all modules
+ lldb::SBFileSpecList compUnit;
+ compUnit.Append(lldb::SBFileSpec(fileName.c_str()));
+ m_brkPt =
+ sbTarget.BreakpointCreateByName(strFileFn.c_str(), module, compUnit);
+ break;
+ }
+ case eBreakPoint_ByFileLine:
+ m_brkPt = sbTarget.BreakpointCreateByLocation(fileName.c_str(), nFileLine);
+ break;
+ case eBreakPoint_ByName:
+ m_brkPt = sbTarget.BreakpointCreateByName(m_brkName.c_str(), nullptr);
+ break;
+ case eBreakPoint_count:
+ case eBreakPoint_NotDefineYet:
+ case eBreakPoint_Invalid:
+ bOk = MIstatus::failure;
+ break;
+ }
+
+ if (bOk) {
+ if (!m_bBrkPtIsPending && (m_brkPt.GetNumLocations() == 0)) {
+ sbTarget.BreakpointDelete(m_brkPt.GetID());
+ SetError(
+ CMIUtilString::Format(MIRSRC(IDS_CMD_ERR_BRKPT_LOCATION_NOT_FOUND),
+ m_cmdData.strMiCmd.c_str(), m_brkName.c_str()));
+ return MIstatus::failure;
}
- if (bOk)
- {
- if (!m_bBrkPtIsPending && (m_brkPt.GetNumLocations() == 0))
- {
- sbTarget.BreakpointDelete(m_brkPt.GetID());
- SetError(CMIUtilString::Format(MIRSRC(IDS_CMD_ERR_BRKPT_LOCATION_NOT_FOUND), m_cmdData.strMiCmd.c_str(), m_brkName.c_str()));
- return MIstatus::failure;
- }
-
- m_brkPt.SetEnabled(m_bBrkPtEnabled);
- m_brkPt.SetIgnoreCount(m_nBrkPtIgnoreCount);
- if (m_bBrkPtCondition)
- m_brkPt.SetCondition(m_brkPtCondition.c_str());
- if (m_bBrkPtThreadId)
- m_brkPt.SetThreadID(m_nBrkPtThreadId);
- }
-
- // CODETAG_LLDB_BREAKPOINT_CREATION
- // This is in the main thread
- // Record break point information to be by LLDB event handler function
- CMICmnLLDBDebugSessionInfo::SBrkPtInfo sBrkPtInfo;
- if (!rSessionInfo.GetBrkPtInfo(m_brkPt, sBrkPtInfo))
- return MIstatus::failure;
- sBrkPtInfo.m_id = m_brkPt.GetID();
- sBrkPtInfo.m_bDisp = m_bBrkPtIsTemp;
- sBrkPtInfo.m_bEnabled = m_bBrkPtEnabled;
- sBrkPtInfo.m_bHaveArgOptionThreadGrp = m_bHaveArgOptionThreadGrp;
- sBrkPtInfo.m_strOptThrdGrp = m_strArgOptionThreadGrp;
- sBrkPtInfo.m_nTimes = m_brkPt.GetHitCount();
- sBrkPtInfo.m_strOrigLoc = m_brkName;
- sBrkPtInfo.m_nIgnore = m_nBrkPtIgnoreCount;
- sBrkPtInfo.m_bPending = m_bBrkPtIsPending;
- sBrkPtInfo.m_bCondition = m_bBrkPtCondition;
- sBrkPtInfo.m_strCondition = m_brkPtCondition;
- sBrkPtInfo.m_bBrkPtThreadId = m_bBrkPtThreadId;
- sBrkPtInfo.m_nBrkPtThreadId = m_nBrkPtThreadId;
-
- bOk = bOk && rSessionInfo.RecordBrkPtInfo(m_brkPt.GetID(), sBrkPtInfo);
- if (!bOk)
- {
- SetError(CMIUtilString::Format(MIRSRC(IDS_CMD_ERR_BRKPT_INVALID), m_cmdData.strMiCmd.c_str(), m_brkName.c_str()));
- return MIstatus::failure;
- }
-
- // CODETAG_LLDB_BRKPT_ID_MAX
- if (m_brkPt.GetID() > (lldb::break_id_t)rSessionInfo.m_nBrkPointCntMax)
- {
- SetError(CMIUtilString::Format(MIRSRC(IDS_CMD_ERR_BRKPT_CNT_EXCEEDED), m_cmdData.strMiCmd.c_str(), rSessionInfo.m_nBrkPointCntMax,
- m_brkName.c_str()));
- return MIstatus::failure;
- }
-
- return MIstatus::success;
-}
-
-//++ ------------------------------------------------------------------------------------
-// Details: The invoker requires this function. The command prepares a MI Record Result
+ m_brkPt.SetEnabled(m_bBrkPtEnabled);
+ m_brkPt.SetIgnoreCount(m_nBrkPtIgnoreCount);
+ if (m_bBrkPtCondition)
+ m_brkPt.SetCondition(m_brkPtCondition.c_str());
+ if (m_bBrkPtThreadId)
+ m_brkPt.SetThreadID(m_nBrkPtThreadId);
+ }
+
+ // CODETAG_LLDB_BREAKPOINT_CREATION
+ // This is in the main thread
+ // Record break point information to be by LLDB event handler function
+ CMICmnLLDBDebugSessionInfo::SBrkPtInfo sBrkPtInfo;
+ if (!rSessionInfo.GetBrkPtInfo(m_brkPt, sBrkPtInfo))
+ return MIstatus::failure;
+ sBrkPtInfo.m_id = m_brkPt.GetID();
+ sBrkPtInfo.m_bDisp = m_bBrkPtIsTemp;
+ sBrkPtInfo.m_bEnabled = m_bBrkPtEnabled;
+ sBrkPtInfo.m_bHaveArgOptionThreadGrp = m_bHaveArgOptionThreadGrp;
+ sBrkPtInfo.m_strOptThrdGrp = m_strArgOptionThreadGrp;
+ sBrkPtInfo.m_nTimes = m_brkPt.GetHitCount();
+ sBrkPtInfo.m_strOrigLoc = m_brkName;
+ sBrkPtInfo.m_nIgnore = m_nBrkPtIgnoreCount;
+ sBrkPtInfo.m_bPending = m_bBrkPtIsPending;
+ sBrkPtInfo.m_bCondition = m_bBrkPtCondition;
+ sBrkPtInfo.m_strCondition = m_brkPtCondition;
+ sBrkPtInfo.m_bBrkPtThreadId = m_bBrkPtThreadId;
+ sBrkPtInfo.m_nBrkPtThreadId = m_nBrkPtThreadId;
+
+ bOk = bOk && rSessionInfo.RecordBrkPtInfo(m_brkPt.GetID(), sBrkPtInfo);
+ if (!bOk) {
+ SetError(CMIUtilString::Format(MIRSRC(IDS_CMD_ERR_BRKPT_INVALID),
+ m_cmdData.strMiCmd.c_str(),
+ m_brkName.c_str()));
+ return MIstatus::failure;
+ }
+
+ // CODETAG_LLDB_BRKPT_ID_MAX
+ if (m_brkPt.GetID() > (lldb::break_id_t)rSessionInfo.m_nBrkPointCntMax) {
+ SetError(CMIUtilString::Format(
+ MIRSRC(IDS_CMD_ERR_BRKPT_CNT_EXCEEDED), m_cmdData.strMiCmd.c_str(),
+ rSessionInfo.m_nBrkPointCntMax, m_brkName.c_str()));
+ 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.
@@ -320,47 +320,51 @@ CMICmdCmdBreakInsert::Execute()
// MIstatus::failure - Functional failed.
// Throws: None.
//--
-bool
-CMICmdCmdBreakInsert::Acknowledge()
-{
- // Get breakpoint information
- CMICmnLLDBDebugSessionInfo &rSessionInfo(CMICmnLLDBDebugSessionInfo::Instance());
- CMICmnLLDBDebugSessionInfo::SBrkPtInfo sBrkPtInfo;
- if (!rSessionInfo.RecordBrkPtInfoGet(m_brkPt.GetID(), sBrkPtInfo))
- return MIstatus::failure;
-
- // MI print
- // "^done,bkpt={number=\"%d\",type=\"breakpoint\",disp=\"%s\",enabled=\"%c\",addr=\"0x%016" PRIx64 "\",func=\"%s\",file=\"%s\",fullname=\"%s/%s\",line=\"%d\",thread-groups=[\"%s\"],times=\"%d\",original-location=\"%s\"}"
- CMICmnMIValueTuple miValueTuple;
- if (!rSessionInfo.MIResponseFormBrkPtInfo(sBrkPtInfo, miValueTuple))
- return MIstatus::failure;
-
- const CMICmnMIValueResult miValueResultD("bkpt", miValueTuple);
- const CMICmnMIResultRecord miRecordResult(m_cmdData.strMiCmdToken, CMICmnMIResultRecord::eResultClass_Done, miValueResultD);
- m_miResultRecord = miRecordResult;
-
- return MIstatus::success;
-}
-
-//++ ------------------------------------------------------------------------------------
-// Details: Required by the CMICmdFactory when registering *this command. The factory
+bool CMICmdCmdBreakInsert::Acknowledge() {
+ // Get breakpoint information
+ CMICmnLLDBDebugSessionInfo &rSessionInfo(
+ CMICmnLLDBDebugSessionInfo::Instance());
+ CMICmnLLDBDebugSessionInfo::SBrkPtInfo sBrkPtInfo;
+ if (!rSessionInfo.RecordBrkPtInfoGet(m_brkPt.GetID(), sBrkPtInfo))
+ return MIstatus::failure;
+
+ // MI print
+ // "^done,bkpt={number=\"%d\",type=\"breakpoint\",disp=\"%s\",enabled=\"%c\",addr=\"0x%016"
+ // PRIx64
+ // "\",func=\"%s\",file=\"%s\",fullname=\"%s/%s\",line=\"%d\",thread-groups=[\"%s\"],times=\"%d\",original-location=\"%s\"}"
+ CMICmnMIValueTuple miValueTuple;
+ if (!rSessionInfo.MIResponseFormBrkPtInfo(sBrkPtInfo, miValueTuple))
+ return MIstatus::failure;
+
+ const CMICmnMIValueResult miValueResultD("bkpt", miValueTuple);
+ const CMICmnMIResultRecord miRecordResult(
+ m_cmdData.strMiCmdToken, CMICmnMIResultRecord::eResultClass_Done,
+ miValueResultD);
+ 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 *
-CMICmdCmdBreakInsert::CreateSelf()
-{
- return new CMICmdCmdBreakInsert();
+CMICmdBase *CMICmdCmdBreakInsert::CreateSelf() {
+ return new CMICmdCmdBreakInsert();
}
//---------------------------------------------------------------------------------------
//---------------------------------------------------------------------------------------
//---------------------------------------------------------------------------------------
-//++ ------------------------------------------------------------------------------------
+//++
+//------------------------------------------------------------------------------------
// Details: CMICmdCmdBreakDelete constructor.
// Type: Method.
// Args: None.
@@ -368,28 +372,28 @@ CMICmdCmdBreakInsert::CreateSelf()
// Throws: None.
//--
CMICmdCmdBreakDelete::CMICmdCmdBreakDelete()
- : m_constStrArgNamedBrkPt("breakpoint")
-{
- // Command factory matches this name with that received from the stdin stream
- m_strMiCmd = "break-delete";
+ : m_constStrArgNamedBrkPt("breakpoint") {
+ // Command factory matches this name with that received from the stdin stream
+ m_strMiCmd = "break-delete";
- // Required by the CMICmdFactory when registering *this command
- m_pSelfCreatorFn = &CMICmdCmdBreakDelete::CreateSelf;
+ // Required by the CMICmdFactory when registering *this command
+ m_pSelfCreatorFn = &CMICmdCmdBreakDelete::CreateSelf;
}
-//++ ------------------------------------------------------------------------------------
+//++
+//------------------------------------------------------------------------------------
// Details: CMICmdCmdBreakDelete destructor.
// Type: Overrideable.
// Args: None.
// Return: None.
// Throws: None.
//--
-CMICmdCmdBreakDelete::~CMICmdCmdBreakDelete()
-{
-}
+CMICmdCmdBreakDelete::~CMICmdCmdBreakDelete() {}
-//++ ------------------------------------------------------------------------------------
-// Details: The invoker requires this function. The parses the command line options
+//++
+//------------------------------------------------------------------------------------
+// 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.
@@ -397,49 +401,56 @@ CMICmdCmdBreakDelete::~CMICmdCmdBreakDel
// MIstatus::failure - Functional failed.
// Throws: None.
//--
-bool
-CMICmdCmdBreakDelete::ParseArgs()
-{
- m_setCmdArgs.Add(new CMICmdArgValListOfN(m_constStrArgNamedBrkPt, true, true, CMICmdArgValListBase::eArgValType_Number));
- return ParseValidateCmdOptions();
+bool CMICmdCmdBreakDelete::ParseArgs() {
+ m_setCmdArgs.Add(
+ new CMICmdArgValListOfN(m_constStrArgNamedBrkPt, true, true,
+ CMICmdArgValListBase::eArgValType_Number));
+ return ParseValidateCmdOptions();
}
-//++ ------------------------------------------------------------------------------------
-// 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.
+//++
+//------------------------------------------------------------------------------------
+// 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
-CMICmdCmdBreakDelete::Execute()
-{
- CMICMDBASE_GETOPTION(pArgBrkPt, ListOfN, m_constStrArgNamedBrkPt);
-
- // ATM we only handle one break point ID
- MIuint64 nBrk = UINT64_MAX;
- if (!pArgBrkPt->GetExpectedOption<CMICmdArgValNumber, MIuint64>(nBrk))
- {
- SetError(CMIUtilString::Format(MIRSRC(IDS_CMD_ERR_BRKPT_INVALID), m_cmdData.strMiCmd.c_str(), m_constStrArgNamedBrkPt.c_str()));
- return MIstatus::failure;
- }
-
- CMICmnLLDBDebugSessionInfo &rSessionInfo(CMICmnLLDBDebugSessionInfo::Instance());
- const bool bBrkPt = rSessionInfo.GetTarget().BreakpointDelete(static_cast<lldb::break_id_t>(nBrk));
- if (!bBrkPt)
- {
- const CMIUtilString strBrkNum(CMIUtilString::Format("%d", nBrk));
- SetError(CMIUtilString::Format(MIRSRC(IDS_CMD_ERR_BRKPT_INVALID), m_cmdData.strMiCmd.c_str(), strBrkNum.c_str()));
- return MIstatus::failure;
- }
-
- return MIstatus::success;
-}
+bool CMICmdCmdBreakDelete::Execute() {
+ CMICMDBASE_GETOPTION(pArgBrkPt, ListOfN, m_constStrArgNamedBrkPt);
-//++ ------------------------------------------------------------------------------------
-// Details: The invoker requires this function. The command prepares a MI Record Result
+ // ATM we only handle one break point ID
+ MIuint64 nBrk = UINT64_MAX;
+ if (!pArgBrkPt->GetExpectedOption<CMICmdArgValNumber, MIuint64>(nBrk)) {
+ SetError(CMIUtilString::Format(MIRSRC(IDS_CMD_ERR_BRKPT_INVALID),
+ m_cmdData.strMiCmd.c_str(),
+ m_constStrArgNamedBrkPt.c_str()));
+ return MIstatus::failure;
+ }
+
+ CMICmnLLDBDebugSessionInfo &rSessionInfo(
+ CMICmnLLDBDebugSessionInfo::Instance());
+ const bool bBrkPt = rSessionInfo.GetTarget().BreakpointDelete(
+ static_cast<lldb::break_id_t>(nBrk));
+ if (!bBrkPt) {
+ const CMIUtilString strBrkNum(CMIUtilString::Format("%d", nBrk));
+ SetError(CMIUtilString::Format(MIRSRC(IDS_CMD_ERR_BRKPT_INVALID),
+ m_cmdData.strMiCmd.c_str(),
+ strBrkNum.c_str()));
+ 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.
@@ -447,34 +458,34 @@ CMICmdCmdBreakDelete::Execute()
// MIstatus::failure - Functional failed.
// Throws: None.
//--
-bool
-CMICmdCmdBreakDelete::Acknowledge()
-{
- const CMICmnMIResultRecord miRecordResult(m_cmdData.strMiCmdToken, CMICmnMIResultRecord::eResultClass_Done);
- m_miResultRecord = miRecordResult;
-
- return MIstatus::success;
+bool CMICmdCmdBreakDelete::Acknowledge() {
+ const CMICmnMIResultRecord miRecordResult(
+ m_cmdData.strMiCmdToken, CMICmnMIResultRecord::eResultClass_Done);
+ m_miResultRecord = miRecordResult;
+
+ return MIstatus::success;
}
-//++ ------------------------------------------------------------------------------------
-// Details: Required by the CMICmdFactory when registering *this command. The factory
+//++
+//------------------------------------------------------------------------------------
+// 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 *
-CMICmdCmdBreakDelete::CreateSelf()
-{
- return new CMICmdCmdBreakDelete();
+CMICmdBase *CMICmdCmdBreakDelete::CreateSelf() {
+ return new CMICmdCmdBreakDelete();
}
//---------------------------------------------------------------------------------------
//---------------------------------------------------------------------------------------
//---------------------------------------------------------------------------------------
-//++ ------------------------------------------------------------------------------------
+//++
+//------------------------------------------------------------------------------------
// Details: CMICmdCmdBreakDisable constructor.
// Type: Method.
// Args: None.
@@ -482,30 +493,29 @@ CMICmdCmdBreakDelete::CreateSelf()
// Throws: None.
//--
CMICmdCmdBreakDisable::CMICmdCmdBreakDisable()
- : m_constStrArgNamedBrkPt("breakpoint")
- , m_bBrkPtDisabledOk(false)
- , m_nBrkPtId(0)
-{
- // Command factory matches this name with that received from the stdin stream
- m_strMiCmd = "break-disable";
+ : m_constStrArgNamedBrkPt("breakpoint"), m_bBrkPtDisabledOk(false),
+ m_nBrkPtId(0) {
+ // Command factory matches this name with that received from the stdin stream
+ m_strMiCmd = "break-disable";
- // Required by the CMICmdFactory when registering *this command
- m_pSelfCreatorFn = &CMICmdCmdBreakDisable::CreateSelf;
+ // Required by the CMICmdFactory when registering *this command
+ m_pSelfCreatorFn = &CMICmdCmdBreakDisable::CreateSelf;
}
-//++ ------------------------------------------------------------------------------------
+//++
+//------------------------------------------------------------------------------------
// Details: CMICmdCmdBreakDisable destructor.
// Type: Overrideable.
// Args: None.
// Return: None.
// Throws: None.
//--
-CMICmdCmdBreakDisable::~CMICmdCmdBreakDisable()
-{
-}
+CMICmdCmdBreakDisable::~CMICmdCmdBreakDisable() {}
-//++ ------------------------------------------------------------------------------------
-// Details: The invoker requires this function. The parses the command line options
+//++
+//------------------------------------------------------------------------------------
+// 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.
@@ -513,49 +523,54 @@ CMICmdCmdBreakDisable::~CMICmdCmdBreakDi
// MIstatus::failure - Functional failed.
// Throws: None.
//--
-bool
-CMICmdCmdBreakDisable::ParseArgs()
-{
- m_setCmdArgs.Add(new CMICmdArgValListOfN(m_constStrArgNamedBrkPt, true, true, CMICmdArgValListBase::eArgValType_Number));
- return ParseValidateCmdOptions();
+bool CMICmdCmdBreakDisable::ParseArgs() {
+ m_setCmdArgs.Add(
+ new CMICmdArgValListOfN(m_constStrArgNamedBrkPt, true, true,
+ CMICmdArgValListBase::eArgValType_Number));
+ return ParseValidateCmdOptions();
}
-//++ ------------------------------------------------------------------------------------
-// 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.
+//++
+//------------------------------------------------------------------------------------
+// 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
-CMICmdCmdBreakDisable::Execute()
-{
- CMICMDBASE_GETOPTION(pArgBrkPt, ListOfN, m_constStrArgNamedBrkPt);
-
- // ATM we only handle one break point ID
- MIuint64 nBrk = UINT64_MAX;
- if (!pArgBrkPt->GetExpectedOption<CMICmdArgValNumber, MIuint64>(nBrk))
- {
- SetError(CMIUtilString::Format(MIRSRC(IDS_CMD_ERR_BRKPT_INVALID), m_cmdData.strMiCmd.c_str(), m_constStrArgNamedBrkPt.c_str()));
- return MIstatus::failure;
- }
-
- CMICmnLLDBDebugSessionInfo &rSessionInfo(CMICmnLLDBDebugSessionInfo::Instance());
- lldb::SBBreakpoint brkPt = rSessionInfo.GetTarget().FindBreakpointByID(static_cast<lldb::break_id_t>(nBrk));
- if (brkPt.IsValid())
- {
- m_bBrkPtDisabledOk = true;
- brkPt.SetEnabled(false);
- m_nBrkPtId = nBrk;
- }
-
- return MIstatus::success;
-}
+bool CMICmdCmdBreakDisable::Execute() {
+ CMICMDBASE_GETOPTION(pArgBrkPt, ListOfN, m_constStrArgNamedBrkPt);
-//++ ------------------------------------------------------------------------------------
-// Details: The invoker requires this function. The command prepares a MI Record Result
+ // ATM we only handle one break point ID
+ MIuint64 nBrk = UINT64_MAX;
+ if (!pArgBrkPt->GetExpectedOption<CMICmdArgValNumber, MIuint64>(nBrk)) {
+ SetError(CMIUtilString::Format(MIRSRC(IDS_CMD_ERR_BRKPT_INVALID),
+ m_cmdData.strMiCmd.c_str(),
+ m_constStrArgNamedBrkPt.c_str()));
+ return MIstatus::failure;
+ }
+
+ CMICmnLLDBDebugSessionInfo &rSessionInfo(
+ CMICmnLLDBDebugSessionInfo::Instance());
+ lldb::SBBreakpoint brkPt = rSessionInfo.GetTarget().FindBreakpointByID(
+ static_cast<lldb::break_id_t>(nBrk));
+ if (brkPt.IsValid()) {
+ m_bBrkPtDisabledOk = true;
+ brkPt.SetEnabled(false);
+ m_nBrkPtId = nBrk;
+ }
+
+ 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.
@@ -563,44 +578,46 @@ CMICmdCmdBreakDisable::Execute()
// MIstatus::failure - Functional failed.
// Throws: None.
//--
-bool
-CMICmdCmdBreakDisable::Acknowledge()
-{
- if (m_bBrkPtDisabledOk)
- {
- const CMICmnMIResultRecord miRecordResult(m_cmdData.strMiCmdToken, CMICmnMIResultRecord::eResultClass_Done);
- m_miResultRecord = miRecordResult;
- return MIstatus::success;
- }
-
- const CMIUtilString strBrkPtId(CMIUtilString::Format("%d", m_nBrkPtId));
- const CMICmnMIValueConst miValueConst(CMIUtilString::Format(MIRSRC(IDS_CMD_ERR_BRKPT_INVALID), strBrkPtId.c_str()));
- const CMICmnMIValueResult miValueResult("msg", miValueConst);
- const CMICmnMIResultRecord miRecordResult(m_cmdData.strMiCmdToken, CMICmnMIResultRecord::eResultClass_Error, miValueResult);
+bool CMICmdCmdBreakDisable::Acknowledge() {
+ if (m_bBrkPtDisabledOk) {
+ const CMICmnMIResultRecord miRecordResult(
+ m_cmdData.strMiCmdToken, CMICmnMIResultRecord::eResultClass_Done);
m_miResultRecord = miRecordResult;
-
return MIstatus::success;
-}
+ }
-//++ ------------------------------------------------------------------------------------
-// Details: Required by the CMICmdFactory when registering *this command. The factory
+ const CMIUtilString strBrkPtId(CMIUtilString::Format("%d", m_nBrkPtId));
+ const CMICmnMIValueConst miValueConst(CMIUtilString::Format(
+ MIRSRC(IDS_CMD_ERR_BRKPT_INVALID), strBrkPtId.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 *
-CMICmdCmdBreakDisable::CreateSelf()
-{
- return new CMICmdCmdBreakDisable();
+CMICmdBase *CMICmdCmdBreakDisable::CreateSelf() {
+ return new CMICmdCmdBreakDisable();
}
//---------------------------------------------------------------------------------------
//---------------------------------------------------------------------------------------
//---------------------------------------------------------------------------------------
-//++ ------------------------------------------------------------------------------------
+//++
+//------------------------------------------------------------------------------------
// Details: CMICmdCmdBreakEnable constructor.
// Type: Method.
// Args: None.
@@ -608,30 +625,29 @@ CMICmdCmdBreakDisable::CreateSelf()
// Throws: None.
//--
CMICmdCmdBreakEnable::CMICmdCmdBreakEnable()
- : m_constStrArgNamedBrkPt("breakpoint")
- , m_bBrkPtEnabledOk(false)
- , m_nBrkPtId(0)
-{
- // Command factory matches this name with that received from the stdin stream
- m_strMiCmd = "break-enable";
+ : m_constStrArgNamedBrkPt("breakpoint"), m_bBrkPtEnabledOk(false),
+ m_nBrkPtId(0) {
+ // Command factory matches this name with that received from the stdin stream
+ m_strMiCmd = "break-enable";
- // Required by the CMICmdFactory when registering *this command
- m_pSelfCreatorFn = &CMICmdCmdBreakEnable::CreateSelf;
+ // Required by the CMICmdFactory when registering *this command
+ m_pSelfCreatorFn = &CMICmdCmdBreakEnable::CreateSelf;
}
-//++ ------------------------------------------------------------------------------------
+//++
+//------------------------------------------------------------------------------------
// Details: CMICmdCmdBreakEnable destructor.
// Type: Overrideable.
// Args: None.
// Return: None.
// Throws: None.
//--
-CMICmdCmdBreakEnable::~CMICmdCmdBreakEnable()
-{
-}
+CMICmdCmdBreakEnable::~CMICmdCmdBreakEnable() {}
-//++ ------------------------------------------------------------------------------------
-// Details: The invoker requires this function. The parses the command line options
+//++
+//------------------------------------------------------------------------------------
+// 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.
@@ -639,49 +655,54 @@ CMICmdCmdBreakEnable::~CMICmdCmdBreakEna
// MIstatus::failure - Functional failed.
// Throws: None.
//--
-bool
-CMICmdCmdBreakEnable::ParseArgs()
-{
- m_setCmdArgs.Add(new CMICmdArgValListOfN(m_constStrArgNamedBrkPt, true, true, CMICmdArgValListBase::eArgValType_Number));
- return ParseValidateCmdOptions();
+bool CMICmdCmdBreakEnable::ParseArgs() {
+ m_setCmdArgs.Add(
+ new CMICmdArgValListOfN(m_constStrArgNamedBrkPt, true, true,
+ CMICmdArgValListBase::eArgValType_Number));
+ return ParseValidateCmdOptions();
}
-//++ ------------------------------------------------------------------------------------
-// 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.
+//++
+//------------------------------------------------------------------------------------
+// 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
-CMICmdCmdBreakEnable::Execute()
-{
- CMICMDBASE_GETOPTION(pArgBrkPt, ListOfN, m_constStrArgNamedBrkPt);
-
- // ATM we only handle one break point ID
- MIuint64 nBrk = UINT64_MAX;
- if (!pArgBrkPt->GetExpectedOption<CMICmdArgValNumber, MIuint64>(nBrk))
- {
- SetError(CMIUtilString::Format(MIRSRC(IDS_CMD_ERR_BRKPT_INVALID), m_cmdData.strMiCmd.c_str(), m_constStrArgNamedBrkPt.c_str()));
- return MIstatus::failure;
- }
+bool CMICmdCmdBreakEnable::Execute() {
+ CMICMDBASE_GETOPTION(pArgBrkPt, ListOfN, m_constStrArgNamedBrkPt);
- CMICmnLLDBDebugSessionInfo &rSessionInfo(CMICmnLLDBDebugSessionInfo::Instance());
- lldb::SBBreakpoint brkPt = rSessionInfo.GetTarget().FindBreakpointByID(static_cast<lldb::break_id_t>(nBrk));
- if (brkPt.IsValid())
- {
- m_bBrkPtEnabledOk = true;
- brkPt.SetEnabled(true);
- m_nBrkPtId = nBrk;
- }
-
- return MIstatus::success;
-}
-
-//++ ------------------------------------------------------------------------------------
-// Details: The invoker requires this function. The command prepares a MI Record Result
+ // ATM we only handle one break point ID
+ MIuint64 nBrk = UINT64_MAX;
+ if (!pArgBrkPt->GetExpectedOption<CMICmdArgValNumber, MIuint64>(nBrk)) {
+ SetError(CMIUtilString::Format(MIRSRC(IDS_CMD_ERR_BRKPT_INVALID),
+ m_cmdData.strMiCmd.c_str(),
+ m_constStrArgNamedBrkPt.c_str()));
+ return MIstatus::failure;
+ }
+
+ CMICmnLLDBDebugSessionInfo &rSessionInfo(
+ CMICmnLLDBDebugSessionInfo::Instance());
+ lldb::SBBreakpoint brkPt = rSessionInfo.GetTarget().FindBreakpointByID(
+ static_cast<lldb::break_id_t>(nBrk));
+ if (brkPt.IsValid()) {
+ m_bBrkPtEnabledOk = true;
+ brkPt.SetEnabled(true);
+ m_nBrkPtId = nBrk;
+ }
+
+ 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.
@@ -689,44 +710,46 @@ CMICmdCmdBreakEnable::Execute()
// MIstatus::failure - Functional failed.
// Throws: None.
//--
-bool
-CMICmdCmdBreakEnable::Acknowledge()
-{
- if (m_bBrkPtEnabledOk)
- {
- const CMICmnMIResultRecord miRecordResult(m_cmdData.strMiCmdToken, CMICmnMIResultRecord::eResultClass_Done);
- m_miResultRecord = miRecordResult;
- return MIstatus::success;
- }
-
- const CMIUtilString strBrkPtId(CMIUtilString::Format("%d", m_nBrkPtId));
- const CMICmnMIValueConst miValueConst(CMIUtilString::Format(MIRSRC(IDS_CMD_ERR_BRKPT_INVALID), strBrkPtId.c_str()));
- const CMICmnMIValueResult miValueResult("msg", miValueConst);
- const CMICmnMIResultRecord miRecordResult(m_cmdData.strMiCmdToken, CMICmnMIResultRecord::eResultClass_Error, miValueResult);
+bool CMICmdCmdBreakEnable::Acknowledge() {
+ if (m_bBrkPtEnabledOk) {
+ const CMICmnMIResultRecord miRecordResult(
+ m_cmdData.strMiCmdToken, CMICmnMIResultRecord::eResultClass_Done);
m_miResultRecord = miRecordResult;
-
return MIstatus::success;
-}
+ }
-//++ ------------------------------------------------------------------------------------
-// Details: Required by the CMICmdFactory when registering *this command. The factory
+ const CMIUtilString strBrkPtId(CMIUtilString::Format("%d", m_nBrkPtId));
+ const CMICmnMIValueConst miValueConst(CMIUtilString::Format(
+ MIRSRC(IDS_CMD_ERR_BRKPT_INVALID), strBrkPtId.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 *
-CMICmdCmdBreakEnable::CreateSelf()
-{
- return new CMICmdCmdBreakEnable();
+CMICmdBase *CMICmdCmdBreakEnable::CreateSelf() {
+ return new CMICmdCmdBreakEnable();
}
//---------------------------------------------------------------------------------------
//---------------------------------------------------------------------------------------
//---------------------------------------------------------------------------------------
-//++ ------------------------------------------------------------------------------------
+//++
+//------------------------------------------------------------------------------------
// Details: CMICmdCmdBreakAfter constructor.
// Type: Method.
// Args: None.
@@ -734,31 +757,29 @@ CMICmdCmdBreakEnable::CreateSelf()
// Throws: None.
//--
CMICmdCmdBreakAfter::CMICmdCmdBreakAfter()
- : m_constStrArgNamedNumber("number")
- , m_constStrArgNamedCount("count")
- , m_nBrkPtId(0)
- , m_nBrkPtCount(0)
-{
- // Command factory matches this name with that received from the stdin stream
- m_strMiCmd = "break-after";
+ : m_constStrArgNamedNumber("number"), m_constStrArgNamedCount("count"),
+ m_nBrkPtId(0), m_nBrkPtCount(0) {
+ // Command factory matches this name with that received from the stdin stream
+ m_strMiCmd = "break-after";
- // Required by the CMICmdFactory when registering *this command
- m_pSelfCreatorFn = &CMICmdCmdBreakAfter::CreateSelf;
+ // Required by the CMICmdFactory when registering *this command
+ m_pSelfCreatorFn = &CMICmdCmdBreakAfter::CreateSelf;
}
-//++ ------------------------------------------------------------------------------------
+//++
+//------------------------------------------------------------------------------------
// Details: CMICmdCmdBreakAfter destructor.
// Type: Overrideable.
// Args: None.
// Return: None.
// Throws: None.
//--
-CMICmdCmdBreakAfter::~CMICmdCmdBreakAfter()
-{
-}
+CMICmdCmdBreakAfter::~CMICmdCmdBreakAfter() {}
-//++ ------------------------------------------------------------------------------------
-// Details: The invoker requires this function. The parses the command line options
+//++
+//------------------------------------------------------------------------------------
+// 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.
@@ -766,59 +787,63 @@ CMICmdCmdBreakAfter::~CMICmdCmdBreakAfte
// MIstatus::failure - Functional failed.
// Throws: None.
//--
-bool
-CMICmdCmdBreakAfter::ParseArgs()
-{
- m_setCmdArgs.Add(new CMICmdArgValNumber(m_constStrArgNamedNumber, true, true));
- m_setCmdArgs.Add(new CMICmdArgValNumber(m_constStrArgNamedCount, true, true));
- return ParseValidateCmdOptions();
+bool CMICmdCmdBreakAfter::ParseArgs() {
+ m_setCmdArgs.Add(
+ new CMICmdArgValNumber(m_constStrArgNamedNumber, true, true));
+ m_setCmdArgs.Add(new CMICmdArgValNumber(m_constStrArgNamedCount, true, true));
+ return ParseValidateCmdOptions();
}
-//++ ------------------------------------------------------------------------------------
-// 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.
+//++
+//------------------------------------------------------------------------------------
+// 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
-CMICmdCmdBreakAfter::Execute()
-{
- CMICMDBASE_GETOPTION(pArgNumber, Number, m_constStrArgNamedNumber);
- CMICMDBASE_GETOPTION(pArgCount, Number, m_constStrArgNamedCount);
+bool CMICmdCmdBreakAfter::Execute() {
+ CMICMDBASE_GETOPTION(pArgNumber, Number, m_constStrArgNamedNumber);
+ CMICMDBASE_GETOPTION(pArgCount, Number, m_constStrArgNamedCount);
+
+ m_nBrkPtId = pArgNumber->GetValue();
+ m_nBrkPtCount = pArgCount->GetValue();
+
+ CMICmnLLDBDebugSessionInfo &rSessionInfo(
+ CMICmnLLDBDebugSessionInfo::Instance());
+ lldb::SBBreakpoint brkPt = rSessionInfo.GetTarget().FindBreakpointByID(
+ static_cast<lldb::break_id_t>(m_nBrkPtId));
+ if (brkPt.IsValid()) {
+ brkPt.SetIgnoreCount(m_nBrkPtCount);
- m_nBrkPtId = pArgNumber->GetValue();
- m_nBrkPtCount = pArgCount->GetValue();
-
- CMICmnLLDBDebugSessionInfo &rSessionInfo(CMICmnLLDBDebugSessionInfo::Instance());
- lldb::SBBreakpoint brkPt = rSessionInfo.GetTarget().FindBreakpointByID(static_cast<lldb::break_id_t>(m_nBrkPtId));
- if (brkPt.IsValid())
- {
- brkPt.SetIgnoreCount(m_nBrkPtCount);
-
- CMICmnLLDBDebugSessionInfo::SBrkPtInfo sBrkPtInfo;
- if (!rSessionInfo.RecordBrkPtInfoGet(m_nBrkPtId, sBrkPtInfo))
- {
- SetError(CMIUtilString::Format(MIRSRC(IDS_CMD_ERR_BRKPT_INFO_OBJ_NOT_FOUND), m_cmdData.strMiCmd.c_str(), m_nBrkPtId));
- return MIstatus::failure;
- }
- sBrkPtInfo.m_nIgnore = m_nBrkPtCount;
- rSessionInfo.RecordBrkPtInfo(m_nBrkPtId, sBrkPtInfo);
- }
- else
- {
- const CMIUtilString strBrkPtId(CMIUtilString::Format("%d", m_nBrkPtId));
- SetError(CMIUtilString::Format(MIRSRC(IDS_CMD_ERR_BRKPT_INVALID), m_cmdData.strMiCmd.c_str(), strBrkPtId.c_str()));
- return MIstatus::failure;
- }
-
- return MIstatus::success;
+ CMICmnLLDBDebugSessionInfo::SBrkPtInfo sBrkPtInfo;
+ if (!rSessionInfo.RecordBrkPtInfoGet(m_nBrkPtId, sBrkPtInfo)) {
+ SetError(
+ CMIUtilString::Format(MIRSRC(IDS_CMD_ERR_BRKPT_INFO_OBJ_NOT_FOUND),
+ m_cmdData.strMiCmd.c_str(), m_nBrkPtId));
+ return MIstatus::failure;
+ }
+ sBrkPtInfo.m_nIgnore = m_nBrkPtCount;
+ rSessionInfo.RecordBrkPtInfo(m_nBrkPtId, sBrkPtInfo);
+ } else {
+ const CMIUtilString strBrkPtId(CMIUtilString::Format("%d", m_nBrkPtId));
+ SetError(CMIUtilString::Format(MIRSRC(IDS_CMD_ERR_BRKPT_INVALID),
+ m_cmdData.strMiCmd.c_str(),
+ strBrkPtId.c_str()));
+ return MIstatus::failure;
+ }
+
+ return MIstatus::success;
}
-//++ ------------------------------------------------------------------------------------
-// Details: The invoker requires this function. The command prepares a MI Record Result
+//++
+//------------------------------------------------------------------------------------
+// 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.
@@ -826,34 +851,34 @@ CMICmdCmdBreakAfter::Execute()
// MIstatus::failure - Functional failed.
// Throws: None.
//--
-bool
-CMICmdCmdBreakAfter::Acknowledge()
-{
- const CMICmnMIResultRecord miRecordResult(m_cmdData.strMiCmdToken, CMICmnMIResultRecord::eResultClass_Done);
- m_miResultRecord = miRecordResult;
-
- return MIstatus::success;
+bool CMICmdCmdBreakAfter::Acknowledge() {
+ const CMICmnMIResultRecord miRecordResult(
+ m_cmdData.strMiCmdToken, CMICmnMIResultRecord::eResultClass_Done);
+ m_miResultRecord = miRecordResult;
+
+ return MIstatus::success;
}
-//++ ------------------------------------------------------------------------------------
-// Details: Required by the CMICmdFactory when registering *this command. The factory
+//++
+//------------------------------------------------------------------------------------
+// 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 *
-CMICmdCmdBreakAfter::CreateSelf()
-{
- return new CMICmdCmdBreakAfter();
+CMICmdBase *CMICmdCmdBreakAfter::CreateSelf() {
+ return new CMICmdCmdBreakAfter();
}
//---------------------------------------------------------------------------------------
//---------------------------------------------------------------------------------------
//---------------------------------------------------------------------------------------
-//++ ------------------------------------------------------------------------------------
+//++
+//------------------------------------------------------------------------------------
// Details: CMICmdCmdBreakCondition constructor.
// Type: Method.
// Args: None.
@@ -861,32 +886,34 @@ CMICmdCmdBreakAfter::CreateSelf()
// Throws: None.
//--
CMICmdCmdBreakCondition::CMICmdCmdBreakCondition()
- : m_constStrArgNamedNumber("number")
- , m_constStrArgNamedExpr("expr")
- , m_constStrArgNamedExprNoQuotes(
- "expression not surround by quotes") // Not specified in MI spec, we need to handle expressions not surrounded by quotes
- , m_nBrkPtId(0)
-{
- // Command factory matches this name with that received from the stdin stream
- m_strMiCmd = "break-condition";
+ : m_constStrArgNamedNumber("number"), m_constStrArgNamedExpr("expr"),
+ m_constStrArgNamedExprNoQuotes(
+ "expression not surround by quotes") // Not specified in MI spec, we
+ // need to handle expressions not
+ // surrounded by quotes
+ ,
+ m_nBrkPtId(0) {
+ // Command factory matches this name with that received from the stdin stream
+ m_strMiCmd = "break-condition";
- // Required by the CMICmdFactory when registering *this command
- m_pSelfCreatorFn = &CMICmdCmdBreakCondition::CreateSelf;
+ // Required by the CMICmdFactory when registering *this command
+ m_pSelfCreatorFn = &CMICmdCmdBreakCondition::CreateSelf;
}
-//++ ------------------------------------------------------------------------------------
+//++
+//------------------------------------------------------------------------------------
// Details: CMICmdCmdBreakCondition destructor.
// Type: Overrideable.
// Args: None.
// Return: None.
// Throws: None.
//--
-CMICmdCmdBreakCondition::~CMICmdCmdBreakCondition()
-{
-}
+CMICmdCmdBreakCondition::~CMICmdCmdBreakCondition() {}
-//++ ------------------------------------------------------------------------------------
-// Details: The invoker requires this function. The parses the command line options
+//++
+//------------------------------------------------------------------------------------
+// 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.
@@ -894,62 +921,68 @@ CMICmdCmdBreakCondition::~CMICmdCmdBreak
// MIstatus::failure - Functional failed.
// Throws: None.
//--
-bool
-CMICmdCmdBreakCondition::ParseArgs()
-{
- m_setCmdArgs.Add(new CMICmdArgValNumber(m_constStrArgNamedNumber, true, true));
- m_setCmdArgs.Add(new CMICmdArgValString(m_constStrArgNamedExpr, true, true, true, true));
- m_setCmdArgs.Add(new CMICmdArgValListOfN(m_constStrArgNamedExprNoQuotes, false, false,
- CMICmdArgValListBase::eArgValType_StringQuotedNumber));
- return ParseValidateCmdOptions();
-}
-
-//++ ------------------------------------------------------------------------------------
-// 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.
+bool CMICmdCmdBreakCondition::ParseArgs() {
+ m_setCmdArgs.Add(
+ new CMICmdArgValNumber(m_constStrArgNamedNumber, true, true));
+ m_setCmdArgs.Add(
+ new CMICmdArgValString(m_constStrArgNamedExpr, true, true, true, true));
+ m_setCmdArgs.Add(new CMICmdArgValListOfN(
+ m_constStrArgNamedExprNoQuotes, false, false,
+ CMICmdArgValListBase::eArgValType_StringQuotedNumber));
+ return ParseValidateCmdOptions();
+}
+
+//++
+//------------------------------------------------------------------------------------
+// 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
-CMICmdCmdBreakCondition::Execute()
-{
- CMICMDBASE_GETOPTION(pArgNumber, Number, m_constStrArgNamedNumber);
- CMICMDBASE_GETOPTION(pArgExpr, String, m_constStrArgNamedExpr);
-
- m_nBrkPtId = pArgNumber->GetValue();
- m_strBrkPtExpr = pArgExpr->GetValue();
- m_strBrkPtExpr += GetRestOfExpressionNotSurroundedInQuotes();
-
- CMICmnLLDBDebugSessionInfo &rSessionInfo(CMICmnLLDBDebugSessionInfo::Instance());
- lldb::SBBreakpoint brkPt = rSessionInfo.GetTarget().FindBreakpointByID(static_cast<lldb::break_id_t>(m_nBrkPtId));
- if (brkPt.IsValid())
- {
- brkPt.SetCondition(m_strBrkPtExpr.c_str());
-
- CMICmnLLDBDebugSessionInfo::SBrkPtInfo sBrkPtInfo;
- if (!rSessionInfo.RecordBrkPtInfoGet(m_nBrkPtId, sBrkPtInfo))
- {
- SetError(CMIUtilString::Format(MIRSRC(IDS_CMD_ERR_BRKPT_INFO_OBJ_NOT_FOUND), m_cmdData.strMiCmd.c_str(), m_nBrkPtId));
- return MIstatus::failure;
- }
- sBrkPtInfo.m_strCondition = m_strBrkPtExpr;
- rSessionInfo.RecordBrkPtInfo(m_nBrkPtId, sBrkPtInfo);
- }
- else
- {
- const CMIUtilString strBrkPtId(CMIUtilString::Format("%d", m_nBrkPtId));
- SetError(CMIUtilString::Format(MIRSRC(IDS_CMD_ERR_BRKPT_INVALID), m_cmdData.strMiCmd.c_str(), strBrkPtId.c_str()));
- return MIstatus::failure;
- }
+bool CMICmdCmdBreakCondition::Execute() {
+ CMICMDBASE_GETOPTION(pArgNumber, Number, m_constStrArgNamedNumber);
+ CMICMDBASE_GETOPTION(pArgExpr, String, m_constStrArgNamedExpr);
+
+ m_nBrkPtId = pArgNumber->GetValue();
+ m_strBrkPtExpr = pArgExpr->GetValue();
+ m_strBrkPtExpr += GetRestOfExpressionNotSurroundedInQuotes();
+
+ CMICmnLLDBDebugSessionInfo &rSessionInfo(
+ CMICmnLLDBDebugSessionInfo::Instance());
+ lldb::SBBreakpoint brkPt = rSessionInfo.GetTarget().FindBreakpointByID(
+ static_cast<lldb::break_id_t>(m_nBrkPtId));
+ if (brkPt.IsValid()) {
+ brkPt.SetCondition(m_strBrkPtExpr.c_str());
- return MIstatus::success;
+ CMICmnLLDBDebugSessionInfo::SBrkPtInfo sBrkPtInfo;
+ if (!rSessionInfo.RecordBrkPtInfoGet(m_nBrkPtId, sBrkPtInfo)) {
+ SetError(
+ CMIUtilString::Format(MIRSRC(IDS_CMD_ERR_BRKPT_INFO_OBJ_NOT_FOUND),
+ m_cmdData.strMiCmd.c_str(), m_nBrkPtId));
+ return MIstatus::failure;
+ }
+ sBrkPtInfo.m_strCondition = m_strBrkPtExpr;
+ rSessionInfo.RecordBrkPtInfo(m_nBrkPtId, sBrkPtInfo);
+ } else {
+ const CMIUtilString strBrkPtId(CMIUtilString::Format("%d", m_nBrkPtId));
+ SetError(CMIUtilString::Format(MIRSRC(IDS_CMD_ERR_BRKPT_INVALID),
+ m_cmdData.strMiCmd.c_str(),
+ strBrkPtId.c_str()));
+ return MIstatus::failure;
+ }
+
+ return MIstatus::success;
}
-//++ ------------------------------------------------------------------------------------
-// Details: The invoker requires this function. The command prepares a MI Record Result
+//++
+//------------------------------------------------------------------------------------
+// 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.
@@ -957,39 +990,43 @@ CMICmdCmdBreakCondition::Execute()
// MIstatus::failure - Functional failed.
// Throws: None.
//--
-bool
-CMICmdCmdBreakCondition::Acknowledge()
-{
- const CMICmnMIResultRecord miRecordResult(m_cmdData.strMiCmdToken, CMICmnMIResultRecord::eResultClass_Done);
- m_miResultRecord = miRecordResult;
-
- return MIstatus::success;
+bool CMICmdCmdBreakCondition::Acknowledge() {
+ const CMICmnMIResultRecord miRecordResult(
+ m_cmdData.strMiCmdToken, CMICmnMIResultRecord::eResultClass_Done);
+ m_miResultRecord = miRecordResult;
+
+ return MIstatus::success;
}
-//++ ------------------------------------------------------------------------------------
-// Details: Required by the CMICmdFactory when registering *this command. The factory
+//++
+//------------------------------------------------------------------------------------
+// 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 *
-CMICmdCmdBreakCondition::CreateSelf()
-{
- return new CMICmdCmdBreakCondition();
+CMICmdBase *CMICmdCmdBreakCondition::CreateSelf() {
+ return new CMICmdCmdBreakCondition();
}
-//++ ------------------------------------------------------------------------------------
+//++
+//------------------------------------------------------------------------------------
// Details: A breakpoint expression can be passed to *this command as:
// a single string i.e. '2' -> ok.
// a quoted string i.e. "a > 100" -> ok
// a non quoted string i.e. 'a > 100' -> not ok
-// CMICmdArgValString only extracts the first space separated string, the "a".
-// This function using the optional argument type CMICmdArgValListOfN collects
-// the rest of the expression so that is may be added to the 'a' part to form a
+// CMICmdArgValString only extracts the first space separated string,
+// the "a".
+// This function using the optional argument type CMICmdArgValListOfN
+// collects
+// the rest of the expression so that is may be added to the 'a' part
+// to form a
// complete expression string i.e. "a > 100".
-// If the expression value was guaranteed to be surrounded by quotes them this
+// If the expression value was guaranteed to be surrounded by quotes
+// them this
// function would not be necessary.
// Type: Method.
// Args: None.
@@ -997,30 +1034,31 @@ CMICmdCmdBreakCondition::CreateSelf()
// Throws: None.
//--
CMIUtilString
-CMICmdCmdBreakCondition::GetRestOfExpressionNotSurroundedInQuotes()
-{
- CMIUtilString strExpression;
-
- CMICmdArgValListOfN *pArgExprNoQuotes = CMICmdBase::GetOption<CMICmdArgValListOfN>(m_constStrArgNamedExprNoQuotes);
- if (pArgExprNoQuotes != nullptr)
- {
- const CMICmdArgValListBase::VecArgObjPtr_t &rVecExprParts(pArgExprNoQuotes->GetExpectedOptions());
- if (!rVecExprParts.empty())
- {
- CMICmdArgValListBase::VecArgObjPtr_t::const_iterator it = rVecExprParts.begin();
- while (it != rVecExprParts.end())
- {
- const CMICmdArgValString *pPartExpr = static_cast<CMICmdArgValString *>(*it);
- const CMIUtilString &rPartExpr = pPartExpr->GetValue();
- strExpression += " ";
- strExpression += rPartExpr;
-
- // Next
- ++it;
- }
- strExpression = strExpression.Trim();
- }
+CMICmdCmdBreakCondition::GetRestOfExpressionNotSurroundedInQuotes() {
+ CMIUtilString strExpression;
+
+ CMICmdArgValListOfN *pArgExprNoQuotes =
+ CMICmdBase::GetOption<CMICmdArgValListOfN>(
+ m_constStrArgNamedExprNoQuotes);
+ if (pArgExprNoQuotes != nullptr) {
+ const CMICmdArgValListBase::VecArgObjPtr_t &rVecExprParts(
+ pArgExprNoQuotes->GetExpectedOptions());
+ if (!rVecExprParts.empty()) {
+ CMICmdArgValListBase::VecArgObjPtr_t::const_iterator it =
+ rVecExprParts.begin();
+ while (it != rVecExprParts.end()) {
+ const CMICmdArgValString *pPartExpr =
+ static_cast<CMICmdArgValString *>(*it);
+ const CMIUtilString &rPartExpr = pPartExpr->GetValue();
+ strExpression += " ";
+ strExpression += rPartExpr;
+
+ // Next
+ ++it;
+ }
+ strExpression = strExpression.Trim();
}
+ }
- return strExpression;
+ return strExpression;
}
Modified: lldb/trunk/tools/lldb-mi/MICmdCmdBreak.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/lldb-mi/MICmdCmdBreak.h?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/tools/lldb-mi/MICmdCmdBreak.h (original)
+++ lldb/trunk/tools/lldb-mi/MICmdCmdBreak.h Tue Sep 6 15:57:50 2016
@@ -14,13 +14,16 @@
// CMICmdCmdBreakAfter interface.
// CMICmdCmdBreakCondition 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 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
+// For an introduction to adding a new command see
+// CMICmdCmdSupportInfoMiCmdQuery
// command class as an example.
#pragma once
@@ -31,228 +34,230 @@
// In-house headers:
#include "MICmdBase.h"
-//++ ============================================================================
+//++
+//============================================================================
// Details: MI command class. MI commands derived from the command base class.
// *this class implements MI command "break-insert".
// This command does not follow the MI documentation exactly.
//--
-class CMICmdCmdBreakInsert : public CMICmdBase
-{
- // Statics:
- public:
- // Required by the CMICmdFactory when registering *this command
- static CMICmdBase *CreateSelf();
-
- // Methods:
- public:
- /* ctor */ CMICmdCmdBreakInsert();
-
- // Overridden:
- public:
- // From CMICmdInvoker::ICmd
- bool Execute() override;
- bool Acknowledge() override;
- bool ParseArgs() override;
- // From CMICmnBase
- /* dtor */ ~CMICmdCmdBreakInsert() override;
-
- // Enumerations:
- private:
- //++ ===================================================================
- // Details: The type of break point give in the MI command text.
- //--
- enum BreakPoint_e
- {
- eBreakPoint_Invalid = 0,
- eBreakPoint_ByFileLine,
- eBreakPoint_ByFileFn,
- eBreakPoint_ByName,
- eBreakPoint_ByAddress,
- eBreakPoint_count,
- eBreakPoint_NotDefineYet
- };
-
- // Attributes:
- private:
- bool m_bBrkPtIsTemp;
- bool m_bHaveArgOptionThreadGrp;
- CMIUtilString m_brkName;
- CMIUtilString m_strArgOptionThreadGrp;
- lldb::SBBreakpoint m_brkPt;
- bool m_bBrkPtIsPending;
- MIuint m_nBrkPtIgnoreCount;
- bool m_bBrkPtEnabled;
- bool m_bBrkPtCondition;
- CMIUtilString m_brkPtCondition;
- bool m_bBrkPtThreadId;
- MIuint m_nBrkPtThreadId;
- const CMIUtilString m_constStrArgNamedTempBrkPt;
- const CMIUtilString m_constStrArgNamedHWBrkPt; // Not handled by *this command
- const CMIUtilString m_constStrArgNamedPendinfBrkPt;
- const CMIUtilString m_constStrArgNamedDisableBrkPt;
- const CMIUtilString m_constStrArgNamedTracePt; // Not handled by *this command
- const CMIUtilString m_constStrArgNamedConditionalBrkPt;
- const CMIUtilString m_constStrArgNamedInoreCnt;
- const CMIUtilString m_constStrArgNamedRestrictBrkPtToThreadId;
- const CMIUtilString m_constStrArgNamedLocation;
+class CMICmdCmdBreakInsert : public CMICmdBase {
+ // Statics:
+public:
+ // Required by the CMICmdFactory when registering *this command
+ static CMICmdBase *CreateSelf();
+
+ // Methods:
+public:
+ /* ctor */ CMICmdCmdBreakInsert();
+
+ // Overridden:
+public:
+ // From CMICmdInvoker::ICmd
+ bool Execute() override;
+ bool Acknowledge() override;
+ bool ParseArgs() override;
+ // From CMICmnBase
+ /* dtor */ ~CMICmdCmdBreakInsert() override;
+
+ // Enumerations:
+private:
+ //++ ===================================================================
+ // Details: The type of break point give in the MI command text.
+ //--
+ enum BreakPoint_e {
+ eBreakPoint_Invalid = 0,
+ eBreakPoint_ByFileLine,
+ eBreakPoint_ByFileFn,
+ eBreakPoint_ByName,
+ eBreakPoint_ByAddress,
+ eBreakPoint_count,
+ eBreakPoint_NotDefineYet
+ };
+
+ // Attributes:
+private:
+ bool m_bBrkPtIsTemp;
+ bool m_bHaveArgOptionThreadGrp;
+ CMIUtilString m_brkName;
+ CMIUtilString m_strArgOptionThreadGrp;
+ lldb::SBBreakpoint m_brkPt;
+ bool m_bBrkPtIsPending;
+ MIuint m_nBrkPtIgnoreCount;
+ bool m_bBrkPtEnabled;
+ bool m_bBrkPtCondition;
+ CMIUtilString m_brkPtCondition;
+ bool m_bBrkPtThreadId;
+ MIuint m_nBrkPtThreadId;
+ const CMIUtilString m_constStrArgNamedTempBrkPt;
+ const CMIUtilString m_constStrArgNamedHWBrkPt; // Not handled by *this command
+ const CMIUtilString m_constStrArgNamedPendinfBrkPt;
+ const CMIUtilString m_constStrArgNamedDisableBrkPt;
+ const CMIUtilString m_constStrArgNamedTracePt; // Not handled by *this command
+ const CMIUtilString m_constStrArgNamedConditionalBrkPt;
+ const CMIUtilString m_constStrArgNamedInoreCnt;
+ const CMIUtilString m_constStrArgNamedRestrictBrkPtToThreadId;
+ const CMIUtilString m_constStrArgNamedLocation;
};
-//++ ============================================================================
+//++
+//============================================================================
// Details: MI command class. MI commands derived from the command base class.
// *this class implements MI command "break-delete".
//--
-class CMICmdCmdBreakDelete : public CMICmdBase
-{
- // Statics:
- public:
- // Required by the CMICmdFactory when registering *this command
- static CMICmdBase *CreateSelf();
-
- // Methods:
- public:
- /* ctor */ CMICmdCmdBreakDelete();
-
- // Overridden:
- public:
- // From CMICmdInvoker::ICmd
- bool Execute() override;
- bool Acknowledge() override;
- bool ParseArgs() override;
- // From CMICmnBase
- /* dtor */ ~CMICmdCmdBreakDelete() override;
-
- // Attributes:
- private:
- const CMIUtilString m_constStrArgNamedBrkPt;
+class CMICmdCmdBreakDelete : public CMICmdBase {
+ // Statics:
+public:
+ // Required by the CMICmdFactory when registering *this command
+ static CMICmdBase *CreateSelf();
+
+ // Methods:
+public:
+ /* ctor */ CMICmdCmdBreakDelete();
+
+ // Overridden:
+public:
+ // From CMICmdInvoker::ICmd
+ bool Execute() override;
+ bool Acknowledge() override;
+ bool ParseArgs() override;
+ // From CMICmnBase
+ /* dtor */ ~CMICmdCmdBreakDelete() override;
+
+ // Attributes:
+private:
+ const CMIUtilString m_constStrArgNamedBrkPt;
};
-//++ ============================================================================
+//++
+//============================================================================
// Details: MI command class. MI commands derived from the command base class.
// *this class implements MI command "break-disable".
//--
-class CMICmdCmdBreakDisable : public CMICmdBase
-{
- // Statics:
- public:
- // Required by the CMICmdFactory when registering *this command
- static CMICmdBase *CreateSelf();
-
- // Methods:
- public:
- /* ctor */ CMICmdCmdBreakDisable();
-
- // Overridden:
- public:
- // From CMICmdInvoker::ICmd
- bool Execute() override;
- bool Acknowledge() override;
- bool ParseArgs() override;
- // From CMICmnBase
- /* dtor */ ~CMICmdCmdBreakDisable() override;
-
- // Attributes:
- private:
- const CMIUtilString m_constStrArgNamedBrkPt;
- bool m_bBrkPtDisabledOk;
- MIuint m_nBrkPtId;
+class CMICmdCmdBreakDisable : public CMICmdBase {
+ // Statics:
+public:
+ // Required by the CMICmdFactory when registering *this command
+ static CMICmdBase *CreateSelf();
+
+ // Methods:
+public:
+ /* ctor */ CMICmdCmdBreakDisable();
+
+ // Overridden:
+public:
+ // From CMICmdInvoker::ICmd
+ bool Execute() override;
+ bool Acknowledge() override;
+ bool ParseArgs() override;
+ // From CMICmnBase
+ /* dtor */ ~CMICmdCmdBreakDisable() override;
+
+ // Attributes:
+private:
+ const CMIUtilString m_constStrArgNamedBrkPt;
+ bool m_bBrkPtDisabledOk;
+ MIuint m_nBrkPtId;
};
-//++ ============================================================================
+//++
+//============================================================================
// Details: MI command class. MI commands derived from the command base class.
// *this class implements MI command "break-enable".
//--
-class CMICmdCmdBreakEnable : public CMICmdBase
-{
- // Statics:
- public:
- // Required by the CMICmdFactory when registering *this command
- static CMICmdBase *CreateSelf();
-
- // Methods:
- public:
- /* ctor */ CMICmdCmdBreakEnable();
-
- // Overridden:
- public:
- // From CMICmdInvoker::ICmd
- bool Execute() override;
- bool Acknowledge() override;
- bool ParseArgs() override;
- // From CMICmnBase
- /* dtor */ ~CMICmdCmdBreakEnable() override;
-
- // Attributes:
- private:
- const CMIUtilString m_constStrArgNamedBrkPt;
- bool m_bBrkPtEnabledOk;
- MIuint m_nBrkPtId;
+class CMICmdCmdBreakEnable : public CMICmdBase {
+ // Statics:
+public:
+ // Required by the CMICmdFactory when registering *this command
+ static CMICmdBase *CreateSelf();
+
+ // Methods:
+public:
+ /* ctor */ CMICmdCmdBreakEnable();
+
+ // Overridden:
+public:
+ // From CMICmdInvoker::ICmd
+ bool Execute() override;
+ bool Acknowledge() override;
+ bool ParseArgs() override;
+ // From CMICmnBase
+ /* dtor */ ~CMICmdCmdBreakEnable() override;
+
+ // Attributes:
+private:
+ const CMIUtilString m_constStrArgNamedBrkPt;
+ bool m_bBrkPtEnabledOk;
+ MIuint m_nBrkPtId;
};
-//++ ============================================================================
+//++
+//============================================================================
// Details: MI command class. MI commands derived from the command base class.
// *this class implements MI command "break-after".
//--
-class CMICmdCmdBreakAfter : public CMICmdBase
-{
- // Statics:
- public:
- // Required by the CMICmdFactory when registering *this command
- static CMICmdBase *CreateSelf();
-
- // Methods:
- public:
- /* ctor */ CMICmdCmdBreakAfter();
-
- // Overridden:
- public:
- // From CMICmdInvoker::ICmd
- bool Execute() override;
- bool Acknowledge() override;
- bool ParseArgs() override;
- // From CMICmnBase
- /* dtor */ ~CMICmdCmdBreakAfter() override;
-
- // Attributes:
- private:
- const CMIUtilString m_constStrArgNamedNumber;
- const CMIUtilString m_constStrArgNamedCount;
- MIuint m_nBrkPtId;
- MIuint m_nBrkPtCount;
+class CMICmdCmdBreakAfter : public CMICmdBase {
+ // Statics:
+public:
+ // Required by the CMICmdFactory when registering *this command
+ static CMICmdBase *CreateSelf();
+
+ // Methods:
+public:
+ /* ctor */ CMICmdCmdBreakAfter();
+
+ // Overridden:
+public:
+ // From CMICmdInvoker::ICmd
+ bool Execute() override;
+ bool Acknowledge() override;
+ bool ParseArgs() override;
+ // From CMICmnBase
+ /* dtor */ ~CMICmdCmdBreakAfter() override;
+
+ // Attributes:
+private:
+ const CMIUtilString m_constStrArgNamedNumber;
+ const CMIUtilString m_constStrArgNamedCount;
+ MIuint m_nBrkPtId;
+ MIuint m_nBrkPtCount;
};
-//++ ============================================================================
+//++
+//============================================================================
// Details: MI command class. MI commands derived from the command base class.
// *this class implements MI command "break-condition".
//--
-class CMICmdCmdBreakCondition : public CMICmdBase
-{
- // Statics:
- public:
- // Required by the CMICmdFactory when registering *this command
- static CMICmdBase *CreateSelf();
-
- // Methods:
- public:
- /* ctor */ CMICmdCmdBreakCondition();
-
- // Overridden:
- public:
- // From CMICmdInvoker::ICmd
- bool Execute() override;
- bool Acknowledge() override;
- bool ParseArgs() override;
- // From CMICmnBase
- /* dtor */ ~CMICmdCmdBreakCondition() override;
-
- // Methods:
- private:
- CMIUtilString GetRestOfExpressionNotSurroundedInQuotes();
-
- // Attributes:
- private:
- const CMIUtilString m_constStrArgNamedNumber;
- const CMIUtilString m_constStrArgNamedExpr;
- const CMIUtilString m_constStrArgNamedExprNoQuotes; // Not specified in MI spec, we need to handle expressions not surrounded by quotes
- MIuint m_nBrkPtId;
- CMIUtilString m_strBrkPtExpr;
+class CMICmdCmdBreakCondition : public CMICmdBase {
+ // Statics:
+public:
+ // Required by the CMICmdFactory when registering *this command
+ static CMICmdBase *CreateSelf();
+
+ // Methods:
+public:
+ /* ctor */ CMICmdCmdBreakCondition();
+
+ // Overridden:
+public:
+ // From CMICmdInvoker::ICmd
+ bool Execute() override;
+ bool Acknowledge() override;
+ bool ParseArgs() override;
+ // From CMICmnBase
+ /* dtor */ ~CMICmdCmdBreakCondition() override;
+
+ // Methods:
+private:
+ CMIUtilString GetRestOfExpressionNotSurroundedInQuotes();
+
+ // Attributes:
+private:
+ const CMIUtilString m_constStrArgNamedNumber;
+ const CMIUtilString m_constStrArgNamedExpr;
+ const CMIUtilString m_constStrArgNamedExprNoQuotes; // Not specified in MI
+ // spec, we need to handle
+ // expressions not
+ // surrounded by quotes
+ MIuint m_nBrkPtId;
+ CMIUtilString m_strBrkPtExpr;
};
Modified: lldb/trunk/tools/lldb-mi/MICmdCmdData.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/lldb-mi/MICmdCmdData.cpp?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/tools/lldb-mi/MICmdCmdData.cpp (original)
+++ lldb/trunk/tools/lldb-mi/MICmdCmdData.cpp Tue Sep 6 15:57:50 2016
@@ -19,34 +19,35 @@
// CMICmdCmdDataInfoLine implementation.
// Third Party Headers:
-#include <inttypes.h> // For PRIx64
#include "lldb/API/SBCommandInterpreter.h"
-#include "lldb/API/SBThread.h"
#include "lldb/API/SBInstruction.h"
#include "lldb/API/SBInstructionList.h"
#include "lldb/API/SBStream.h"
+#include "lldb/API/SBThread.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/Support/Regex.h"
+#include <inttypes.h> // For PRIx64
// In-house headers:
-#include "MICmdCmdData.h"
-#include "MICmnMIResultRecord.h"
-#include "MICmnMIValueConst.h"
-#include "MICmnLLDBDebugger.h"
-#include "MICmnLLDBDebugSessionInfo.h"
-#include "MICmnLLDBProxySBValue.h"
+#include "MICmdArgValConsume.h"
+#include "MICmdArgValListOfN.h"
#include "MICmdArgValNumber.h"
-#include "MICmdArgValString.h"
-#include "MICmdArgValThreadGrp.h"
#include "MICmdArgValOptionLong.h"
#include "MICmdArgValOptionShort.h"
-#include "MICmdArgValListOfN.h"
-#include "MICmdArgValConsume.h"
+#include "MICmdArgValString.h"
+#include "MICmdArgValThreadGrp.h"
+#include "MICmdCmdData.h"
+#include "MICmnLLDBDebugSessionInfo.h"
#include "MICmnLLDBDebugSessionInfoVarObj.h"
+#include "MICmnLLDBDebugger.h"
+#include "MICmnLLDBProxySBValue.h"
#include "MICmnLLDBUtilSBValue.h"
+#include "MICmnMIResultRecord.h"
+#include "MICmnMIValueConst.h"
-//++ ------------------------------------------------------------------------------------
+//++
+//------------------------------------------------------------------------------------
// Details: CMICmdCmdDataEvaluateExpression constructor.
// Type: Method.
// Args: None.
@@ -54,33 +55,30 @@
// Throws: None.
//--
CMICmdCmdDataEvaluateExpression::CMICmdCmdDataEvaluateExpression()
- : m_bExpressionValid(true)
- , m_bEvaluatedExpression(true)
- , m_strValue("??")
- , m_bFoundInvalidChar(false)
- , m_cExpressionInvalidChar(0x00)
- , m_constStrArgExpr("expr")
-{
- // Command factory matches this name with that received from the stdin stream
- m_strMiCmd = "data-evaluate-expression";
+ : m_bExpressionValid(true), m_bEvaluatedExpression(true), m_strValue("??"),
+ m_bFoundInvalidChar(false), m_cExpressionInvalidChar(0x00),
+ m_constStrArgExpr("expr") {
+ // Command factory matches this name with that received from the stdin stream
+ m_strMiCmd = "data-evaluate-expression";
- // Required by the CMICmdFactory when registering *this command
- m_pSelfCreatorFn = &CMICmdCmdDataEvaluateExpression::CreateSelf;
+ // Required by the CMICmdFactory when registering *this command
+ m_pSelfCreatorFn = &CMICmdCmdDataEvaluateExpression::CreateSelf;
}
-//++ ------------------------------------------------------------------------------------
+//++
+//------------------------------------------------------------------------------------
// Details: CMICmdCmdDataEvaluateExpression destructor.
// Type: Overrideable.
// Args: None.
// Return: None.
// Throws: None.
//--
-CMICmdCmdDataEvaluateExpression::~CMICmdCmdDataEvaluateExpression()
-{
-}
+CMICmdCmdDataEvaluateExpression::~CMICmdCmdDataEvaluateExpression() {}
-//++ ------------------------------------------------------------------------------------
-// Details: The invoker requires this function. The parses the command line options
+//++
+//------------------------------------------------------------------------------------
+// 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.
@@ -88,68 +86,68 @@ CMICmdCmdDataEvaluateExpression::~CMICmd
// MIstatus::failure - Functional failed.
// Throws: None.
//--
-bool
-CMICmdCmdDataEvaluateExpression::ParseArgs()
-{
- m_setCmdArgs.Add(new CMICmdArgValString(m_constStrArgExpr, true, true, true, true));
- return ParseValidateCmdOptions();
+bool CMICmdCmdDataEvaluateExpression::ParseArgs() {
+ m_setCmdArgs.Add(
+ new CMICmdArgValString(m_constStrArgExpr, true, true, true, true));
+ return ParseValidateCmdOptions();
}
-//++ ------------------------------------------------------------------------------------
-// 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.
+//++
+//------------------------------------------------------------------------------------
+// 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
-CMICmdCmdDataEvaluateExpression::Execute()
-{
- CMICMDBASE_GETOPTION(pArgExpr, String, m_constStrArgExpr);
+bool CMICmdCmdDataEvaluateExpression::Execute() {
+ CMICMDBASE_GETOPTION(pArgExpr, String, m_constStrArgExpr);
- const CMIUtilString &rExpression(pArgExpr->GetValue());
- CMICmnLLDBDebugSessionInfo &rSessionInfo(CMICmnLLDBDebugSessionInfo::Instance());
- lldb::SBProcess sbProcess = rSessionInfo.GetProcess();
- lldb::SBThread thread = sbProcess.GetSelectedThread();
- m_bExpressionValid = (thread.GetNumFrames() > 0);
- if (!m_bExpressionValid)
- return MIstatus::success;
+ const CMIUtilString &rExpression(pArgExpr->GetValue());
+ CMICmnLLDBDebugSessionInfo &rSessionInfo(
+ CMICmnLLDBDebugSessionInfo::Instance());
+ lldb::SBProcess sbProcess = rSessionInfo.GetProcess();
+ lldb::SBThread thread = sbProcess.GetSelectedThread();
+ m_bExpressionValid = (thread.GetNumFrames() > 0);
+ if (!m_bExpressionValid)
+ return MIstatus::success;
- lldb::SBFrame frame = thread.GetSelectedFrame();
- lldb::SBValue value = frame.EvaluateExpression(rExpression.c_str());
- 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())
- {
- m_bEvaluatedExpression = false;
- return MIstatus::success;
+ lldb::SBFrame frame = thread.GetSelectedFrame();
+ lldb::SBValue value = frame.EvaluateExpression(rExpression.c_str());
+ 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()) {
+ m_bEvaluatedExpression = false;
+ return MIstatus::success;
+ }
+ if (!utilValue.HasName()) {
+ if (HaveInvalidCharacterInExpression(rExpression,
+ m_cExpressionInvalidChar)) {
+ m_bFoundInvalidChar = true;
+ return MIstatus::success;
}
- if (!utilValue.HasName())
- {
- if (HaveInvalidCharacterInExpression(rExpression, m_cExpressionInvalidChar))
- {
- m_bFoundInvalidChar = true;
- return MIstatus::success;
- }
- m_strValue = rExpression;
- return MIstatus::success;
- }
- if (rExpression.IsQuoted())
- {
- m_strValue = rExpression.Trim('\"');
- return MIstatus::success;
- }
- m_strValue = utilValue.GetValue(true).Escape().AddSlashes();
+ m_strValue = rExpression;
+ return MIstatus::success;
+ }
+ if (rExpression.IsQuoted()) {
+ m_strValue = rExpression.Trim('\"');
return MIstatus::success;
+ }
+ m_strValue = utilValue.GetValue(true).Escape().AddSlashes();
+ return MIstatus::success;
}
-//++ ------------------------------------------------------------------------------------
-// Details: The invoker requires this function. The command prepares a MI Record Result
+//++
+//------------------------------------------------------------------------------------
+// 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.
@@ -157,84 +155,93 @@ CMICmdCmdDataEvaluateExpression::Execute
// MIstatus::failure - Functional failed.
// Throws: None.
//--
-bool
-CMICmdCmdDataEvaluateExpression::Acknowledge()
-{
- if (m_bExpressionValid)
- {
- if (m_bEvaluatedExpression)
- {
- if (m_bFoundInvalidChar)
- {
- const CMICmnMIValueConst miValueConst(
- CMIUtilString::Format("Invalid character '%c' in expression", m_cExpressionInvalidChar));
- const CMICmnMIValueResult miValueResult("msg", miValueConst);
- const CMICmnMIResultRecord miRecordResult(m_cmdData.strMiCmdToken, CMICmnMIResultRecord::eResultClass_Error, miValueResult);
- m_miResultRecord = miRecordResult;
- return MIstatus::success;
- }
-
- const CMICmnMIValueConst miValueConst(m_strValue);
- const CMICmnMIValueResult miValueResult("value", miValueConst);
- const CMICmnMIResultRecord miRecordResult(m_cmdData.strMiCmdToken, CMICmnMIResultRecord::eResultClass_Done, miValueResult);
- m_miResultRecord = miRecordResult;
- return MIstatus::success;
- }
- 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));
+bool CMICmdCmdDataEvaluateExpression::Acknowledge() {
+ if (m_bExpressionValid) {
+ if (m_bEvaluatedExpression) {
+ if (m_bFoundInvalidChar) {
+ const CMICmnMIValueConst miValueConst(CMIUtilString::Format(
+ "Invalid character '%c' in expression", m_cExpressionInvalidChar));
const CMICmnMIValueResult miValueResult("msg", miValueConst);
- const CMICmnMIResultRecord miRecordResult(m_cmdData.strMiCmdToken, CMICmnMIResultRecord::eResultClass_Error, miValueResult);
+ const CMICmnMIResultRecord miRecordResult(
+ m_cmdData.strMiCmdToken, CMICmnMIResultRecord::eResultClass_Error,
+ miValueResult);
m_miResultRecord = miRecordResult;
return MIstatus::success;
- }
+ }
- const CMICmnMIValueConst miValueConst("Invalid expression");
+ const CMICmnMIValueConst miValueConst(m_strValue);
+ const CMICmnMIValueResult miValueResult("value", miValueConst);
+ const CMICmnMIResultRecord miRecordResult(
+ m_cmdData.strMiCmdToken, CMICmnMIResultRecord::eResultClass_Done,
+ miValueResult);
+ m_miResultRecord = miRecordResult;
+ return MIstatus::success;
+ }
+ 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);
+ 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
+ const CMICmnMIValueConst miValueConst("Invalid expression");
+ 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 *
-CMICmdCmdDataEvaluateExpression::CreateSelf()
-{
- return new CMICmdCmdDataEvaluateExpression();
+CMICmdBase *CMICmdCmdDataEvaluateExpression::CreateSelf() {
+ return new CMICmdCmdDataEvaluateExpression();
}
-//++ ------------------------------------------------------------------------------------
-// Details: Examine the expression string to see if it contains invalid characters.
+//++
+//------------------------------------------------------------------------------------
+// Details: Examine the expression string to see if it contains invalid
+// characters.
// Type: Method.
// Args: vrExpr - (R) Expression string given to *this command.
-// vrwInvalidChar - (W) True = Invalid character found, false = nothing found.
+// vrwInvalidChar - (W) True = Invalid character found, false =
+// nothing found.
// Return: bool - True = Invalid character found, false = nothing found.
// Throws: None.
//--
-bool
-CMICmdCmdDataEvaluateExpression::HaveInvalidCharacterInExpression(const CMIUtilString &vrExpr, char &vrwInvalidChar)
-{
- static const std::string strInvalidCharacters(";#\\");
- const size_t nInvalidCharacterOffset = vrExpr.find_first_of(strInvalidCharacters);
- const bool bFoundInvalidCharInExpression = (nInvalidCharacterOffset != CMIUtilString::npos);
- vrwInvalidChar = bFoundInvalidCharInExpression ? vrExpr[nInvalidCharacterOffset] : 0x00;
- return bFoundInvalidCharInExpression;
+bool CMICmdCmdDataEvaluateExpression::HaveInvalidCharacterInExpression(
+ const CMIUtilString &vrExpr, char &vrwInvalidChar) {
+ static const std::string strInvalidCharacters(";#\\");
+ const size_t nInvalidCharacterOffset =
+ vrExpr.find_first_of(strInvalidCharacters);
+ const bool bFoundInvalidCharInExpression =
+ (nInvalidCharacterOffset != CMIUtilString::npos);
+ vrwInvalidChar =
+ bFoundInvalidCharInExpression ? vrExpr[nInvalidCharacterOffset] : 0x00;
+ return bFoundInvalidCharInExpression;
}
//---------------------------------------------------------------------------------------
//---------------------------------------------------------------------------------------
//---------------------------------------------------------------------------------------
-//++ ------------------------------------------------------------------------------------
+//++
+//------------------------------------------------------------------------------------
// Details: CMICmdCmdDataDisassemble constructor.
// Type: Method.
// Args: None.
@@ -242,31 +249,29 @@ CMICmdCmdDataEvaluateExpression::HaveInv
// Throws: None.
//--
CMICmdCmdDataDisassemble::CMICmdCmdDataDisassemble()
- : m_constStrArgAddrStart("s")
- , m_constStrArgAddrEnd("e")
- , m_constStrArgMode("mode")
- , m_miValueList(true)
-{
- // Command factory matches this name with that received from the stdin stream
- m_strMiCmd = "data-disassemble";
+ : m_constStrArgAddrStart("s"), m_constStrArgAddrEnd("e"),
+ m_constStrArgMode("mode"), m_miValueList(true) {
+ // Command factory matches this name with that received from the stdin stream
+ m_strMiCmd = "data-disassemble";
- // Required by the CMICmdFactory when registering *this command
- m_pSelfCreatorFn = &CMICmdCmdDataDisassemble::CreateSelf;
+ // Required by the CMICmdFactory when registering *this command
+ m_pSelfCreatorFn = &CMICmdCmdDataDisassemble::CreateSelf;
}
-//++ ------------------------------------------------------------------------------------
+//++
+//------------------------------------------------------------------------------------
// Details: CMICmdCmdDataDisassemble destructor.
// Type: Overrideable.
// Args: None.
// Return: None.
// Throws: None.
//--
-CMICmdCmdDataDisassemble::~CMICmdCmdDataDisassemble()
-{
-}
+CMICmdCmdDataDisassemble::~CMICmdCmdDataDisassemble() {}
-//++ ------------------------------------------------------------------------------------
-// Details: The invoker requires this function. The parses the command line options
+//++
+//------------------------------------------------------------------------------------
+// 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.
@@ -274,149 +279,164 @@ CMICmdCmdDataDisassemble::~CMICmdCmdData
// MIstatus::failure - Functional failed.
// Throws: None.
//--
-bool
-CMICmdCmdDataDisassemble::ParseArgs()
-{
- m_setCmdArgs.Add(
- new CMICmdArgValOptionShort(m_constStrArgAddrStart, true, true, CMICmdArgValListBase::eArgValType_StringQuotedNumber, 1));
- m_setCmdArgs.Add(
- new CMICmdArgValOptionShort(m_constStrArgAddrEnd, true, true, CMICmdArgValListBase::eArgValType_StringQuotedNumber, 1));
- m_setCmdArgs.Add(new CMICmdArgValNumber(m_constStrArgMode, true, true));
- return ParseValidateCmdOptions();
-}
-
-//++ ------------------------------------------------------------------------------------
-// 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.
+bool CMICmdCmdDataDisassemble::ParseArgs() {
+ m_setCmdArgs.Add(new CMICmdArgValOptionShort(
+ m_constStrArgAddrStart, true, true,
+ CMICmdArgValListBase::eArgValType_StringQuotedNumber, 1));
+ m_setCmdArgs.Add(new CMICmdArgValOptionShort(
+ m_constStrArgAddrEnd, true, true,
+ CMICmdArgValListBase::eArgValType_StringQuotedNumber, 1));
+ m_setCmdArgs.Add(new CMICmdArgValNumber(m_constStrArgMode, true, true));
+ return ParseValidateCmdOptions();
+}
+
+//++
+//------------------------------------------------------------------------------------
+// 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
-CMICmdCmdDataDisassemble::Execute()
-{
- CMICMDBASE_GETOPTION(pArgThread, OptionLong, m_constStrArgThread);
- CMICMDBASE_GETOPTION(pArgAddrStart, OptionShort, m_constStrArgAddrStart);
- CMICMDBASE_GETOPTION(pArgAddrEnd, OptionShort, m_constStrArgAddrEnd);
- CMICMDBASE_GETOPTION(pArgMode, Number, m_constStrArgMode);
-
- // Retrieve the --thread option's thread ID (only 1)
- MIuint64 nThreadId = UINT64_MAX;
- if (pArgThread->GetFound() && !pArgThread->GetExpectedOption<CMICmdArgValNumber, MIuint64>(nThreadId))
- {
- SetError(CMIUtilString::Format(MIRSRC(IDS_CMD_ERR_THREAD_INVALID), m_cmdData.strMiCmd.c_str(), m_constStrArgThread.c_str()));
- return MIstatus::failure;
- }
- CMIUtilString strAddrStart;
- if (!pArgAddrStart->GetExpectedOption<CMICmdArgValString, CMIUtilString>(strAddrStart))
- {
- SetError(CMIUtilString::Format(MIRSRC(IDS_CMD_ERR_DISASM_ADDR_START_INVALID), m_cmdData.strMiCmd.c_str(),
- m_constStrArgAddrStart.c_str()));
- return MIstatus::failure;
- }
- MIint64 nAddrStart = 0;
- if (!strAddrStart.ExtractNumber(nAddrStart))
- {
- SetError(CMIUtilString::Format(MIRSRC(IDS_CMD_ERR_DISASM_ADDR_START_INVALID), m_cmdData.strMiCmd.c_str(),
- m_constStrArgAddrStart.c_str()));
- return MIstatus::failure;
- }
-
- CMIUtilString strAddrEnd;
- if (!pArgAddrEnd->GetExpectedOption<CMICmdArgValString, CMIUtilString>(strAddrEnd))
- {
- SetError(
- CMIUtilString::Format(MIRSRC(IDS_CMD_ERR_DISASM_ADDR_END_INVALID), m_cmdData.strMiCmd.c_str(), m_constStrArgAddrEnd.c_str()));
- return MIstatus::failure;
- }
- MIint64 nAddrEnd = 0;
- if (!strAddrEnd.ExtractNumber(nAddrEnd))
- {
- SetError(
- CMIUtilString::Format(MIRSRC(IDS_CMD_ERR_DISASM_ADDR_END_INVALID), m_cmdData.strMiCmd.c_str(), m_constStrArgAddrEnd.c_str()));
- return MIstatus::failure;
- }
- const MIuint nDisasmMode = pArgMode->GetValue();
-
- CMICmnLLDBDebugSessionInfo &rSessionInfo(CMICmnLLDBDebugSessionInfo::Instance());
- lldb::SBTarget sbTarget = rSessionInfo.GetTarget();
- lldb::addr_t lldbStartAddr = static_cast<lldb::addr_t>(nAddrStart);
- lldb::SBInstructionList instructions = sbTarget.ReadInstructions(lldb::SBAddress(lldbStartAddr, sbTarget), nAddrEnd - nAddrStart);
- const MIuint nInstructions = instructions.GetSize();
- // Calculate the offset of first instruction so that we can generate offset starting at 0
- lldb::addr_t start_offset = 0;
- if(nInstructions > 0)
- start_offset = instructions.GetInstructionAtIndex(0).GetAddress().GetOffset();
-
- for (size_t i = 0; i < nInstructions; i++)
- {
- const char *pUnknown = "??";
- lldb::SBInstruction instrt = instructions.GetInstructionAtIndex(i);
- const char *pStrMnemonic = instrt.GetMnemonic(sbTarget);
- pStrMnemonic = (pStrMnemonic != nullptr) ? pStrMnemonic : pUnknown;
- const char *pStrComment = instrt.GetComment(sbTarget);
- CMIUtilString strComment;
- if (pStrComment != nullptr && *pStrComment != '\0')
- strComment = CMIUtilString::Format("; %s", pStrComment);
- lldb::SBAddress address = instrt.GetAddress();
- lldb::addr_t addr = address.GetLoadAddress(sbTarget);
- const char *pFnName = address.GetFunction().GetName();
- pFnName = (pFnName != nullptr) ? pFnName : pUnknown;
- lldb::addr_t addrOffSet = address.GetOffset() - start_offset;
- const char *pStrOperands = instrt.GetOperands(sbTarget);
- pStrOperands = (pStrOperands != nullptr) ? pStrOperands : pUnknown;
- const size_t instrtSize = instrt.GetByteSize();
-
- // MI "{address=\"0x%016" PRIx64 "\",func-name=\"%s\",offset=\"%lld\",inst=\"%s %s\"}"
- const CMICmnMIValueConst miValueConst(CMIUtilString::Format("0x%016" PRIx64, addr));
- const CMICmnMIValueResult miValueResult("address", miValueConst);
- CMICmnMIValueTuple miValueTuple(miValueResult);
- const CMICmnMIValueConst miValueConst2(pFnName);
- const CMICmnMIValueResult miValueResult2("func-name", miValueConst2);
- miValueTuple.Add(miValueResult2);
- const CMICmnMIValueConst miValueConst3(CMIUtilString::Format("%lld", addrOffSet));
- const CMICmnMIValueResult miValueResult3("offset", miValueConst3);
- miValueTuple.Add(miValueResult3);
- const CMICmnMIValueConst miValueConst4(CMIUtilString::Format("%d", instrtSize));
- const CMICmnMIValueResult miValueResult4("size", miValueConst4);
- miValueTuple.Add(miValueResult4);
- const CMICmnMIValueConst miValueConst5(CMIUtilString::Format("%s %s%s", pStrMnemonic, pStrOperands, strComment.Escape(true).c_str()));
- const CMICmnMIValueResult miValueResult5("inst", miValueConst5);
- miValueTuple.Add(miValueResult5);
-
- if (nDisasmMode == 1)
- {
- lldb::SBLineEntry lineEntry = address.GetLineEntry();
- const MIuint nLine = lineEntry.GetLine();
- const char *pFileName = lineEntry.GetFileSpec().GetFilename();
- pFileName = (pFileName != nullptr) ? pFileName : pUnknown;
-
- // MI "src_and_asm_line={line=\"%u\",file=\"%s\",line_asm_insn=[ ]}"
- const CMICmnMIValueConst miValueConst(CMIUtilString::Format("0x%u", nLine));
- const CMICmnMIValueResult miValueResult("line", miValueConst);
- CMICmnMIValueTuple miValueTuple2(miValueResult);
- const CMICmnMIValueConst miValueConst2(pFileName);
- const CMICmnMIValueResult miValueResult2("file", miValueConst2);
- miValueTuple2.Add(miValueResult2);
- const CMICmnMIValueList miValueList(miValueTuple);
- const CMICmnMIValueResult miValueResult3("line_asm_insn", miValueList);
- miValueTuple2.Add(miValueResult3);
- const CMICmnMIValueResult miValueResult4("src_and_asm_line", miValueTuple2);
- m_miValueList.Add(miValueResult4);
- }
- else
- {
- m_miValueList.Add(miValueTuple);
- }
- }
-
- return MIstatus::success;
-}
-
-//++ ------------------------------------------------------------------------------------
-// Details: The invoker requires this function. The command prepares a MI Record Result
+bool CMICmdCmdDataDisassemble::Execute() {
+ CMICMDBASE_GETOPTION(pArgThread, OptionLong, m_constStrArgThread);
+ CMICMDBASE_GETOPTION(pArgAddrStart, OptionShort, m_constStrArgAddrStart);
+ CMICMDBASE_GETOPTION(pArgAddrEnd, OptionShort, m_constStrArgAddrEnd);
+ CMICMDBASE_GETOPTION(pArgMode, Number, m_constStrArgMode);
+
+ // Retrieve the --thread option's thread ID (only 1)
+ MIuint64 nThreadId = UINT64_MAX;
+ if (pArgThread->GetFound() &&
+ !pArgThread->GetExpectedOption<CMICmdArgValNumber, MIuint64>(nThreadId)) {
+ SetError(CMIUtilString::Format(MIRSRC(IDS_CMD_ERR_THREAD_INVALID),
+ m_cmdData.strMiCmd.c_str(),
+ m_constStrArgThread.c_str()));
+ return MIstatus::failure;
+ }
+ CMIUtilString strAddrStart;
+ if (!pArgAddrStart->GetExpectedOption<CMICmdArgValString, CMIUtilString>(
+ strAddrStart)) {
+ SetError(CMIUtilString::Format(
+ MIRSRC(IDS_CMD_ERR_DISASM_ADDR_START_INVALID),
+ m_cmdData.strMiCmd.c_str(), m_constStrArgAddrStart.c_str()));
+ return MIstatus::failure;
+ }
+ MIint64 nAddrStart = 0;
+ if (!strAddrStart.ExtractNumber(nAddrStart)) {
+ SetError(CMIUtilString::Format(
+ MIRSRC(IDS_CMD_ERR_DISASM_ADDR_START_INVALID),
+ m_cmdData.strMiCmd.c_str(), m_constStrArgAddrStart.c_str()));
+ return MIstatus::failure;
+ }
+
+ CMIUtilString strAddrEnd;
+ if (!pArgAddrEnd->GetExpectedOption<CMICmdArgValString, CMIUtilString>(
+ strAddrEnd)) {
+ SetError(CMIUtilString::Format(MIRSRC(IDS_CMD_ERR_DISASM_ADDR_END_INVALID),
+ m_cmdData.strMiCmd.c_str(),
+ m_constStrArgAddrEnd.c_str()));
+ return MIstatus::failure;
+ }
+ MIint64 nAddrEnd = 0;
+ if (!strAddrEnd.ExtractNumber(nAddrEnd)) {
+ SetError(CMIUtilString::Format(MIRSRC(IDS_CMD_ERR_DISASM_ADDR_END_INVALID),
+ m_cmdData.strMiCmd.c_str(),
+ m_constStrArgAddrEnd.c_str()));
+ return MIstatus::failure;
+ }
+ const MIuint nDisasmMode = pArgMode->GetValue();
+
+ CMICmnLLDBDebugSessionInfo &rSessionInfo(
+ CMICmnLLDBDebugSessionInfo::Instance());
+ lldb::SBTarget sbTarget = rSessionInfo.GetTarget();
+ lldb::addr_t lldbStartAddr = static_cast<lldb::addr_t>(nAddrStart);
+ lldb::SBInstructionList instructions = sbTarget.ReadInstructions(
+ lldb::SBAddress(lldbStartAddr, sbTarget), nAddrEnd - nAddrStart);
+ const MIuint nInstructions = instructions.GetSize();
+ // Calculate the offset of first instruction so that we can generate offset
+ // starting at 0
+ lldb::addr_t start_offset = 0;
+ if (nInstructions > 0)
+ start_offset =
+ instructions.GetInstructionAtIndex(0).GetAddress().GetOffset();
+
+ for (size_t i = 0; i < nInstructions; i++) {
+ const char *pUnknown = "??";
+ lldb::SBInstruction instrt = instructions.GetInstructionAtIndex(i);
+ const char *pStrMnemonic = instrt.GetMnemonic(sbTarget);
+ pStrMnemonic = (pStrMnemonic != nullptr) ? pStrMnemonic : pUnknown;
+ const char *pStrComment = instrt.GetComment(sbTarget);
+ CMIUtilString strComment;
+ if (pStrComment != nullptr && *pStrComment != '\0')
+ strComment = CMIUtilString::Format("; %s", pStrComment);
+ lldb::SBAddress address = instrt.GetAddress();
+ lldb::addr_t addr = address.GetLoadAddress(sbTarget);
+ const char *pFnName = address.GetFunction().GetName();
+ pFnName = (pFnName != nullptr) ? pFnName : pUnknown;
+ lldb::addr_t addrOffSet = address.GetOffset() - start_offset;
+ const char *pStrOperands = instrt.GetOperands(sbTarget);
+ pStrOperands = (pStrOperands != nullptr) ? pStrOperands : pUnknown;
+ const size_t instrtSize = instrt.GetByteSize();
+
+ // MI "{address=\"0x%016" PRIx64
+ // "\",func-name=\"%s\",offset=\"%lld\",inst=\"%s %s\"}"
+ const CMICmnMIValueConst miValueConst(
+ CMIUtilString::Format("0x%016" PRIx64, addr));
+ const CMICmnMIValueResult miValueResult("address", miValueConst);
+ CMICmnMIValueTuple miValueTuple(miValueResult);
+ const CMICmnMIValueConst miValueConst2(pFnName);
+ const CMICmnMIValueResult miValueResult2("func-name", miValueConst2);
+ miValueTuple.Add(miValueResult2);
+ const CMICmnMIValueConst miValueConst3(
+ CMIUtilString::Format("%lld", addrOffSet));
+ const CMICmnMIValueResult miValueResult3("offset", miValueConst3);
+ miValueTuple.Add(miValueResult3);
+ const CMICmnMIValueConst miValueConst4(
+ CMIUtilString::Format("%d", instrtSize));
+ const CMICmnMIValueResult miValueResult4("size", miValueConst4);
+ miValueTuple.Add(miValueResult4);
+ const CMICmnMIValueConst miValueConst5(
+ CMIUtilString::Format("%s %s%s", pStrMnemonic, pStrOperands,
+ strComment.Escape(true).c_str()));
+ const CMICmnMIValueResult miValueResult5("inst", miValueConst5);
+ miValueTuple.Add(miValueResult5);
+
+ if (nDisasmMode == 1) {
+ lldb::SBLineEntry lineEntry = address.GetLineEntry();
+ const MIuint nLine = lineEntry.GetLine();
+ const char *pFileName = lineEntry.GetFileSpec().GetFilename();
+ pFileName = (pFileName != nullptr) ? pFileName : pUnknown;
+
+ // MI "src_and_asm_line={line=\"%u\",file=\"%s\",line_asm_insn=[ ]}"
+ const CMICmnMIValueConst miValueConst(
+ CMIUtilString::Format("0x%u", nLine));
+ const CMICmnMIValueResult miValueResult("line", miValueConst);
+ CMICmnMIValueTuple miValueTuple2(miValueResult);
+ const CMICmnMIValueConst miValueConst2(pFileName);
+ const CMICmnMIValueResult miValueResult2("file", miValueConst2);
+ miValueTuple2.Add(miValueResult2);
+ const CMICmnMIValueList miValueList(miValueTuple);
+ const CMICmnMIValueResult miValueResult3("line_asm_insn", miValueList);
+ miValueTuple2.Add(miValueResult3);
+ const CMICmnMIValueResult miValueResult4("src_and_asm_line",
+ miValueTuple2);
+ m_miValueList.Add(miValueResult4);
+ } else {
+ m_miValueList.Add(miValueTuple);
+ }
+ }
+
+ 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.
@@ -424,35 +444,36 @@ CMICmdCmdDataDisassemble::Execute()
// MIstatus::failure - Functional failed.
// Throws: None.
//--
-bool
-CMICmdCmdDataDisassemble::Acknowledge()
-{
- const CMICmnMIValueResult miValueResult("asm_insns", m_miValueList);
- const CMICmnMIResultRecord miRecordResult(m_cmdData.strMiCmdToken, CMICmnMIResultRecord::eResultClass_Done, miValueResult);
- m_miResultRecord = miRecordResult;
-
- return MIstatus::success;
+bool CMICmdCmdDataDisassemble::Acknowledge() {
+ const CMICmnMIValueResult miValueResult("asm_insns", m_miValueList);
+ const CMICmnMIResultRecord miRecordResult(
+ m_cmdData.strMiCmdToken, CMICmnMIResultRecord::eResultClass_Done,
+ miValueResult);
+ m_miResultRecord = miRecordResult;
+
+ return MIstatus::success;
}
-//++ ------------------------------------------------------------------------------------
-// Details: Required by the CMICmdFactory when registering *this command. The factory
+//++
+//------------------------------------------------------------------------------------
+// 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 *
-CMICmdCmdDataDisassemble::CreateSelf()
-{
- return new CMICmdCmdDataDisassemble();
+CMICmdBase *CMICmdCmdDataDisassemble::CreateSelf() {
+ return new CMICmdCmdDataDisassemble();
}
//---------------------------------------------------------------------------------------
//---------------------------------------------------------------------------------------
//---------------------------------------------------------------------------------------
-//++ ------------------------------------------------------------------------------------
+//++
+//------------------------------------------------------------------------------------
// Details: CMICmdCmdDataReadMemoryBytes constructor.
// Type: Method.
// Args: None.
@@ -460,38 +481,35 @@ CMICmdCmdDataDisassemble::CreateSelf()
// Throws: None.
//--
CMICmdCmdDataReadMemoryBytes::CMICmdCmdDataReadMemoryBytes()
- : m_constStrArgByteOffset("o")
- , m_constStrArgAddrExpr("address")
- , m_constStrArgNumBytes("count")
- , m_pBufferMemory(nullptr)
- , m_nAddrStart(0)
- , m_nAddrNumBytesToRead(0)
-{
- // Command factory matches this name with that received from the stdin stream
- m_strMiCmd = "data-read-memory-bytes";
+ : m_constStrArgByteOffset("o"), m_constStrArgAddrExpr("address"),
+ m_constStrArgNumBytes("count"), m_pBufferMemory(nullptr), m_nAddrStart(0),
+ m_nAddrNumBytesToRead(0) {
+ // Command factory matches this name with that received from the stdin stream
+ m_strMiCmd = "data-read-memory-bytes";
- // Required by the CMICmdFactory when registering *this command
- m_pSelfCreatorFn = &CMICmdCmdDataReadMemoryBytes::CreateSelf;
+ // Required by the CMICmdFactory when registering *this command
+ m_pSelfCreatorFn = &CMICmdCmdDataReadMemoryBytes::CreateSelf;
}
-//++ ------------------------------------------------------------------------------------
+//++
+//------------------------------------------------------------------------------------
// Details: CMICmdCmdDataReadMemoryBytes destructor.
// Type: Overrideable.
// Args: None.
// Return: None.
// Throws: None.
//--
-CMICmdCmdDataReadMemoryBytes::~CMICmdCmdDataReadMemoryBytes()
-{
- if (m_pBufferMemory != nullptr)
- {
- delete[] m_pBufferMemory;
- m_pBufferMemory = nullptr;
- }
+CMICmdCmdDataReadMemoryBytes::~CMICmdCmdDataReadMemoryBytes() {
+ if (m_pBufferMemory != nullptr) {
+ delete[] m_pBufferMemory;
+ m_pBufferMemory = nullptr;
+ }
}
-//++ ------------------------------------------------------------------------------------
-// Details: The invoker requires this function. The parses the command line options
+//++
+//------------------------------------------------------------------------------------
+// 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.
@@ -499,140 +517,150 @@ CMICmdCmdDataReadMemoryBytes::~CMICmdCmd
// MIstatus::failure - Functional failed.
// Throws: None.
//--
-bool
-CMICmdCmdDataReadMemoryBytes::ParseArgs()
-{
- m_setCmdArgs.Add(new CMICmdArgValOptionShort(m_constStrArgByteOffset, false, true, CMICmdArgValListBase::eArgValType_Number, 1));
- m_setCmdArgs.Add(new CMICmdArgValString(m_constStrArgAddrExpr, true, true, true, true));
- m_setCmdArgs.Add(new CMICmdArgValNumber(m_constStrArgNumBytes, true, true));
- return ParseValidateCmdOptions();
-}
-
-//++ ------------------------------------------------------------------------------------
-// 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.
+bool CMICmdCmdDataReadMemoryBytes::ParseArgs() {
+ m_setCmdArgs.Add(
+ new CMICmdArgValOptionShort(m_constStrArgByteOffset, false, true,
+ CMICmdArgValListBase::eArgValType_Number, 1));
+ m_setCmdArgs.Add(
+ new CMICmdArgValString(m_constStrArgAddrExpr, true, true, true, true));
+ m_setCmdArgs.Add(new CMICmdArgValNumber(m_constStrArgNumBytes, true, true));
+ return ParseValidateCmdOptions();
+}
+
+//++
+//------------------------------------------------------------------------------------
+// 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 - Function succeeded.
// MIstatus::failure - Function failed.
// Throws: None.
//--
-bool
-CMICmdCmdDataReadMemoryBytes::Execute()
-{
- CMICMDBASE_GETOPTION(pArgThread, OptionLong, m_constStrArgThread);
- CMICMDBASE_GETOPTION(pArgFrame, OptionLong, m_constStrArgFrame);
- CMICMDBASE_GETOPTION(pArgAddrOffset, OptionShort, m_constStrArgByteOffset);
- CMICMDBASE_GETOPTION(pArgAddrExpr, String, m_constStrArgAddrExpr);
- CMICMDBASE_GETOPTION(pArgNumBytes, Number, m_constStrArgNumBytes);
-
- // get the --thread option value
- MIuint64 nThreadId = UINT64_MAX;
- if (pArgThread->GetFound() && !pArgThread->GetExpectedOption<CMICmdArgValNumber, MIuint64>(nThreadId))
- {
- SetError(CMIUtilString::Format(MIRSRC(IDS_CMD_ERR_OPTION_NOT_FOUND),
- m_cmdData.strMiCmd.c_str(), m_constStrArgThread.c_str()));
- return MIstatus::failure;
- }
-
- // get the --frame option value
- MIuint64 nFrame = UINT64_MAX;
- if (pArgFrame->GetFound() && !pArgFrame->GetExpectedOption<CMICmdArgValNumber, MIuint64>(nFrame))
- {
- SetError(CMIUtilString::Format(MIRSRC(IDS_CMD_ERR_OPTION_NOT_FOUND),
- m_cmdData.strMiCmd.c_str(), m_constStrArgFrame.c_str()));
- return MIstatus::failure;
- }
-
- // get the -o option value
- MIuint64 nAddrOffset = 0;
- if (pArgAddrOffset->GetFound() && !pArgAddrOffset->GetExpectedOption<CMICmdArgValNumber, MIuint64>(nAddrOffset))
- {
- SetError(CMIUtilString::Format(MIRSRC(IDS_CMD_ERR_OPTION_NOT_FOUND),
- m_cmdData.strMiCmd.c_str(), m_constStrArgByteOffset.c_str()));
- return MIstatus::failure;
- }
-
- CMICmnLLDBDebugSessionInfo &rSessionInfo(CMICmnLLDBDebugSessionInfo::Instance());
- lldb::SBProcess sbProcess = rSessionInfo.GetProcess();
- if (!sbProcess.IsValid())
- {
- SetError(CMIUtilString::Format(MIRSRC(IDS_CMD_ERR_INVALID_PROCESS), m_cmdData.strMiCmd.c_str()));
- return MIstatus::failure;
- }
-
- lldb::SBThread thread = (nThreadId != UINT64_MAX) ?
- sbProcess.GetThreadByIndexID(nThreadId) : sbProcess.GetSelectedThread();
- if (!thread.IsValid())
- {
- SetError(CMIUtilString::Format(MIRSRC(IDS_CMD_ERR_THREAD_INVALID), m_cmdData.strMiCmd.c_str()));
- return MIstatus::failure;
- }
-
- lldb::SBFrame frame = (nFrame != UINT64_MAX) ?
- thread.GetFrameAtIndex(nFrame) : thread.GetSelectedFrame();
- if (!frame.IsValid())
- {
- SetError(CMIUtilString::Format(MIRSRC(IDS_CMD_ERR_FRAME_INVALID), m_cmdData.strMiCmd.c_str()));
- return MIstatus::failure;
- }
-
- const CMIUtilString &rAddrExpr = pArgAddrExpr->GetValue();
- lldb::SBValue addrExprValue = frame.EvaluateExpression(rAddrExpr.c_str());
- lldb::SBError error = addrExprValue.GetError();
- if (error.Fail())
- {
- SetError(error.GetCString());
- return MIstatus::failure;
- }
- else if (!addrExprValue.IsValid())
- {
- SetError(CMIUtilString::Format(MIRSRC(IDS_CMD_ERR_EXPR_INVALID), rAddrExpr.c_str()));
- return MIstatus::failure;
- }
-
- MIuint64 nAddrStart = 0;
- if (!CMICmnLLDBProxySBValue::GetValueAsUnsigned(addrExprValue, nAddrStart))
- {
- SetError(CMIUtilString::Format(MIRSRC(IDS_CMD_ERR_EXPR_INVALID), rAddrExpr.c_str()));
- return MIstatus::failure;
- }
-
- nAddrStart += nAddrOffset;
- const MIuint64 nAddrNumBytes = pArgNumBytes->GetValue();
-
- m_pBufferMemory = new unsigned char[nAddrNumBytes];
- if (m_pBufferMemory == nullptr)
- {
- SetError(CMIUtilString::Format(MIRSRC(IDS_CMD_ERR_MEMORY_ALLOC_FAILURE), m_cmdData.strMiCmd.c_str(), nAddrNumBytes));
- return MIstatus::failure;
- }
-
- const MIuint64 nReadBytes = sbProcess.ReadMemory(static_cast<lldb::addr_t>(nAddrStart), (void *)m_pBufferMemory, nAddrNumBytes, error);
- if (nReadBytes != nAddrNumBytes)
- {
- SetError(
- CMIUtilString::Format(MIRSRC(IDS_CMD_ERR_LLDB_ERR_NOT_READ_WHOLE_BLK), m_cmdData.strMiCmd.c_str(), nAddrNumBytes, nAddrStart));
- return MIstatus::failure;
- }
- if (error.Fail())
- {
- lldb::SBStream err;
- const bool bOk = error.GetDescription(err);
- MIunused(bOk);
- SetError(CMIUtilString::Format(MIRSRC(IDS_CMD_ERR_LLDB_ERR_READ_MEM_BYTES), m_cmdData.strMiCmd.c_str(), nAddrNumBytes, nAddrStart,
- err.GetData()));
- return MIstatus::failure;
- }
-
- m_nAddrStart = nAddrStart;
- m_nAddrNumBytesToRead = nAddrNumBytes;
-
- return MIstatus::success;
-}
-
-//++ ------------------------------------------------------------------------------------
-// Details: The invoker requires this function. The command prepares a MI Record Result
+bool CMICmdCmdDataReadMemoryBytes::Execute() {
+ CMICMDBASE_GETOPTION(pArgThread, OptionLong, m_constStrArgThread);
+ CMICMDBASE_GETOPTION(pArgFrame, OptionLong, m_constStrArgFrame);
+ CMICMDBASE_GETOPTION(pArgAddrOffset, OptionShort, m_constStrArgByteOffset);
+ CMICMDBASE_GETOPTION(pArgAddrExpr, String, m_constStrArgAddrExpr);
+ CMICMDBASE_GETOPTION(pArgNumBytes, Number, m_constStrArgNumBytes);
+
+ // get the --thread option value
+ MIuint64 nThreadId = UINT64_MAX;
+ if (pArgThread->GetFound() &&
+ !pArgThread->GetExpectedOption<CMICmdArgValNumber, MIuint64>(nThreadId)) {
+ SetError(CMIUtilString::Format(MIRSRC(IDS_CMD_ERR_OPTION_NOT_FOUND),
+ m_cmdData.strMiCmd.c_str(),
+ m_constStrArgThread.c_str()));
+ return MIstatus::failure;
+ }
+
+ // get the --frame option value
+ MIuint64 nFrame = UINT64_MAX;
+ if (pArgFrame->GetFound() &&
+ !pArgFrame->GetExpectedOption<CMICmdArgValNumber, MIuint64>(nFrame)) {
+ SetError(CMIUtilString::Format(MIRSRC(IDS_CMD_ERR_OPTION_NOT_FOUND),
+ m_cmdData.strMiCmd.c_str(),
+ m_constStrArgFrame.c_str()));
+ return MIstatus::failure;
+ }
+
+ // get the -o option value
+ MIuint64 nAddrOffset = 0;
+ if (pArgAddrOffset->GetFound() &&
+ !pArgAddrOffset->GetExpectedOption<CMICmdArgValNumber, MIuint64>(
+ nAddrOffset)) {
+ SetError(CMIUtilString::Format(MIRSRC(IDS_CMD_ERR_OPTION_NOT_FOUND),
+ m_cmdData.strMiCmd.c_str(),
+ m_constStrArgByteOffset.c_str()));
+ return MIstatus::failure;
+ }
+
+ CMICmnLLDBDebugSessionInfo &rSessionInfo(
+ CMICmnLLDBDebugSessionInfo::Instance());
+ lldb::SBProcess sbProcess = rSessionInfo.GetProcess();
+ if (!sbProcess.IsValid()) {
+ SetError(CMIUtilString::Format(MIRSRC(IDS_CMD_ERR_INVALID_PROCESS),
+ m_cmdData.strMiCmd.c_str()));
+ return MIstatus::failure;
+ }
+
+ lldb::SBThread thread = (nThreadId != UINT64_MAX)
+ ? sbProcess.GetThreadByIndexID(nThreadId)
+ : sbProcess.GetSelectedThread();
+ if (!thread.IsValid()) {
+ SetError(CMIUtilString::Format(MIRSRC(IDS_CMD_ERR_THREAD_INVALID),
+ m_cmdData.strMiCmd.c_str()));
+ return MIstatus::failure;
+ }
+
+ lldb::SBFrame frame = (nFrame != UINT64_MAX) ? thread.GetFrameAtIndex(nFrame)
+ : thread.GetSelectedFrame();
+ if (!frame.IsValid()) {
+ SetError(CMIUtilString::Format(MIRSRC(IDS_CMD_ERR_FRAME_INVALID),
+ m_cmdData.strMiCmd.c_str()));
+ return MIstatus::failure;
+ }
+
+ const CMIUtilString &rAddrExpr = pArgAddrExpr->GetValue();
+ lldb::SBValue addrExprValue = frame.EvaluateExpression(rAddrExpr.c_str());
+ lldb::SBError error = addrExprValue.GetError();
+ if (error.Fail()) {
+ SetError(error.GetCString());
+ return MIstatus::failure;
+ } else if (!addrExprValue.IsValid()) {
+ SetError(CMIUtilString::Format(MIRSRC(IDS_CMD_ERR_EXPR_INVALID),
+ rAddrExpr.c_str()));
+ return MIstatus::failure;
+ }
+
+ MIuint64 nAddrStart = 0;
+ if (!CMICmnLLDBProxySBValue::GetValueAsUnsigned(addrExprValue, nAddrStart)) {
+ SetError(CMIUtilString::Format(MIRSRC(IDS_CMD_ERR_EXPR_INVALID),
+ rAddrExpr.c_str()));
+ return MIstatus::failure;
+ }
+
+ nAddrStart += nAddrOffset;
+ const MIuint64 nAddrNumBytes = pArgNumBytes->GetValue();
+
+ m_pBufferMemory = new unsigned char[nAddrNumBytes];
+ if (m_pBufferMemory == nullptr) {
+ SetError(CMIUtilString::Format(MIRSRC(IDS_CMD_ERR_MEMORY_ALLOC_FAILURE),
+ m_cmdData.strMiCmd.c_str(), nAddrNumBytes));
+ return MIstatus::failure;
+ }
+
+ const MIuint64 nReadBytes =
+ sbProcess.ReadMemory(static_cast<lldb::addr_t>(nAddrStart),
+ (void *)m_pBufferMemory, nAddrNumBytes, error);
+ if (nReadBytes != nAddrNumBytes) {
+ SetError(CMIUtilString::Format(
+ MIRSRC(IDS_CMD_ERR_LLDB_ERR_NOT_READ_WHOLE_BLK),
+ m_cmdData.strMiCmd.c_str(), nAddrNumBytes, nAddrStart));
+ return MIstatus::failure;
+ }
+ if (error.Fail()) {
+ lldb::SBStream err;
+ const bool bOk = error.GetDescription(err);
+ MIunused(bOk);
+ SetError(CMIUtilString::Format(MIRSRC(IDS_CMD_ERR_LLDB_ERR_READ_MEM_BYTES),
+ m_cmdData.strMiCmd.c_str(), nAddrNumBytes,
+ nAddrStart, err.GetData()));
+ return MIstatus::failure;
+ }
+
+ m_nAddrStart = nAddrStart;
+ m_nAddrNumBytesToRead = nAddrNumBytes;
+
+ 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.
@@ -640,103 +668,108 @@ CMICmdCmdDataReadMemoryBytes::Execute()
// MIstatus::failure - Functional failed.
// Throws: None.
//--
-bool
-CMICmdCmdDataReadMemoryBytes::Acknowledge()
-{
- // MI: memory=[{begin=\"0x%016" PRIx64 "\",offset=\"0x%016" PRIx64" \",end=\"0x%016" PRIx64 "\",contents=\" \" }]"
- const CMICmnMIValueConst miValueConst(CMIUtilString::Format("0x%016" PRIx64, m_nAddrStart));
- const CMICmnMIValueResult miValueResult("begin", miValueConst);
- CMICmnMIValueTuple miValueTuple(miValueResult);
- const MIuint64 nAddrOffset = 0;
- const CMICmnMIValueConst miValueConst2(CMIUtilString::Format("0x%016" PRIx64, nAddrOffset));
- const CMICmnMIValueResult miValueResult2("offset", miValueConst2);
- miValueTuple.Add(miValueResult2);
- const CMICmnMIValueConst miValueConst3(CMIUtilString::Format("0x%016" PRIx64, m_nAddrStart + m_nAddrNumBytesToRead));
- const CMICmnMIValueResult miValueResult3("end", miValueConst3);
- miValueTuple.Add(miValueResult3);
-
- // MI: contents=\" \"
- CMIUtilString strContent;
- strContent.reserve((m_nAddrNumBytesToRead << 1) + 1);
- for (MIuint64 i = 0; i < m_nAddrNumBytesToRead; i++)
- {
- strContent += CMIUtilString::Format("%02hhx", m_pBufferMemory[i]);
- }
- const CMICmnMIValueConst miValueConst4(strContent);
- const CMICmnMIValueResult miValueResult4("contents", miValueConst4);
- miValueTuple.Add(miValueResult4);
- const CMICmnMIValueList miValueList(miValueTuple);
- const CMICmnMIValueResult miValueResult5("memory", miValueList);
-
- const CMICmnMIResultRecord miRecordResult(m_cmdData.strMiCmdToken, CMICmnMIResultRecord::eResultClass_Done, miValueResult5);
- m_miResultRecord = miRecordResult;
-
- return MIstatus::success;
-}
-
-//++ ------------------------------------------------------------------------------------
-// Details: Required by the CMICmdFactory when registering *this command. The factory
+bool CMICmdCmdDataReadMemoryBytes::Acknowledge() {
+ // MI: memory=[{begin=\"0x%016" PRIx64 "\",offset=\"0x%016" PRIx64"
+ // \",end=\"0x%016" PRIx64 "\",contents=\" \" }]"
+ const CMICmnMIValueConst miValueConst(
+ CMIUtilString::Format("0x%016" PRIx64, m_nAddrStart));
+ const CMICmnMIValueResult miValueResult("begin", miValueConst);
+ CMICmnMIValueTuple miValueTuple(miValueResult);
+ const MIuint64 nAddrOffset = 0;
+ const CMICmnMIValueConst miValueConst2(
+ CMIUtilString::Format("0x%016" PRIx64, nAddrOffset));
+ const CMICmnMIValueResult miValueResult2("offset", miValueConst2);
+ miValueTuple.Add(miValueResult2);
+ const CMICmnMIValueConst miValueConst3(CMIUtilString::Format(
+ "0x%016" PRIx64, m_nAddrStart + m_nAddrNumBytesToRead));
+ const CMICmnMIValueResult miValueResult3("end", miValueConst3);
+ miValueTuple.Add(miValueResult3);
+
+ // MI: contents=\" \"
+ CMIUtilString strContent;
+ strContent.reserve((m_nAddrNumBytesToRead << 1) + 1);
+ for (MIuint64 i = 0; i < m_nAddrNumBytesToRead; i++) {
+ strContent += CMIUtilString::Format("%02hhx", m_pBufferMemory[i]);
+ }
+ const CMICmnMIValueConst miValueConst4(strContent);
+ const CMICmnMIValueResult miValueResult4("contents", miValueConst4);
+ miValueTuple.Add(miValueResult4);
+ const CMICmnMIValueList miValueList(miValueTuple);
+ const CMICmnMIValueResult miValueResult5("memory", miValueList);
+
+ const CMICmnMIResultRecord miRecordResult(
+ m_cmdData.strMiCmdToken, CMICmnMIResultRecord::eResultClass_Done,
+ miValueResult5);
+ 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 *
-CMICmdCmdDataReadMemoryBytes::CreateSelf()
-{
- return new CMICmdCmdDataReadMemoryBytes();
+CMICmdBase *CMICmdCmdDataReadMemoryBytes::CreateSelf() {
+ return new CMICmdCmdDataReadMemoryBytes();
}
//---------------------------------------------------------------------------------------
//---------------------------------------------------------------------------------------
//---------------------------------------------------------------------------------------
-//++ ------------------------------------------------------------------------------------
+//++
+//------------------------------------------------------------------------------------
// Details: CMICmdCmdDataReadMemory constructor.
// Type: Method.
// Args: None.
// Return: None.
// Throws: None.
//--
-CMICmdCmdDataReadMemory::CMICmdCmdDataReadMemory()
-{
- // Command factory matches this name with that received from the stdin stream
- m_strMiCmd = "data-read-memory";
+CMICmdCmdDataReadMemory::CMICmdCmdDataReadMemory() {
+ // Command factory matches this name with that received from the stdin stream
+ m_strMiCmd = "data-read-memory";
- // Required by the CMICmdFactory when registering *this command
- m_pSelfCreatorFn = &CMICmdCmdDataReadMemory::CreateSelf;
+ // Required by the CMICmdFactory when registering *this command
+ m_pSelfCreatorFn = &CMICmdCmdDataReadMemory::CreateSelf;
}
-//++ ------------------------------------------------------------------------------------
+//++
+//------------------------------------------------------------------------------------
// Details: CMICmdCmdDataReadMemory destructor.
// Type: Overrideable.
// Args: None.
// Return: None.
// Throws: None.
//--
-CMICmdCmdDataReadMemory::~CMICmdCmdDataReadMemory()
-{
-}
+CMICmdCmdDataReadMemory::~CMICmdCmdDataReadMemory() {}
-//++ ------------------------------------------------------------------------------------
-// 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.
+//++
+//------------------------------------------------------------------------------------
+// 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
-CMICmdCmdDataReadMemory::Execute()
-{
- // Do nothing - command deprecated use "data-read-memory-bytes" command
- return MIstatus::success;
+bool CMICmdCmdDataReadMemory::Execute() {
+ // Do nothing - command deprecated use "data-read-memory-bytes" command
+ return MIstatus::success;
}
-//++ ------------------------------------------------------------------------------------
-// Details: The invoker requires this function. The command prepares a MI Record Result
+//++
+//------------------------------------------------------------------------------------
+// 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.
@@ -744,37 +777,40 @@ CMICmdCmdDataReadMemory::Execute()
// MIstatus::failure - Functional failed.
// Throws: None.
//--
-bool
-CMICmdCmdDataReadMemory::Acknowledge()
-{
- // Command CMICmdCmdSupportListFeatures sends "data-read-memory-bytes" which causes this command not to be called
- const CMICmnMIValueConst miValueConst(MIRSRC(IDS_CMD_ERR_NOT_IMPLEMENTED_DEPRECATED));
- 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
+bool CMICmdCmdDataReadMemory::Acknowledge() {
+ // Command CMICmdCmdSupportListFeatures sends "data-read-memory-bytes" which
+ // causes this command not to be called
+ const CMICmnMIValueConst miValueConst(
+ MIRSRC(IDS_CMD_ERR_NOT_IMPLEMENTED_DEPRECATED));
+ 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 *
-CMICmdCmdDataReadMemory::CreateSelf()
-{
- return new CMICmdCmdDataReadMemory();
+CMICmdBase *CMICmdCmdDataReadMemory::CreateSelf() {
+ return new CMICmdCmdDataReadMemory();
}
//---------------------------------------------------------------------------------------
//---------------------------------------------------------------------------------------
//---------------------------------------------------------------------------------------
-//++ ------------------------------------------------------------------------------------
+//++
+//------------------------------------------------------------------------------------
// Details: CMICmdCmdDataListRegisterNames constructor.
// Type: Method.
// Args: None.
@@ -782,29 +818,28 @@ CMICmdCmdDataReadMemory::CreateSelf()
// Throws: None.
//--
CMICmdCmdDataListRegisterNames::CMICmdCmdDataListRegisterNames()
- : m_constStrArgRegNo("regno")
- , m_miValueList(true)
-{
- // Command factory matches this name with that received from the stdin stream
- m_strMiCmd = "data-list-register-names";
+ : m_constStrArgRegNo("regno"), m_miValueList(true) {
+ // Command factory matches this name with that received from the stdin stream
+ m_strMiCmd = "data-list-register-names";
- // Required by the CMICmdFactory when registering *this command
- m_pSelfCreatorFn = &CMICmdCmdDataListRegisterNames::CreateSelf;
+ // Required by the CMICmdFactory when registering *this command
+ m_pSelfCreatorFn = &CMICmdCmdDataListRegisterNames::CreateSelf;
}
-//++ ------------------------------------------------------------------------------------
+//++
+//------------------------------------------------------------------------------------
// Details: CMICmdCmdDataReadMemoryBytes destructor.
// Type: Overrideable.
// Args: None.
// Return: None.
// Throws: None.
//--
-CMICmdCmdDataListRegisterNames::~CMICmdCmdDataListRegisterNames()
-{
-}
+CMICmdCmdDataListRegisterNames::~CMICmdCmdDataListRegisterNames() {}
-//++ ------------------------------------------------------------------------------------
-// Details: The invoker requires this function. The parses the command line options
+//++
+//------------------------------------------------------------------------------------
+// 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.
@@ -812,83 +847,82 @@ CMICmdCmdDataListRegisterNames::~CMICmdC
// MIstatus::failure - Functional failed.
// Throws: None.
//--
-bool
-CMICmdCmdDataListRegisterNames::ParseArgs()
-{
- m_setCmdArgs.Add(new CMICmdArgValListOfN(m_constStrArgRegNo, false, false, CMICmdArgValListBase::eArgValType_Number));
- return ParseValidateCmdOptions();
-}
-
-//++ ------------------------------------------------------------------------------------
-// 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.
+bool CMICmdCmdDataListRegisterNames::ParseArgs() {
+ m_setCmdArgs.Add(
+ new CMICmdArgValListOfN(m_constStrArgRegNo, false, false,
+ CMICmdArgValListBase::eArgValType_Number));
+ return ParseValidateCmdOptions();
+}
+
+//++
+//------------------------------------------------------------------------------------
+// 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
-CMICmdCmdDataListRegisterNames::Execute()
-{
- CMICMDBASE_GETOPTION(pArgRegNo, ListOfN, m_constStrArgRegNo);
+bool CMICmdCmdDataListRegisterNames::Execute() {
+ CMICMDBASE_GETOPTION(pArgRegNo, ListOfN, m_constStrArgRegNo);
+
+ CMICmnLLDBDebugSessionInfo &rSessionInfo(
+ CMICmnLLDBDebugSessionInfo::Instance());
+ lldb::SBProcess sbProcess = rSessionInfo.GetProcess();
+ if (!sbProcess.IsValid()) {
+ SetError(CMIUtilString::Format(MIRSRC(IDS_CMD_ERR_INVALID_PROCESS),
+ m_cmdData.strMiCmd.c_str()));
+ return MIstatus::failure;
+ }
+
+ const CMICmdArgValListBase::VecArgObjPtr_t &rVecRegNo(
+ pArgRegNo->GetExpectedOptions());
+ if (!rVecRegNo.empty()) {
+ // List of required registers
+ CMICmdArgValListBase::VecArgObjPtr_t::const_iterator it = rVecRegNo.begin();
+ while (it != rVecRegNo.end()) {
+ const CMICmdArgValNumber *pRegNo = static_cast<CMICmdArgValNumber *>(*it);
+ const MIuint nRegIndex = pRegNo->GetValue();
+ lldb::SBValue regValue = GetRegister(nRegIndex);
+ if (regValue.IsValid()) {
+ const CMICmnMIValueConst miValueConst(
+ CMICmnLLDBUtilSBValue(regValue).GetName());
+ m_miValueList.Add(miValueConst);
+ }
- CMICmnLLDBDebugSessionInfo &rSessionInfo(CMICmnLLDBDebugSessionInfo::Instance());
- lldb::SBProcess sbProcess = rSessionInfo.GetProcess();
- if (!sbProcess.IsValid())
- {
- SetError(CMIUtilString::Format(MIRSRC(IDS_CMD_ERR_INVALID_PROCESS), m_cmdData.strMiCmd.c_str()));
- return MIstatus::failure;
+ // Next
+ ++it;
}
-
- const CMICmdArgValListBase::VecArgObjPtr_t &rVecRegNo(pArgRegNo->GetExpectedOptions());
- if (!rVecRegNo.empty())
- {
- // List of required registers
- CMICmdArgValListBase::VecArgObjPtr_t::const_iterator it = rVecRegNo.begin();
- while (it != rVecRegNo.end())
- {
- const CMICmdArgValNumber *pRegNo = static_cast<CMICmdArgValNumber *>(*it);
- const MIuint nRegIndex = pRegNo->GetValue();
- lldb::SBValue regValue = GetRegister(nRegIndex);
- if (regValue.IsValid())
- {
- const CMICmnMIValueConst miValueConst(CMICmnLLDBUtilSBValue(regValue).GetName());
- m_miValueList.Add(miValueConst);
- }
-
- // Next
- ++it;
- }
- }
- else
- {
- // List of all registers
- lldb::SBThread thread = sbProcess.GetSelectedThread();
- lldb::SBFrame frame = thread.GetSelectedFrame();
- lldb::SBValueList registers = frame.GetRegisters();
- const MIuint nRegisters = registers.GetSize();
- for (MIuint i = 0; i < nRegisters; i++)
- {
- lldb::SBValue value = registers.GetValueAtIndex(i);
- const MIuint nRegChildren = value.GetNumChildren();
- for (MIuint j = 0; j < nRegChildren; j++)
- {
- lldb::SBValue regValue = value.GetChildAtIndex(j);
- if (regValue.IsValid())
- {
- const CMICmnMIValueConst miValueConst(CMICmnLLDBUtilSBValue(regValue).GetName());
- m_miValueList.Add(miValueConst);
- }
- }
+ } else {
+ // List of all registers
+ lldb::SBThread thread = sbProcess.GetSelectedThread();
+ lldb::SBFrame frame = thread.GetSelectedFrame();
+ lldb::SBValueList registers = frame.GetRegisters();
+ const MIuint nRegisters = registers.GetSize();
+ for (MIuint i = 0; i < nRegisters; i++) {
+ lldb::SBValue value = registers.GetValueAtIndex(i);
+ const MIuint nRegChildren = value.GetNumChildren();
+ for (MIuint j = 0; j < nRegChildren; j++) {
+ lldb::SBValue regValue = value.GetChildAtIndex(j);
+ if (regValue.IsValid()) {
+ const CMICmnMIValueConst miValueConst(
+ CMICmnLLDBUtilSBValue(regValue).GetName());
+ m_miValueList.Add(miValueConst);
}
+ }
}
+ }
- return MIstatus::success;
+ return MIstatus::success;
}
-//++ ------------------------------------------------------------------------------------
-// Details: The invoker requires this function. The command prepares a MI Record Result
+//++
+//------------------------------------------------------------------------------------
+// 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.
@@ -896,32 +930,34 @@ CMICmdCmdDataListRegisterNames::Execute(
// MIstatus::failure - Functional failed.
// Throws: None.
//--
-bool
-CMICmdCmdDataListRegisterNames::Acknowledge()
-{
- const CMICmnMIValueResult miValueResult("register-names", m_miValueList);
- const CMICmnMIResultRecord miRecordResult(m_cmdData.strMiCmdToken, CMICmnMIResultRecord::eResultClass_Done, miValueResult);
- m_miResultRecord = miRecordResult;
-
- return MIstatus::success;
+bool CMICmdCmdDataListRegisterNames::Acknowledge() {
+ const CMICmnMIValueResult miValueResult("register-names", m_miValueList);
+ const CMICmnMIResultRecord miRecordResult(
+ m_cmdData.strMiCmdToken, CMICmnMIResultRecord::eResultClass_Done,
+ miValueResult);
+ m_miResultRecord = miRecordResult;
+
+ return MIstatus::success;
}
-//++ ------------------------------------------------------------------------------------
-// Details: Required by the CMICmdFactory when registering *this command. The factory
+//++
+//------------------------------------------------------------------------------------
+// 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 *
-CMICmdCmdDataListRegisterNames::CreateSelf()
-{
- return new CMICmdCmdDataListRegisterNames();
+CMICmdBase *CMICmdCmdDataListRegisterNames::CreateSelf() {
+ return new CMICmdCmdDataListRegisterNames();
}
-//++ ------------------------------------------------------------------------------------
-// Details: Required by the CMICmdFactory when registering *this command. The factory
+//++
+//------------------------------------------------------------------------------------
+// Details: Required by the CMICmdFactory when registering *this command. The
+// factory
// calls this function to create an instance of *this command.
// Type: Method.
// Args: None.
@@ -929,38 +965,36 @@ CMICmdCmdDataListRegisterNames::CreateSe
// Throws: None.
//--
lldb::SBValue
-CMICmdCmdDataListRegisterNames::GetRegister(const MIuint vRegisterIndex) const
-{
- lldb::SBThread thread = CMICmnLLDBDebugSessionInfo::Instance().GetProcess().GetSelectedThread();
- lldb::SBFrame frame = thread.GetSelectedFrame();
- lldb::SBValueList registers = frame.GetRegisters();
- const MIuint nRegisters = registers.GetSize();
- MIuint nRegisterIndex(vRegisterIndex);
- for (MIuint i = 0; i < nRegisters; i++)
- {
- lldb::SBValue value = registers.GetValueAtIndex(i);
- const MIuint nRegChildren = value.GetNumChildren();
- if (nRegisterIndex >= nRegChildren)
- {
- nRegisterIndex -= nRegChildren;
- continue;
- }
+CMICmdCmdDataListRegisterNames::GetRegister(const MIuint vRegisterIndex) const {
+ lldb::SBThread thread =
+ CMICmnLLDBDebugSessionInfo::Instance().GetProcess().GetSelectedThread();
+ lldb::SBFrame frame = thread.GetSelectedFrame();
+ lldb::SBValueList registers = frame.GetRegisters();
+ const MIuint nRegisters = registers.GetSize();
+ MIuint nRegisterIndex(vRegisterIndex);
+ for (MIuint i = 0; i < nRegisters; i++) {
+ lldb::SBValue value = registers.GetValueAtIndex(i);
+ const MIuint nRegChildren = value.GetNumChildren();
+ if (nRegisterIndex >= nRegChildren) {
+ nRegisterIndex -= nRegChildren;
+ continue;
+ }
- lldb::SBValue value2 = value.GetChildAtIndex(nRegisterIndex);
- if (value2.IsValid())
- {
- return value2;
- }
+ lldb::SBValue value2 = value.GetChildAtIndex(nRegisterIndex);
+ if (value2.IsValid()) {
+ return value2;
}
+ }
- return lldb::SBValue();
+ return lldb::SBValue();
}
//---------------------------------------------------------------------------------------
//---------------------------------------------------------------------------------------
//---------------------------------------------------------------------------------------
-//++ ------------------------------------------------------------------------------------
+//++
+//------------------------------------------------------------------------------------
// Details: CMICmdCmdDataListRegisterValues constructor.
// Type: Method.
// Args: None.
@@ -968,31 +1002,29 @@ CMICmdCmdDataListRegisterNames::GetRegis
// Throws: None.
//--
CMICmdCmdDataListRegisterValues::CMICmdCmdDataListRegisterValues()
- : m_constStrArgSkip("skip-unavailable")
- , m_constStrArgFormat("fmt")
- , m_constStrArgRegNo("regno")
- , m_miValueList(true)
-{
- // Command factory matches this name with that received from the stdin stream
- m_strMiCmd = "data-list-register-values";
+ : m_constStrArgSkip("skip-unavailable"), m_constStrArgFormat("fmt"),
+ m_constStrArgRegNo("regno"), m_miValueList(true) {
+ // Command factory matches this name with that received from the stdin stream
+ m_strMiCmd = "data-list-register-values";
- // Required by the CMICmdFactory when registering *this command
- m_pSelfCreatorFn = &CMICmdCmdDataListRegisterValues::CreateSelf;
+ // Required by the CMICmdFactory when registering *this command
+ m_pSelfCreatorFn = &CMICmdCmdDataListRegisterValues::CreateSelf;
}
-//++ ------------------------------------------------------------------------------------
+//++
+//------------------------------------------------------------------------------------
// Details: CMICmdCmdDataListRegisterValues destructor.
// Type: Overrideable.
// Args: None.
// Return: None.
// Throws: None.
//--
-CMICmdCmdDataListRegisterValues::~CMICmdCmdDataListRegisterValues()
-{
-}
+CMICmdCmdDataListRegisterValues::~CMICmdCmdDataListRegisterValues() {}
-//++ ------------------------------------------------------------------------------------
-// Details: The invoker requires this function. The parses the command line options
+//++
+//------------------------------------------------------------------------------------
+// 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.
@@ -1000,102 +1032,104 @@ CMICmdCmdDataListRegisterValues::~CMICmd
// MIstatus::failure - Functional failed.
// Throws: None.
//--
-bool
-CMICmdCmdDataListRegisterValues::ParseArgs()
-{
- m_setCmdArgs.Add(new CMICmdArgValOptionLong(m_constStrArgThread, false, false, CMICmdArgValListBase::eArgValType_Number, 1));
- m_setCmdArgs.Add(new CMICmdArgValOptionLong(m_constStrArgSkip, false, false));
- m_setCmdArgs.Add(new CMICmdArgValString(m_constStrArgFormat, true, true));
- m_setCmdArgs.Add(new CMICmdArgValListOfN(m_constStrArgRegNo, false, true, CMICmdArgValListBase::eArgValType_Number));
- return ParseValidateCmdOptions();
-}
-
-//++ ------------------------------------------------------------------------------------
-// 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.
+bool CMICmdCmdDataListRegisterValues::ParseArgs() {
+ m_setCmdArgs.Add(
+ new CMICmdArgValOptionLong(m_constStrArgThread, false, false,
+ CMICmdArgValListBase::eArgValType_Number, 1));
+ m_setCmdArgs.Add(new CMICmdArgValOptionLong(m_constStrArgSkip, false, false));
+ m_setCmdArgs.Add(new CMICmdArgValString(m_constStrArgFormat, true, true));
+ m_setCmdArgs.Add(
+ new CMICmdArgValListOfN(m_constStrArgRegNo, false, true,
+ CMICmdArgValListBase::eArgValType_Number));
+ return ParseValidateCmdOptions();
+}
+
+//++
+//------------------------------------------------------------------------------------
+// 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
-CMICmdCmdDataListRegisterValues::Execute()
-{
- CMICMDBASE_GETOPTION(pArgFormat, String, m_constStrArgFormat);
- CMICMDBASE_GETOPTION(pArgRegNo, ListOfN, m_constStrArgRegNo);
-
- const CMIUtilString &rStrFormat(pArgFormat->GetValue());
- if (rStrFormat.length() != 1)
- {
- SetError(CMIUtilString::Format(MIRSRC(IDS_CMD_ERR_INVALID_FORMAT_TYPE), m_cmdData.strMiCmd.c_str(), rStrFormat.c_str()));
- return MIstatus::failure;
- }
- const CMICmnLLDBDebugSessionInfoVarObj::varFormat_e eFormat = CMICmnLLDBDebugSessionInfoVarObj::GetVarFormatForChar(rStrFormat[0]);
- if (eFormat == CMICmnLLDBDebugSessionInfoVarObj::eVarFormat_Invalid)
- {
- SetError(CMIUtilString::Format(MIRSRC(IDS_CMD_ERR_INVALID_FORMAT_TYPE), m_cmdData.strMiCmd.c_str(), rStrFormat.c_str()));
- return MIstatus::failure;
- }
-
- CMICmnLLDBDebugSessionInfo &rSessionInfo(CMICmnLLDBDebugSessionInfo::Instance());
- lldb::SBProcess sbProcess = rSessionInfo.GetProcess();
- if (!sbProcess.IsValid())
- {
- SetError(CMIUtilString::Format(MIRSRC(IDS_CMD_ERR_INVALID_PROCESS), m_cmdData.strMiCmd.c_str()));
- return MIstatus::failure;
- }
+bool CMICmdCmdDataListRegisterValues::Execute() {
+ CMICMDBASE_GETOPTION(pArgFormat, String, m_constStrArgFormat);
+ CMICMDBASE_GETOPTION(pArgRegNo, ListOfN, m_constStrArgRegNo);
+
+ const CMIUtilString &rStrFormat(pArgFormat->GetValue());
+ if (rStrFormat.length() != 1) {
+ SetError(CMIUtilString::Format(MIRSRC(IDS_CMD_ERR_INVALID_FORMAT_TYPE),
+ m_cmdData.strMiCmd.c_str(),
+ rStrFormat.c_str()));
+ return MIstatus::failure;
+ }
+ const CMICmnLLDBDebugSessionInfoVarObj::varFormat_e eFormat =
+ CMICmnLLDBDebugSessionInfoVarObj::GetVarFormatForChar(rStrFormat[0]);
+ if (eFormat == CMICmnLLDBDebugSessionInfoVarObj::eVarFormat_Invalid) {
+ SetError(CMIUtilString::Format(MIRSRC(IDS_CMD_ERR_INVALID_FORMAT_TYPE),
+ m_cmdData.strMiCmd.c_str(),
+ rStrFormat.c_str()));
+ return MIstatus::failure;
+ }
+
+ CMICmnLLDBDebugSessionInfo &rSessionInfo(
+ CMICmnLLDBDebugSessionInfo::Instance());
+ lldb::SBProcess sbProcess = rSessionInfo.GetProcess();
+ if (!sbProcess.IsValid()) {
+ SetError(CMIUtilString::Format(MIRSRC(IDS_CMD_ERR_INVALID_PROCESS),
+ m_cmdData.strMiCmd.c_str()));
+ return MIstatus::failure;
+ }
+
+ const CMICmdArgValListBase::VecArgObjPtr_t &rVecRegNo(
+ pArgRegNo->GetExpectedOptions());
+ if (!rVecRegNo.empty()) {
+ // List of required registers
+ CMICmdArgValListBase::VecArgObjPtr_t::const_iterator it = rVecRegNo.begin();
+ while (it != rVecRegNo.end()) {
+ const CMICmdArgValNumber *pRegNo = static_cast<CMICmdArgValNumber *>(*it);
+ const MIuint nRegIndex = pRegNo->GetValue();
+ lldb::SBValue regValue = GetRegister(nRegIndex);
+ if (regValue.IsValid()) {
+ AddToOutput(nRegIndex, regValue, eFormat);
+ }
- const CMICmdArgValListBase::VecArgObjPtr_t &rVecRegNo(pArgRegNo->GetExpectedOptions());
- if (!rVecRegNo.empty())
- {
- // List of required registers
- CMICmdArgValListBase::VecArgObjPtr_t::const_iterator it = rVecRegNo.begin();
- while (it != rVecRegNo.end())
- {
- const CMICmdArgValNumber *pRegNo = static_cast<CMICmdArgValNumber *>(*it);
- const MIuint nRegIndex = pRegNo->GetValue();
- lldb::SBValue regValue = GetRegister(nRegIndex);
- if (regValue.IsValid())
- {
- AddToOutput(nRegIndex, regValue, eFormat);
- }
-
- // Next
- ++it;
- }
+ // Next
+ ++it;
}
- else
- {
- // No register numbers are provided. Output all registers.
- lldb::SBThread thread = sbProcess.GetSelectedThread();
- lldb::SBFrame frame = thread.GetSelectedFrame();
- lldb::SBValueList registers = frame.GetRegisters();
- const MIuint nRegisters = registers.GetSize();
- MIuint nRegIndex = 0;
- for (MIuint i = 0; i < nRegisters; i++)
- {
- lldb::SBValue value = registers.GetValueAtIndex(i);
- const MIuint nRegChildren = value.GetNumChildren();
- for (MIuint j = 0; j < nRegChildren; j++)
- {
- lldb::SBValue regValue = value.GetChildAtIndex(j);
- if (regValue.IsValid())
- {
- AddToOutput(nRegIndex, regValue, eFormat);
- }
-
- // Next
- ++nRegIndex;
- }
+ } else {
+ // No register numbers are provided. Output all registers.
+ lldb::SBThread thread = sbProcess.GetSelectedThread();
+ lldb::SBFrame frame = thread.GetSelectedFrame();
+ lldb::SBValueList registers = frame.GetRegisters();
+ const MIuint nRegisters = registers.GetSize();
+ MIuint nRegIndex = 0;
+ for (MIuint i = 0; i < nRegisters; i++) {
+ lldb::SBValue value = registers.GetValueAtIndex(i);
+ const MIuint nRegChildren = value.GetNumChildren();
+ for (MIuint j = 0; j < nRegChildren; j++) {
+ lldb::SBValue regValue = value.GetChildAtIndex(j);
+ if (regValue.IsValid()) {
+ AddToOutput(nRegIndex, regValue, eFormat);
}
+
+ // Next
+ ++nRegIndex;
+ }
}
+ }
- return MIstatus::success;
+ return MIstatus::success;
}
-//++ ------------------------------------------------------------------------------------
-// Details: The invoker requires this function. The command prepares a MI Record Result
+//++
+//------------------------------------------------------------------------------------
+// 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.
@@ -1103,137 +1137,140 @@ CMICmdCmdDataListRegisterValues::Execute
// MIstatus::failure - Functional failed.
// Throws: None.
//--
-bool
-CMICmdCmdDataListRegisterValues::Acknowledge()
-{
- const CMICmnMIValueResult miValueResult("register-values", m_miValueList);
- const CMICmnMIResultRecord miRecordResult(m_cmdData.strMiCmdToken, CMICmnMIResultRecord::eResultClass_Done, miValueResult);
- m_miResultRecord = miRecordResult;
-
- return MIstatus::success;
+bool CMICmdCmdDataListRegisterValues::Acknowledge() {
+ const CMICmnMIValueResult miValueResult("register-values", m_miValueList);
+ const CMICmnMIResultRecord miRecordResult(
+ m_cmdData.strMiCmdToken, CMICmnMIResultRecord::eResultClass_Done,
+ miValueResult);
+ m_miResultRecord = miRecordResult;
+
+ return MIstatus::success;
}
-//++ ------------------------------------------------------------------------------------
-// Details: Required by the CMICmdFactory when registering *this command. The factory
+//++
+//------------------------------------------------------------------------------------
+// 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 *
-CMICmdCmdDataListRegisterValues::CreateSelf()
-{
- return new CMICmdCmdDataListRegisterValues();
+CMICmdBase *CMICmdCmdDataListRegisterValues::CreateSelf() {
+ return new CMICmdCmdDataListRegisterValues();
}
-//++ ------------------------------------------------------------------------------------
-// Details: Required by the CMICmdFactory when registering *this command. The factory
+//++
+//------------------------------------------------------------------------------------
+// Details: Required by the CMICmdFactory when registering *this command. The
+// factory
// calls this function to create an instance of *this command.
// Type: Method.
// Args: None.
// Return: lldb::SBValue - LLDB SBValue object.
// Throws: None.
//--
-lldb::SBValue
-CMICmdCmdDataListRegisterValues::GetRegister(const MIuint vRegisterIndex) const
-{
- lldb::SBThread thread = CMICmnLLDBDebugSessionInfo::Instance().GetProcess().GetSelectedThread();
- lldb::SBFrame frame = thread.GetSelectedFrame();
- lldb::SBValueList registers = frame.GetRegisters();
- const MIuint nRegisters = registers.GetSize();
- MIuint nRegisterIndex(vRegisterIndex);
- for (MIuint i = 0; i < nRegisters; i++)
- {
- lldb::SBValue value = registers.GetValueAtIndex(i);
- const MIuint nRegChildren = value.GetNumChildren();
- if (nRegisterIndex >= nRegChildren)
- {
- nRegisterIndex -= nRegChildren;
- continue;
- }
-
- lldb::SBValue value2 = value.GetChildAtIndex(nRegisterIndex);
- if (value2.IsValid())
- {
- return value2;
- }
+lldb::SBValue CMICmdCmdDataListRegisterValues::GetRegister(
+ const MIuint vRegisterIndex) const {
+ lldb::SBThread thread =
+ CMICmnLLDBDebugSessionInfo::Instance().GetProcess().GetSelectedThread();
+ lldb::SBFrame frame = thread.GetSelectedFrame();
+ lldb::SBValueList registers = frame.GetRegisters();
+ const MIuint nRegisters = registers.GetSize();
+ MIuint nRegisterIndex(vRegisterIndex);
+ for (MIuint i = 0; i < nRegisters; i++) {
+ lldb::SBValue value = registers.GetValueAtIndex(i);
+ const MIuint nRegChildren = value.GetNumChildren();
+ if (nRegisterIndex >= nRegChildren) {
+ nRegisterIndex -= nRegChildren;
+ continue;
+ }
+
+ lldb::SBValue value2 = value.GetChildAtIndex(nRegisterIndex);
+ if (value2.IsValid()) {
+ return value2;
}
+ }
- return lldb::SBValue();
+ return lldb::SBValue();
}
-//++ ------------------------------------------------------------------------------------
+//++
+//------------------------------------------------------------------------------------
// Details: Adds the register value to the output list.
// Type: Method.
// Args: Value of the register, its index and output format.
// Return: None
// Throws: None.
//--
-void
-CMICmdCmdDataListRegisterValues::AddToOutput(const MIuint vnIndex, const lldb::SBValue &vrValue,
- CMICmnLLDBDebugSessionInfoVarObj::varFormat_e veVarFormat)
-{
- const CMICmnMIValueConst miValueConst(CMIUtilString::Format("%u", vnIndex));
- const CMICmnMIValueResult miValueResult("number", miValueConst);
- CMICmnMIValueTuple miValueTuple(miValueResult);
- const CMIUtilString strRegValue(CMICmnLLDBDebugSessionInfoVarObj::GetValueStringFormatted(vrValue, veVarFormat));
- const CMICmnMIValueConst miValueConst2(strRegValue);
- const CMICmnMIValueResult miValueResult2("value", miValueConst2);
- miValueTuple.Add(miValueResult2);
- m_miValueList.Add(miValueTuple);
+void CMICmdCmdDataListRegisterValues::AddToOutput(
+ const MIuint vnIndex, const lldb::SBValue &vrValue,
+ CMICmnLLDBDebugSessionInfoVarObj::varFormat_e veVarFormat) {
+ const CMICmnMIValueConst miValueConst(CMIUtilString::Format("%u", vnIndex));
+ const CMICmnMIValueResult miValueResult("number", miValueConst);
+ CMICmnMIValueTuple miValueTuple(miValueResult);
+ const CMIUtilString strRegValue(
+ CMICmnLLDBDebugSessionInfoVarObj::GetValueStringFormatted(vrValue,
+ veVarFormat));
+ const CMICmnMIValueConst miValueConst2(strRegValue);
+ const CMICmnMIValueResult miValueResult2("value", miValueConst2);
+ miValueTuple.Add(miValueResult2);
+ m_miValueList.Add(miValueTuple);
}
//---------------------------------------------------------------------------------------
//---------------------------------------------------------------------------------------
//---------------------------------------------------------------------------------------
-//++ ------------------------------------------------------------------------------------
+//++
+//------------------------------------------------------------------------------------
// Details: CMICmdCmdDataListRegisterChanged constructor.
// Type: Method.
// Args: None.
// Return: None.
// Throws: None.
//--
-CMICmdCmdDataListRegisterChanged::CMICmdCmdDataListRegisterChanged()
-{
- // Command factory matches this name with that received from the stdin stream
- m_strMiCmd = "data-list-changed-registers";
+CMICmdCmdDataListRegisterChanged::CMICmdCmdDataListRegisterChanged() {
+ // Command factory matches this name with that received from the stdin stream
+ m_strMiCmd = "data-list-changed-registers";
- // Required by the CMICmdFactory when registering *this command
- m_pSelfCreatorFn = &CMICmdCmdDataListRegisterChanged::CreateSelf;
+ // Required by the CMICmdFactory when registering *this command
+ m_pSelfCreatorFn = &CMICmdCmdDataListRegisterChanged::CreateSelf;
}
-//++ ------------------------------------------------------------------------------------
+//++
+//------------------------------------------------------------------------------------
// Details: CMICmdCmdDataListRegisterChanged destructor.
// Type: Overrideable.
// Args: None.
// Return: None.
// Throws: None.
//--
-CMICmdCmdDataListRegisterChanged::~CMICmdCmdDataListRegisterChanged()
-{
-}
+CMICmdCmdDataListRegisterChanged::~CMICmdCmdDataListRegisterChanged() {}
-//++ ------------------------------------------------------------------------------------
-// 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.
+//++
+//------------------------------------------------------------------------------------
+// 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
-CMICmdCmdDataListRegisterChanged::Execute()
-{
- // Do nothing
+bool CMICmdCmdDataListRegisterChanged::Execute() {
+ // Do nothing
- return MIstatus::success;
+ return MIstatus::success;
}
-//++ ------------------------------------------------------------------------------------
-// Details: The invoker requires this function. The command prepares a MI Record Result
+//++
+//------------------------------------------------------------------------------------
+// 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.
@@ -1241,36 +1278,37 @@ CMICmdCmdDataListRegisterChanged::Execut
// MIstatus::failure - Functional failed.
// Throws: None.
//--
-bool
-CMICmdCmdDataListRegisterChanged::Acknowledge()
-{
- 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;
+bool CMICmdCmdDataListRegisterChanged::Acknowledge() {
+ 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
+//++
+//------------------------------------------------------------------------------------
+// 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 *
-CMICmdCmdDataListRegisterChanged::CreateSelf()
-{
- return new CMICmdCmdDataListRegisterChanged();
+CMICmdBase *CMICmdCmdDataListRegisterChanged::CreateSelf() {
+ return new CMICmdCmdDataListRegisterChanged();
}
//---------------------------------------------------------------------------------------
//---------------------------------------------------------------------------------------
//---------------------------------------------------------------------------------------
-//++ ------------------------------------------------------------------------------------
+//++
+//------------------------------------------------------------------------------------
// Details: CMICmdCmdDataWriteMemoryBytes constructor.
// Type: Method.
// Args: None.
@@ -1278,30 +1316,29 @@ CMICmdCmdDataListRegisterChanged::Create
// Throws: None.
//--
CMICmdCmdDataWriteMemoryBytes::CMICmdCmdDataWriteMemoryBytes()
- : m_constStrArgAddr("address")
- , m_constStrArgContents("contents")
- , m_constStrArgCount("count")
-{
- // Command factory matches this name with that received from the stdin stream
- m_strMiCmd = "data-write-memory-bytes";
+ : m_constStrArgAddr("address"), m_constStrArgContents("contents"),
+ m_constStrArgCount("count") {
+ // Command factory matches this name with that received from the stdin stream
+ m_strMiCmd = "data-write-memory-bytes";
- // Required by the CMICmdFactory when registering *this command
- m_pSelfCreatorFn = &CMICmdCmdDataWriteMemoryBytes::CreateSelf;
+ // Required by the CMICmdFactory when registering *this command
+ m_pSelfCreatorFn = &CMICmdCmdDataWriteMemoryBytes::CreateSelf;
}
-//++ ------------------------------------------------------------------------------------
+//++
+//------------------------------------------------------------------------------------
// Details: CMICmdCmdDataWriteMemoryBytes destructor.
// Type: Overrideable.
// Args: None.
// Return: None.
// Throws: None.
//--
-CMICmdCmdDataWriteMemoryBytes::~CMICmdCmdDataWriteMemoryBytes()
-{
-}
+CMICmdCmdDataWriteMemoryBytes::~CMICmdCmdDataWriteMemoryBytes() {}
-//++ ------------------------------------------------------------------------------------
-// Details: The invoker requires this function. The parses the command line options
+//++
+//------------------------------------------------------------------------------------
+// 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.
@@ -1309,41 +1346,45 @@ CMICmdCmdDataWriteMemoryBytes::~CMICmdCm
// MIstatus::failure - Functional failed.
// Throws: None.
//--
-bool
-CMICmdCmdDataWriteMemoryBytes::ParseArgs()
-{
- m_setCmdArgs.Add(new CMICmdArgValString(m_constStrArgAddr, true, true, false, true));
- m_setCmdArgs.Add(new CMICmdArgValString(m_constStrArgContents, true, true, true, true));
- m_setCmdArgs.Add(new CMICmdArgValString(m_constStrArgCount, false, true, false, true));
- return ParseValidateCmdOptions();
+bool CMICmdCmdDataWriteMemoryBytes::ParseArgs() {
+ m_setCmdArgs.Add(
+ new CMICmdArgValString(m_constStrArgAddr, true, true, false, true));
+ m_setCmdArgs.Add(
+ new CMICmdArgValString(m_constStrArgContents, true, true, true, true));
+ m_setCmdArgs.Add(
+ new CMICmdArgValString(m_constStrArgCount, false, true, false, true));
+ return ParseValidateCmdOptions();
}
-//++ ------------------------------------------------------------------------------------
-// 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.
+//++
+//------------------------------------------------------------------------------------
+// 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
-CMICmdCmdDataWriteMemoryBytes::Execute()
-{
- // Do nothing - not reproduceable (yet) in Eclipse
- // CMICMDBASE_GETOPTION( pArgOffset, OptionShort, m_constStrArgOffset );
- // CMICMDBASE_GETOPTION( pArgAddr, String, m_constStrArgAddr );
- // CMICMDBASE_GETOPTION( pArgNumber, String, m_constStrArgNumber );
- // CMICMDBASE_GETOPTION( pArgContents, String, m_constStrArgContents );
- //
- // Numbers extracts as string types as they could be hex numbers
- // '&' is not recognised and so has to be removed
+bool CMICmdCmdDataWriteMemoryBytes::Execute() {
+ // Do nothing - not reproduceable (yet) in Eclipse
+ // CMICMDBASE_GETOPTION( pArgOffset, OptionShort, m_constStrArgOffset );
+ // CMICMDBASE_GETOPTION( pArgAddr, String, m_constStrArgAddr );
+ // CMICMDBASE_GETOPTION( pArgNumber, String, m_constStrArgNumber );
+ // CMICMDBASE_GETOPTION( pArgContents, String, m_constStrArgContents );
+ //
+ // Numbers extracts as string types as they could be hex numbers
+ // '&' is not recognised and so has to be removed
- return MIstatus::success;
+ return MIstatus::success;
}
-//++ ------------------------------------------------------------------------------------
-// Details: The invoker requires this function. The command prepares a MI Record Result
+//++
+//------------------------------------------------------------------------------------
+// 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.
@@ -1351,36 +1392,37 @@ CMICmdCmdDataWriteMemoryBytes::Execute()
// MIstatus::failure - Functional failed.
// Throws: None.
//--
-bool
-CMICmdCmdDataWriteMemoryBytes::Acknowledge()
-{
- 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;
+bool CMICmdCmdDataWriteMemoryBytes::Acknowledge() {
+ 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
+//++
+//------------------------------------------------------------------------------------
+// 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 *
-CMICmdCmdDataWriteMemoryBytes::CreateSelf()
-{
- return new CMICmdCmdDataWriteMemoryBytes();
+CMICmdBase *CMICmdCmdDataWriteMemoryBytes::CreateSelf() {
+ return new CMICmdCmdDataWriteMemoryBytes();
}
//---------------------------------------------------------------------------------------
//---------------------------------------------------------------------------------------
//---------------------------------------------------------------------------------------
-//++ ------------------------------------------------------------------------------------
+//++
+//------------------------------------------------------------------------------------
// Details: CMICmdCmdDataWriteMemory constructor.
// Type: Method.
// Args: None.
@@ -1388,40 +1430,36 @@ CMICmdCmdDataWriteMemoryBytes::CreateSel
// Throws: None.
//--
CMICmdCmdDataWriteMemory::CMICmdCmdDataWriteMemory()
- : m_constStrArgOffset("o")
- , m_constStrArgAddr("address")
- , m_constStrArgD("d")
- , m_constStrArgNumber("a number")
- , m_constStrArgContents("contents")
- , m_nAddr(0)
- , m_nCount(0)
- , m_pBufferMemory(nullptr)
-{
- // Command factory matches this name with that received from the stdin stream
- m_strMiCmd = "data-write-memory";
+ : m_constStrArgOffset("o"), m_constStrArgAddr("address"),
+ m_constStrArgD("d"), m_constStrArgNumber("a number"),
+ m_constStrArgContents("contents"), m_nAddr(0), m_nCount(0),
+ m_pBufferMemory(nullptr) {
+ // Command factory matches this name with that received from the stdin stream
+ m_strMiCmd = "data-write-memory";
- // Required by the CMICmdFactory when registering *this command
- m_pSelfCreatorFn = &CMICmdCmdDataWriteMemory::CreateSelf;
+ // Required by the CMICmdFactory when registering *this command
+ m_pSelfCreatorFn = &CMICmdCmdDataWriteMemory::CreateSelf;
}
-//++ ------------------------------------------------------------------------------------
+//++
+//------------------------------------------------------------------------------------
// Details: CMICmdCmdDataWriteMemory destructor.
// Type: Overrideable.
// Args: None.
// Return: None.
// Throws: None.
//--
-CMICmdCmdDataWriteMemory::~CMICmdCmdDataWriteMemory()
-{
- if (m_pBufferMemory != nullptr)
- {
- delete[] m_pBufferMemory;
- m_pBufferMemory = nullptr;
- }
+CMICmdCmdDataWriteMemory::~CMICmdCmdDataWriteMemory() {
+ if (m_pBufferMemory != nullptr) {
+ delete[] m_pBufferMemory;
+ m_pBufferMemory = nullptr;
+ }
}
-//++ ------------------------------------------------------------------------------------
-// Details: The invoker requires this function. The parses the command line options
+//++
+//------------------------------------------------------------------------------------
+// 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.
@@ -1429,77 +1467,85 @@ CMICmdCmdDataWriteMemory::~CMICmdCmdData
// MIstatus::failure - Functional failed.
// Throws: None.
//--
-bool
-CMICmdCmdDataWriteMemory::ParseArgs()
-{
- m_setCmdArgs.Add(new CMICmdArgValOptionShort(m_constStrArgOffset, false, true, CMICmdArgValListBase::eArgValType_Number, 1));
- m_setCmdArgs.Add(new CMICmdArgValNumber(m_constStrArgAddr, true, true));
- m_setCmdArgs.Add(new CMICmdArgValString(m_constStrArgD, true, true));
- m_setCmdArgs.Add(new CMICmdArgValNumber(m_constStrArgNumber, true, true));
- m_setCmdArgs.Add(new CMICmdArgValNumber(m_constStrArgContents, true, true));
- return ParseValidateCmdOptions();
-}
-
-//++ ------------------------------------------------------------------------------------
-// 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.
+bool CMICmdCmdDataWriteMemory::ParseArgs() {
+ m_setCmdArgs.Add(
+ new CMICmdArgValOptionShort(m_constStrArgOffset, false, true,
+ CMICmdArgValListBase::eArgValType_Number, 1));
+ m_setCmdArgs.Add(new CMICmdArgValNumber(m_constStrArgAddr, true, true));
+ m_setCmdArgs.Add(new CMICmdArgValString(m_constStrArgD, true, true));
+ m_setCmdArgs.Add(new CMICmdArgValNumber(m_constStrArgNumber, true, true));
+ m_setCmdArgs.Add(new CMICmdArgValNumber(m_constStrArgContents, true, true));
+ return ParseValidateCmdOptions();
+}
+
+//++
+//------------------------------------------------------------------------------------
+// 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
-CMICmdCmdDataWriteMemory::Execute()
-{
- CMICMDBASE_GETOPTION(pArgOffset, OptionShort, m_constStrArgOffset);
- CMICMDBASE_GETOPTION(pArgAddr, Number, m_constStrArgAddr);
- CMICMDBASE_GETOPTION(pArgNumber, Number, m_constStrArgNumber);
- CMICMDBASE_GETOPTION(pArgContents, Number, m_constStrArgContents);
-
- MIuint nAddrOffset = 0;
- if (pArgOffset->GetFound() && !pArgOffset->GetExpectedOption<CMICmdArgValNumber, MIuint>(nAddrOffset))
- {
- SetError(CMIUtilString::Format(MIRSRC(IDS_CMD_ARGS_ERR_VALIDATION_INVALID), m_cmdData.strMiCmd.c_str(), m_constStrArgAddr.c_str()));
- return MIstatus::failure;
- }
- m_nAddr = pArgAddr->GetValue();
- m_nCount = pArgNumber->GetValue();
- const MIuint64 nValue = pArgContents->GetValue();
-
- m_pBufferMemory = new unsigned char[m_nCount];
- if (m_pBufferMemory == nullptr)
- {
- SetError(CMIUtilString::Format(MIRSRC(IDS_CMD_ERR_MEMORY_ALLOC_FAILURE), m_cmdData.strMiCmd.c_str(), m_nCount));
- return MIstatus::failure;
- }
- *m_pBufferMemory = static_cast<char>(nValue);
-
- CMICmnLLDBDebugSessionInfo &rSessionInfo(CMICmnLLDBDebugSessionInfo::Instance());
- lldb::SBProcess sbProcess = rSessionInfo.GetProcess();
- lldb::SBError error;
- lldb::addr_t addr = static_cast<lldb::addr_t>(m_nAddr + nAddrOffset);
- const size_t nBytesWritten = sbProcess.WriteMemory(addr, (const void *)m_pBufferMemory, (size_t)m_nCount, error);
- if (nBytesWritten != static_cast<size_t>(m_nCount))
- {
- SetError(CMIUtilString::Format(MIRSRC(IDS_CMD_ERR_LLDB_ERR_NOT_WRITE_WHOLEBLK), m_cmdData.strMiCmd.c_str(), m_nCount, addr));
- return MIstatus::failure;
- }
- if (error.Fail())
- {
- lldb::SBStream err;
- const bool bOk = error.GetDescription(err);
- MIunused(bOk);
- SetError(
- CMIUtilString::Format(MIRSRC(IDS_CMD_ERR_LLDB_ERR_WRITE_MEM_BYTES), m_cmdData.strMiCmd.c_str(), m_nCount, addr, err.GetData()));
- return MIstatus::failure;
- }
-
- return MIstatus::success;
-}
-
-//++ ------------------------------------------------------------------------------------
-// Details: The invoker requires this function. The command prepares a MI Record Result
+bool CMICmdCmdDataWriteMemory::Execute() {
+ CMICMDBASE_GETOPTION(pArgOffset, OptionShort, m_constStrArgOffset);
+ CMICMDBASE_GETOPTION(pArgAddr, Number, m_constStrArgAddr);
+ CMICMDBASE_GETOPTION(pArgNumber, Number, m_constStrArgNumber);
+ CMICMDBASE_GETOPTION(pArgContents, Number, m_constStrArgContents);
+
+ MIuint nAddrOffset = 0;
+ if (pArgOffset->GetFound() &&
+ !pArgOffset->GetExpectedOption<CMICmdArgValNumber, MIuint>(nAddrOffset)) {
+ SetError(CMIUtilString::Format(MIRSRC(IDS_CMD_ARGS_ERR_VALIDATION_INVALID),
+ m_cmdData.strMiCmd.c_str(),
+ m_constStrArgAddr.c_str()));
+ return MIstatus::failure;
+ }
+ m_nAddr = pArgAddr->GetValue();
+ m_nCount = pArgNumber->GetValue();
+ const MIuint64 nValue = pArgContents->GetValue();
+
+ m_pBufferMemory = new unsigned char[m_nCount];
+ if (m_pBufferMemory == nullptr) {
+ SetError(CMIUtilString::Format(MIRSRC(IDS_CMD_ERR_MEMORY_ALLOC_FAILURE),
+ m_cmdData.strMiCmd.c_str(), m_nCount));
+ return MIstatus::failure;
+ }
+ *m_pBufferMemory = static_cast<char>(nValue);
+
+ CMICmnLLDBDebugSessionInfo &rSessionInfo(
+ CMICmnLLDBDebugSessionInfo::Instance());
+ lldb::SBProcess sbProcess = rSessionInfo.GetProcess();
+ lldb::SBError error;
+ lldb::addr_t addr = static_cast<lldb::addr_t>(m_nAddr + nAddrOffset);
+ const size_t nBytesWritten = sbProcess.WriteMemory(
+ addr, (const void *)m_pBufferMemory, (size_t)m_nCount, error);
+ if (nBytesWritten != static_cast<size_t>(m_nCount)) {
+ SetError(
+ CMIUtilString::Format(MIRSRC(IDS_CMD_ERR_LLDB_ERR_NOT_WRITE_WHOLEBLK),
+ m_cmdData.strMiCmd.c_str(), m_nCount, addr));
+ return MIstatus::failure;
+ }
+ if (error.Fail()) {
+ lldb::SBStream err;
+ const bool bOk = error.GetDescription(err);
+ MIunused(bOk);
+ SetError(CMIUtilString::Format(MIRSRC(IDS_CMD_ERR_LLDB_ERR_WRITE_MEM_BYTES),
+ m_cmdData.strMiCmd.c_str(), m_nCount, addr,
+ err.GetData()));
+ 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.
@@ -1507,34 +1553,34 @@ CMICmdCmdDataWriteMemory::Execute()
// MIstatus::failure - Functional failed.
// Throws: None.
//--
-bool
-CMICmdCmdDataWriteMemory::Acknowledge()
-{
- const CMICmnMIResultRecord miRecordResult(m_cmdData.strMiCmdToken, CMICmnMIResultRecord::eResultClass_Done);
- m_miResultRecord = miRecordResult;
-
- return MIstatus::success;
+bool CMICmdCmdDataWriteMemory::Acknowledge() {
+ const CMICmnMIResultRecord miRecordResult(
+ m_cmdData.strMiCmdToken, CMICmnMIResultRecord::eResultClass_Done);
+ m_miResultRecord = miRecordResult;
+
+ return MIstatus::success;
}
-//++ ------------------------------------------------------------------------------------
-// Details: Required by the CMICmdFactory when registering *this command. The factory
+//++
+//------------------------------------------------------------------------------------
+// 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 *
-CMICmdCmdDataWriteMemory::CreateSelf()
-{
- return new CMICmdCmdDataWriteMemory();
+CMICmdBase *CMICmdCmdDataWriteMemory::CreateSelf() {
+ return new CMICmdCmdDataWriteMemory();
}
//---------------------------------------------------------------------------------------
//---------------------------------------------------------------------------------------
//---------------------------------------------------------------------------------------
-//++ ------------------------------------------------------------------------------------
+//++
+//------------------------------------------------------------------------------------
// Details: CMICmdCmdDataInfoLine constructor.
// Type: Method.
// Args: None.
@@ -1542,28 +1588,28 @@ CMICmdCmdDataWriteMemory::CreateSelf()
// Throws: None.
//--
CMICmdCmdDataInfoLine::CMICmdCmdDataInfoLine()
- : m_constStrArgLocation("location")
-{
- // Command factory matches this name with that received from the stdin stream
- m_strMiCmd = "data-info-line";
+ : m_constStrArgLocation("location") {
+ // Command factory matches this name with that received from the stdin stream
+ m_strMiCmd = "data-info-line";
- // Required by the CMICmdFactory when registering *this command
- m_pSelfCreatorFn = &CMICmdCmdDataInfoLine::CreateSelf;
+ // Required by the CMICmdFactory when registering *this command
+ m_pSelfCreatorFn = &CMICmdCmdDataInfoLine::CreateSelf;
}
-//++ ------------------------------------------------------------------------------------
+//++
+//------------------------------------------------------------------------------------
// Details: CMICmdCmdDataInfoLine destructor.
// Type: Overrideable.
// Args: None.
// Return: None.
// Throws: None.
//--
-CMICmdCmdDataInfoLine::~CMICmdCmdDataInfoLine()
-{
-}
+CMICmdCmdDataInfoLine::~CMICmdCmdDataInfoLine() {}
-//++ ------------------------------------------------------------------------------------
-// Details: The invoker requires this function. The parses the command line options
+//++
+//------------------------------------------------------------------------------------
+// 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.
@@ -1571,112 +1617,124 @@ CMICmdCmdDataInfoLine::~CMICmdCmdDataInf
// MIstatus::failure - Functional failed.
// Throws: None.
//--
-bool
-CMICmdCmdDataInfoLine::ParseArgs()
-{
- m_setCmdArgs.Add(new CMICmdArgValString(m_constStrArgLocation, true, true));
- return ParseValidateCmdOptions();
-}
-
-//++ ------------------------------------------------------------------------------------
-// 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.
+bool CMICmdCmdDataInfoLine::ParseArgs() {
+ m_setCmdArgs.Add(new CMICmdArgValString(m_constStrArgLocation, true, true));
+ return ParseValidateCmdOptions();
+}
+
+//++
+//------------------------------------------------------------------------------------
+// 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
-CMICmdCmdDataInfoLine::Execute()
-{
- CMICMDBASE_GETOPTION(pArgLocation, String, m_constStrArgLocation);
-
- const CMIUtilString &strLocation(pArgLocation->GetValue());
- CMIUtilString strCmdOptionsLocation;
- if (strLocation.at(0) == '*')
- {
- // Parse argument:
- // *0x12345
- // ^^^^^^^ -- address
- const CMIUtilString strAddress(strLocation.substr(1));
- strCmdOptionsLocation = CMIUtilString::Format("--address %s", strAddress.c_str());
- }
- else
- {
- const size_t nLineStartPos = strLocation.rfind(':');
- if ((nLineStartPos == std::string::npos) || (nLineStartPos == 0) || (nLineStartPos == strLocation.length() - 1))
- {
- SetError(CMIUtilString::Format(MIRSRC(IDS_CMD_ERR_INVALID_LOCATION_FORMAT), m_cmdData.strMiCmd.c_str(), strLocation.c_str())
- .c_str());
- return MIstatus::failure;
- }
- // Parse argument:
- // hello.cpp:5
- // ^^^^^^^^^ -- file
- // ^ -- line
- const CMIUtilString strFile(strLocation.substr(0, nLineStartPos));
- const CMIUtilString strLine(strLocation.substr(nLineStartPos + 1));
- strCmdOptionsLocation = CMIUtilString::Format("--file \"%s\" --line %s", strFile.AddSlashes().c_str(), strLine.c_str());
- }
- const CMIUtilString strCmd(CMIUtilString::Format("target modules lookup -v %s", strCmdOptionsLocation.c_str()));
-
- CMICmnLLDBDebugSessionInfo &rSessionInfo(CMICmnLLDBDebugSessionInfo::Instance());
- const lldb::ReturnStatus rtn = rSessionInfo.GetDebugger().GetCommandInterpreter().HandleCommand(strCmd.c_str(), m_lldbResult);
- MIunused(rtn);
-
- return MIstatus::success;
-}
-
-//++ ------------------------------------------------------------------------------------
-// Details: Helper function for parsing a line entry returned from lldb for the command:
+bool CMICmdCmdDataInfoLine::Execute() {
+ CMICMDBASE_GETOPTION(pArgLocation, String, m_constStrArgLocation);
+
+ const CMIUtilString &strLocation(pArgLocation->GetValue());
+ CMIUtilString strCmdOptionsLocation;
+ if (strLocation.at(0) == '*') {
+ // Parse argument:
+ // *0x12345
+ // ^^^^^^^ -- address
+ const CMIUtilString strAddress(strLocation.substr(1));
+ strCmdOptionsLocation =
+ CMIUtilString::Format("--address %s", strAddress.c_str());
+ } else {
+ const size_t nLineStartPos = strLocation.rfind(':');
+ if ((nLineStartPos == std::string::npos) || (nLineStartPos == 0) ||
+ (nLineStartPos == strLocation.length() - 1)) {
+ SetError(
+ CMIUtilString::Format(MIRSRC(IDS_CMD_ERR_INVALID_LOCATION_FORMAT),
+ m_cmdData.strMiCmd.c_str(), strLocation.c_str())
+ .c_str());
+ return MIstatus::failure;
+ }
+ // Parse argument:
+ // hello.cpp:5
+ // ^^^^^^^^^ -- file
+ // ^ -- line
+ const CMIUtilString strFile(strLocation.substr(0, nLineStartPos));
+ const CMIUtilString strLine(strLocation.substr(nLineStartPos + 1));
+ strCmdOptionsLocation =
+ CMIUtilString::Format("--file \"%s\" --line %s",
+ strFile.AddSlashes().c_str(), strLine.c_str());
+ }
+ const CMIUtilString strCmd(CMIUtilString::Format(
+ "target modules lookup -v %s", strCmdOptionsLocation.c_str()));
+
+ CMICmnLLDBDebugSessionInfo &rSessionInfo(
+ CMICmnLLDBDebugSessionInfo::Instance());
+ const lldb::ReturnStatus rtn =
+ rSessionInfo.GetDebugger().GetCommandInterpreter().HandleCommand(
+ strCmd.c_str(), m_lldbResult);
+ MIunused(rtn);
+
+ return MIstatus::success;
+}
+
+//++
+//------------------------------------------------------------------------------------
+// Details: Helper function for parsing a line entry returned from lldb for the
+// command:
// target modules lookup -v <location>
// where the line entry is of the format:
-// LineEntry: \[0x0000000100000f37-0x0000000100000f45\): /path/file:3[:1]
-// start end file line column(opt)
+// LineEntry: \[0x0000000100000f37-0x0000000100000f45\):
+// /path/file:3[:1]
+// start end file
+// line column(opt)
// Args: input - (R) Input string to parse.
// start - (W) String representing the start address.
// end - (W) String representing the end address.
// file - (W) String representing the file.
// line - (W) String representing the line.
-// Return: bool - True = input was parsed successfully, false = input could not be parsed.
+// Return: bool - True = input was parsed successfully, false = input could not
+// be parsed.
// Throws: None.
//--
-static bool
-ParseLLDBLineEntry(const char *input, CMIUtilString &start, CMIUtilString &end,
- CMIUtilString &file, CMIUtilString &line)
-{
- // Note: Ambiguities arise because the column is optional, and
- // because : can appear in filenames or as a byte in a multibyte
- // UTF8 character. We keep those cases to a minimum by using regex
- // to work on the string from both the left and right, so that what
- // is remains is assumed to be the filename.
-
- // Match LineEntry using regex.
- static llvm::Regex g_lineentry_nocol_regex(
- llvm::StringRef("^ *LineEntry: \\[(0x[0-9a-fA-F]+)-(0x[0-9a-fA-F]+)\\): (.+):([0-9]+)$"));
- static llvm::Regex g_lineentry_col_regex(
- llvm::StringRef("^ *LineEntry: \\[(0x[0-9a-fA-F]+)-(0x[0-9a-fA-F]+)\\): (.+):([0-9]+):[0-9]+$"));
- // ^1=start ^2=end ^3=f ^4=line ^5=:col(opt)
-
- llvm::SmallVector<llvm::StringRef, 6> match;
-
- // First try matching the LineEntry with the column,
- // then try without the column.
- const bool ok = g_lineentry_col_regex.match(input, &match) ||
- g_lineentry_nocol_regex.match(input, &match);
- if (ok)
- {
- start = match[1];
- end = match[2];
- file = match[3];
- line = match[4];
- }
- return ok;
-}
-
-//++ ------------------------------------------------------------------------------------
-// Details: The invoker requires this function. The command prepares a MI Record Result
+static bool ParseLLDBLineEntry(const char *input, CMIUtilString &start,
+ CMIUtilString &end, CMIUtilString &file,
+ CMIUtilString &line) {
+ // Note: Ambiguities arise because the column is optional, and
+ // because : can appear in filenames or as a byte in a multibyte
+ // UTF8 character. We keep those cases to a minimum by using regex
+ // to work on the string from both the left and right, so that what
+ // is remains is assumed to be the filename.
+
+ // Match LineEntry using regex.
+ static llvm::Regex g_lineentry_nocol_regex(llvm::StringRef(
+ "^ *LineEntry: \\[(0x[0-9a-fA-F]+)-(0x[0-9a-fA-F]+)\\): (.+):([0-9]+)$"));
+ static llvm::Regex g_lineentry_col_regex(
+ llvm::StringRef("^ *LineEntry: \\[(0x[0-9a-fA-F]+)-(0x[0-9a-fA-F]+)\\): "
+ "(.+):([0-9]+):[0-9]+$"));
+ // ^1=start ^2=end ^3=f
+ // ^4=line ^5=:col(opt)
+
+ llvm::SmallVector<llvm::StringRef, 6> match;
+
+ // First try matching the LineEntry with the column,
+ // then try without the column.
+ const bool ok = g_lineentry_col_regex.match(input, &match) ||
+ g_lineentry_nocol_regex.match(input, &match);
+ if (ok) {
+ start = match[1];
+ end = match[2];
+ file = match[3];
+ line = match[4];
+ }
+ return ok;
+}
+
+//++
+//------------------------------------------------------------------------------------
+// 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.
@@ -1684,77 +1742,80 @@ ParseLLDBLineEntry(const char *input, CM
// MIstatus::failure - Functional failed.
// Throws: None.
//--
-bool
-CMICmdCmdDataInfoLine::Acknowledge()
-{
- if (m_lldbResult.GetErrorSize() > 0)
- {
- const CMICmnMIValueConst miValueConst(m_lldbResult.GetError());
- const CMICmnMIValueResult miValueResult("msg", miValueConst);
- const CMICmnMIResultRecord miRecordResult(m_cmdData.strMiCmdToken, CMICmnMIResultRecord::eResultClass_Error, miValueResult);
- m_miResultRecord = miRecordResult;
- return MIstatus::success;
- }
- else if (m_lldbResult.GetOutputSize() > 0)
- {
- CMIUtilString::VecString_t vecLines;
- const CMIUtilString strLldbMsg(m_lldbResult.GetOutput());
- const MIuint nLines(strLldbMsg.SplitLines(vecLines));
-
- for (MIuint i = 0; i < nLines; ++i)
- {
- // String looks like:
- // LineEntry: \[0x0000000100000f37-0x0000000100000f45\): /path/to/file:3[:1]
- const CMIUtilString &rLine(vecLines[i]);
- CMIUtilString strStart;
- CMIUtilString strEnd;
- CMIUtilString strFile;
- CMIUtilString strLine;
-
- if (!ParseLLDBLineEntry(rLine.c_str(), strStart, strEnd, strFile, strLine))
- continue;
-
- const CMICmnMIValueConst miValueConst(strStart);
- const CMICmnMIValueResult miValueResult("start", miValueConst);
- CMICmnMIResultRecord miRecordResult(m_cmdData.strMiCmdToken,
- CMICmnMIResultRecord::eResultClass_Done,
- miValueResult);
- const CMICmnMIValueConst miValueConst2(strEnd);
- const CMICmnMIValueResult miValueResult2("end", miValueConst2);
- miRecordResult.Add(miValueResult2);
- const CMICmnMIValueConst miValueConst3(strFile);
- const CMICmnMIValueResult miValueResult3("file", miValueConst3);
- miRecordResult.Add(miValueResult3);
- const CMICmnMIValueConst miValueConst4(strLine);
- const CMICmnMIValueResult miValueResult4("line", miValueConst4);
- miRecordResult.Add(miValueResult4);
-
- // MI print "%s^done,start=\"%d\",end=\"%d\"",file=\"%s\",line=\"%d\"
- m_miResultRecord = miRecordResult;
-
- return MIstatus::success;
- }
- }
-
- // MI print "%s^error,msg=\"Command '-data-info-line'. Error: The LineEntry is absent or has an unknown format.\""
- const CMICmnMIValueConst miValueConst(CMIUtilString::Format(MIRSRC(IDS_CMD_ERR_SOME_ERROR), m_cmdData.strMiCmd.c_str(), "The LineEntry is absent or has an unknown format."));
+bool CMICmdCmdDataInfoLine::Acknowledge() {
+ if (m_lldbResult.GetErrorSize() > 0) {
+ const CMICmnMIValueConst miValueConst(m_lldbResult.GetError());
const CMICmnMIValueResult miValueResult("msg", miValueConst);
- const CMICmnMIResultRecord miRecordResult(m_cmdData.strMiCmdToken, CMICmnMIResultRecord::eResultClass_Error, miValueResult);
+ 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
+ } else if (m_lldbResult.GetOutputSize() > 0) {
+ CMIUtilString::VecString_t vecLines;
+ const CMIUtilString strLldbMsg(m_lldbResult.GetOutput());
+ const MIuint nLines(strLldbMsg.SplitLines(vecLines));
+
+ for (MIuint i = 0; i < nLines; ++i) {
+ // String looks like:
+ // LineEntry: \[0x0000000100000f37-0x0000000100000f45\):
+ // /path/to/file:3[:1]
+ const CMIUtilString &rLine(vecLines[i]);
+ CMIUtilString strStart;
+ CMIUtilString strEnd;
+ CMIUtilString strFile;
+ CMIUtilString strLine;
+
+ if (!ParseLLDBLineEntry(rLine.c_str(), strStart, strEnd, strFile,
+ strLine))
+ continue;
+
+ const CMICmnMIValueConst miValueConst(strStart);
+ const CMICmnMIValueResult miValueResult("start", miValueConst);
+ CMICmnMIResultRecord miRecordResult(
+ m_cmdData.strMiCmdToken, CMICmnMIResultRecord::eResultClass_Done,
+ miValueResult);
+ const CMICmnMIValueConst miValueConst2(strEnd);
+ const CMICmnMIValueResult miValueResult2("end", miValueConst2);
+ miRecordResult.Add(miValueResult2);
+ const CMICmnMIValueConst miValueConst3(strFile);
+ const CMICmnMIValueResult miValueResult3("file", miValueConst3);
+ miRecordResult.Add(miValueResult3);
+ const CMICmnMIValueConst miValueConst4(strLine);
+ const CMICmnMIValueResult miValueResult4("line", miValueConst4);
+ miRecordResult.Add(miValueResult4);
+
+ // MI print "%s^done,start=\"%d\",end=\"%d\"",file=\"%s\",line=\"%d\"
+ m_miResultRecord = miRecordResult;
+
+ return MIstatus::success;
+ }
+ }
+
+ // MI print "%s^error,msg=\"Command '-data-info-line'. Error: The LineEntry is
+ // absent or has an unknown format.\""
+ const CMICmnMIValueConst miValueConst(CMIUtilString::Format(
+ MIRSRC(IDS_CMD_ERR_SOME_ERROR), m_cmdData.strMiCmd.c_str(),
+ "The LineEntry is absent or has an unknown format."));
+ 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 *
-CMICmdCmdDataInfoLine::CreateSelf()
-{
- return new CMICmdCmdDataInfoLine();
+CMICmdBase *CMICmdCmdDataInfoLine::CreateSelf() {
+ return new CMICmdCmdDataInfoLine();
}
Modified: lldb/trunk/tools/lldb-mi/MICmdCmdData.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/lldb-mi/MICmdCmdData.h?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/tools/lldb-mi/MICmdCmdData.h (original)
+++ lldb/trunk/tools/lldb-mi/MICmdCmdData.h Tue Sep 6 15:57:50 2016
@@ -18,13 +18,16 @@
// CMICmdCmdDataWriteMemory interface.
// CMICmdCmdDataInfoLine 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 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
+// For an introduction to adding a new command see
+// CMICmdCmdSupportInfoMiCmdQuery
// command class as an example.
//
@@ -36,332 +39,344 @@
// In-house headers:
#include "MICmdBase.h"
-#include "MICmnMIValueTuple.h"
-#include "MICmnMIValueList.h"
#include "MICmnLLDBDebugSessionInfoVarObj.h"
+#include "MICmnMIValueList.h"
+#include "MICmnMIValueTuple.h"
-//++ ============================================================================
+//++
+//============================================================================
// Details: MI command class. MI commands derived from the command base class.
// *this class implements MI command "data-evaluate-expression".
//--
-class CMICmdCmdDataEvaluateExpression : public CMICmdBase
-{
- // Statics:
- public:
- // Required by the CMICmdFactory when registering *this command
- static CMICmdBase *CreateSelf();
-
- // Methods:
- public:
- /* ctor */ CMICmdCmdDataEvaluateExpression();
-
- // Overridden:
- public:
- // From CMICmdInvoker::ICmd
- bool Execute() override;
- bool Acknowledge() override;
- bool ParseArgs() override;
- // From CMICmnBase
- /* dtor */ ~CMICmdCmdDataEvaluateExpression() override;
-
- // Methods:
- private:
- bool HaveInvalidCharacterInExpression(const CMIUtilString &vrExpr, char &vrwInvalidChar);
-
- // Attributes:
- 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
- char m_cExpressionInvalidChar;
- const CMIUtilString m_constStrArgExpr;
+class CMICmdCmdDataEvaluateExpression : public CMICmdBase {
+ // Statics:
+public:
+ // Required by the CMICmdFactory when registering *this command
+ static CMICmdBase *CreateSelf();
+
+ // Methods:
+public:
+ /* ctor */ CMICmdCmdDataEvaluateExpression();
+
+ // Overridden:
+public:
+ // From CMICmdInvoker::ICmd
+ bool Execute() override;
+ bool Acknowledge() override;
+ bool ParseArgs() override;
+ // From CMICmnBase
+ /* dtor */ ~CMICmdCmdDataEvaluateExpression() override;
+
+ // Methods:
+private:
+ bool HaveInvalidCharacterInExpression(const CMIUtilString &vrExpr,
+ char &vrwInvalidChar);
+
+ // Attributes:
+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
+ char m_cExpressionInvalidChar;
+ const CMIUtilString m_constStrArgExpr;
};
-//++ ============================================================================
+//++
+//============================================================================
// Details: MI command class. MI commands derived from the command base class.
// *this class implements MI command "data-disassemble".
//--
-class CMICmdCmdDataDisassemble : public CMICmdBase
-{
- // Statics:
- public:
- // Required by the CMICmdFactory when registering *this command
- static CMICmdBase *CreateSelf();
-
- // Methods:
- public:
- /* ctor */ CMICmdCmdDataDisassemble();
-
- // Overridden:
- public:
- // From CMICmdInvoker::ICmd
- bool Execute() override;
- bool Acknowledge() override;
- bool ParseArgs() override;
- // From CMICmnBase
- /* dtor */ ~CMICmdCmdDataDisassemble() override;
-
- // Attributes:
- private:
- const CMIUtilString m_constStrArgAddrStart; // MI spec non mandatory, *this command mandatory
- const CMIUtilString m_constStrArgAddrEnd; // MI spec non mandatory, *this command mandatory
- const CMIUtilString m_constStrArgMode;
- CMICmnMIValueList m_miValueList;
+class CMICmdCmdDataDisassemble : public CMICmdBase {
+ // Statics:
+public:
+ // Required by the CMICmdFactory when registering *this command
+ static CMICmdBase *CreateSelf();
+
+ // Methods:
+public:
+ /* ctor */ CMICmdCmdDataDisassemble();
+
+ // Overridden:
+public:
+ // From CMICmdInvoker::ICmd
+ bool Execute() override;
+ bool Acknowledge() override;
+ bool ParseArgs() override;
+ // From CMICmnBase
+ /* dtor */ ~CMICmdCmdDataDisassemble() override;
+
+ // Attributes:
+private:
+ const CMIUtilString
+ m_constStrArgAddrStart; // MI spec non mandatory, *this command mandatory
+ const CMIUtilString
+ m_constStrArgAddrEnd; // MI spec non mandatory, *this command mandatory
+ const CMIUtilString m_constStrArgMode;
+ CMICmnMIValueList m_miValueList;
};
-//++ ============================================================================
+//++
+//============================================================================
// Details: MI command class. MI commands derived from the command base class.
// *this class implements MI command "data-read-memory-bytes".
//--
-class CMICmdCmdDataReadMemoryBytes : public CMICmdBase
-{
- // Statics:
- public:
- // Required by the CMICmdFactory when registering *this command
- static CMICmdBase *CreateSelf();
-
- // Methods:
- public:
- /* ctor */ CMICmdCmdDataReadMemoryBytes();
-
- // Overridden:
- public:
- // From CMICmdInvoker::ICmd
- bool Execute() override;
- bool Acknowledge() override;
- bool ParseArgs() override;
- // From CMICmnBase
- /* dtor */ ~CMICmdCmdDataReadMemoryBytes() override;
-
- // Attributes:
- private:
- const CMIUtilString m_constStrArgByteOffset;
- const CMIUtilString m_constStrArgAddrExpr;
- const CMIUtilString m_constStrArgNumBytes;
- unsigned char *m_pBufferMemory;
- MIuint64 m_nAddrStart;
- MIuint64 m_nAddrNumBytesToRead;
+class CMICmdCmdDataReadMemoryBytes : public CMICmdBase {
+ // Statics:
+public:
+ // Required by the CMICmdFactory when registering *this command
+ static CMICmdBase *CreateSelf();
+
+ // Methods:
+public:
+ /* ctor */ CMICmdCmdDataReadMemoryBytes();
+
+ // Overridden:
+public:
+ // From CMICmdInvoker::ICmd
+ bool Execute() override;
+ bool Acknowledge() override;
+ bool ParseArgs() override;
+ // From CMICmnBase
+ /* dtor */ ~CMICmdCmdDataReadMemoryBytes() override;
+
+ // Attributes:
+private:
+ const CMIUtilString m_constStrArgByteOffset;
+ const CMIUtilString m_constStrArgAddrExpr;
+ const CMIUtilString m_constStrArgNumBytes;
+ unsigned char *m_pBufferMemory;
+ MIuint64 m_nAddrStart;
+ MIuint64 m_nAddrNumBytesToRead;
};
-//++ ============================================================================
+//++
+//============================================================================
// Details: MI command class. MI commands derived from the command base class.
// *this class implements MI command "data-read-memory".
//--
-class CMICmdCmdDataReadMemory : public CMICmdBase
-{
- // Statics:
- public:
- // Required by the CMICmdFactory when registering *this command
- static CMICmdBase *CreateSelf();
-
- // Methods:
- public:
- /* ctor */ CMICmdCmdDataReadMemory();
-
- // Overridden:
- public:
- // From CMICmdInvoker::ICmd
- bool Execute() override;
- bool Acknowledge() override;
- // From CMICmnBase
- /* dtor */ ~CMICmdCmdDataReadMemory() override;
+class CMICmdCmdDataReadMemory : public CMICmdBase {
+ // Statics:
+public:
+ // Required by the CMICmdFactory when registering *this command
+ static CMICmdBase *CreateSelf();
+
+ // Methods:
+public:
+ /* ctor */ CMICmdCmdDataReadMemory();
+
+ // Overridden:
+public:
+ // From CMICmdInvoker::ICmd
+ bool Execute() override;
+ bool Acknowledge() override;
+ // From CMICmnBase
+ /* dtor */ ~CMICmdCmdDataReadMemory() override;
};
-//++ ============================================================================
+//++
+//============================================================================
// Details: MI command class. MI commands derived from the command base class.
// *this class implements MI command "data-list-register-names".
//--
-class CMICmdCmdDataListRegisterNames : public CMICmdBase
-{
- // Statics:
- public:
- // Required by the CMICmdFactory when registering *this command
- static CMICmdBase *CreateSelf();
-
- // Methods:
- public:
- /* ctor */ CMICmdCmdDataListRegisterNames();
-
- // Overridden:
- public:
- // From CMICmdInvoker::ICmd
- bool Execute() override;
- bool Acknowledge() override;
- bool ParseArgs() override;
- // From CMICmnBase
- /* dtor */ ~CMICmdCmdDataListRegisterNames() override;
-
- // Methods:
- private:
- lldb::SBValue GetRegister(const MIuint vRegisterIndex) const;
-
- // Attributes:
- private:
- const CMIUtilString m_constStrArgRegNo; // Not handled by *this command
- CMICmnMIValueList m_miValueList;
+class CMICmdCmdDataListRegisterNames : public CMICmdBase {
+ // Statics:
+public:
+ // Required by the CMICmdFactory when registering *this command
+ static CMICmdBase *CreateSelf();
+
+ // Methods:
+public:
+ /* ctor */ CMICmdCmdDataListRegisterNames();
+
+ // Overridden:
+public:
+ // From CMICmdInvoker::ICmd
+ bool Execute() override;
+ bool Acknowledge() override;
+ bool ParseArgs() override;
+ // From CMICmnBase
+ /* dtor */ ~CMICmdCmdDataListRegisterNames() override;
+
+ // Methods:
+private:
+ lldb::SBValue GetRegister(const MIuint vRegisterIndex) const;
+
+ // Attributes:
+private:
+ const CMIUtilString m_constStrArgRegNo; // Not handled by *this command
+ CMICmnMIValueList m_miValueList;
};
-//++ ============================================================================
+//++
+//============================================================================
// Details: MI command class. MI commands derived from the command base class.
// *this class implements MI command "data-list-register-values".
//--
-class CMICmdCmdDataListRegisterValues : public CMICmdBase
-{
- // Statics:
- public:
- // Required by the CMICmdFactory when registering *this command
- static CMICmdBase *CreateSelf();
-
- // Methods:
- public:
- /* ctor */ CMICmdCmdDataListRegisterValues();
-
- // Overridden:
- public:
- // From CMICmdInvoker::ICmd
- bool Execute() override;
- bool Acknowledge() override;
- bool ParseArgs() override;
- // From CMICmnBase
- /* dtor */ ~CMICmdCmdDataListRegisterValues() override;
-
- // Methods:
- private:
- lldb::SBValue GetRegister(const MIuint vRegisterIndex) const;
- void AddToOutput(const MIuint vnIndex, const lldb::SBValue &vrValue, CMICmnLLDBDebugSessionInfoVarObj::varFormat_e veVarFormat);
-
- // Attributes:
- private:
- const CMIUtilString m_constStrArgSkip; // Not handled by *this command
- const CMIUtilString m_constStrArgFormat;
- const CMIUtilString m_constStrArgRegNo;
- CMICmnMIValueList m_miValueList;
+class CMICmdCmdDataListRegisterValues : public CMICmdBase {
+ // Statics:
+public:
+ // Required by the CMICmdFactory when registering *this command
+ static CMICmdBase *CreateSelf();
+
+ // Methods:
+public:
+ /* ctor */ CMICmdCmdDataListRegisterValues();
+
+ // Overridden:
+public:
+ // From CMICmdInvoker::ICmd
+ bool Execute() override;
+ bool Acknowledge() override;
+ bool ParseArgs() override;
+ // From CMICmnBase
+ /* dtor */ ~CMICmdCmdDataListRegisterValues() override;
+
+ // Methods:
+private:
+ lldb::SBValue GetRegister(const MIuint vRegisterIndex) const;
+ void AddToOutput(const MIuint vnIndex, const lldb::SBValue &vrValue,
+ CMICmnLLDBDebugSessionInfoVarObj::varFormat_e veVarFormat);
+
+ // Attributes:
+private:
+ const CMIUtilString m_constStrArgSkip; // Not handled by *this command
+ const CMIUtilString m_constStrArgFormat;
+ const CMIUtilString m_constStrArgRegNo;
+ CMICmnMIValueList m_miValueList;
};
-//++ ============================================================================
+//++
+//============================================================================
// Details: MI command class. MI commands derived from the command base class.
// *this class implements MI command "data-list-changed-registers".
//--
-class CMICmdCmdDataListRegisterChanged : public CMICmdBase
-{
- // Statics:
- public:
- // Required by the CMICmdFactory when registering *this command
- static CMICmdBase *CreateSelf();
-
- // Methods:
- public:
- /* ctor */ CMICmdCmdDataListRegisterChanged();
-
- // Overridden:
- public:
- // From CMICmdInvoker::ICmd
- bool Execute() override;
- bool Acknowledge() override;
- // From CMICmnBase
- /* dtor */ ~CMICmdCmdDataListRegisterChanged() override;
+class CMICmdCmdDataListRegisterChanged : public CMICmdBase {
+ // Statics:
+public:
+ // Required by the CMICmdFactory when registering *this command
+ static CMICmdBase *CreateSelf();
+
+ // Methods:
+public:
+ /* ctor */ CMICmdCmdDataListRegisterChanged();
+
+ // Overridden:
+public:
+ // From CMICmdInvoker::ICmd
+ bool Execute() override;
+ bool Acknowledge() override;
+ // From CMICmnBase
+ /* dtor */ ~CMICmdCmdDataListRegisterChanged() override;
};
-//++ ============================================================================
+//++
+//============================================================================
// Details: MI command class. MI commands derived from the command base class.
// *this class implements MI command "data-read-memory-bytes".
//--
-class CMICmdCmdDataWriteMemoryBytes : public CMICmdBase
-{
- // Statics:
- public:
- // Required by the CMICmdFactory when registering *this command
- static CMICmdBase *CreateSelf();
-
- // Methods:
- public:
- /* ctor */ CMICmdCmdDataWriteMemoryBytes();
-
- // Overridden:
- public:
- // From CMICmdInvoker::ICmd
- bool Execute() override;
- bool Acknowledge() override;
- bool ParseArgs() override;
- // From CMICmnBase
- /* dtor */ ~CMICmdCmdDataWriteMemoryBytes() override;
-
- // Attributes:
- private:
- const CMIUtilString m_constStrArgAddr;
- const CMIUtilString m_constStrArgContents;
- const CMIUtilString m_constStrArgCount;
- CMIUtilString m_strContents;
+class CMICmdCmdDataWriteMemoryBytes : public CMICmdBase {
+ // Statics:
+public:
+ // Required by the CMICmdFactory when registering *this command
+ static CMICmdBase *CreateSelf();
+
+ // Methods:
+public:
+ /* ctor */ CMICmdCmdDataWriteMemoryBytes();
+
+ // Overridden:
+public:
+ // From CMICmdInvoker::ICmd
+ bool Execute() override;
+ bool Acknowledge() override;
+ bool ParseArgs() override;
+ // From CMICmnBase
+ /* dtor */ ~CMICmdCmdDataWriteMemoryBytes() override;
+
+ // Attributes:
+private:
+ const CMIUtilString m_constStrArgAddr;
+ const CMIUtilString m_constStrArgContents;
+ const CMIUtilString m_constStrArgCount;
+ CMIUtilString m_strContents;
};
-//++ ============================================================================
+//++
+//============================================================================
// Details: MI command class. MI commands derived from the command base class.
// *this class implements MI command "data-read-memory".
// Not specified in MI spec but Eclipse gives *this command.
//--
-class CMICmdCmdDataWriteMemory : public CMICmdBase
-{
- // Statics:
- public:
- // Required by the CMICmdFactory when registering *this command
- static CMICmdBase *CreateSelf();
-
- // Methods:
- public:
- /* ctor */ CMICmdCmdDataWriteMemory();
-
- // Overridden:
- public:
- // From CMICmdInvoker::ICmd
- bool Execute() override;
- bool Acknowledge() override;
- bool ParseArgs() override;
- // From CMICmnBase
- /* dtor */ ~CMICmdCmdDataWriteMemory() override;
-
- // Attributes:
- private:
- const CMIUtilString m_constStrArgOffset; // Not specified in MI spec but Eclipse gives this option.
- const CMIUtilString m_constStrArgAddr; // Not specified in MI spec but Eclipse gives this option.
- const CMIUtilString m_constStrArgD; // Not specified in MI spec but Eclipse gives this option.
- const CMIUtilString m_constStrArgNumber; // Not specified in MI spec but Eclipse gives this option.
- const CMIUtilString m_constStrArgContents; // Not specified in MI spec but Eclipse gives this option.
- MIuint64 m_nAddr;
- CMIUtilString m_strContents;
- MIuint64 m_nCount;
- unsigned char *m_pBufferMemory;
+class CMICmdCmdDataWriteMemory : public CMICmdBase {
+ // Statics:
+public:
+ // Required by the CMICmdFactory when registering *this command
+ static CMICmdBase *CreateSelf();
+
+ // Methods:
+public:
+ /* ctor */ CMICmdCmdDataWriteMemory();
+
+ // Overridden:
+public:
+ // From CMICmdInvoker::ICmd
+ bool Execute() override;
+ bool Acknowledge() override;
+ bool ParseArgs() override;
+ // From CMICmnBase
+ /* dtor */ ~CMICmdCmdDataWriteMemory() override;
+
+ // Attributes:
+private:
+ const CMIUtilString m_constStrArgOffset; // Not specified in MI spec but
+ // Eclipse gives this option.
+ const CMIUtilString m_constStrArgAddr; // Not specified in MI spec but Eclipse
+ // gives this option.
+ const CMIUtilString
+ m_constStrArgD; // Not specified in MI spec but Eclipse gives this option.
+ const CMIUtilString m_constStrArgNumber; // Not specified in MI spec but
+ // Eclipse gives this option.
+ const CMIUtilString m_constStrArgContents; // Not specified in MI spec but
+ // Eclipse gives this option.
+ MIuint64 m_nAddr;
+ CMIUtilString m_strContents;
+ MIuint64 m_nCount;
+ unsigned char *m_pBufferMemory;
};
-//++ ============================================================================
+//++
+//============================================================================
// Details: MI command class. MI commands derived from the command base class.
// *this class implements MI command "data-info-line".
// See MIExtensions.txt for details.
//--
-class CMICmdCmdDataInfoLine : public CMICmdBase
-{
- // Statics:
- public:
- // Required by the CMICmdFactory when registering *this command
- static CMICmdBase *CreateSelf();
-
- // Methods:
- public:
- /* ctor */ CMICmdCmdDataInfoLine();
-
- // Overridden:
- public:
- // From CMICmdInvoker::ICmd
- bool Execute() override;
- bool Acknowledge() override;
- bool ParseArgs() override;
- // From CMICmnBase
- /* dtor */ ~CMICmdCmdDataInfoLine() override;
-
- // Attributes:
- private:
- lldb::SBCommandReturnObject m_lldbResult;
- const CMIUtilString m_constStrArgLocation;
+class CMICmdCmdDataInfoLine : public CMICmdBase {
+ // Statics:
+public:
+ // Required by the CMICmdFactory when registering *this command
+ static CMICmdBase *CreateSelf();
+
+ // Methods:
+public:
+ /* ctor */ CMICmdCmdDataInfoLine();
+
+ // Overridden:
+public:
+ // From CMICmdInvoker::ICmd
+ bool Execute() override;
+ bool Acknowledge() override;
+ bool ParseArgs() override;
+ // From CMICmnBase
+ /* dtor */ ~CMICmdCmdDataInfoLine() override;
+
+ // Attributes:
+private:
+ lldb::SBCommandReturnObject m_lldbResult;
+ const CMIUtilString m_constStrArgLocation;
};
Modified: lldb/trunk/tools/lldb-mi/MICmdCmdEnviro.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/lldb-mi/MICmdCmdEnviro.cpp?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/tools/lldb-mi/MICmdCmdEnviro.cpp (original)
+++ lldb/trunk/tools/lldb-mi/MICmdCmdEnviro.cpp Tue Sep 6 15:57:50 2016
@@ -11,13 +11,14 @@
// In-house headers:
#include "MICmdCmdEnviro.h"
+#include "MICmdArgValFile.h"
+#include "MICmnLLDBDebugSessionInfo.h"
+#include "MICmnLLDBDebugger.h"
#include "MICmnMIResultRecord.h"
#include "MICmnMIValueConst.h"
-#include "MICmnLLDBDebugger.h"
-#include "MICmnLLDBDebugSessionInfo.h"
-#include "MICmdArgValFile.h"
-//++ ------------------------------------------------------------------------------------
+//++
+//------------------------------------------------------------------------------------
// Details: CMICmdCmdEnvironmentCd constructor.
// Type: Method.
// Args: None.
@@ -25,28 +26,28 @@
// Throws: None.
//--
CMICmdCmdEnvironmentCd::CMICmdCmdEnvironmentCd()
- : m_constStrArgNamePathDir("pathdir")
-{
- // Command factory matches this name with that received from the stdin stream
- m_strMiCmd = "environment-cd";
+ : m_constStrArgNamePathDir("pathdir") {
+ // Command factory matches this name with that received from the stdin stream
+ m_strMiCmd = "environment-cd";
- // Required by the CMICmdFactory when registering *this command
- m_pSelfCreatorFn = &CMICmdCmdEnvironmentCd::CreateSelf;
+ // Required by the CMICmdFactory when registering *this command
+ m_pSelfCreatorFn = &CMICmdCmdEnvironmentCd::CreateSelf;
}
-//++ ------------------------------------------------------------------------------------
+//++
+//------------------------------------------------------------------------------------
// Details: CMICmdCmdEnvironmentCd destructor.
// Type: Overrideable.
// Args: None.
// Return: None.
// Throws: None.
//--
-CMICmdCmdEnvironmentCd::~CMICmdCmdEnvironmentCd()
-{
-}
+CMICmdCmdEnvironmentCd::~CMICmdCmdEnvironmentCd() {}
-//++ ------------------------------------------------------------------------------------
-// Details: The invoker requires this function. The parses the command line options
+//++
+//------------------------------------------------------------------------------------
+// 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.
@@ -54,48 +55,52 @@ CMICmdCmdEnvironmentCd::~CMICmdCmdEnviro
// MIstatus::failure - Functional failed.
// Throws: None.
//--
-bool
-CMICmdCmdEnvironmentCd::ParseArgs()
-{
- m_setCmdArgs.Add(new CMICmdArgValFile(m_constStrArgNamePathDir, true, true));
- CMICmdArgContext argCntxt(m_cmdData.strMiCmdOption);
- return ParseValidateCmdOptions();
+bool CMICmdCmdEnvironmentCd::ParseArgs() {
+ m_setCmdArgs.Add(new CMICmdArgValFile(m_constStrArgNamePathDir, true, true));
+ CMICmdArgContext argCntxt(m_cmdData.strMiCmdOption);
+ return ParseValidateCmdOptions();
}
-//++ ------------------------------------------------------------------------------------
-// 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.
+//++
+//------------------------------------------------------------------------------------
+// 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
-CMICmdCmdEnvironmentCd::Execute()
-{
- CMICMDBASE_GETOPTION(pArgPathDir, File, m_constStrArgNamePathDir);
- const CMIUtilString &strWkDir(pArgPathDir->GetValue());
- CMICmnLLDBDebugger &rDbg(CMICmnLLDBDebugger::Instance());
- lldb::SBDebugger &rLldbDbg = rDbg.GetTheDebugger();
- bool bOk = rLldbDbg.SetCurrentPlatformSDKRoot(strWkDir.c_str());
- if (bOk)
- {
- const CMIUtilString &rStrKeyWkDir(m_rLLDBDebugSessionInfo.m_constStrSharedDataKeyWkDir);
- if (!m_rLLDBDebugSessionInfo.SharedDataAdd<CMIUtilString>(rStrKeyWkDir, strWkDir))
- {
- SetError(CMIUtilString::Format(MIRSRC(IDS_DBGSESSION_ERR_SHARED_DATA_ADD), m_cmdData.strMiCmd.c_str(), rStrKeyWkDir.c_str()));
- bOk = MIstatus::failure;
- }
+bool CMICmdCmdEnvironmentCd::Execute() {
+ CMICMDBASE_GETOPTION(pArgPathDir, File, m_constStrArgNamePathDir);
+ const CMIUtilString &strWkDir(pArgPathDir->GetValue());
+ CMICmnLLDBDebugger &rDbg(CMICmnLLDBDebugger::Instance());
+ lldb::SBDebugger &rLldbDbg = rDbg.GetTheDebugger();
+ bool bOk = rLldbDbg.SetCurrentPlatformSDKRoot(strWkDir.c_str());
+ if (bOk) {
+ const CMIUtilString &rStrKeyWkDir(
+ m_rLLDBDebugSessionInfo.m_constStrSharedDataKeyWkDir);
+ if (!m_rLLDBDebugSessionInfo.SharedDataAdd<CMIUtilString>(rStrKeyWkDir,
+ strWkDir)) {
+ SetError(CMIUtilString::Format(MIRSRC(IDS_DBGSESSION_ERR_SHARED_DATA_ADD),
+ m_cmdData.strMiCmd.c_str(),
+ rStrKeyWkDir.c_str()));
+ bOk = MIstatus::failure;
}
- else
- SetError(CMIUtilString::Format(MIRSRC(IDS_CMD_ERR_FNFAILED), m_cmdData.strMiCmd.c_str(), "SetCurrentPlatformSDKRoot()"));
-
- return bOk;
+ } else
+ SetError(CMIUtilString::Format(MIRSRC(IDS_CMD_ERR_FNFAILED),
+ m_cmdData.strMiCmd.c_str(),
+ "SetCurrentPlatformSDKRoot()"));
+
+ return bOk;
}
-//++ ------------------------------------------------------------------------------------
-// Details: The invoker requires this function. The command prepares a MI Record Result
+//++
+//------------------------------------------------------------------------------------
+// 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.
@@ -103,35 +108,38 @@ CMICmdCmdEnvironmentCd::Execute()
// MIstatus::failure - Functional failed.
// Throws: None.
//--
-bool
-CMICmdCmdEnvironmentCd::Acknowledge()
-{
- const CMIUtilString &rStrKeyWkDir(m_rLLDBDebugSessionInfo.m_constStrSharedDataKeyWkDir);
- CMIUtilString strWkDir;
- const bool bOk = m_rLLDBDebugSessionInfo.SharedDataRetrieve<CMIUtilString>(rStrKeyWkDir, strWkDir);
- if (bOk)
- {
- const CMICmnMIValueConst miValueConst(strWkDir);
- const CMICmnMIValueResult miValueResult("path", miValueConst);
- const CMICmnMIResultRecord miRecordResult(m_cmdData.strMiCmdToken, CMICmnMIResultRecord::eResultClass_Done, miValueResult);
- m_miResultRecord = miRecordResult;
- return MIstatus::success;
- }
-
- SetError(CMIUtilString::Format(MIRSRC(IDS_CMD_ERR_SHARED_DATA_NOT_FOUND), m_cmdData.strMiCmd.c_str(), rStrKeyWkDir.c_str()));
- return MIstatus::failure;
-}
-
-//++ ------------------------------------------------------------------------------------
-// Details: Required by the CMICmdFactory when registering *this command. The factory
+bool CMICmdCmdEnvironmentCd::Acknowledge() {
+ const CMIUtilString &rStrKeyWkDir(
+ m_rLLDBDebugSessionInfo.m_constStrSharedDataKeyWkDir);
+ CMIUtilString strWkDir;
+ const bool bOk = m_rLLDBDebugSessionInfo.SharedDataRetrieve<CMIUtilString>(
+ rStrKeyWkDir, strWkDir);
+ if (bOk) {
+ const CMICmnMIValueConst miValueConst(strWkDir);
+ const CMICmnMIValueResult miValueResult("path", miValueConst);
+ const CMICmnMIResultRecord miRecordResult(
+ m_cmdData.strMiCmdToken, CMICmnMIResultRecord::eResultClass_Done,
+ miValueResult);
+ m_miResultRecord = miRecordResult;
+ return MIstatus::success;
+ }
+
+ SetError(CMIUtilString::Format(MIRSRC(IDS_CMD_ERR_SHARED_DATA_NOT_FOUND),
+ m_cmdData.strMiCmd.c_str(),
+ rStrKeyWkDir.c_str()));
+ return MIstatus::failure;
+}
+
+//++
+//------------------------------------------------------------------------------------
+// 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 *
-CMICmdCmdEnvironmentCd::CreateSelf()
-{
- return new CMICmdCmdEnvironmentCd();
+CMICmdBase *CMICmdCmdEnvironmentCd::CreateSelf() {
+ return new CMICmdCmdEnvironmentCd();
}
Modified: lldb/trunk/tools/lldb-mi/MICmdCmdEnviro.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/lldb-mi/MICmdCmdEnviro.h?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/tools/lldb-mi/MICmdCmdEnviro.h (original)
+++ lldb/trunk/tools/lldb-mi/MICmdCmdEnviro.h Tue Sep 6 15:57:50 2016
@@ -9,47 +9,50 @@
// Overview: CMICmdCmdEnvironmentCd 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 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
+// For an introduction to adding a new command see
+// CMICmdCmdSupportInfoMiCmdQuery
// command class as an example.
#pragma once
// In-house headers:
#include "MICmdBase.h"
-#include "MICmnMIValueTuple.h"
#include "MICmnMIValueList.h"
+#include "MICmnMIValueTuple.h"
-//++ ============================================================================
+//++
+//============================================================================
// Details: MI command class. MI commands derived from the command base class.
// *this class implements MI command "environment-cd".
//--
-class CMICmdCmdEnvironmentCd : public CMICmdBase
-{
- // Statics:
- public:
- // Required by the CMICmdFactory when registering *this command
- static CMICmdBase *CreateSelf();
-
- // Methods:
- public:
- /* ctor */ CMICmdCmdEnvironmentCd();
-
- // Overridden:
- public:
- // From CMICmdInvoker::ICmd
- bool Execute() override;
- bool Acknowledge() override;
- bool ParseArgs() override;
- // From CMICmnBase
- /* dtor */ ~CMICmdCmdEnvironmentCd() override;
-
- // Attributes:
- private:
- const CMIUtilString m_constStrArgNamePathDir;
+class CMICmdCmdEnvironmentCd : public CMICmdBase {
+ // Statics:
+public:
+ // Required by the CMICmdFactory when registering *this command
+ static CMICmdBase *CreateSelf();
+
+ // Methods:
+public:
+ /* ctor */ CMICmdCmdEnvironmentCd();
+
+ // Overridden:
+public:
+ // From CMICmdInvoker::ICmd
+ bool Execute() override;
+ bool Acknowledge() override;
+ bool ParseArgs() override;
+ // From CMICmnBase
+ /* dtor */ ~CMICmdCmdEnvironmentCd() override;
+
+ // Attributes:
+private:
+ const CMIUtilString m_constStrArgNamePathDir;
};
Modified: lldb/trunk/tools/lldb-mi/MICmdCmdExec.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/lldb-mi/MICmdCmdExec.cpp?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/tools/lldb-mi/MICmdCmdExec.cpp (original)
+++ lldb/trunk/tools/lldb-mi/MICmdCmdExec.cpp Tue Sep 6 15:57:50 2016
@@ -25,51 +25,51 @@
#include "lldb/lldb-enumerations.h"
// In-house headers:
-#include "MICmdCmdExec.h"
-#include "MICmnMIResultRecord.h"
-#include "MICmnMIValueConst.h"
-#include "MICmnLLDBDebugger.h"
-#include "MICmnLLDBDebugSessionInfo.h"
-#include "MIDriver.h"
+#include "MICmdArgValListOfN.h"
#include "MICmdArgValNumber.h"
-#include "MICmdArgValString.h"
-#include "MICmdArgValThreadGrp.h"
#include "MICmdArgValOptionLong.h"
#include "MICmdArgValOptionShort.h"
-#include "MICmdArgValListOfN.h"
-#include "MICmnStreamStdout.h"
+#include "MICmdArgValString.h"
+#include "MICmdArgValThreadGrp.h"
+#include "MICmdCmdExec.h"
+#include "MICmnLLDBDebugSessionInfo.h"
+#include "MICmnLLDBDebugger.h"
#include "MICmnMIOutOfBandRecord.h"
+#include "MICmnMIResultRecord.h"
+#include "MICmnMIValueConst.h"
+#include "MICmnStreamStdout.h"
+#include "MIDriver.h"
-//++ ------------------------------------------------------------------------------------
+//++
+//------------------------------------------------------------------------------------
// Details: CMICmdCmdExecRun constructor.
// Type: Method.
// Args: None.
// Return: None.
// Throws: None.
//--
-CMICmdCmdExecRun::CMICmdCmdExecRun()
- : m_constStrArgStart("start")
-{
- // Command factory matches this name with that received from the stdin stream
- m_strMiCmd = "exec-run";
+CMICmdCmdExecRun::CMICmdCmdExecRun() : m_constStrArgStart("start") {
+ // Command factory matches this name with that received from the stdin stream
+ m_strMiCmd = "exec-run";
- // Required by the CMICmdFactory when registering *this command
- m_pSelfCreatorFn = &CMICmdCmdExecRun::CreateSelf;
+ // Required by the CMICmdFactory when registering *this command
+ m_pSelfCreatorFn = &CMICmdCmdExecRun::CreateSelf;
}
-//++ ------------------------------------------------------------------------------------
+//++
+//------------------------------------------------------------------------------------
// Details: CMICmdCmdExecRun destructor.
// Type: Overrideable.
// Args: None.
// Return: None.
// Throws: None.
//--
-CMICmdCmdExecRun::~CMICmdCmdExecRun()
-{
-}
+CMICmdCmdExecRun::~CMICmdCmdExecRun() {}
-//++ ------------------------------------------------------------------------------------
-// Details: The invoker requires this function. It parses the command line options'
+//++
+//------------------------------------------------------------------------------------
+// Details: The invoker requires this function. It parses the command line
+// options'
// arguments to extract values for each of those arguments.
// Type: Overridden.
// Args: None.
@@ -77,57 +77,62 @@ CMICmdCmdExecRun::~CMICmdCmdExecRun()
// MIstatus::failure - Functional failed.
// Throws: None.
//--
-bool
-CMICmdCmdExecRun::ParseArgs()
-{
- m_setCmdArgs.Add(
- new CMICmdArgValOptionLong(m_constStrArgStart, false, true, CMICmdArgValListBase::eArgValType_OptionLong, 0));
- return ParseValidateCmdOptions();
-}
-
-//++ ------------------------------------------------------------------------------------
-// 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.
+bool CMICmdCmdExecRun::ParseArgs() {
+ m_setCmdArgs.Add(new CMICmdArgValOptionLong(
+ m_constStrArgStart, false, true,
+ CMICmdArgValListBase::eArgValType_OptionLong, 0));
+ return ParseValidateCmdOptions();
+}
+
+//++
+//------------------------------------------------------------------------------------
+// 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
-CMICmdCmdExecRun::Execute()
-{
- CMICmnLLDBDebugSessionInfo &rSessionInfo(CMICmnLLDBDebugSessionInfo::Instance());
- lldb::SBError error;
- lldb::SBStream errMsg;
- lldb::SBLaunchInfo launchInfo = rSessionInfo.GetTarget().GetLaunchInfo();
- launchInfo.SetListener(rSessionInfo.GetListener());
-
- // Run to first instruction or main() requested?
- CMICMDBASE_GETOPTION(pArgStart, OptionLong, m_constStrArgStart);
- if (pArgStart->GetFound())
- {
- launchInfo.SetLaunchFlags(launchInfo.GetLaunchFlags() | lldb::eLaunchFlagStopAtEntry);
- }
-
- lldb::SBProcess process = rSessionInfo.GetTarget().Launch(launchInfo, error);
- if ((!process.IsValid()) || (error.Fail()))
- {
- SetError(CMIUtilString::Format(MIRSRC(IDS_CMD_ERR_INVALID_PROCESS), m_cmdData.strMiCmd.c_str(), errMsg.GetData()));
- return MIstatus::failure;
- }
-
- if (!CMIDriver::Instance().SetDriverStateRunningDebugging())
- {
- const CMIUtilString &rErrMsg(CMIDriver::Instance().GetErrorDescription());
- SetError(CMIUtilString::Format(MIRSRC(IDS_CMD_ERR_SET_NEW_DRIVER_STATE), m_cmdData.strMiCmd.c_str(), rErrMsg.c_str()));
- return MIstatus::failure;
- }
- return MIstatus::success;
-}
-
-//++ ------------------------------------------------------------------------------------
-// Details: The invoker requires this function. The command prepares a MI Record Result
+bool CMICmdCmdExecRun::Execute() {
+ CMICmnLLDBDebugSessionInfo &rSessionInfo(
+ CMICmnLLDBDebugSessionInfo::Instance());
+ lldb::SBError error;
+ lldb::SBStream errMsg;
+ lldb::SBLaunchInfo launchInfo = rSessionInfo.GetTarget().GetLaunchInfo();
+ launchInfo.SetListener(rSessionInfo.GetListener());
+
+ // Run to first instruction or main() requested?
+ CMICMDBASE_GETOPTION(pArgStart, OptionLong, m_constStrArgStart);
+ if (pArgStart->GetFound()) {
+ launchInfo.SetLaunchFlags(launchInfo.GetLaunchFlags() |
+ lldb::eLaunchFlagStopAtEntry);
+ }
+
+ lldb::SBProcess process = rSessionInfo.GetTarget().Launch(launchInfo, error);
+ if ((!process.IsValid()) || (error.Fail())) {
+ SetError(CMIUtilString::Format(MIRSRC(IDS_CMD_ERR_INVALID_PROCESS),
+ m_cmdData.strMiCmd.c_str(),
+ errMsg.GetData()));
+ return MIstatus::failure;
+ }
+
+ if (!CMIDriver::Instance().SetDriverStateRunningDebugging()) {
+ const CMIUtilString &rErrMsg(CMIDriver::Instance().GetErrorDescription());
+ SetError(CMIUtilString::Format(MIRSRC(IDS_CMD_ERR_SET_NEW_DRIVER_STATE),
+ m_cmdData.strMiCmd.c_str(),
+ rErrMsg.c_str()));
+ 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().
// Called only if Execute() set status as successful on completion.
// Type: Overridden.
@@ -136,117 +141,119 @@ CMICmdCmdExecRun::Execute()
// MIstatus::failure - Functional failed.
// Throws: None.
//--
-bool
-CMICmdCmdExecRun::Acknowledge()
-{
- const CMICmnMIResultRecord miRecordResult(m_cmdData.strMiCmdToken, CMICmnMIResultRecord::eResultClass_Running);
- m_miResultRecord = miRecordResult;
-
- CMICmnLLDBDebugSessionInfo &rSessionInfo(CMICmnLLDBDebugSessionInfo::Instance());
- lldb::pid_t pid = rSessionInfo.GetProcess().GetProcessID();
- // Give the client '=thread-group-started,id="i1" pid="xyz"'
- m_bHasResultRecordExtra = true;
- const CMICmnMIValueConst miValueConst2("i1");
- const CMICmnMIValueResult miValueResult2("id", miValueConst2);
- const CMIUtilString strPid(CMIUtilString::Format("%lld", pid));
- const CMICmnMIValueConst miValueConst(strPid);
- const CMICmnMIValueResult miValueResult("pid", miValueConst);
- CMICmnMIOutOfBandRecord miOutOfBand(CMICmnMIOutOfBandRecord::eOutOfBand_ThreadGroupStarted, miValueResult2);
- miOutOfBand.Add(miValueResult);
- m_miResultRecordExtra = miOutOfBand.GetString();
-
- return MIstatus::success;
-}
-
-//++ ------------------------------------------------------------------------------------
-// Details: Required by the CMICmdFactory when registering *this command. The factory
+bool CMICmdCmdExecRun::Acknowledge() {
+ const CMICmnMIResultRecord miRecordResult(
+ m_cmdData.strMiCmdToken, CMICmnMIResultRecord::eResultClass_Running);
+ m_miResultRecord = miRecordResult;
+
+ CMICmnLLDBDebugSessionInfo &rSessionInfo(
+ CMICmnLLDBDebugSessionInfo::Instance());
+ lldb::pid_t pid = rSessionInfo.GetProcess().GetProcessID();
+ // Give the client '=thread-group-started,id="i1" pid="xyz"'
+ m_bHasResultRecordExtra = true;
+ const CMICmnMIValueConst miValueConst2("i1");
+ const CMICmnMIValueResult miValueResult2("id", miValueConst2);
+ const CMIUtilString strPid(CMIUtilString::Format("%lld", pid));
+ const CMICmnMIValueConst miValueConst(strPid);
+ const CMICmnMIValueResult miValueResult("pid", miValueConst);
+ CMICmnMIOutOfBandRecord miOutOfBand(
+ CMICmnMIOutOfBandRecord::eOutOfBand_ThreadGroupStarted, miValueResult2);
+ miOutOfBand.Add(miValueResult);
+ m_miResultRecordExtra = miOutOfBand.GetString();
+
+ 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 *
-CMICmdCmdExecRun::CreateSelf()
-{
- return new CMICmdCmdExecRun();
-}
+CMICmdBase *CMICmdCmdExecRun::CreateSelf() { return new CMICmdCmdExecRun(); }
//---------------------------------------------------------------------------------------
//---------------------------------------------------------------------------------------
//---------------------------------------------------------------------------------------
-//++ ------------------------------------------------------------------------------------
+//++
+//------------------------------------------------------------------------------------
// Details: CMICmdCmdExecContinue constructor.
// Type: Method.
// Args: None.
// Return: None.
// Throws: None.
//--
-CMICmdCmdExecContinue::CMICmdCmdExecContinue()
-{
- // Command factory matches this name with that received from the stdin stream
- m_strMiCmd = "exec-continue";
+CMICmdCmdExecContinue::CMICmdCmdExecContinue() {
+ // Command factory matches this name with that received from the stdin stream
+ m_strMiCmd = "exec-continue";
- // Required by the CMICmdFactory when registering *this command
- m_pSelfCreatorFn = &CMICmdCmdExecContinue::CreateSelf;
+ // Required by the CMICmdFactory when registering *this command
+ m_pSelfCreatorFn = &CMICmdCmdExecContinue::CreateSelf;
}
-//++ ------------------------------------------------------------------------------------
+//++
+//------------------------------------------------------------------------------------
// Details: CMICmdCmdExecContinue destructor.
// Type: Overrideable.
// Args: None.
// Return: None.
// Throws: None.
//--
-CMICmdCmdExecContinue::~CMICmdCmdExecContinue()
-{
-}
+CMICmdCmdExecContinue::~CMICmdCmdExecContinue() {}
-//++ ------------------------------------------------------------------------------------
-// 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.
+//++
+//------------------------------------------------------------------------------------
+// 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
-CMICmdCmdExecContinue::Execute()
-{
- const char *pCmd = "continue";
- CMICmnLLDBDebugSessionInfo &rSessionInfo(CMICmnLLDBDebugSessionInfo::Instance());
- const lldb::ReturnStatus rtn = rSessionInfo.GetDebugger().GetCommandInterpreter().HandleCommand(pCmd, m_lldbResult);
- MIunused(rtn);
-
- if (m_lldbResult.GetErrorSize() == 0)
- {
- // CODETAG_DEBUG_SESSION_RUNNING_PROG_RECEIVED_SIGINT_PAUSE_PROGRAM
- if (!CMIDriver::Instance().SetDriverStateRunningDebugging())
- {
- const CMIUtilString &rErrMsg(CMIDriver::Instance().GetErrorDescription());
- SetError(CMIUtilString::Format(MIRSRC(IDS_CMD_ERR_SET_NEW_DRIVER_STATE), m_cmdData.strMiCmd.c_str(), rErrMsg.c_str()));
- return MIstatus::failure;
- }
- }
- else
- {
- // ToDo: Re-evaluate if this is required when application near finished as this is parsing LLDB error message
- // which seems a hack and is code brittle
- const char *pLldbErr = m_lldbResult.GetError();
- const CMIUtilString strLldbMsg(CMIUtilString(pLldbErr).StripCREndOfLine());
- if (strLldbMsg == "error: Process must be launched.")
- {
- CMIDriver::Instance().SetExitApplicationFlag(true);
- }
- }
-
- return MIstatus::success;
-}
+bool CMICmdCmdExecContinue::Execute() {
+ const char *pCmd = "continue";
+ CMICmnLLDBDebugSessionInfo &rSessionInfo(
+ CMICmnLLDBDebugSessionInfo::Instance());
+ const lldb::ReturnStatus rtn =
+ rSessionInfo.GetDebugger().GetCommandInterpreter().HandleCommand(
+ pCmd, m_lldbResult);
+ MIunused(rtn);
-//++ ------------------------------------------------------------------------------------
-// Details: The invoker requires this function. The command prepares a MI Record Result
+ if (m_lldbResult.GetErrorSize() == 0) {
+ // CODETAG_DEBUG_SESSION_RUNNING_PROG_RECEIVED_SIGINT_PAUSE_PROGRAM
+ if (!CMIDriver::Instance().SetDriverStateRunningDebugging()) {
+ const CMIUtilString &rErrMsg(CMIDriver::Instance().GetErrorDescription());
+ SetError(CMIUtilString::Format(MIRSRC(IDS_CMD_ERR_SET_NEW_DRIVER_STATE),
+ m_cmdData.strMiCmd.c_str(),
+ rErrMsg.c_str()));
+ return MIstatus::failure;
+ }
+ } else {
+ // ToDo: Re-evaluate if this is required when application near finished as
+ // this is parsing LLDB error message
+ // which seems a hack and is code brittle
+ const char *pLldbErr = m_lldbResult.GetError();
+ const CMIUtilString strLldbMsg(CMIUtilString(pLldbErr).StripCREndOfLine());
+ if (strLldbMsg == "error: Process must be launched.") {
+ CMIDriver::Instance().SetExitApplicationFlag(true);
+ }
+ }
+
+ 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.
@@ -254,73 +261,71 @@ CMICmdCmdExecContinue::Execute()
// MIstatus::failure - Functional failed.
// Throws: None.
//--
-bool
-CMICmdCmdExecContinue::Acknowledge()
-{
- if (m_lldbResult.GetErrorSize() > 0)
- {
- const CMICmnMIValueConst miValueConst(m_lldbResult.GetError());
- const CMICmnMIValueResult miValueResult("message", miValueConst);
- const CMICmnMIResultRecord miRecordResult(m_cmdData.strMiCmdToken, CMICmnMIResultRecord::eResultClass_Error, miValueResult);
- m_miResultRecord = miRecordResult;
- }
- else
- {
- const CMICmnMIResultRecord miRecordResult(m_cmdData.strMiCmdToken, CMICmnMIResultRecord::eResultClass_Running);
- m_miResultRecord = miRecordResult;
- }
+bool CMICmdCmdExecContinue::Acknowledge() {
+ if (m_lldbResult.GetErrorSize() > 0) {
+ const CMICmnMIValueConst miValueConst(m_lldbResult.GetError());
+ const CMICmnMIValueResult miValueResult("message", miValueConst);
+ const CMICmnMIResultRecord miRecordResult(
+ m_cmdData.strMiCmdToken, CMICmnMIResultRecord::eResultClass_Error,
+ miValueResult);
+ m_miResultRecord = miRecordResult;
+ } else {
+ const CMICmnMIResultRecord miRecordResult(
+ m_cmdData.strMiCmdToken, CMICmnMIResultRecord::eResultClass_Running);
+ m_miResultRecord = miRecordResult;
+ }
- return MIstatus::success;
+ return MIstatus::success;
}
-//++ ------------------------------------------------------------------------------------
-// Details: Required by the CMICmdFactory when registering *this command. The factory
+//++
+//------------------------------------------------------------------------------------
+// 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 *
-CMICmdCmdExecContinue::CreateSelf()
-{
- return new CMICmdCmdExecContinue();
+CMICmdBase *CMICmdCmdExecContinue::CreateSelf() {
+ return new CMICmdCmdExecContinue();
}
//---------------------------------------------------------------------------------------
//---------------------------------------------------------------------------------------
//---------------------------------------------------------------------------------------
-//++ ------------------------------------------------------------------------------------
+//++
+//------------------------------------------------------------------------------------
// Details: CMICmdCmdExecNext constructor.
// Type: Method.
// Args: None.
// Return: None.
// Throws: None.
//--
-CMICmdCmdExecNext::CMICmdCmdExecNext()
- : m_constStrArgNumber("number")
-{
- // Command factory matches this name with that received from the stdin stream
- m_strMiCmd = "exec-next";
+CMICmdCmdExecNext::CMICmdCmdExecNext() : m_constStrArgNumber("number") {
+ // Command factory matches this name with that received from the stdin stream
+ m_strMiCmd = "exec-next";
- // Required by the CMICmdFactory when registering *this command
- m_pSelfCreatorFn = &CMICmdCmdExecNext::CreateSelf;
+ // Required by the CMICmdFactory when registering *this command
+ m_pSelfCreatorFn = &CMICmdCmdExecNext::CreateSelf;
}
-//++ ------------------------------------------------------------------------------------
+//++
+//------------------------------------------------------------------------------------
// Details: CMICmdCmdExecNext destructor.
// Type: Overrideable.
// Args: None.
// Return: None.
// Throws: None.
//--
-CMICmdCmdExecNext::~CMICmdCmdExecNext()
-{
-}
+CMICmdCmdExecNext::~CMICmdCmdExecNext() {}
-//++ ------------------------------------------------------------------------------------
-// Details: The invoker requires this function. The parses the command line options
+//++
+//------------------------------------------------------------------------------------
+// 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.
@@ -328,47 +333,52 @@ CMICmdCmdExecNext::~CMICmdCmdExecNext()
// MIstatus::failure - Functional failed.
// Throws: None.
//--
-bool
-CMICmdCmdExecNext::ParseArgs()
-{
- m_setCmdArgs.Add(new CMICmdArgValNumber(m_constStrArgNumber, false, false));
- return ParseValidateCmdOptions();
+bool CMICmdCmdExecNext::ParseArgs() {
+ m_setCmdArgs.Add(new CMICmdArgValNumber(m_constStrArgNumber, false, false));
+ return ParseValidateCmdOptions();
}
-//++ ------------------------------------------------------------------------------------
-// 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.
+//++
+//------------------------------------------------------------------------------------
+// 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
-CMICmdCmdExecNext::Execute()
-{
- CMICMDBASE_GETOPTION(pArgThread, OptionLong, m_constStrArgThread);
+bool CMICmdCmdExecNext::Execute() {
+ CMICMDBASE_GETOPTION(pArgThread, OptionLong, m_constStrArgThread);
- // Retrieve the --thread option's thread ID (only 1)
- MIuint64 nThreadId = UINT64_MAX;
- if (pArgThread->GetFound() && !pArgThread->GetExpectedOption<CMICmdArgValNumber, MIuint64>(nThreadId))
- {
- SetError(CMIUtilString::Format(MIRSRC(IDS_CMD_ERR_THREAD_INVALID), m_cmdData.strMiCmd.c_str(), m_constStrArgThread.c_str()));
- return MIstatus::failure;
- }
+ // Retrieve the --thread option's thread ID (only 1)
+ MIuint64 nThreadId = UINT64_MAX;
+ if (pArgThread->GetFound() &&
+ !pArgThread->GetExpectedOption<CMICmdArgValNumber, MIuint64>(nThreadId)) {
+ SetError(CMIUtilString::Format(MIRSRC(IDS_CMD_ERR_THREAD_INVALID),
+ m_cmdData.strMiCmd.c_str(),
+ m_constStrArgThread.c_str()));
+ return MIstatus::failure;
+ }
- CMICmnLLDBDebugSessionInfo &rSessionInfo(CMICmnLLDBDebugSessionInfo::Instance());
- lldb::SBDebugger &rDebugger = rSessionInfo.GetDebugger();
- CMIUtilString strCmd("thread step-over");
- if (nThreadId != UINT64_MAX)
- strCmd += CMIUtilString::Format(" %llu", nThreadId);
- rDebugger.GetCommandInterpreter().HandleCommand(strCmd.c_str(), m_lldbResult, false);
+ CMICmnLLDBDebugSessionInfo &rSessionInfo(
+ CMICmnLLDBDebugSessionInfo::Instance());
+ lldb::SBDebugger &rDebugger = rSessionInfo.GetDebugger();
+ CMIUtilString strCmd("thread step-over");
+ if (nThreadId != UINT64_MAX)
+ strCmd += CMIUtilString::Format(" %llu", nThreadId);
+ rDebugger.GetCommandInterpreter().HandleCommand(strCmd.c_str(), m_lldbResult,
+ false);
- return MIstatus::success;
+ return MIstatus::success;
}
-//++ ------------------------------------------------------------------------------------
-// Details: The invoker requires this function. The command prepares a MI Record Result
+//++
+//------------------------------------------------------------------------------------
+// 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.
@@ -376,75 +386,71 @@ CMICmdCmdExecNext::Execute()
// MIstatus::failure - Functional failed.
// Throws: None.
//--
-bool
-CMICmdCmdExecNext::Acknowledge()
-{
- if (m_lldbResult.GetErrorSize() > 0)
- {
- const char *pLldbErr = m_lldbResult.GetError();
- MIunused(pLldbErr);
- const CMICmnMIValueConst miValueConst(m_lldbResult.GetError());
- const CMICmnMIValueResult miValueResult("message", miValueConst);
- const CMICmnMIResultRecord miRecordResult(m_cmdData.strMiCmdToken, CMICmnMIResultRecord::eResultClass_Error, miValueResult);
- m_miResultRecord = miRecordResult;
- }
- else
- {
- const CMICmnMIResultRecord miRecordResult(m_cmdData.strMiCmdToken, CMICmnMIResultRecord::eResultClass_Running);
- m_miResultRecord = miRecordResult;
- }
+bool CMICmdCmdExecNext::Acknowledge() {
+ if (m_lldbResult.GetErrorSize() > 0) {
+ const char *pLldbErr = m_lldbResult.GetError();
+ MIunused(pLldbErr);
+ const CMICmnMIValueConst miValueConst(m_lldbResult.GetError());
+ const CMICmnMIValueResult miValueResult("message", miValueConst);
+ const CMICmnMIResultRecord miRecordResult(
+ m_cmdData.strMiCmdToken, CMICmnMIResultRecord::eResultClass_Error,
+ miValueResult);
+ m_miResultRecord = miRecordResult;
+ } else {
+ const CMICmnMIResultRecord miRecordResult(
+ m_cmdData.strMiCmdToken, CMICmnMIResultRecord::eResultClass_Running);
+ m_miResultRecord = miRecordResult;
+ }
- return MIstatus::success;
+ return MIstatus::success;
}
-//++ ------------------------------------------------------------------------------------
-// Details: Required by the CMICmdFactory when registering *this command. The factory
+//++
+//------------------------------------------------------------------------------------
+// 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 *
-CMICmdCmdExecNext::CreateSelf()
-{
- return new CMICmdCmdExecNext();
-}
+CMICmdBase *CMICmdCmdExecNext::CreateSelf() { return new CMICmdCmdExecNext(); }
//---------------------------------------------------------------------------------------
//---------------------------------------------------------------------------------------
//---------------------------------------------------------------------------------------
-//++ ------------------------------------------------------------------------------------
+//++
+//------------------------------------------------------------------------------------
// Details: CMICmdCmdExecStep constructor.
// Type: Method.
// Args: None.
// Return: None.
// Throws: None.
//--
-CMICmdCmdExecStep::CMICmdCmdExecStep()
- : m_constStrArgNumber("number")
-{
- // Command factory matches this name with that received from the stdin stream
- m_strMiCmd = "exec-step";
+CMICmdCmdExecStep::CMICmdCmdExecStep() : m_constStrArgNumber("number") {
+ // Command factory matches this name with that received from the stdin stream
+ m_strMiCmd = "exec-step";
- // Required by the CMICmdFactory when registering *this command
- m_pSelfCreatorFn = &CMICmdCmdExecStep::CreateSelf;
+ // Required by the CMICmdFactory when registering *this command
+ m_pSelfCreatorFn = &CMICmdCmdExecStep::CreateSelf;
}
-//++ ------------------------------------------------------------------------------------
+//++
+//------------------------------------------------------------------------------------
// Details: CMICmdCmdExecStep destructor.
// Type: Overrideable.
// Args: None.
// Return: None.
// Throws: None.
//--
-CMICmdCmdExecStep::~CMICmdCmdExecStep()
-{
-}
+CMICmdCmdExecStep::~CMICmdCmdExecStep() {}
-//++ ------------------------------------------------------------------------------------
-// Details: The invoker requires this function. The parses the command line options
+//++
+//------------------------------------------------------------------------------------
+// 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.
@@ -452,47 +458,52 @@ CMICmdCmdExecStep::~CMICmdCmdExecStep()
// MIstatus::failure - Functional failed.
// Throws: None.
//--
-bool
-CMICmdCmdExecStep::ParseArgs()
-{
- m_setCmdArgs.Add(new CMICmdArgValNumber(m_constStrArgNumber, false, false));
- return ParseValidateCmdOptions();
+bool CMICmdCmdExecStep::ParseArgs() {
+ m_setCmdArgs.Add(new CMICmdArgValNumber(m_constStrArgNumber, false, false));
+ return ParseValidateCmdOptions();
}
-//++ ------------------------------------------------------------------------------------
-// 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.
+//++
+//------------------------------------------------------------------------------------
+// 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
-CMICmdCmdExecStep::Execute()
-{
- CMICMDBASE_GETOPTION(pArgThread, OptionLong, m_constStrArgThread);
+bool CMICmdCmdExecStep::Execute() {
+ CMICMDBASE_GETOPTION(pArgThread, OptionLong, m_constStrArgThread);
- // Retrieve the --thread option's thread ID (only 1)
- MIuint64 nThreadId = UINT64_MAX;
- if (pArgThread->GetFound() && !pArgThread->GetExpectedOption<CMICmdArgValNumber, MIuint64>(nThreadId))
- {
- SetError(CMIUtilString::Format(MIRSRC(IDS_CMD_ERR_OPTION_NOT_FOUND), m_cmdData.strMiCmd.c_str(), m_constStrArgThread.c_str()));
- return MIstatus::failure;
- }
+ // Retrieve the --thread option's thread ID (only 1)
+ MIuint64 nThreadId = UINT64_MAX;
+ if (pArgThread->GetFound() &&
+ !pArgThread->GetExpectedOption<CMICmdArgValNumber, MIuint64>(nThreadId)) {
+ SetError(CMIUtilString::Format(MIRSRC(IDS_CMD_ERR_OPTION_NOT_FOUND),
+ m_cmdData.strMiCmd.c_str(),
+ m_constStrArgThread.c_str()));
+ return MIstatus::failure;
+ }
- CMICmnLLDBDebugSessionInfo &rSessionInfo(CMICmnLLDBDebugSessionInfo::Instance());
- lldb::SBDebugger &rDebugger = rSessionInfo.GetDebugger();
- CMIUtilString strCmd("thread step-in");
- if (nThreadId != UINT64_MAX)
- strCmd += CMIUtilString::Format(" %llu", nThreadId);
- rDebugger.GetCommandInterpreter().HandleCommand(strCmd.c_str(), m_lldbResult, false);
+ CMICmnLLDBDebugSessionInfo &rSessionInfo(
+ CMICmnLLDBDebugSessionInfo::Instance());
+ lldb::SBDebugger &rDebugger = rSessionInfo.GetDebugger();
+ CMIUtilString strCmd("thread step-in");
+ if (nThreadId != UINT64_MAX)
+ strCmd += CMIUtilString::Format(" %llu", nThreadId);
+ rDebugger.GetCommandInterpreter().HandleCommand(strCmd.c_str(), m_lldbResult,
+ false);
- return MIstatus::success;
+ return MIstatus::success;
}
-//++ ------------------------------------------------------------------------------------
-// Details: The invoker requires this function. The command prepares a MI Record Result
+//++
+//------------------------------------------------------------------------------------
+// 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.
@@ -500,46 +511,43 @@ CMICmdCmdExecStep::Execute()
// MIstatus::failure - Functional failed.
// Throws: None.
//--
-bool
-CMICmdCmdExecStep::Acknowledge()
-{
- if (m_lldbResult.GetErrorSize() > 0)
- {
- const char *pLldbErr = m_lldbResult.GetError();
- MIunused(pLldbErr);
- const CMICmnMIValueConst miValueConst(m_lldbResult.GetError());
- const CMICmnMIValueResult miValueResult("message", miValueConst);
- const CMICmnMIResultRecord miRecordResult(m_cmdData.strMiCmdToken, CMICmnMIResultRecord::eResultClass_Error, miValueResult);
- m_miResultRecord = miRecordResult;
- }
- else
- {
- const CMICmnMIResultRecord miRecordResult(m_cmdData.strMiCmdToken, CMICmnMIResultRecord::eResultClass_Running);
- m_miResultRecord = miRecordResult;
- }
+bool CMICmdCmdExecStep::Acknowledge() {
+ if (m_lldbResult.GetErrorSize() > 0) {
+ const char *pLldbErr = m_lldbResult.GetError();
+ MIunused(pLldbErr);
+ const CMICmnMIValueConst miValueConst(m_lldbResult.GetError());
+ const CMICmnMIValueResult miValueResult("message", miValueConst);
+ const CMICmnMIResultRecord miRecordResult(
+ m_cmdData.strMiCmdToken, CMICmnMIResultRecord::eResultClass_Error,
+ miValueResult);
+ m_miResultRecord = miRecordResult;
+ } else {
+ const CMICmnMIResultRecord miRecordResult(
+ m_cmdData.strMiCmdToken, CMICmnMIResultRecord::eResultClass_Running);
+ m_miResultRecord = miRecordResult;
+ }
- return MIstatus::success;
+ return MIstatus::success;
}
-//++ ------------------------------------------------------------------------------------
-// Details: Required by the CMICmdFactory when registering *this command. The factory
+//++
+//------------------------------------------------------------------------------------
+// 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 *
-CMICmdCmdExecStep::CreateSelf()
-{
- return new CMICmdCmdExecStep();
-}
+CMICmdBase *CMICmdCmdExecStep::CreateSelf() { return new CMICmdCmdExecStep(); }
//---------------------------------------------------------------------------------------
//---------------------------------------------------------------------------------------
//---------------------------------------------------------------------------------------
-//++ ------------------------------------------------------------------------------------
+//++
+//------------------------------------------------------------------------------------
// Details: CMICmdCmdExecNextInstruction constructor.
// Type: Method.
// Args: None.
@@ -547,28 +555,28 @@ CMICmdCmdExecStep::CreateSelf()
// Throws: None.
//--
CMICmdCmdExecNextInstruction::CMICmdCmdExecNextInstruction()
- : m_constStrArgNumber("number")
-{
- // Command factory matches this name with that received from the stdin stream
- m_strMiCmd = "exec-next-instruction";
+ : m_constStrArgNumber("number") {
+ // Command factory matches this name with that received from the stdin stream
+ m_strMiCmd = "exec-next-instruction";
- // Required by the CMICmdFactory when registering *this command
- m_pSelfCreatorFn = &CMICmdCmdExecNextInstruction::CreateSelf;
+ // Required by the CMICmdFactory when registering *this command
+ m_pSelfCreatorFn = &CMICmdCmdExecNextInstruction::CreateSelf;
}
-//++ ------------------------------------------------------------------------------------
+//++
+//------------------------------------------------------------------------------------
// Details: CMICmdCmdExecNextInstruction destructor.
// Type: Overrideable.
// Args: None.
// Return: None.
// Throws: None.
//--
-CMICmdCmdExecNextInstruction::~CMICmdCmdExecNextInstruction()
-{
-}
+CMICmdCmdExecNextInstruction::~CMICmdCmdExecNextInstruction() {}
-//++ ------------------------------------------------------------------------------------
-// Details: The invoker requires this function. The parses the command line options
+//++
+//------------------------------------------------------------------------------------
+// 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.
@@ -576,47 +584,52 @@ CMICmdCmdExecNextInstruction::~CMICmdCmd
// MIstatus::failure - Functional failed.
// Throws: None.
//--
-bool
-CMICmdCmdExecNextInstruction::ParseArgs()
-{
- m_setCmdArgs.Add(new CMICmdArgValNumber(m_constStrArgNumber, false, false));
- return ParseValidateCmdOptions();
+bool CMICmdCmdExecNextInstruction::ParseArgs() {
+ m_setCmdArgs.Add(new CMICmdArgValNumber(m_constStrArgNumber, false, false));
+ return ParseValidateCmdOptions();
}
-//++ ------------------------------------------------------------------------------------
-// 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.
+//++
+//------------------------------------------------------------------------------------
+// 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
-CMICmdCmdExecNextInstruction::Execute()
-{
- CMICMDBASE_GETOPTION(pArgThread, OptionLong, m_constStrArgThread);
+bool CMICmdCmdExecNextInstruction::Execute() {
+ CMICMDBASE_GETOPTION(pArgThread, OptionLong, m_constStrArgThread);
- // Retrieve the --thread option's thread ID (only 1)
- MIuint64 nThreadId = UINT64_MAX;
- if (pArgThread->GetFound() && !pArgThread->GetExpectedOption<CMICmdArgValNumber, MIuint64>(nThreadId))
- {
- SetError(CMIUtilString::Format(MIRSRC(IDS_CMD_ERR_OPTION_NOT_FOUND), m_cmdData.strMiCmd.c_str(), m_constStrArgThread.c_str()));
- return MIstatus::failure;
- }
+ // Retrieve the --thread option's thread ID (only 1)
+ MIuint64 nThreadId = UINT64_MAX;
+ if (pArgThread->GetFound() &&
+ !pArgThread->GetExpectedOption<CMICmdArgValNumber, MIuint64>(nThreadId)) {
+ SetError(CMIUtilString::Format(MIRSRC(IDS_CMD_ERR_OPTION_NOT_FOUND),
+ m_cmdData.strMiCmd.c_str(),
+ m_constStrArgThread.c_str()));
+ return MIstatus::failure;
+ }
- CMICmnLLDBDebugSessionInfo &rSessionInfo(CMICmnLLDBDebugSessionInfo::Instance());
- lldb::SBDebugger &rDebugger = rSessionInfo.GetDebugger();
- CMIUtilString strCmd("thread step-inst-over");
- if (nThreadId != UINT64_MAX)
- strCmd += CMIUtilString::Format(" %llu", nThreadId);
- rDebugger.GetCommandInterpreter().HandleCommand(strCmd.c_str(), m_lldbResult, false);
+ CMICmnLLDBDebugSessionInfo &rSessionInfo(
+ CMICmnLLDBDebugSessionInfo::Instance());
+ lldb::SBDebugger &rDebugger = rSessionInfo.GetDebugger();
+ CMIUtilString strCmd("thread step-inst-over");
+ if (nThreadId != UINT64_MAX)
+ strCmd += CMIUtilString::Format(" %llu", nThreadId);
+ rDebugger.GetCommandInterpreter().HandleCommand(strCmd.c_str(), m_lldbResult,
+ false);
- return MIstatus::success;
+ return MIstatus::success;
}
-//++ ------------------------------------------------------------------------------------
-// Details: The invoker requires this function. The command prepares a MI Record Result
+//++
+//------------------------------------------------------------------------------------
+// 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.
@@ -624,46 +637,45 @@ CMICmdCmdExecNextInstruction::Execute()
// MIstatus::failure - Functional failed.
// Throws: None.
//--
-bool
-CMICmdCmdExecNextInstruction::Acknowledge()
-{
- if (m_lldbResult.GetErrorSize() > 0)
- {
- const char *pLldbErr = m_lldbResult.GetError();
- MIunused(pLldbErr);
- const CMICmnMIValueConst miValueConst(m_lldbResult.GetError());
- const CMICmnMIValueResult miValueResult("message", miValueConst);
- const CMICmnMIResultRecord miRecordResult(m_cmdData.strMiCmdToken, CMICmnMIResultRecord::eResultClass_Error, miValueResult);
- m_miResultRecord = miRecordResult;
- }
- else
- {
- const CMICmnMIResultRecord miRecordResult(m_cmdData.strMiCmdToken, CMICmnMIResultRecord::eResultClass_Running);
- m_miResultRecord = miRecordResult;
- }
+bool CMICmdCmdExecNextInstruction::Acknowledge() {
+ if (m_lldbResult.GetErrorSize() > 0) {
+ const char *pLldbErr = m_lldbResult.GetError();
+ MIunused(pLldbErr);
+ const CMICmnMIValueConst miValueConst(m_lldbResult.GetError());
+ const CMICmnMIValueResult miValueResult("message", miValueConst);
+ const CMICmnMIResultRecord miRecordResult(
+ m_cmdData.strMiCmdToken, CMICmnMIResultRecord::eResultClass_Error,
+ miValueResult);
+ m_miResultRecord = miRecordResult;
+ } else {
+ const CMICmnMIResultRecord miRecordResult(
+ m_cmdData.strMiCmdToken, CMICmnMIResultRecord::eResultClass_Running);
+ m_miResultRecord = miRecordResult;
+ }
- return MIstatus::success;
+ return MIstatus::success;
}
-//++ ------------------------------------------------------------------------------------
-// Details: Required by the CMICmdFactory when registering *this command. The factory
+//++
+//------------------------------------------------------------------------------------
+// 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 *
-CMICmdCmdExecNextInstruction::CreateSelf()
-{
- return new CMICmdCmdExecNextInstruction();
+CMICmdBase *CMICmdCmdExecNextInstruction::CreateSelf() {
+ return new CMICmdCmdExecNextInstruction();
}
//---------------------------------------------------------------------------------------
//---------------------------------------------------------------------------------------
//---------------------------------------------------------------------------------------
-//++ ------------------------------------------------------------------------------------
+//++
+//------------------------------------------------------------------------------------
// Details: CMICmdCmdExecStepInstruction constructor.
// Type: Method.
// Args: None.
@@ -671,28 +683,28 @@ CMICmdCmdExecNextInstruction::CreateSelf
// Throws: None.
//--
CMICmdCmdExecStepInstruction::CMICmdCmdExecStepInstruction()
- : m_constStrArgNumber("number")
-{
- // Command factory matches this name with that received from the stdin stream
- m_strMiCmd = "exec-step-instruction";
+ : m_constStrArgNumber("number") {
+ // Command factory matches this name with that received from the stdin stream
+ m_strMiCmd = "exec-step-instruction";
- // Required by the CMICmdFactory when registering *this command
- m_pSelfCreatorFn = &CMICmdCmdExecStepInstruction::CreateSelf;
+ // Required by the CMICmdFactory when registering *this command
+ m_pSelfCreatorFn = &CMICmdCmdExecStepInstruction::CreateSelf;
}
-//++ ------------------------------------------------------------------------------------
+//++
+//------------------------------------------------------------------------------------
// Details: CMICmdCmdExecStepInstruction destructor.
// Type: Overrideable.
// Args: None.
// Return: None.
// Throws: None.
//--
-CMICmdCmdExecStepInstruction::~CMICmdCmdExecStepInstruction()
-{
-}
+CMICmdCmdExecStepInstruction::~CMICmdCmdExecStepInstruction() {}
-//++ ------------------------------------------------------------------------------------
-// Details: The invoker requires this function. The parses the command line options
+//++
+//------------------------------------------------------------------------------------
+// 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.
@@ -700,47 +712,52 @@ CMICmdCmdExecStepInstruction::~CMICmdCmd
// MIstatus::failure - Functional failed.
// Throws: None.
//--
-bool
-CMICmdCmdExecStepInstruction::ParseArgs()
-{
- m_setCmdArgs.Add(new CMICmdArgValNumber(m_constStrArgNumber, false, false));
- return ParseValidateCmdOptions();
+bool CMICmdCmdExecStepInstruction::ParseArgs() {
+ m_setCmdArgs.Add(new CMICmdArgValNumber(m_constStrArgNumber, false, false));
+ return ParseValidateCmdOptions();
}
-//++ ------------------------------------------------------------------------------------
-// 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.
+//++
+//------------------------------------------------------------------------------------
+// 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
-CMICmdCmdExecStepInstruction::Execute()
-{
- CMICMDBASE_GETOPTION(pArgThread, OptionLong, m_constStrArgThread);
+bool CMICmdCmdExecStepInstruction::Execute() {
+ CMICMDBASE_GETOPTION(pArgThread, OptionLong, m_constStrArgThread);
- // Retrieve the --thread option's thread ID (only 1)
- MIuint64 nThreadId = UINT64_MAX;
- if (pArgThread->GetFound() && !pArgThread->GetExpectedOption<CMICmdArgValNumber, MIuint64>(nThreadId))
- {
- SetError(CMIUtilString::Format(MIRSRC(IDS_CMD_ERR_OPTION_NOT_FOUND), m_cmdData.strMiCmd.c_str(), m_constStrArgThread.c_str()));
- return MIstatus::failure;
- }
+ // Retrieve the --thread option's thread ID (only 1)
+ MIuint64 nThreadId = UINT64_MAX;
+ if (pArgThread->GetFound() &&
+ !pArgThread->GetExpectedOption<CMICmdArgValNumber, MIuint64>(nThreadId)) {
+ SetError(CMIUtilString::Format(MIRSRC(IDS_CMD_ERR_OPTION_NOT_FOUND),
+ m_cmdData.strMiCmd.c_str(),
+ m_constStrArgThread.c_str()));
+ return MIstatus::failure;
+ }
- CMICmnLLDBDebugSessionInfo &rSessionInfo(CMICmnLLDBDebugSessionInfo::Instance());
- lldb::SBDebugger &rDebugger = rSessionInfo.GetDebugger();
- CMIUtilString strCmd("thread step-inst");
- if (nThreadId != UINT64_MAX)
- strCmd += CMIUtilString::Format(" %llu", nThreadId);
- rDebugger.GetCommandInterpreter().HandleCommand(strCmd.c_str(), m_lldbResult, false);
+ CMICmnLLDBDebugSessionInfo &rSessionInfo(
+ CMICmnLLDBDebugSessionInfo::Instance());
+ lldb::SBDebugger &rDebugger = rSessionInfo.GetDebugger();
+ CMIUtilString strCmd("thread step-inst");
+ if (nThreadId != UINT64_MAX)
+ strCmd += CMIUtilString::Format(" %llu", nThreadId);
+ rDebugger.GetCommandInterpreter().HandleCommand(strCmd.c_str(), m_lldbResult,
+ false);
- return MIstatus::success;
+ return MIstatus::success;
}
-//++ ------------------------------------------------------------------------------------
-// Details: The invoker requires this function. The command prepares a MI Record Result
+//++
+//------------------------------------------------------------------------------------
+// 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.
@@ -748,74 +765,73 @@ CMICmdCmdExecStepInstruction::Execute()
// MIstatus::failure - Functional failed.
// Throws: None.
//--
-bool
-CMICmdCmdExecStepInstruction::Acknowledge()
-{
- if (m_lldbResult.GetErrorSize() > 0)
- {
- const char *pLldbErr = m_lldbResult.GetError();
- MIunused(pLldbErr);
- const CMICmnMIValueConst miValueConst(m_lldbResult.GetError());
- const CMICmnMIValueResult miValueResult("message", miValueConst);
- const CMICmnMIResultRecord miRecordResult(m_cmdData.strMiCmdToken, CMICmnMIResultRecord::eResultClass_Error, miValueResult);
- m_miResultRecord = miRecordResult;
- }
- else
- {
- const CMICmnMIResultRecord miRecordResult(m_cmdData.strMiCmdToken, CMICmnMIResultRecord::eResultClass_Running);
- m_miResultRecord = miRecordResult;
- }
+bool CMICmdCmdExecStepInstruction::Acknowledge() {
+ if (m_lldbResult.GetErrorSize() > 0) {
+ const char *pLldbErr = m_lldbResult.GetError();
+ MIunused(pLldbErr);
+ const CMICmnMIValueConst miValueConst(m_lldbResult.GetError());
+ const CMICmnMIValueResult miValueResult("message", miValueConst);
+ const CMICmnMIResultRecord miRecordResult(
+ m_cmdData.strMiCmdToken, CMICmnMIResultRecord::eResultClass_Error,
+ miValueResult);
+ m_miResultRecord = miRecordResult;
+ } else {
+ const CMICmnMIResultRecord miRecordResult(
+ m_cmdData.strMiCmdToken, CMICmnMIResultRecord::eResultClass_Running);
+ m_miResultRecord = miRecordResult;
+ }
- return MIstatus::success;
+ return MIstatus::success;
}
-//++ ------------------------------------------------------------------------------------
-// Details: Required by the CMICmdFactory when registering *this command. The factory
+//++
+//------------------------------------------------------------------------------------
+// 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 *
-CMICmdCmdExecStepInstruction::CreateSelf()
-{
- return new CMICmdCmdExecStepInstruction();
+CMICmdBase *CMICmdCmdExecStepInstruction::CreateSelf() {
+ return new CMICmdCmdExecStepInstruction();
}
//---------------------------------------------------------------------------------------
//---------------------------------------------------------------------------------------
//---------------------------------------------------------------------------------------
-//++ ------------------------------------------------------------------------------------
+//++
+//------------------------------------------------------------------------------------
// Details: CMICmdCmdExecFinish constructor.
// Type: Method.
// Args: None.
// Return: None.
// Throws: None.
//--
-CMICmdCmdExecFinish::CMICmdCmdExecFinish()
-{
- // Command factory matches this name with that received from the stdin stream
- m_strMiCmd = "exec-finish";
+CMICmdCmdExecFinish::CMICmdCmdExecFinish() {
+ // Command factory matches this name with that received from the stdin stream
+ m_strMiCmd = "exec-finish";
- // Required by the CMICmdFactory when registering *this command
- m_pSelfCreatorFn = &CMICmdCmdExecFinish::CreateSelf;
+ // Required by the CMICmdFactory when registering *this command
+ m_pSelfCreatorFn = &CMICmdCmdExecFinish::CreateSelf;
}
-//++ ------------------------------------------------------------------------------------
+//++
+//------------------------------------------------------------------------------------
// Details: CMICmdCmdExecFinish destructor.
// Type: Overrideable.
// Args: None.
// Return: None.
// Throws: None.
//--
-CMICmdCmdExecFinish::~CMICmdCmdExecFinish()
-{
-}
+CMICmdCmdExecFinish::~CMICmdCmdExecFinish() {}
-//++ ------------------------------------------------------------------------------------
-// Details: The invoker requires this function. The parses the command line options
+//++
+//------------------------------------------------------------------------------------
+// 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.
@@ -823,46 +839,49 @@ CMICmdCmdExecFinish::~CMICmdCmdExecFinis
// MIstatus::failure - Functional failed.
// Throws: None.
//--
-bool
-CMICmdCmdExecFinish::ParseArgs()
-{
- return ParseValidateCmdOptions();
-}
+bool CMICmdCmdExecFinish::ParseArgs() { return ParseValidateCmdOptions(); }
-//++ ------------------------------------------------------------------------------------
-// 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.
+//++
+//------------------------------------------------------------------------------------
+// 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
-CMICmdCmdExecFinish::Execute()
-{
- CMICMDBASE_GETOPTION(pArgThread, OptionLong, m_constStrArgThread);
+bool CMICmdCmdExecFinish::Execute() {
+ CMICMDBASE_GETOPTION(pArgThread, OptionLong, m_constStrArgThread);
- // Retrieve the --thread option's thread ID (only 1)
- MIuint64 nThreadId = UINT64_MAX;
- if (pArgThread->GetFound() && !pArgThread->GetExpectedOption<CMICmdArgValNumber, MIuint64>(nThreadId))
- {
- SetError(CMIUtilString::Format(MIRSRC(IDS_CMD_ERR_OPTION_NOT_FOUND), m_cmdData.strMiCmd.c_str(), m_constStrArgThread.c_str()));
- return MIstatus::failure;
- }
+ // Retrieve the --thread option's thread ID (only 1)
+ MIuint64 nThreadId = UINT64_MAX;
+ if (pArgThread->GetFound() &&
+ !pArgThread->GetExpectedOption<CMICmdArgValNumber, MIuint64>(nThreadId)) {
+ SetError(CMIUtilString::Format(MIRSRC(IDS_CMD_ERR_OPTION_NOT_FOUND),
+ m_cmdData.strMiCmd.c_str(),
+ m_constStrArgThread.c_str()));
+ return MIstatus::failure;
+ }
- CMICmnLLDBDebugSessionInfo &rSessionInfo(CMICmnLLDBDebugSessionInfo::Instance());
- lldb::SBDebugger &rDebugger = rSessionInfo.GetDebugger();
- CMIUtilString strCmd("thread step-out");
- if (nThreadId != UINT64_MAX)
- strCmd += CMIUtilString::Format(" %llu", nThreadId);
- rDebugger.GetCommandInterpreter().HandleCommand(strCmd.c_str(), m_lldbResult, false);
+ CMICmnLLDBDebugSessionInfo &rSessionInfo(
+ CMICmnLLDBDebugSessionInfo::Instance());
+ lldb::SBDebugger &rDebugger = rSessionInfo.GetDebugger();
+ CMIUtilString strCmd("thread step-out");
+ if (nThreadId != UINT64_MAX)
+ strCmd += CMIUtilString::Format(" %llu", nThreadId);
+ rDebugger.GetCommandInterpreter().HandleCommand(strCmd.c_str(), m_lldbResult,
+ false);
- return MIstatus::success;
+ return MIstatus::success;
}
-//++ ------------------------------------------------------------------------------------
-// Details: The invoker requires this function. The command prepares a MI Record Result
+//++
+//------------------------------------------------------------------------------------
+// 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.
@@ -870,103 +889,107 @@ CMICmdCmdExecFinish::Execute()
// MIstatus::failure - Functional failed.
// Throws: None.
//--
-bool
-CMICmdCmdExecFinish::Acknowledge()
-{
- if (m_lldbResult.GetErrorSize() > 0)
- {
- const char *pLldbErr = m_lldbResult.GetError();
- MIunused(pLldbErr);
- const CMICmnMIValueConst miValueConst(m_lldbResult.GetError());
- const CMICmnMIValueResult miValueResult("message", miValueConst);
- const CMICmnMIResultRecord miRecordResult(m_cmdData.strMiCmdToken, CMICmnMIResultRecord::eResultClass_Error, miValueResult);
- m_miResultRecord = miRecordResult;
- }
- else
- {
- const CMICmnMIResultRecord miRecordResult(m_cmdData.strMiCmdToken, CMICmnMIResultRecord::eResultClass_Running);
- m_miResultRecord = miRecordResult;
- }
+bool CMICmdCmdExecFinish::Acknowledge() {
+ if (m_lldbResult.GetErrorSize() > 0) {
+ const char *pLldbErr = m_lldbResult.GetError();
+ MIunused(pLldbErr);
+ const CMICmnMIValueConst miValueConst(m_lldbResult.GetError());
+ const CMICmnMIValueResult miValueResult("message", miValueConst);
+ const CMICmnMIResultRecord miRecordResult(
+ m_cmdData.strMiCmdToken, CMICmnMIResultRecord::eResultClass_Error,
+ miValueResult);
+ m_miResultRecord = miRecordResult;
+ } else {
+ const CMICmnMIResultRecord miRecordResult(
+ m_cmdData.strMiCmdToken, CMICmnMIResultRecord::eResultClass_Running);
+ m_miResultRecord = miRecordResult;
+ }
- return MIstatus::success;
+ return MIstatus::success;
}
-//++ ------------------------------------------------------------------------------------
-// Details: Required by the CMICmdFactory when registering *this command. The factory
+//++
+//------------------------------------------------------------------------------------
+// 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 *
-CMICmdCmdExecFinish::CreateSelf()
-{
- return new CMICmdCmdExecFinish();
+CMICmdBase *CMICmdCmdExecFinish::CreateSelf() {
+ return new CMICmdCmdExecFinish();
}
//---------------------------------------------------------------------------------------
//---------------------------------------------------------------------------------------
//---------------------------------------------------------------------------------------
-//++ ------------------------------------------------------------------------------------
+//++
+//------------------------------------------------------------------------------------
// Details: CMICmdCmdExecInterrupt constructor.
// Type: Method.
// Args: None.
// Return: None.
// Throws: None.
//--
-CMICmdCmdExecInterrupt::CMICmdCmdExecInterrupt()
-{
- // Command factory matches this name with that received from the stdin stream
- m_strMiCmd = "exec-interrupt";
+CMICmdCmdExecInterrupt::CMICmdCmdExecInterrupt() {
+ // Command factory matches this name with that received from the stdin stream
+ m_strMiCmd = "exec-interrupt";
- // Required by the CMICmdFactory when registering *this command
- m_pSelfCreatorFn = &CMICmdCmdExecInterrupt::CreateSelf;
+ // Required by the CMICmdFactory when registering *this command
+ m_pSelfCreatorFn = &CMICmdCmdExecInterrupt::CreateSelf;
}
-//++ ------------------------------------------------------------------------------------
+//++
+//------------------------------------------------------------------------------------
// Details: CMICmdCmdExecInterrupt destructor.
// Type: Overrideable.
// Args: None.
// Return: None.
// Throws: None.
//--
-CMICmdCmdExecInterrupt::~CMICmdCmdExecInterrupt()
-{
-}
+CMICmdCmdExecInterrupt::~CMICmdCmdExecInterrupt() {}
-//++ ------------------------------------------------------------------------------------
-// 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.
+//++
+//------------------------------------------------------------------------------------
+// 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
-CMICmdCmdExecInterrupt::Execute()
-{
- CMICmnLLDBDebugSessionInfo &rSessionInfo(CMICmnLLDBDebugSessionInfo::Instance());
- lldb::SBDebugger &rDebugger = rSessionInfo.GetDebugger();
- CMIUtilString strCmd("process interrupt");
- const lldb::ReturnStatus status = rDebugger.GetCommandInterpreter().HandleCommand(strCmd.c_str(), m_lldbResult, false);
- MIunused(status);
+bool CMICmdCmdExecInterrupt::Execute() {
+ CMICmnLLDBDebugSessionInfo &rSessionInfo(
+ CMICmnLLDBDebugSessionInfo::Instance());
+ lldb::SBDebugger &rDebugger = rSessionInfo.GetDebugger();
+ CMIUtilString strCmd("process interrupt");
+ const lldb::ReturnStatus status =
+ rDebugger.GetCommandInterpreter().HandleCommand(strCmd.c_str(),
+ m_lldbResult, false);
+ MIunused(status);
- // CODETAG_DEBUG_SESSION_RUNNING_PROG_RECEIVED_SIGINT_PAUSE_PROGRAM
- if (!CMIDriver::Instance().SetDriverStateRunningNotDebugging())
- {
- const CMIUtilString &rErrMsg(CMIDriver::Instance().GetErrorDescription());
- SetErrorDescription(CMIUtilString::Format(MIRSRC(IDS_CMD_ERR_SET_NEW_DRIVER_STATE), strCmd.c_str(), rErrMsg.c_str()));
- return MIstatus::failure;
- }
+ // CODETAG_DEBUG_SESSION_RUNNING_PROG_RECEIVED_SIGINT_PAUSE_PROGRAM
+ if (!CMIDriver::Instance().SetDriverStateRunningNotDebugging()) {
+ const CMIUtilString &rErrMsg(CMIDriver::Instance().GetErrorDescription());
+ SetErrorDescription(
+ CMIUtilString::Format(MIRSRC(IDS_CMD_ERR_SET_NEW_DRIVER_STATE),
+ strCmd.c_str(), rErrMsg.c_str()));
+ return MIstatus::failure;
+ }
- return MIstatus::success;
+ return MIstatus::success;
}
-//++ ------------------------------------------------------------------------------------
-// Details: The invoker requires this function. The command prepares a MI Record Result
+//++
+//------------------------------------------------------------------------------------
+// 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.
@@ -974,44 +997,43 @@ CMICmdCmdExecInterrupt::Execute()
// MIstatus::failure - Functional failed.
// Throws: None.
//--
-bool
-CMICmdCmdExecInterrupt::Acknowledge()
-{
- if (m_lldbResult.GetErrorSize() > 0)
- {
- const CMICmnMIValueConst miValueConst(m_lldbResult.GetError());
- const CMICmnMIValueResult miValueResult("message", miValueConst);
- const CMICmnMIResultRecord miRecordResult(m_cmdData.strMiCmdToken, CMICmnMIResultRecord::eResultClass_Error, miValueResult);
- m_miResultRecord = miRecordResult;
- }
- else
- {
- const CMICmnMIResultRecord miRecordResult(m_cmdData.strMiCmdToken, CMICmnMIResultRecord::eResultClass_Done);
- m_miResultRecord = miRecordResult;
- }
+bool CMICmdCmdExecInterrupt::Acknowledge() {
+ if (m_lldbResult.GetErrorSize() > 0) {
+ const CMICmnMIValueConst miValueConst(m_lldbResult.GetError());
+ const CMICmnMIValueResult miValueResult("message", miValueConst);
+ const CMICmnMIResultRecord miRecordResult(
+ m_cmdData.strMiCmdToken, CMICmnMIResultRecord::eResultClass_Error,
+ miValueResult);
+ m_miResultRecord = miRecordResult;
+ } else {
+ const CMICmnMIResultRecord miRecordResult(
+ m_cmdData.strMiCmdToken, CMICmnMIResultRecord::eResultClass_Done);
+ m_miResultRecord = miRecordResult;
+ }
- return MIstatus::success;
+ return MIstatus::success;
}
-//++ ------------------------------------------------------------------------------------
-// Details: Required by the CMICmdFactory when registering *this command. The factory
+//++
+//------------------------------------------------------------------------------------
+// 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 *
-CMICmdCmdExecInterrupt::CreateSelf()
-{
- return new CMICmdCmdExecInterrupt();
+CMICmdBase *CMICmdCmdExecInterrupt::CreateSelf() {
+ return new CMICmdCmdExecInterrupt();
}
//---------------------------------------------------------------------------------------
//---------------------------------------------------------------------------------------
//---------------------------------------------------------------------------------------
-//++ ------------------------------------------------------------------------------------
+//++
+//------------------------------------------------------------------------------------
// Details: CMICmdCmdExecArguments constructor.
// Type: Method.
// Args: None.
@@ -1019,28 +1041,28 @@ CMICmdCmdExecInterrupt::CreateSelf()
// Throws: None.
//--
CMICmdCmdExecArguments::CMICmdCmdExecArguments()
- : m_constStrArgArguments("arguments")
-{
- // Command factory matches this name with that received from the stdin stream
- m_strMiCmd = "exec-arguments";
+ : m_constStrArgArguments("arguments") {
+ // Command factory matches this name with that received from the stdin stream
+ m_strMiCmd = "exec-arguments";
- // Required by the CMICmdFactory when registering *this command
- m_pSelfCreatorFn = &CMICmdCmdExecArguments::CreateSelf;
+ // Required by the CMICmdFactory when registering *this command
+ m_pSelfCreatorFn = &CMICmdCmdExecArguments::CreateSelf;
}
-//++ ------------------------------------------------------------------------------------
+//++
+//------------------------------------------------------------------------------------
// Details: CMICmdCmdExecArguments destructor.
// Type: Overrideable.
// Args: None.
// Return: None.
// Throws: None.
//--
-CMICmdCmdExecArguments::~CMICmdCmdExecArguments()
-{
-}
+CMICmdCmdExecArguments::~CMICmdCmdExecArguments() {}
-//++ ------------------------------------------------------------------------------------
-// Details: The invoker requires this function. The parses the command line options
+//++
+//------------------------------------------------------------------------------------
+// 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.
@@ -1048,55 +1070,58 @@ CMICmdCmdExecArguments::~CMICmdCmdExecAr
// MIstatus::failure - Function failed.
// Throws: None.
//--
-bool
-CMICmdCmdExecArguments::ParseArgs()
-{
- m_setCmdArgs.Add(
- new CMICmdArgValListOfN(m_constStrArgArguments, false, true, CMICmdArgValListBase::eArgValType_StringAnything));
- return ParseValidateCmdOptions();
+bool CMICmdCmdExecArguments::ParseArgs() {
+ m_setCmdArgs.Add(new CMICmdArgValListOfN(
+ m_constStrArgArguments, false, true,
+ CMICmdArgValListBase::eArgValType_StringAnything));
+ return ParseValidateCmdOptions();
}
-//++ ------------------------------------------------------------------------------------
-// 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.
+//++
+//------------------------------------------------------------------------------------
+// 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 - Function succeeded.
// MIstatus::failure - Function failed.
// Throws: None.
//--
-bool
-CMICmdCmdExecArguments::Execute()
-{
- CMICMDBASE_GETOPTION(pArgArguments, ListOfN, m_constStrArgArguments);
-
- CMICmnLLDBDebugSessionInfo &rSessionInfo(CMICmnLLDBDebugSessionInfo::Instance());
- lldb::SBTarget sbTarget = rSessionInfo.GetTarget();
- if (!sbTarget.IsValid())
- {
- SetError(CMIUtilString::Format(MIRSRC(IDS_CMD_ERR_INVALID_TARGET_CURRENT), m_cmdData.strMiCmd.c_str()));
- return MIstatus::failure;
- }
-
- lldb::SBLaunchInfo sbLaunchInfo = sbTarget.GetLaunchInfo();
- sbLaunchInfo.SetArguments(NULL, false);
-
- CMIUtilString strArg;
- size_t nArgIndex = 0;
- while (pArgArguments->GetExpectedOption<CMICmdArgValString, CMIUtilString>(strArg, nArgIndex))
- {
- const char *argv[2] = { strArg.c_str(), NULL };
- sbLaunchInfo.SetArguments(argv, true);
- ++nArgIndex;
- }
+bool CMICmdCmdExecArguments::Execute() {
+ CMICMDBASE_GETOPTION(pArgArguments, ListOfN, m_constStrArgArguments);
- sbTarget.SetLaunchInfo(sbLaunchInfo);
-
- return MIstatus::success;
-}
-
-//++ ------------------------------------------------------------------------------------
-// Details: The invoker requires this function. The command prepares a MI Record Result
+ CMICmnLLDBDebugSessionInfo &rSessionInfo(
+ CMICmnLLDBDebugSessionInfo::Instance());
+ lldb::SBTarget sbTarget = rSessionInfo.GetTarget();
+ if (!sbTarget.IsValid()) {
+ SetError(CMIUtilString::Format(MIRSRC(IDS_CMD_ERR_INVALID_TARGET_CURRENT),
+ m_cmdData.strMiCmd.c_str()));
+ return MIstatus::failure;
+ }
+
+ lldb::SBLaunchInfo sbLaunchInfo = sbTarget.GetLaunchInfo();
+ sbLaunchInfo.SetArguments(NULL, false);
+
+ CMIUtilString strArg;
+ size_t nArgIndex = 0;
+ while (pArgArguments->GetExpectedOption<CMICmdArgValString, CMIUtilString>(
+ strArg, nArgIndex)) {
+ const char *argv[2] = {strArg.c_str(), NULL};
+ sbLaunchInfo.SetArguments(argv, true);
+ ++nArgIndex;
+ }
+
+ sbTarget.SetLaunchInfo(sbLaunchInfo);
+
+ 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.
@@ -1104,92 +1129,95 @@ CMICmdCmdExecArguments::Execute()
// MIstatus::failure - Function failed.
// Throws: None.
//--
-bool
-CMICmdCmdExecArguments::Acknowledge()
-{
- const CMICmnMIResultRecord miRecordResult(m_cmdData.strMiCmdToken, CMICmnMIResultRecord::eResultClass_Done);
- m_miResultRecord = miRecordResult;
-
- return MIstatus::success;
+bool CMICmdCmdExecArguments::Acknowledge() {
+ const CMICmnMIResultRecord miRecordResult(
+ m_cmdData.strMiCmdToken, CMICmnMIResultRecord::eResultClass_Done);
+ m_miResultRecord = miRecordResult;
+
+ return MIstatus::success;
}
-//++ ------------------------------------------------------------------------------------
-// Details: Required by the CMICmdFactory when registering *this command. The factory
+//++
+//------------------------------------------------------------------------------------
+// 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 *
-CMICmdCmdExecArguments::CreateSelf()
-{
- return new CMICmdCmdExecArguments();
+CMICmdBase *CMICmdCmdExecArguments::CreateSelf() {
+ return new CMICmdCmdExecArguments();
}
//---------------------------------------------------------------------------------------
//---------------------------------------------------------------------------------------
//---------------------------------------------------------------------------------------
-//++ ------------------------------------------------------------------------------------
+//++
+//------------------------------------------------------------------------------------
// Details: CMICmdCmdExecAbort constructor.
// Type: Method.
// Args: None.
// Return: None.
// Throws: None.
//--
-CMICmdCmdExecAbort::CMICmdCmdExecAbort()
-{
- // Command factory matches this name with that received from the stdin stream
- m_strMiCmd = "exec-abort";
+CMICmdCmdExecAbort::CMICmdCmdExecAbort() {
+ // Command factory matches this name with that received from the stdin stream
+ m_strMiCmd = "exec-abort";
- // Required by the CMICmdFactory when registering *this command
- m_pSelfCreatorFn = &CMICmdCmdExecAbort::CreateSelf;
+ // Required by the CMICmdFactory when registering *this command
+ m_pSelfCreatorFn = &CMICmdCmdExecAbort::CreateSelf;
}
-//++ ------------------------------------------------------------------------------------
+//++
+//------------------------------------------------------------------------------------
// Details: CMICmdCmdExecAbort destructor.
// Type: Overrideable.
// Args: None.
// Return: None.
// Throws: None.
//--
-CMICmdCmdExecAbort::~CMICmdCmdExecAbort()
-{
-}
+CMICmdCmdExecAbort::~CMICmdCmdExecAbort() {}
-//++ ------------------------------------------------------------------------------------
-// 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.
+//++
+//------------------------------------------------------------------------------------
+// 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 - Function succeeded.
// MIstatus::failure - Function failed.
// Throws: None.
//--
-bool
-CMICmdCmdExecAbort::Execute()
-{
- CMICmnLLDBDebugSessionInfo &rSessionInfo(CMICmnLLDBDebugSessionInfo::Instance());
- lldb::SBProcess sbProcess = rSessionInfo.GetProcess();
- if (!sbProcess.IsValid())
- {
- SetError(CMIUtilString::Format(MIRSRC(IDS_CMD_ERR_INVALID_PROCESS), m_cmdData.strMiCmd.c_str()));
- return MIstatus::failure;
- }
-
- lldb::SBError sbError = sbProcess.Destroy();
- if (sbError.Fail())
- {
- SetError(CMIUtilString::Format(MIRSRC(IDS_CMD_ERR_LLDBPROCESS_DESTROY), m_cmdData.strMiCmd.c_str(), sbError.GetCString()));
- return MIstatus::failure;
- }
-
- return MIstatus::success;
-}
-
-//++ ------------------------------------------------------------------------------------
-// Details: The invoker requires this function. The command prepares a MI Record Result
+bool CMICmdCmdExecAbort::Execute() {
+ CMICmnLLDBDebugSessionInfo &rSessionInfo(
+ CMICmnLLDBDebugSessionInfo::Instance());
+ lldb::SBProcess sbProcess = rSessionInfo.GetProcess();
+ if (!sbProcess.IsValid()) {
+ SetError(CMIUtilString::Format(MIRSRC(IDS_CMD_ERR_INVALID_PROCESS),
+ m_cmdData.strMiCmd.c_str()));
+ return MIstatus::failure;
+ }
+
+ lldb::SBError sbError = sbProcess.Destroy();
+ if (sbError.Fail()) {
+ SetError(CMIUtilString::Format(MIRSRC(IDS_CMD_ERR_LLDBPROCESS_DESTROY),
+ m_cmdData.strMiCmd.c_str(),
+ sbError.GetCString()));
+ 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.
@@ -1197,24 +1225,23 @@ CMICmdCmdExecAbort::Execute()
// MIstatus::failure - Function failed.
// Throws: None.
//--
-bool
-CMICmdCmdExecAbort::Acknowledge()
-{
- const CMICmnMIResultRecord miRecordResult(m_cmdData.strMiCmdToken, CMICmnMIResultRecord::eResultClass_Done);
- m_miResultRecord = miRecordResult;
- return MIstatus::success;
+bool CMICmdCmdExecAbort::Acknowledge() {
+ const CMICmnMIResultRecord miRecordResult(
+ m_cmdData.strMiCmdToken, CMICmnMIResultRecord::eResultClass_Done);
+ m_miResultRecord = miRecordResult;
+ return MIstatus::success;
}
-//++ ------------------------------------------------------------------------------------
-// Details: Required by the CMICmdFactory when registering *this command. The factory
+//++
+//------------------------------------------------------------------------------------
+// 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 *
-CMICmdCmdExecAbort::CreateSelf()
-{
- return new CMICmdCmdExecAbort();
+CMICmdBase *CMICmdCmdExecAbort::CreateSelf() {
+ return new CMICmdCmdExecAbort();
}
Modified: lldb/trunk/tools/lldb-mi/MICmdCmdExec.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/lldb-mi/MICmdCmdExec.h?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/tools/lldb-mi/MICmdCmdExec.h (original)
+++ lldb/trunk/tools/lldb-mi/MICmdCmdExec.h Tue Sep 6 15:57:50 2016
@@ -18,13 +18,16 @@
// CMICmdCmdExecArguments interface.
// CMICmdCmdExecAbort 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 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
+// For an introduction to adding a new command see
+// CMICmdCmdSupportInfoMiCmdQuery
// command class as an example.
#pragma once
@@ -35,293 +38,299 @@
// In-house headers:
#include "MICmdBase.h"
-//++ ============================================================================
+//++
+//============================================================================
// Details: MI command class. MI commands derived from the command base class.
// *this class implements MI command "exec-run".
//--
-class CMICmdCmdExecRun : public CMICmdBase
-{
- // Statics:
- public:
- // Required by the CMICmdFactory when registering *this command
- static CMICmdBase *CreateSelf();
-
- // Methods:
- public:
- /* ctor */ CMICmdCmdExecRun();
-
- // Overridden:
- public:
- // From CMICmdInvoker::ICmd
- bool Execute() override;
- bool Acknowledge() override;
- bool ParseArgs() override;
- // From CMICmnBase
- /* dtor */ ~CMICmdCmdExecRun() override;
-
- // Attributes:
- private:
- const CMIUtilString m_constStrArgStart; // StopAtEntry - run to first instruction or main() if specified
- lldb::SBCommandReturnObject m_lldbResult;
+class CMICmdCmdExecRun : public CMICmdBase {
+ // Statics:
+public:
+ // Required by the CMICmdFactory when registering *this command
+ static CMICmdBase *CreateSelf();
+
+ // Methods:
+public:
+ /* ctor */ CMICmdCmdExecRun();
+
+ // Overridden:
+public:
+ // From CMICmdInvoker::ICmd
+ bool Execute() override;
+ bool Acknowledge() override;
+ bool ParseArgs() override;
+ // From CMICmnBase
+ /* dtor */ ~CMICmdCmdExecRun() override;
+
+ // Attributes:
+private:
+ const CMIUtilString m_constStrArgStart; // StopAtEntry - run to first
+ // instruction or main() if specified
+ lldb::SBCommandReturnObject m_lldbResult;
};
-//++ ============================================================================
+//++
+//============================================================================
// Details: MI command class. MI commands derived from the command base class.
// *this class implements MI command "exec-continue".
//--
-class CMICmdCmdExecContinue : public CMICmdBase
-{
- // Statics:
- public:
- // Required by the CMICmdFactory when registering *this command
- static CMICmdBase *CreateSelf();
-
- // Methods:
- public:
- /* ctor */ CMICmdCmdExecContinue();
-
- // Overridden:
- public:
- // From CMICmdInvoker::ICmd
- bool Execute() override;
- bool Acknowledge() override;
- // From CMICmnBase
- /* dtor */ ~CMICmdCmdExecContinue() override;
-
- // Attributes:
- private:
- lldb::SBCommandReturnObject m_lldbResult;
+class CMICmdCmdExecContinue : public CMICmdBase {
+ // Statics:
+public:
+ // Required by the CMICmdFactory when registering *this command
+ static CMICmdBase *CreateSelf();
+
+ // Methods:
+public:
+ /* ctor */ CMICmdCmdExecContinue();
+
+ // Overridden:
+public:
+ // From CMICmdInvoker::ICmd
+ bool Execute() override;
+ bool Acknowledge() override;
+ // From CMICmnBase
+ /* dtor */ ~CMICmdCmdExecContinue() override;
+
+ // Attributes:
+private:
+ lldb::SBCommandReturnObject m_lldbResult;
};
-//++ ============================================================================
+//++
+//============================================================================
// Details: MI command class. MI commands derived from the command base class.
// *this class implements MI command "exec-next".
//--
-class CMICmdCmdExecNext : public CMICmdBase
-{
- // Statics:
- public:
- // Required by the CMICmdFactory when registering *this command
- static CMICmdBase *CreateSelf();
-
- // Methods:
- public:
- /* ctor */ CMICmdCmdExecNext();
-
- // Overridden:
- public:
- // From CMICmdInvoker::ICmd
- bool Execute() override;
- bool Acknowledge() override;
- bool ParseArgs() override;
- // From CMICmnBase
- /* dtor */ ~CMICmdCmdExecNext() override;
-
- // Attributes:
- private:
- lldb::SBCommandReturnObject m_lldbResult;
- const CMIUtilString m_constStrArgNumber; // Not specified in MI spec but Eclipse gives this option
+class CMICmdCmdExecNext : public CMICmdBase {
+ // Statics:
+public:
+ // Required by the CMICmdFactory when registering *this command
+ static CMICmdBase *CreateSelf();
+
+ // Methods:
+public:
+ /* ctor */ CMICmdCmdExecNext();
+
+ // Overridden:
+public:
+ // From CMICmdInvoker::ICmd
+ bool Execute() override;
+ bool Acknowledge() override;
+ bool ParseArgs() override;
+ // From CMICmnBase
+ /* dtor */ ~CMICmdCmdExecNext() override;
+
+ // Attributes:
+private:
+ lldb::SBCommandReturnObject m_lldbResult;
+ const CMIUtilString m_constStrArgNumber; // Not specified in MI spec but
+ // Eclipse gives this option
};
-//++ ============================================================================
+//++
+//============================================================================
// Details: MI command class. MI commands derived from the command base class.
// *this class implements MI command "exec-step".
//--
-class CMICmdCmdExecStep : public CMICmdBase
-{
- // Statics:
- public:
- // Required by the CMICmdFactory when registering *this command
- static CMICmdBase *CreateSelf();
-
- // Methods:
- public:
- /* ctor */ CMICmdCmdExecStep();
-
- // Overridden:
- public:
- // From CMICmdInvoker::ICmd
- bool Execute() override;
- bool Acknowledge() override;
- bool ParseArgs() override;
- // From CMICmnBase
- /* dtor */ ~CMICmdCmdExecStep() override;
-
- // Attributes:
- private:
- lldb::SBCommandReturnObject m_lldbResult;
- const CMIUtilString m_constStrArgNumber; // Not specified in MI spec but Eclipse gives this option
+class CMICmdCmdExecStep : public CMICmdBase {
+ // Statics:
+public:
+ // Required by the CMICmdFactory when registering *this command
+ static CMICmdBase *CreateSelf();
+
+ // Methods:
+public:
+ /* ctor */ CMICmdCmdExecStep();
+
+ // Overridden:
+public:
+ // From CMICmdInvoker::ICmd
+ bool Execute() override;
+ bool Acknowledge() override;
+ bool ParseArgs() override;
+ // From CMICmnBase
+ /* dtor */ ~CMICmdCmdExecStep() override;
+
+ // Attributes:
+private:
+ lldb::SBCommandReturnObject m_lldbResult;
+ const CMIUtilString m_constStrArgNumber; // Not specified in MI spec but
+ // Eclipse gives this option
};
-//++ ============================================================================
+//++
+//============================================================================
// Details: MI command class. MI commands derived from the command base class.
// *this class implements MI command "exec-next-instruction".
//--
-class CMICmdCmdExecNextInstruction : public CMICmdBase
-{
- // Statics:
- public:
- // Required by the CMICmdFactory when registering *this command
- static CMICmdBase *CreateSelf();
-
- // Methods:
- public:
- /* ctor */ CMICmdCmdExecNextInstruction();
-
- // Overridden:
- public:
- // From CMICmdInvoker::ICmd
- bool Execute() override;
- bool Acknowledge() override;
- bool ParseArgs() override;
- // From CMICmnBase
- /* dtor */ ~CMICmdCmdExecNextInstruction() override;
-
- // Attributes:
- private:
- lldb::SBCommandReturnObject m_lldbResult;
- const CMIUtilString m_constStrArgNumber; // Not specified in MI spec but Eclipse gives this option
+class CMICmdCmdExecNextInstruction : public CMICmdBase {
+ // Statics:
+public:
+ // Required by the CMICmdFactory when registering *this command
+ static CMICmdBase *CreateSelf();
+
+ // Methods:
+public:
+ /* ctor */ CMICmdCmdExecNextInstruction();
+
+ // Overridden:
+public:
+ // From CMICmdInvoker::ICmd
+ bool Execute() override;
+ bool Acknowledge() override;
+ bool ParseArgs() override;
+ // From CMICmnBase
+ /* dtor */ ~CMICmdCmdExecNextInstruction() override;
+
+ // Attributes:
+private:
+ lldb::SBCommandReturnObject m_lldbResult;
+ const CMIUtilString m_constStrArgNumber; // Not specified in MI spec but
+ // Eclipse gives this option
};
-//++ ============================================================================
+//++
+//============================================================================
// Details: MI command class. MI commands derived from the command base class.
// *this class implements MI command "exec-step-instruction".
//--
-class CMICmdCmdExecStepInstruction : public CMICmdBase
-{
- // Statics:
- public:
- // Required by the CMICmdFactory when registering *this command
- static CMICmdBase *CreateSelf();
-
- // Methods:
- public:
- /* ctor */ CMICmdCmdExecStepInstruction();
-
- // Overridden:
- public:
- // From CMICmdInvoker::ICmd
- bool Execute() override;
- bool Acknowledge() override;
- bool ParseArgs() override;
- // From CMICmnBase
- /* dtor */ ~CMICmdCmdExecStepInstruction() override;
-
- // Attributes:
- private:
- lldb::SBCommandReturnObject m_lldbResult;
- const CMIUtilString m_constStrArgNumber; // Not specified in MI spec but Eclipse gives this option
+class CMICmdCmdExecStepInstruction : public CMICmdBase {
+ // Statics:
+public:
+ // Required by the CMICmdFactory when registering *this command
+ static CMICmdBase *CreateSelf();
+
+ // Methods:
+public:
+ /* ctor */ CMICmdCmdExecStepInstruction();
+
+ // Overridden:
+public:
+ // From CMICmdInvoker::ICmd
+ bool Execute() override;
+ bool Acknowledge() override;
+ bool ParseArgs() override;
+ // From CMICmnBase
+ /* dtor */ ~CMICmdCmdExecStepInstruction() override;
+
+ // Attributes:
+private:
+ lldb::SBCommandReturnObject m_lldbResult;
+ const CMIUtilString m_constStrArgNumber; // Not specified in MI spec but
+ // Eclipse gives this option
};
-//++ ============================================================================
+//++
+//============================================================================
// Details: MI command class. MI commands derived from the command base class.
// *this class implements MI command "exec-finish".
//--
-class CMICmdCmdExecFinish : public CMICmdBase
-{
- // Statics:
- public:
- // Required by the CMICmdFactory when registering *this command
- static CMICmdBase *CreateSelf();
-
- // Methods:
- public:
- /* ctor */ CMICmdCmdExecFinish();
-
- // Overridden:
- public:
- // From CMICmdInvoker::ICmd
- bool Execute() override;
- bool Acknowledge() override;
- bool ParseArgs() override;
- // From CMICmnBase
- /* dtor */ ~CMICmdCmdExecFinish() override;
-
- // Attributes:
- private:
- lldb::SBCommandReturnObject m_lldbResult;
+class CMICmdCmdExecFinish : public CMICmdBase {
+ // Statics:
+public:
+ // Required by the CMICmdFactory when registering *this command
+ static CMICmdBase *CreateSelf();
+
+ // Methods:
+public:
+ /* ctor */ CMICmdCmdExecFinish();
+
+ // Overridden:
+public:
+ // From CMICmdInvoker::ICmd
+ bool Execute() override;
+ bool Acknowledge() override;
+ bool ParseArgs() override;
+ // From CMICmnBase
+ /* dtor */ ~CMICmdCmdExecFinish() override;
+
+ // Attributes:
+private:
+ lldb::SBCommandReturnObject m_lldbResult;
};
// CODETAG_DEBUG_SESSION_RUNNING_PROG_RECEIVED_SIGINT_PAUSE_PROGRAM
-//++ ============================================================================
+//++
+//============================================================================
// Details: MI command class. MI commands derived from the command base class.
// *this class implements MI command "exec-interrupt".
-// Gotchas: Using Eclipse this command is injected into the command system when a
+// Gotchas: Using Eclipse this command is injected into the command system when
+// a
// SIGINT signal is received while running an inferior program.
//--
-class CMICmdCmdExecInterrupt : public CMICmdBase
-{
- // Statics:
- public:
- // Required by the CMICmdFactory when registering *this command
- static CMICmdBase *CreateSelf();
-
- // Methods:
- public:
- /* ctor */ CMICmdCmdExecInterrupt();
-
- // Overridden:
- public:
- // From CMICmdInvoker::ICmd
- bool Execute() override;
- bool Acknowledge() override;
- // From CMICmnBase
- /* dtor */ ~CMICmdCmdExecInterrupt() override;
-
- // Attributes:
- private:
- lldb::SBCommandReturnObject m_lldbResult;
+class CMICmdCmdExecInterrupt : public CMICmdBase {
+ // Statics:
+public:
+ // Required by the CMICmdFactory when registering *this command
+ static CMICmdBase *CreateSelf();
+
+ // Methods:
+public:
+ /* ctor */ CMICmdCmdExecInterrupt();
+
+ // Overridden:
+public:
+ // From CMICmdInvoker::ICmd
+ bool Execute() override;
+ bool Acknowledge() override;
+ // From CMICmnBase
+ /* dtor */ ~CMICmdCmdExecInterrupt() override;
+
+ // Attributes:
+private:
+ lldb::SBCommandReturnObject m_lldbResult;
};
-//++ ============================================================================
+//++
+//============================================================================
// Details: MI command class. MI commands derived from the command base class.
// *this class implements MI command "exec-arguments".
//--
-class CMICmdCmdExecArguments : public CMICmdBase
-{
- // Statics:
- public:
- // Required by the CMICmdFactory when registering *this command
- static CMICmdBase *CreateSelf();
-
- // Methods:
- public:
- /* ctor */ CMICmdCmdExecArguments();
-
- // Overridden:
- public:
- // From CMICmdInvoker::ICmd
- bool Execute() override;
- bool Acknowledge() override;
- bool ParseArgs() override;
- // From CMICmnBase
- /* dtor */ ~CMICmdCmdExecArguments() override;
-
- // Attributes:
- private:
- const CMIUtilString m_constStrArgArguments;
+class CMICmdCmdExecArguments : public CMICmdBase {
+ // Statics:
+public:
+ // Required by the CMICmdFactory when registering *this command
+ static CMICmdBase *CreateSelf();
+
+ // Methods:
+public:
+ /* ctor */ CMICmdCmdExecArguments();
+
+ // Overridden:
+public:
+ // From CMICmdInvoker::ICmd
+ bool Execute() override;
+ bool Acknowledge() override;
+ bool ParseArgs() override;
+ // From CMICmnBase
+ /* dtor */ ~CMICmdCmdExecArguments() override;
+
+ // Attributes:
+private:
+ const CMIUtilString m_constStrArgArguments;
};
-//++ ============================================================================
+//++
+//============================================================================
// Details: MI command class. MI commands derived from the command base class.
// *this class implements MI command "exec-abort".
//--
-class CMICmdCmdExecAbort : public CMICmdBase
-{
- // Statics:
- public:
- // Required by the CMICmdFactory when registering *this command
- static CMICmdBase *CreateSelf();
-
- // Methods:
- public:
- /* ctor */ CMICmdCmdExecAbort();
-
- // Overridden:
- public:
- // From CMICmdInvoker::ICmd
- bool Execute() override;
- bool Acknowledge() override;
- // From CMICmnBase
- /* dtor */ ~CMICmdCmdExecAbort() override;
+class CMICmdCmdExecAbort : public CMICmdBase {
+ // Statics:
+public:
+ // Required by the CMICmdFactory when registering *this command
+ static CMICmdBase *CreateSelf();
+
+ // Methods:
+public:
+ /* ctor */ CMICmdCmdExecAbort();
+
+ // Overridden:
+public:
+ // From CMICmdInvoker::ICmd
+ bool Execute() override;
+ bool Acknowledge() override;
+ // From CMICmnBase
+ /* dtor */ ~CMICmdCmdExecAbort() override;
};
Modified: lldb/trunk/tools/lldb-mi/MICmdCmdFile.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/lldb-mi/MICmdCmdFile.cpp?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/tools/lldb-mi/MICmdCmdFile.cpp (original)
+++ lldb/trunk/tools/lldb-mi/MICmdCmdFile.cpp Tue Sep 6 15:57:50 2016
@@ -13,17 +13,18 @@
#include "lldb/API/SBStream.h"
// In-house headers:
-#include "MICmdCmdFile.h"
-#include "MICmnMIResultRecord.h"
-#include "MICmnLLDBDebugger.h"
-#include "MICmnLLDBDebugSessionInfo.h"
-#include "MIUtilFileStd.h"
#include "MICmdArgValFile.h"
-#include "MICmdArgValString.h"
#include "MICmdArgValOptionLong.h"
#include "MICmdArgValOptionShort.h"
+#include "MICmdArgValString.h"
+#include "MICmdCmdFile.h"
+#include "MICmnLLDBDebugSessionInfo.h"
+#include "MICmnLLDBDebugger.h"
+#include "MICmnMIResultRecord.h"
+#include "MIUtilFileStd.h"
-//++ ------------------------------------------------------------------------------------
+//++
+//------------------------------------------------------------------------------------
// Details: CMICmdCmdFileExecAndSymbols constructor.
// Type: Method.
// Args: None.
@@ -31,30 +32,29 @@
// Throws: None.
//--
CMICmdCmdFileExecAndSymbols::CMICmdCmdFileExecAndSymbols()
- : m_constStrArgNameFile("file")
- , m_constStrArgNamedPlatformName("p")
- , m_constStrArgNamedRemotePath("r")
-{
- // Command factory matches this name with that received from the stdin stream
- m_strMiCmd = "file-exec-and-symbols";
+ : m_constStrArgNameFile("file"), m_constStrArgNamedPlatformName("p"),
+ m_constStrArgNamedRemotePath("r") {
+ // Command factory matches this name with that received from the stdin stream
+ m_strMiCmd = "file-exec-and-symbols";
- // Required by the CMICmdFactory when registering *this command
- m_pSelfCreatorFn = &CMICmdCmdFileExecAndSymbols::CreateSelf;
+ // Required by the CMICmdFactory when registering *this command
+ m_pSelfCreatorFn = &CMICmdCmdFileExecAndSymbols::CreateSelf;
}
-//++ ------------------------------------------------------------------------------------
+//++
+//------------------------------------------------------------------------------------
// Details: CMICmdCmdFileExecAndSymbols destructor.
// Type: Overrideable.
// Args: None.
// Return: None.
// Throws: None.
//--
-CMICmdCmdFileExecAndSymbols::~CMICmdCmdFileExecAndSymbols()
-{
-}
+CMICmdCmdFileExecAndSymbols::~CMICmdCmdFileExecAndSymbols() {}
-//++ ------------------------------------------------------------------------------------
-// Details: The invoker requires this function. The parses the command line options
+//++
+//------------------------------------------------------------------------------------
+// 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.
@@ -62,99 +62,107 @@ CMICmdCmdFileExecAndSymbols::~CMICmdCmdF
// MIstatus::failure - Functional failed.
// Throws: None.
//--
-bool
-CMICmdCmdFileExecAndSymbols::ParseArgs()
-{
- m_setCmdArgs.Add(new CMICmdArgValFile(m_constStrArgNameFile, true, true));
- m_setCmdArgs.Add(new CMICmdArgValOptionShort(m_constStrArgNamedPlatformName, false, true,
- CMICmdArgValListBase::eArgValType_String, 1));
- m_setCmdArgs.Add(new CMICmdArgValOptionShort(m_constStrArgNamedRemotePath, false, true,
- CMICmdArgValListBase::eArgValType_StringQuotedNumberPath, 1));
- return ParseValidateCmdOptions();
-}
-
-//++ ------------------------------------------------------------------------------------
-// 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.
+bool CMICmdCmdFileExecAndSymbols::ParseArgs() {
+ m_setCmdArgs.Add(new CMICmdArgValFile(m_constStrArgNameFile, true, true));
+ m_setCmdArgs.Add(
+ new CMICmdArgValOptionShort(m_constStrArgNamedPlatformName, false, true,
+ CMICmdArgValListBase::eArgValType_String, 1));
+ m_setCmdArgs.Add(new CMICmdArgValOptionShort(
+ m_constStrArgNamedRemotePath, false, true,
+ CMICmdArgValListBase::eArgValType_StringQuotedNumberPath, 1));
+ return ParseValidateCmdOptions();
+}
+
+//++
+//------------------------------------------------------------------------------------
+// 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.
// Synopsis: -file-exec-and-symbols file
-// Ref: http://sourceware.org/gdb/onlinedocs/gdb/GDB_002fMI-File-Commands.html#GDB_002fMI-File-Commands
+// Ref:
+// http://sourceware.org/gdb/onlinedocs/gdb/GDB_002fMI-File-Commands.html#GDB_002fMI-File-Commands
// Type: Overridden.
// Args: None.
// Return: MIstatus::success - Functional succeeded.
// MIstatus::failure - Functional failed.
// Throws: None.
//--
-bool
-CMICmdCmdFileExecAndSymbols::Execute()
-{
- CMICMDBASE_GETOPTION(pArgNamedFile, File, m_constStrArgNameFile);
- CMICMDBASE_GETOPTION(pArgPlatformName, OptionShort, m_constStrArgNamedPlatformName);
- CMICMDBASE_GETOPTION(pArgRemotePath, OptionShort, m_constStrArgNamedRemotePath);
- CMICmdArgValFile *pArgFile = static_cast<CMICmdArgValFile *>(pArgNamedFile);
- const CMIUtilString &strExeFilePath(pArgFile->GetValue());
- bool bPlatformName = pArgPlatformName->GetFound();
- CMIUtilString platformName;
- if (bPlatformName)
- {
- pArgPlatformName->GetExpectedOption<CMICmdArgValString, CMIUtilString>(platformName);
- }
- CMICmnLLDBDebugSessionInfo &rSessionInfo(CMICmnLLDBDebugSessionInfo::Instance());
- lldb::SBDebugger &rDbgr = rSessionInfo.GetDebugger();
- lldb::SBError error;
- const char *pTargetTriple = nullptr; // Let LLDB discover the triple required
- const char *pTargetPlatformName = platformName.c_str();
- const bool bAddDepModules = false;
- lldb::SBTarget target = rDbgr.CreateTarget(strExeFilePath.c_str(), pTargetTriple, pTargetPlatformName, bAddDepModules, error);
- CMIUtilString strWkDir;
- const CMIUtilString &rStrKeyWkDir(rSessionInfo.m_constStrSharedDataKeyWkDir);
- if (!rSessionInfo.SharedDataRetrieve<CMIUtilString>(rStrKeyWkDir, strWkDir))
- {
- strWkDir = CMIUtilFileStd::StripOffFileName(strExeFilePath);
- if (!rSessionInfo.SharedDataAdd<CMIUtilString>(rStrKeyWkDir, strWkDir))
- {
- SetError(CMIUtilString::Format(MIRSRC(IDS_DBGSESSION_ERR_SHARED_DATA_ADD), m_cmdData.strMiCmd.c_str(), rStrKeyWkDir.c_str()));
- return MIstatus::failure;
- }
- }
- if (!rDbgr.SetCurrentPlatformSDKRoot(strWkDir.c_str()))
- {
-
- SetError(CMIUtilString::Format(MIRSRC(IDS_CMD_ERR_FNFAILED), m_cmdData.strMiCmd.c_str(), "SetCurrentPlatformSDKRoot()"));
- return MIstatus::failure;
- }
- if (pArgRemotePath->GetFound())
- {
- CMIUtilString remotePath;
- pArgRemotePath->GetExpectedOption<CMICmdArgValString, CMIUtilString>(remotePath);
- lldb::SBModule module = target.FindModule(target.GetExecutable());
- if (module.IsValid())
- {
- module.SetPlatformFileSpec(lldb::SBFileSpec(remotePath.c_str()));
- }
- }
- lldb::SBStream err;
- if (error.Fail())
- {
- const bool bOk = error.GetDescription(err);
- MIunused(bOk);
- }
- if (!target.IsValid())
- {
- SetError(
- CMIUtilString::Format(MIRSRC(IDS_CMD_ERR_INVALID_TARGET), m_cmdData.strMiCmd.c_str(), strExeFilePath.c_str(), err.GetData()));
- return MIstatus::failure;
- }
- if (error.Fail())
- {
- SetError(CMIUtilString::Format(MIRSRC(IDS_CMD_ERR_CREATE_TARGET), m_cmdData.strMiCmd.c_str(), err.GetData()));
- return MIstatus::failure;
- }
-
- return MIstatus::success;
-}
-
-//++ ------------------------------------------------------------------------------------
-// Details: The invoker requires this function. The command prepares a MI Record Result
+bool CMICmdCmdFileExecAndSymbols::Execute() {
+ CMICMDBASE_GETOPTION(pArgNamedFile, File, m_constStrArgNameFile);
+ CMICMDBASE_GETOPTION(pArgPlatformName, OptionShort,
+ m_constStrArgNamedPlatformName);
+ CMICMDBASE_GETOPTION(pArgRemotePath, OptionShort,
+ m_constStrArgNamedRemotePath);
+ CMICmdArgValFile *pArgFile = static_cast<CMICmdArgValFile *>(pArgNamedFile);
+ const CMIUtilString &strExeFilePath(pArgFile->GetValue());
+ bool bPlatformName = pArgPlatformName->GetFound();
+ CMIUtilString platformName;
+ if (bPlatformName) {
+ pArgPlatformName->GetExpectedOption<CMICmdArgValString, CMIUtilString>(
+ platformName);
+ }
+ CMICmnLLDBDebugSessionInfo &rSessionInfo(
+ CMICmnLLDBDebugSessionInfo::Instance());
+ lldb::SBDebugger &rDbgr = rSessionInfo.GetDebugger();
+ lldb::SBError error;
+ const char *pTargetTriple = nullptr; // Let LLDB discover the triple required
+ const char *pTargetPlatformName = platformName.c_str();
+ const bool bAddDepModules = false;
+ lldb::SBTarget target =
+ rDbgr.CreateTarget(strExeFilePath.c_str(), pTargetTriple,
+ pTargetPlatformName, bAddDepModules, error);
+ CMIUtilString strWkDir;
+ const CMIUtilString &rStrKeyWkDir(rSessionInfo.m_constStrSharedDataKeyWkDir);
+ if (!rSessionInfo.SharedDataRetrieve<CMIUtilString>(rStrKeyWkDir, strWkDir)) {
+ strWkDir = CMIUtilFileStd::StripOffFileName(strExeFilePath);
+ if (!rSessionInfo.SharedDataAdd<CMIUtilString>(rStrKeyWkDir, strWkDir)) {
+ SetError(CMIUtilString::Format(MIRSRC(IDS_DBGSESSION_ERR_SHARED_DATA_ADD),
+ m_cmdData.strMiCmd.c_str(),
+ rStrKeyWkDir.c_str()));
+ return MIstatus::failure;
+ }
+ }
+ if (!rDbgr.SetCurrentPlatformSDKRoot(strWkDir.c_str())) {
+
+ SetError(CMIUtilString::Format(MIRSRC(IDS_CMD_ERR_FNFAILED),
+ m_cmdData.strMiCmd.c_str(),
+ "SetCurrentPlatformSDKRoot()"));
+ return MIstatus::failure;
+ }
+ if (pArgRemotePath->GetFound()) {
+ CMIUtilString remotePath;
+ pArgRemotePath->GetExpectedOption<CMICmdArgValString, CMIUtilString>(
+ remotePath);
+ lldb::SBModule module = target.FindModule(target.GetExecutable());
+ if (module.IsValid()) {
+ module.SetPlatformFileSpec(lldb::SBFileSpec(remotePath.c_str()));
+ }
+ }
+ lldb::SBStream err;
+ if (error.Fail()) {
+ const bool bOk = error.GetDescription(err);
+ MIunused(bOk);
+ }
+ if (!target.IsValid()) {
+ SetError(CMIUtilString::Format(MIRSRC(IDS_CMD_ERR_INVALID_TARGET),
+ m_cmdData.strMiCmd.c_str(),
+ strExeFilePath.c_str(), err.GetData()));
+ return MIstatus::failure;
+ }
+ if (error.Fail()) {
+ SetError(CMIUtilString::Format(MIRSRC(IDS_CMD_ERR_CREATE_TARGET),
+ m_cmdData.strMiCmd.c_str(), err.GetData()));
+ 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.
@@ -162,42 +170,45 @@ CMICmdCmdFileExecAndSymbols::Execute()
// MIstatus::failure - Functional failed.
// Throws: None.
//--
-bool
-CMICmdCmdFileExecAndSymbols::Acknowledge()
-{
- const CMICmnMIResultRecord miRecordResult(m_cmdData.strMiCmdToken, CMICmnMIResultRecord::eResultClass_Done);
- m_miResultRecord = miRecordResult;
-
- return MIstatus::success;
+bool CMICmdCmdFileExecAndSymbols::Acknowledge() {
+ const CMICmnMIResultRecord miRecordResult(
+ m_cmdData.strMiCmdToken, CMICmnMIResultRecord::eResultClass_Done);
+ m_miResultRecord = miRecordResult;
+
+ return MIstatus::success;
}
-//++ ------------------------------------------------------------------------------------
-// Details: Required by the CMICmdFactory when registering *this command. The factory
+//++
+//------------------------------------------------------------------------------------
+// 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 *
-CMICmdCmdFileExecAndSymbols::CreateSelf()
-{
- return new CMICmdCmdFileExecAndSymbols();
+CMICmdBase *CMICmdCmdFileExecAndSymbols::CreateSelf() {
+ return new CMICmdCmdFileExecAndSymbols();
}
-//++ ------------------------------------------------------------------------------------
-// Details: If the MI Driver is not operating via a client i.e. Eclipse but say operating
-// on a executable passed in as a argument to the drive then what should the driver
-// do on a command failing? Either continue operating or exit the application.
-// Override this function where a command failure cannot allow the driver to
+//++
+//------------------------------------------------------------------------------------
+// Details: If the MI Driver is not operating via a client i.e. Eclipse but say
+// operating
+// on a executable passed in as a argument to the drive then what
+// should the driver
+// do on a command failing? Either continue operating or exit the
+// application.
+// Override this function where a command failure cannot allow the
+// driver to
// continue operating.
// Type: Overridden.
// Args: None.
-// Return: bool - True = Fatal if command fails, false = can continue if command fails.
+// Return: bool - True = Fatal if command fails, false = can continue if
+// command fails.
// Throws: None.
//--
-bool
-CMICmdCmdFileExecAndSymbols::GetExitAppOnCommandFailure() const
-{
- return true;
+bool CMICmdCmdFileExecAndSymbols::GetExitAppOnCommandFailure() const {
+ return true;
}
Modified: lldb/trunk/tools/lldb-mi/MICmdCmdFile.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/lldb-mi/MICmdCmdFile.h?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/tools/lldb-mi/MICmdCmdFile.h (original)
+++ lldb/trunk/tools/lldb-mi/MICmdCmdFile.h Tue Sep 6 15:57:50 2016
@@ -9,53 +9,59 @@
// Overview: CMICmdCmdFileExecAndSymbols 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 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
+// For an introduction to adding a new command see
+// CMICmdCmdSupportInfoMiCmdQuery
// command class as an example.
#pragma once
// In-house headers:
#include "MICmdBase.h"
-#include "MICmnMIValueTuple.h"
#include "MICmnMIValueList.h"
+#include "MICmnMIValueTuple.h"
-//++ ============================================================================
+//++
+//============================================================================
// Details: MI command class. MI commands derived from the command base class.
// *this class implements MI command "file-exec-and-symbols".
// This command does not follow the MI documentation exactly.
// Gotchas: This command has additional flags that were not available in GDB MI.
// See MIextensions.txt for details.
//--
-class CMICmdCmdFileExecAndSymbols : public CMICmdBase
-{
- // Statics:
- public:
- // Required by the CMICmdFactory when registering *this command
- static CMICmdBase *CreateSelf();
-
- // Methods:
- public:
- /* ctor */ CMICmdCmdFileExecAndSymbols();
-
- // Overridden:
- public:
- // From CMICmdInvoker::ICmd
- bool Execute() override;
- bool Acknowledge() override;
- bool ParseArgs() override;
- // From CMICmnBase
- /* dtor */ ~CMICmdCmdFileExecAndSymbols() override;
- bool GetExitAppOnCommandFailure() const override;
-
- // Attributes:
- private:
- const CMIUtilString m_constStrArgNameFile;
- const CMIUtilString m_constStrArgNamedPlatformName; // Added to support iOS platform selection
- const CMIUtilString m_constStrArgNamedRemotePath; // Added to support iOS device remote file location
+class CMICmdCmdFileExecAndSymbols : public CMICmdBase {
+ // Statics:
+public:
+ // Required by the CMICmdFactory when registering *this command
+ static CMICmdBase *CreateSelf();
+
+ // Methods:
+public:
+ /* ctor */ CMICmdCmdFileExecAndSymbols();
+
+ // Overridden:
+public:
+ // From CMICmdInvoker::ICmd
+ bool Execute() override;
+ bool Acknowledge() override;
+ bool ParseArgs() override;
+ // From CMICmnBase
+ /* dtor */ ~CMICmdCmdFileExecAndSymbols() override;
+ bool GetExitAppOnCommandFailure() const override;
+
+ // Attributes:
+private:
+ const CMIUtilString m_constStrArgNameFile;
+ const CMIUtilString
+ m_constStrArgNamedPlatformName; // Added to support iOS platform selection
+ const CMIUtilString m_constStrArgNamedRemotePath; // Added to support iOS
+ // device remote file
+ // location
};
Modified: lldb/trunk/tools/lldb-mi/MICmdCmdGdbInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/lldb-mi/MICmdCmdGdbInfo.cpp?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/tools/lldb-mi/MICmdCmdGdbInfo.cpp (original)
+++ lldb/trunk/tools/lldb-mi/MICmdCmdGdbInfo.cpp Tue Sep 6 15:57:50 2016
@@ -10,22 +10,24 @@
// Overview: CMICmdCmdGdbInfo implementation.
// Third party headers:
-#include <inttypes.h> // For PRIx64
#include "lldb/API/SBCommandReturnObject.h"
+#include <inttypes.h> // For PRIx64
// In-house headers:
+#include "MICmdArgValString.h"
#include "MICmdCmdGdbInfo.h"
+#include "MICmnLLDBDebugSessionInfo.h"
#include "MICmnMIResultRecord.h"
#include "MICmnMIValueConst.h"
-#include "MICmdArgValString.h"
#include "MICmnStreamStdout.h"
-#include "MICmnLLDBDebugSessionInfo.h"
// Instantiations:
-const CMICmdCmdGdbInfo::MapPrintFnNameToPrintFn_t CMICmdCmdGdbInfo::ms_mapPrintFnNameToPrintFn = {
- {"sharedlibrary", &CMICmdCmdGdbInfo::PrintFnSharedLibrary}};
+const CMICmdCmdGdbInfo::MapPrintFnNameToPrintFn_t
+ CMICmdCmdGdbInfo::ms_mapPrintFnNameToPrintFn = {
+ {"sharedlibrary", &CMICmdCmdGdbInfo::PrintFnSharedLibrary}};
-//++ ------------------------------------------------------------------------------------
+//++
+//------------------------------------------------------------------------------------
// Details: CMICmdCmdGdbInfo constructor.
// Type: Method.
// Args: None.
@@ -33,31 +35,30 @@ const CMICmdCmdGdbInfo::MapPrintFnNameTo
// Throws: None.
//--
CMICmdCmdGdbInfo::CMICmdCmdGdbInfo()
- : 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";
+ : 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;
+ // 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()
-{
-}
+CMICmdCmdGdbInfo::~CMICmdCmdGdbInfo() {}
-//++ ------------------------------------------------------------------------------------
-// Details: The invoker requires this function. The parses the command line options
+//++
+//------------------------------------------------------------------------------------
+// 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.
@@ -65,43 +66,43 @@ CMICmdCmdGdbInfo::~CMICmdCmdGdbInfo()
// MIstatus::failure - Functional failed.
// Throws: None.
//--
-bool
-CMICmdCmdGdbInfo::ParseArgs()
-{
- m_setCmdArgs.Add(new CMICmdArgValString(m_constStrArgNamedPrint, true, true));
- return ParseValidateCmdOptions();
+bool CMICmdCmdGdbInfo::ParseArgs() {
+ m_setCmdArgs.Add(new CMICmdArgValString(m_constStrArgNamedPrint, true, true));
+ return ParseValidateCmdOptions();
}
-//++ ------------------------------------------------------------------------------------
-// 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.
+//++
+//------------------------------------------------------------------------------------
+// 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()
-{
- 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;
- }
+bool CMICmdCmdGdbInfo::Execute() {
+ 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))();
+ m_bPrintFnSuccessful = (this->*(pPrintRequestFn))();
- return MIstatus::success;
+ return MIstatus::success;
}
-//++ ------------------------------------------------------------------------------------
-// Details: The invoker requires this function. The command prepares a MI Record Result
+//++
+//------------------------------------------------------------------------------------
+// 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.
@@ -109,72 +110,77 @@ CMICmdCmdGdbInfo::Execute()
// MIstatus::failure - Functional failed.
// Throws: None.
//--
-bool
-CMICmdCmdGdbInfo::Acknowledge()
-{
- 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()));
+bool CMICmdCmdGdbInfo::Acknowledge() {
+ 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);
+ 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;
-}
+ }
-//++ ------------------------------------------------------------------------------------
-// Details: Required by the CMICmdFactory when registering *this command. The factory
+ 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()
-{
- return new CMICmdCmdGdbInfo();
-}
+CMICmdBase *CMICmdCmdGdbInfo::CreateSelf() { return new CMICmdCmdGdbInfo(); }
-//++ ------------------------------------------------------------------------------------
-// Details: Retrieve the print function's pointer for the matching print request.
+//++
+//------------------------------------------------------------------------------------
+// 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
+// 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
+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.
@@ -182,48 +188,48 @@ CMICmdCmdGdbInfo::GetPrintFn(const CMIUt
// MIstatus::failure - Functional failed.
// Throws: None.
//--
-bool
-CMICmdCmdGdbInfo::PrintFnSharedLibrary()
-{
- CMICmnStreamStdout &rStdout = CMICmnStreamStdout::Instance();
- bool bOk = rStdout.TextToStdout("~\"From To Syms Read Shared Object Library\"");
-
- CMICmnLLDBDebugSessionInfo &rSessionInfo(CMICmnLLDBDebugSessionInfo::Instance());
- lldb::SBTarget sbTarget = rSessionInfo.GetTarget();
- const MIuint nModules = sbTarget.GetNumModules();
- for (MIuint i = 0; bOk && (i < nModules); i++)
- {
- lldb::SBModule module = sbTarget.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 = 0xffffffffffffffff;
- 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(sbTarget);
- if (addrLoad != (lldb::addr_t) - 1)
- {
- if (!bHaveAddrLoad)
- {
- bHaveAddrLoad = true;
- addrLoadS = addrLoad;
- }
-
- addrLoadSize += section.GetByteSize();
- }
- }
- bOk = bOk &&
- rStdout.TextToStdout(CMIUtilString::Format("~\"0x%016" PRIx64 "\t0x%016" PRIx64 "\t%s\t\t%s\"", addrLoadS, addrLoadS + addrLoadSize,
- strHasSymbols.c_str(), strModuleFullPath.c_str()));
+bool CMICmdCmdGdbInfo::PrintFnSharedLibrary() {
+ CMICmnStreamStdout &rStdout = CMICmnStreamStdout::Instance();
+ bool bOk = rStdout.TextToStdout(
+ "~\"From To Syms Read Shared Object Library\"");
+
+ CMICmnLLDBDebugSessionInfo &rSessionInfo(
+ CMICmnLLDBDebugSessionInfo::Instance());
+ lldb::SBTarget sbTarget = rSessionInfo.GetTarget();
+ const MIuint nModules = sbTarget.GetNumModules();
+ for (MIuint i = 0; bOk && (i < nModules); i++) {
+ lldb::SBModule module = sbTarget.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 = 0xffffffffffffffff;
+ 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(sbTarget);
+ if (addrLoad != (lldb::addr_t)-1) {
+ if (!bHaveAddrLoad) {
+ bHaveAddrLoad = true;
+ addrLoadS = addrLoad;
+ }
+
+ addrLoadSize += section.GetByteSize();
}
+ }
+ bOk = bOk &&
+ rStdout.TextToStdout(CMIUtilString::Format(
+ "~\"0x%016" PRIx64 "\t0x%016" PRIx64 "\t%s\t\t%s\"", addrLoadS,
+ addrLoadS + addrLoadSize, strHasSymbols.c_str(),
+ strModuleFullPath.c_str()));
}
+ }
- return bOk;
+ return bOk;
}
Modified: lldb/trunk/tools/lldb-mi/MICmdCmdGdbInfo.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/lldb-mi/MICmdCmdGdbInfo.h?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/tools/lldb-mi/MICmdCmdGdbInfo.h (original)
+++ lldb/trunk/tools/lldb-mi/MICmdCmdGdbInfo.h Tue Sep 6 15:57:50 2016
@@ -9,13 +9,16 @@
// 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 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
+// For an introduction to adding a new command see
+// CMICmdCmdSupportInfoMiCmdQuery
// command class as an example.
#pragma once
@@ -26,55 +29,60 @@
// 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
+// *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
+// 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.
//--
-class CMICmdCmdGdbInfo : public CMICmdBase
-{
- // Statics:
- public:
- // Required by the CMICmdFactory when registering *this command
- static CMICmdBase *CreateSelf();
-
- // Methods:
- public:
- /* ctor */ CMICmdCmdGdbInfo();
-
- // Overridden:
- public:
- // From CMICmdInvoker::ICmd
- bool Execute() override;
- bool Acknowledge() override;
- bool ParseArgs() override;
- // From CMICmnBase
- /* dtor */ ~CMICmdCmdGdbInfo() override;
-
- // 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();
-
- // 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;
+class CMICmdCmdGdbInfo : public CMICmdBase {
+ // Statics:
+public:
+ // Required by the CMICmdFactory when registering *this command
+ static CMICmdBase *CreateSelf();
+
+ // Methods:
+public:
+ /* ctor */ CMICmdCmdGdbInfo();
+
+ // Overridden:
+public:
+ // From CMICmdInvoker::ICmd
+ bool Execute() override;
+ bool Acknowledge() override;
+ bool ParseArgs() override;
+ // From CMICmnBase
+ /* dtor */ ~CMICmdCmdGdbInfo() override;
+
+ // 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();
+
+ // 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;
};
Modified: lldb/trunk/tools/lldb-mi/MICmdCmdGdbSet.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/lldb-mi/MICmdCmdGdbSet.cpp?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/tools/lldb-mi/MICmdCmdGdbSet.cpp (original)
+++ lldb/trunk/tools/lldb-mi/MICmdCmdGdbSet.cpp Tue Sep 6 15:57:50 2016
@@ -11,23 +11,26 @@
// In-house headers:
#include "MICmdCmdGdbSet.h"
-#include "MICmnMIResultRecord.h"
-#include "MICmnMIValueConst.h"
-#include "MICmdArgValString.h"
#include "MICmdArgValListOfN.h"
#include "MICmdArgValOptionLong.h"
+#include "MICmdArgValString.h"
#include "MICmnLLDBDebugSessionInfo.h"
+#include "MICmnMIResultRecord.h"
+#include "MICmnMIValueConst.h"
// Instantiations:
-const CMICmdCmdGdbSet::MapGdbOptionNameToFnGdbOptionPtr_t CMICmdCmdGdbSet::ms_mapGdbOptionNameToFnGdbOptionPtr = {
- {"target-async", &CMICmdCmdGdbSet::OptionFnTargetAsync},
- {"print", &CMICmdCmdGdbSet::OptionFnPrint},
- // { "auto-solib-add", &CMICmdCmdGdbSet::OptionFnAutoSolibAdd }, // Example code if need to implement GDB set other options
- {"output-radix", &CMICmdCmdGdbSet::OptionFnOutputRadix},
- {"solib-search-path", &CMICmdCmdGdbSet::OptionFnSolibSearchPath},
- {"fallback", &CMICmdCmdGdbSet::OptionFnFallback}};
+const CMICmdCmdGdbSet::MapGdbOptionNameToFnGdbOptionPtr_t
+ CMICmdCmdGdbSet::ms_mapGdbOptionNameToFnGdbOptionPtr = {
+ {"target-async", &CMICmdCmdGdbSet::OptionFnTargetAsync},
+ {"print", &CMICmdCmdGdbSet::OptionFnPrint},
+ // { "auto-solib-add", &CMICmdCmdGdbSet::OptionFnAutoSolibAdd }, //
+ // Example code if need to implement GDB set other options
+ {"output-radix", &CMICmdCmdGdbSet::OptionFnOutputRadix},
+ {"solib-search-path", &CMICmdCmdGdbSet::OptionFnSolibSearchPath},
+ {"fallback", &CMICmdCmdGdbSet::OptionFnFallback}};
-//++ ------------------------------------------------------------------------------------
+//++
+//------------------------------------------------------------------------------------
// Details: CMICmdCmdGdbSet constructor.
// Type: Method.
// Args: None.
@@ -35,32 +38,30 @@ const CMICmdCmdGdbSet::MapGdbOptionNameT
// Throws: None.
//--
CMICmdCmdGdbSet::CMICmdCmdGdbSet()
- : 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";
+ : 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;
+ // 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()
-{
-}
+CMICmdCmdGdbSet::~CMICmdCmdGdbSet() {}
-//++ ------------------------------------------------------------------------------------
-// Details: The invoker requires this function. The parses the command line options
+//++
+//------------------------------------------------------------------------------------
+// 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.
@@ -68,69 +69,71 @@ CMICmdCmdGdbSet::~CMICmdCmdGdbSet()
// MIstatus::failure - Functional failed.
// Throws: None.
//--
-bool
-CMICmdCmdGdbSet::ParseArgs()
-{
- m_setCmdArgs.Add(
- new CMICmdArgValListOfN(m_constStrArgNamedGdbOption, true, true, CMICmdArgValListBase::eArgValType_StringAnything));
- return ParseValidateCmdOptions();
+bool CMICmdCmdGdbSet::ParseArgs() {
+ m_setCmdArgs.Add(new CMICmdArgValListOfN(
+ m_constStrArgNamedGdbOption, true, true,
+ CMICmdArgValListBase::eArgValType_StringAnything));
+ return ParseValidateCmdOptions();
}
-//++ ------------------------------------------------------------------------------------
-// Details: The invoker requires this function. The command is executed in this function.
-// The command is likely to communicate with the LLDB SBDebugger in here.
+//++
+//------------------------------------------------------------------------------------
+// Details: The invoker requires this function. The command is executed 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()
-{
- CMICMDBASE_GETOPTION(pArgGdbOption, ListOfN, m_constStrArgNamedGdbOption);
- const CMICmdArgValListBase::VecArgObjPtr_t &rVecWords(pArgGdbOption->GetExpectedOptions());
-
- // Get the gdb-set option to carry out. This option will be used as an action
- // which should be done. Further arguments will be used as parameters for it.
- CMICmdArgValListBase::VecArgObjPtr_t::const_iterator it = rVecWords.begin();
- const CMICmdArgValString *pOption = static_cast<const CMICmdArgValString *>(*it);
- const CMIUtilString strOption(pOption->GetValue());
- ++it;
+bool CMICmdCmdGdbSet::Execute() {
+ CMICMDBASE_GETOPTION(pArgGdbOption, ListOfN, m_constStrArgNamedGdbOption);
+ const CMICmdArgValListBase::VecArgObjPtr_t &rVecWords(
+ pArgGdbOption->GetExpectedOptions());
+
+ // Get the gdb-set option to carry out. This option will be used as an action
+ // which should be done. Further arguments will be used as parameters for it.
+ 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());
- // 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;
-}
+ // Next
+ ++it;
+ }
-//++ ------------------------------------------------------------------------------------
-// Details: The invoker requires this function. The command prepares a MI Record Result
+ 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() method.
// Type: Overridden.
// Args: None.
@@ -138,78 +141,83 @@ CMICmdCmdGdbSet::Execute()
// MIstatus::failure - Functional failed.
// Throws: None.
//--
-bool
-CMICmdCmdGdbSet::Acknowledge()
-{
- // Print error if option isn't recognized:
- // ^error,msg="The request '%s' was not recognized, not implemented"
- 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;
- }
-
- // ^done,value="%s"
- if (m_bGdbOptionFnSuccessful)
- {
- const CMICmnMIResultRecord miRecordResult(m_cmdData.strMiCmdToken, CMICmnMIResultRecord::eResultClass_Done);
- m_miResultRecord = miRecordResult;
- return MIstatus::success;
- }
-
- // Print error if request failed:
- // ^error,msg="The request '%s' failed.
- const CMICmnMIValueConst miValueConst(CMIUtilString::Format(MIRSRC(IDS_CMD_ERR_INFO_PRINTFN_FAILED), m_strGdbOptionFnError.c_str()));
+bool CMICmdCmdGdbSet::Acknowledge() {
+ // Print error if option isn't recognized:
+ // ^error,msg="The request '%s' was not recognized, not implemented"
+ 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);
+ const CMICmnMIResultRecord miRecordResult(
+ m_cmdData.strMiCmdToken, CMICmnMIResultRecord::eResultClass_Error,
+ miValueResult);
m_miResultRecord = miRecordResult;
+ return MIstatus::success;
+ }
+ // ^done,value="%s"
+ if (m_bGdbOptionFnSuccessful) {
+ const CMICmnMIResultRecord miRecordResult(
+ m_cmdData.strMiCmdToken, CMICmnMIResultRecord::eResultClass_Done);
+ m_miResultRecord = miRecordResult;
return MIstatus::success;
-}
+ }
-//++ ------------------------------------------------------------------------------------
-// Details: Required by the CMICmdFactory when registering *this command. The factory
+ // Print error if request failed:
+ // ^error,msg="The request '%s' failed.
+ 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()
-{
- return new CMICmdCmdGdbSet();
-}
+CMICmdBase *CMICmdCmdGdbSet::CreateSelf() { return new CMICmdCmdGdbSet(); }
-//++ ------------------------------------------------------------------------------------
-// Details: Retrieve the print function's pointer for the matching print request.
+//++
+//------------------------------------------------------------------------------------
+// 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
+// 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 'target-async' to prepare
+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 'target-async' to
+// prepare
// and send back information asked for.
// Type: Method.
// Args: vrWords - (R) List of additional parameters used by this option.
@@ -217,43 +225,44 @@ CMICmdCmdGdbSet::GetOptionFn(const CMIUt
// MIstatus::failure - Function failed.
// Throws: None.
//--
-bool
-CMICmdCmdGdbSet::OptionFnTargetAsync(const CMIUtilString::VecString_t &vrWords)
-{
- bool bAsyncMode = false;
- bool bOk = true;
-
- if (vrWords.size() > 1)
- // Too many arguments.
- bOk = false;
- else if (vrWords.size() == 0)
- // If no arguments, default is "on".
- bAsyncMode = true;
- else if (CMIUtilString::Compare(vrWords[0], "on"))
- bAsyncMode = true;
- else if (CMIUtilString::Compare(vrWords[0], "off"))
- bAsyncMode = false;
- else
- // Unrecognized argument.
- bOk = false;
-
- if (!bOk)
- {
- // Report error.
- m_bGbbOptionFnHasError = true;
- m_strGdbOptionFnError = MIRSRC(IDS_CMD_ERR_GDBSET_OPT_TARGETASYNC);
- return MIstatus::failure;
- }
-
- // Turn async mode on/off.
- CMICmnLLDBDebugSessionInfo &rSessionInfo(CMICmnLLDBDebugSessionInfo::Instance());
- rSessionInfo.GetDebugger().SetAsync(bAsyncMode);
-
- return MIstatus::success;
-}
-
-//++ ------------------------------------------------------------------------------------
-// Details: Carry out work to complete the GDB set option 'print-char-array-as-string' to
+bool CMICmdCmdGdbSet::OptionFnTargetAsync(
+ const CMIUtilString::VecString_t &vrWords) {
+ bool bAsyncMode = false;
+ bool bOk = true;
+
+ if (vrWords.size() > 1)
+ // Too many arguments.
+ bOk = false;
+ else if (vrWords.size() == 0)
+ // If no arguments, default is "on".
+ bAsyncMode = true;
+ else if (CMIUtilString::Compare(vrWords[0], "on"))
+ bAsyncMode = true;
+ else if (CMIUtilString::Compare(vrWords[0], "off"))
+ bAsyncMode = false;
+ else
+ // Unrecognized argument.
+ bOk = false;
+
+ if (!bOk) {
+ // Report error.
+ m_bGbbOptionFnHasError = true;
+ m_strGdbOptionFnError = MIRSRC(IDS_CMD_ERR_GDBSET_OPT_TARGETASYNC);
+ return MIstatus::failure;
+ }
+
+ // Turn async mode on/off.
+ CMICmnLLDBDebugSessionInfo &rSessionInfo(
+ CMICmnLLDBDebugSessionInfo::Instance());
+ rSessionInfo.GetDebugger().SetAsync(bAsyncMode);
+
+ return MIstatus::success;
+}
+
+//++
+//------------------------------------------------------------------------------------
+// Details: Carry out work to complete the GDB set option
+// 'print-char-array-as-string' to
// prepare and send back information asked for.
// Type: Method.
// Args: vrWords - (R) List of additional parameters used by this option.
@@ -261,47 +270,50 @@ CMICmdCmdGdbSet::OptionFnTargetAsync(con
// MIstatus::failure - Function failed.
// Throws: None.
//--
-bool
-CMICmdCmdGdbSet::OptionFnPrint(const CMIUtilString::VecString_t &vrWords)
-{
- const bool bAllArgs(vrWords.size() == 2);
- const bool bArgOn(bAllArgs && (CMIUtilString::Compare(vrWords[1], "on") || CMIUtilString::Compare(vrWords[1], "1")));
- const bool bArgOff(bAllArgs && (CMIUtilString::Compare(vrWords[1], "off") || CMIUtilString::Compare(vrWords[1], "0")));
- if (!bAllArgs || (!bArgOn && !bArgOff))
- {
- m_bGbbOptionFnHasError = true;
- m_strGdbOptionFnError = MIRSRC(IDS_CMD_ERR_GDBSET_OPT_PRINT_BAD_ARGS);
- return MIstatus::failure;
- }
-
- const CMIUtilString strOption(vrWords[0]);
- CMIUtilString strOptionKey;
- if (CMIUtilString::Compare(strOption, "char-array-as-string"))
- strOptionKey = m_rLLDBDebugSessionInfo.m_constStrPrintCharArrayAsString;
- else if (CMIUtilString::Compare(strOption, "expand-aggregates"))
- strOptionKey = m_rLLDBDebugSessionInfo.m_constStrPrintExpandAggregates;
- else if (CMIUtilString::Compare(strOption, "aggregate-field-names"))
- strOptionKey = m_rLLDBDebugSessionInfo.m_constStrPrintAggregateFieldNames;
- else
- {
- m_bGbbOptionFnHasError = true;
- m_strGdbOptionFnError = CMIUtilString::Format(MIRSRC(IDS_CMD_ERR_GDBSET_OPT_PRINT_UNKNOWN_OPTION), strOption.c_str());
- return MIstatus::failure;
- }
-
- const bool bOptionValue(bArgOn);
- if (!m_rLLDBDebugSessionInfo.SharedDataAdd<bool>(strOptionKey, bOptionValue))
- {
- m_bGbbOptionFnHasError = false;
- SetError(CMIUtilString::Format(MIRSRC(IDS_DBGSESSION_ERR_SHARED_DATA_ADD), m_cmdData.strMiCmd.c_str(), strOptionKey.c_str()));
- return MIstatus::failure;
- }
-
- return MIstatus::success;
-}
-
-//++ ------------------------------------------------------------------------------------
-// Details: Carry out work to complete the GDB set option 'solib-search-path' to prepare
+bool CMICmdCmdGdbSet::OptionFnPrint(const CMIUtilString::VecString_t &vrWords) {
+ const bool bAllArgs(vrWords.size() == 2);
+ const bool bArgOn(bAllArgs && (CMIUtilString::Compare(vrWords[1], "on") ||
+ CMIUtilString::Compare(vrWords[1], "1")));
+ const bool bArgOff(bAllArgs && (CMIUtilString::Compare(vrWords[1], "off") ||
+ CMIUtilString::Compare(vrWords[1], "0")));
+ if (!bAllArgs || (!bArgOn && !bArgOff)) {
+ m_bGbbOptionFnHasError = true;
+ m_strGdbOptionFnError = MIRSRC(IDS_CMD_ERR_GDBSET_OPT_PRINT_BAD_ARGS);
+ return MIstatus::failure;
+ }
+
+ const CMIUtilString strOption(vrWords[0]);
+ CMIUtilString strOptionKey;
+ if (CMIUtilString::Compare(strOption, "char-array-as-string"))
+ strOptionKey = m_rLLDBDebugSessionInfo.m_constStrPrintCharArrayAsString;
+ else if (CMIUtilString::Compare(strOption, "expand-aggregates"))
+ strOptionKey = m_rLLDBDebugSessionInfo.m_constStrPrintExpandAggregates;
+ else if (CMIUtilString::Compare(strOption, "aggregate-field-names"))
+ strOptionKey = m_rLLDBDebugSessionInfo.m_constStrPrintAggregateFieldNames;
+ else {
+ m_bGbbOptionFnHasError = true;
+ m_strGdbOptionFnError = CMIUtilString::Format(
+ MIRSRC(IDS_CMD_ERR_GDBSET_OPT_PRINT_UNKNOWN_OPTION), strOption.c_str());
+ return MIstatus::failure;
+ }
+
+ const bool bOptionValue(bArgOn);
+ if (!m_rLLDBDebugSessionInfo.SharedDataAdd<bool>(strOptionKey,
+ bOptionValue)) {
+ m_bGbbOptionFnHasError = false;
+ SetError(CMIUtilString::Format(MIRSRC(IDS_DBGSESSION_ERR_SHARED_DATA_ADD),
+ m_cmdData.strMiCmd.c_str(),
+ strOptionKey.c_str()));
+ return MIstatus::failure;
+ }
+
+ return MIstatus::success;
+}
+
+//++
+//------------------------------------------------------------------------------------
+// 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.
@@ -309,32 +321,35 @@ CMICmdCmdGdbSet::OptionFnPrint(const CMI
// 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 'output-radix' to prepare
+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 'output-radix' to
+// prepare
// and send back information asked for.
// Type: Method.
// Args: vrWords - (R) List of additional parameters used by this option.
@@ -342,51 +357,50 @@ CMICmdCmdGdbSet::OptionFnSolibSearchPath
// MIstatus::failure - Functional failed.
// Throws: None.
//--
-bool
-CMICmdCmdGdbSet::OptionFnOutputRadix(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 &rStrValOutputRadix(vrWords[0]);
-
- CMICmnLLDBDebugSessionInfoVarObj::varFormat_e format = CMICmnLLDBDebugSessionInfoVarObj::eVarFormat_Invalid;
- MIint64 radix;
- if (rStrValOutputRadix.ExtractNumber(radix))
- {
- switch (radix)
- {
- case 8:
- format = CMICmnLLDBDebugSessionInfoVarObj::eVarFormat_Octal;
- break;
- case 10:
- format = CMICmnLLDBDebugSessionInfoVarObj::eVarFormat_Natural;
- break;
- case 16:
- format = CMICmnLLDBDebugSessionInfoVarObj::eVarFormat_Hex;
- break;
- default:
- format = CMICmnLLDBDebugSessionInfoVarObj::eVarFormat_Invalid;
- break;
- }
- }
- if (format == CMICmnLLDBDebugSessionInfoVarObj::eVarFormat_Invalid)
- {
- m_bGbbOptionFnHasError = false;
- SetError(CMIUtilString::Format(MIRSRC(IDS_DBGSESSION_ERR_SHARED_DATA_ADD), m_cmdData.strMiCmd.c_str(), "Output Radix"));
- return MIstatus::failure;
- }
- CMICmnLLDBDebugSessionInfoVarObj::VarObjSetFormat(format);
-
- return MIstatus::success;
-}
-
-//++ ------------------------------------------------------------------------------------
-// Details: Carry out work to complete the GDB set option to prepare and send back the
+bool CMICmdCmdGdbSet::OptionFnOutputRadix(
+ 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 &rStrValOutputRadix(vrWords[0]);
+
+ CMICmnLLDBDebugSessionInfoVarObj::varFormat_e format =
+ CMICmnLLDBDebugSessionInfoVarObj::eVarFormat_Invalid;
+ MIint64 radix;
+ if (rStrValOutputRadix.ExtractNumber(radix)) {
+ switch (radix) {
+ case 8:
+ format = CMICmnLLDBDebugSessionInfoVarObj::eVarFormat_Octal;
+ break;
+ case 10:
+ format = CMICmnLLDBDebugSessionInfoVarObj::eVarFormat_Natural;
+ break;
+ case 16:
+ format = CMICmnLLDBDebugSessionInfoVarObj::eVarFormat_Hex;
+ break;
+ default:
+ format = CMICmnLLDBDebugSessionInfoVarObj::eVarFormat_Invalid;
+ break;
+ }
+ }
+ if (format == CMICmnLLDBDebugSessionInfoVarObj::eVarFormat_Invalid) {
+ m_bGbbOptionFnHasError = false;
+ SetError(CMIUtilString::Format(MIRSRC(IDS_DBGSESSION_ERR_SHARED_DATA_ADD),
+ m_cmdData.strMiCmd.c_str(), "Output Radix"));
+ return MIstatus::failure;
+ }
+ CMICmnLLDBDebugSessionInfoVarObj::VarObjSetFormat(format);
+
+ return MIstatus::success;
+}
+
+//++
+//------------------------------------------------------------------------------------
+// Details: Carry out work to complete the GDB set option to prepare and send
+// back the
// requested information.
// Type: Method.
// Args: None.
@@ -394,14 +408,14 @@ CMICmdCmdGdbSet::OptionFnOutputRadix(con
// MIstatus::failure - Functional failed.
// Throws: None.
//--
-bool
-CMICmdCmdGdbSet::OptionFnFallback(const CMIUtilString::VecString_t &vrWords)
-{
- MIunused(vrWords);
-
- // Do nothing - intentional. This is a fallback function to do nothing.
- // This allows the search for gdb-set options to always succeed when the option is not
- // found (implemented).
+bool CMICmdCmdGdbSet::OptionFnFallback(
+ const CMIUtilString::VecString_t &vrWords) {
+ MIunused(vrWords);
+
+ // Do nothing - intentional. This is a fallback function to do nothing.
+ // This allows the search for gdb-set options to always succeed when the
+ // option is not
+ // found (implemented).
- return MIstatus::success;
+ return MIstatus::success;
}
Modified: lldb/trunk/tools/lldb-mi/MICmdCmdGdbSet.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/lldb-mi/MICmdCmdGdbSet.h?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/tools/lldb-mi/MICmdCmdGdbSet.h (original)
+++ lldb/trunk/tools/lldb-mi/MICmdCmdGdbSet.h Tue Sep 6 15:57:50 2016
@@ -9,13 +9,16 @@
// 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 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
+// For an introduction to adding a new command see
+// CMICmdCmdSupportInfoMiCmdQuery
// command class as an example.
#pragma once
@@ -23,63 +26,75 @@
// 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
+// 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
+// *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
+// 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.
//--
-class CMICmdCmdGdbSet : public CMICmdBase
-{
- // Statics:
- public:
- // Required by the CMICmdFactory when registering *this command
- static CMICmdBase *CreateSelf();
-
- // Methods:
- public:
- /* ctor */ CMICmdCmdGdbSet();
-
- // Overridden:
- public:
- // From CMICmdInvoker::ICmd
- bool Execute() override;
- bool Acknowledge() override;
- bool ParseArgs() override;
- // From CMICmnBase
- /* dtor */ ~CMICmdCmdGdbSet() override;
-
- // 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 OptionFnTargetAsync(const CMIUtilString::VecString_t &vrWords);
- bool OptionFnPrint(const CMIUtilString::VecString_t &vrWords);
- bool OptionFnSolibSearchPath(const CMIUtilString::VecString_t &vrWords);
- bool OptionFnOutputRadix(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;
+class CMICmdCmdGdbSet : public CMICmdBase {
+ // Statics:
+public:
+ // Required by the CMICmdFactory when registering *this command
+ static CMICmdBase *CreateSelf();
+
+ // Methods:
+public:
+ /* ctor */ CMICmdCmdGdbSet();
+
+ // Overridden:
+public:
+ // From CMICmdInvoker::ICmd
+ bool Execute() override;
+ bool Acknowledge() override;
+ bool ParseArgs() override;
+ // From CMICmnBase
+ /* dtor */ ~CMICmdCmdGdbSet() override;
+
+ // 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 OptionFnTargetAsync(const CMIUtilString::VecString_t &vrWords);
+ bool OptionFnPrint(const CMIUtilString::VecString_t &vrWords);
+ bool OptionFnSolibSearchPath(const CMIUtilString::VecString_t &vrWords);
+ bool OptionFnOutputRadix(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;
};
Modified: lldb/trunk/tools/lldb-mi/MICmdCmdGdbShow.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/lldb-mi/MICmdCmdGdbShow.cpp?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/tools/lldb-mi/MICmdCmdGdbShow.cpp (original)
+++ lldb/trunk/tools/lldb-mi/MICmdCmdGdbShow.cpp Tue Sep 6 15:57:50 2016
@@ -16,22 +16,24 @@
#include "lldb/API/SBThread.h"
// In-house headers:
-#include "MICmdCmdGdbShow.h"
-#include "MICmnMIResultRecord.h"
-#include "MICmnMIValueConst.h"
-#include "MICmdArgValString.h"
#include "MICmdArgValListOfN.h"
#include "MICmdArgValOptionLong.h"
+#include "MICmdArgValString.h"
+#include "MICmdCmdGdbShow.h"
#include "MICmnLLDBDebugSessionInfo.h"
+#include "MICmnMIResultRecord.h"
+#include "MICmnMIValueConst.h"
// Instantiations:
-const CMICmdCmdGdbShow::MapGdbOptionNameToFnGdbOptionPtr_t CMICmdCmdGdbShow::ms_mapGdbOptionNameToFnGdbOptionPtr = {
- {"target-async", &CMICmdCmdGdbShow::OptionFnTargetAsync},
- {"print", &CMICmdCmdGdbShow::OptionFnPrint},
- {"language", &CMICmdCmdGdbShow::OptionFnLanguage},
- {"fallback", &CMICmdCmdGdbShow::OptionFnFallback}};
+const CMICmdCmdGdbShow::MapGdbOptionNameToFnGdbOptionPtr_t
+ CMICmdCmdGdbShow::ms_mapGdbOptionNameToFnGdbOptionPtr = {
+ {"target-async", &CMICmdCmdGdbShow::OptionFnTargetAsync},
+ {"print", &CMICmdCmdGdbShow::OptionFnPrint},
+ {"language", &CMICmdCmdGdbShow::OptionFnLanguage},
+ {"fallback", &CMICmdCmdGdbShow::OptionFnFallback}};
-//++ ------------------------------------------------------------------------------------
+//++
+//------------------------------------------------------------------------------------
// Details: CMICmdCmdGdbShow constructor.
// Type: Method.
// Args: None.
@@ -39,32 +41,30 @@ const CMICmdCmdGdbShow::MapGdbOptionName
// Throws: None.
//--
CMICmdCmdGdbShow::CMICmdCmdGdbShow()
- : 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-show";
+ : 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-show";
- // Required by the CMICmdFactory when registering *this command
- m_pSelfCreatorFn = &CMICmdCmdGdbShow::CreateSelf;
+ // Required by the CMICmdFactory when registering *this command
+ m_pSelfCreatorFn = &CMICmdCmdGdbShow::CreateSelf;
}
-//++ ------------------------------------------------------------------------------------
+//++
+//------------------------------------------------------------------------------------
// Details: CMICmdCmdGdbShow destructor.
// Type: Overrideable.
// Args: None.
// Return: None.
// Throws: None.
//--
-CMICmdCmdGdbShow::~CMICmdCmdGdbShow()
-{
-}
+CMICmdCmdGdbShow::~CMICmdCmdGdbShow() {}
-//++ ------------------------------------------------------------------------------------
-// Details: The invoker requires this function. The parses the command line options
+//++
+//------------------------------------------------------------------------------------
+// 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.
@@ -72,68 +72,69 @@ CMICmdCmdGdbShow::~CMICmdCmdGdbShow()
// MIstatus::failure - Function failed.
// Throws: None.
//--
-bool
-CMICmdCmdGdbShow::ParseArgs()
-{
- m_setCmdArgs.Add(
- new CMICmdArgValListOfN(m_constStrArgNamedGdbOption, true, true, CMICmdArgValListBase::eArgValType_StringAnything));
- return ParseValidateCmdOptions();
+bool CMICmdCmdGdbShow::ParseArgs() {
+ m_setCmdArgs.Add(new CMICmdArgValListOfN(
+ m_constStrArgNamedGdbOption, true, true,
+ CMICmdArgValListBase::eArgValType_StringAnything));
+ return ParseValidateCmdOptions();
}
-//++ ------------------------------------------------------------------------------------
-// Details: The invoker requires this function. The command is executed in this function.
+//++
+//------------------------------------------------------------------------------------
+// Details: The invoker requires this function. The command is executed in this
+// function.
// Type: Overridden.
// Args: None.
// Return: MIstatus::success - Function succeeded.
// MIstatus::failure - Function failed.
// Throws: None.
//--
-bool
-CMICmdCmdGdbShow::Execute()
-{
- CMICMDBASE_GETOPTION(pArgGdbOption, ListOfN, m_constStrArgNamedGdbOption);
- const CMICmdArgValListBase::VecArgObjPtr_t &rVecWords(pArgGdbOption->GetExpectedOptions());
-
- // Get the gdb-show option to carry out. This option will be used as an action
- // which should be done. Further arguments will be used as parameters for it.
- 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());
+bool CMICmdCmdGdbShow::Execute() {
+ CMICMDBASE_GETOPTION(pArgGdbOption, ListOfN, m_constStrArgNamedGdbOption);
+ const CMICmdArgValListBase::VecArgObjPtr_t &rVecWords(
+ pArgGdbOption->GetExpectedOptions());
+
+ // Get the gdb-show option to carry out. This option will be used as an action
+ // which should be done. Further arguments will be used as parameters for it.
+ 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;
- }
+ // Next
+ ++it;
+ }
- FnGdbOptionPtr pPrintRequestFn = nullptr;
- if (!GetOptionFn(strOption, pPrintRequestFn))
- {
- // For unimplemented option handlers, fallback to 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;
- }
+ FnGdbOptionPtr pPrintRequestFn = nullptr;
+ if (!GetOptionFn(strOption, pPrintRequestFn)) {
+ // For unimplemented option handlers, fallback to 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;
+ m_bGdbOptionFnSuccessful = (this->*(pPrintRequestFn))(vecWords);
+ if (!m_bGdbOptionFnSuccessful && !m_bGbbOptionFnHasError)
+ return MIstatus::failure;
- return MIstatus::success;
+ return MIstatus::success;
}
-//++ ------------------------------------------------------------------------------------
-// Details: The invoker requires this function. The command prepares a MI Record Result
+//++
+//------------------------------------------------------------------------------------
+// Details: The invoker requires this function. The command prepares a MI Record
+// Result
// for the work carried out in the Execute() method.
// Type: Overridden.
// Args: None.
@@ -141,87 +142,92 @@ CMICmdCmdGdbShow::Execute()
// MIstatus::failure - Function failed.
// Throws: None.
//--
-bool
-CMICmdCmdGdbShow::Acknowledge()
-{
- // Print error if option isn't recognized:
- // ^error,msg="The request '%s' was not recognized, not implemented"
- 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;
- }
-
- // ^done,value="%s"
- if (m_bGdbOptionFnSuccessful && !m_strValue.empty())
- {
- const CMICmnMIValueConst miValueConst(m_strValue);
- const CMICmnMIValueResult miValueResult("value", miValueConst);
- const CMICmnMIResultRecord miRecordResult(m_cmdData.strMiCmdToken, CMICmnMIResultRecord::eResultClass_Done, miValueResult);
- m_miResultRecord = miRecordResult;
- return MIstatus::success;
- }
- else if (m_bGdbOptionFnSuccessful)
- {
- // Ignore empty value (for fallback)
- const CMICmnMIResultRecord miRecordResult(m_cmdData.strMiCmdToken, CMICmnMIResultRecord::eResultClass_Done);
- m_miResultRecord = miRecordResult;
- return MIstatus::success;
- }
-
- // Print error if request failed:
- // ^error,msg="The request '%s' failed.
- const CMICmnMIValueConst miValueConst(CMIUtilString::Format(MIRSRC(IDS_CMD_ERR_INFO_PRINTFN_FAILED), m_strGdbOptionFnError.c_str()));
+bool CMICmdCmdGdbShow::Acknowledge() {
+ // Print error if option isn't recognized:
+ // ^error,msg="The request '%s' was not recognized, not implemented"
+ 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);
+ const CMICmnMIResultRecord miRecordResult(
+ m_cmdData.strMiCmdToken, CMICmnMIResultRecord::eResultClass_Error,
+ miValueResult);
m_miResultRecord = miRecordResult;
+ return MIstatus::success;
+ }
+ // ^done,value="%s"
+ if (m_bGdbOptionFnSuccessful && !m_strValue.empty()) {
+ const CMICmnMIValueConst miValueConst(m_strValue);
+ const CMICmnMIValueResult miValueResult("value", miValueConst);
+ const CMICmnMIResultRecord miRecordResult(
+ m_cmdData.strMiCmdToken, CMICmnMIResultRecord::eResultClass_Done,
+ miValueResult);
+ m_miResultRecord = miRecordResult;
return MIstatus::success;
-}
+ } else if (m_bGdbOptionFnSuccessful) {
+ // Ignore empty value (for fallback)
+ const CMICmnMIResultRecord miRecordResult(
+ m_cmdData.strMiCmdToken, CMICmnMIResultRecord::eResultClass_Done);
+ m_miResultRecord = miRecordResult;
+ return MIstatus::success;
+ }
-//++ ------------------------------------------------------------------------------------
-// Details: Required by the CMICmdFactory when registering *this command. The factory
+ // Print error if request failed:
+ // ^error,msg="The request '%s' failed.
+ 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 *
-CMICmdCmdGdbShow::CreateSelf()
-{
- return new CMICmdCmdGdbShow();
-}
+CMICmdBase *CMICmdCmdGdbShow::CreateSelf() { return new CMICmdCmdGdbShow(); }
-//++ ------------------------------------------------------------------------------------
-// Details: Retrieve the print function's pointer for the matching print request.
+//++
+//------------------------------------------------------------------------------------
+// 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
+// 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
-CMICmdCmdGdbShow::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 show option 'target-async' to prepare
+bool CMICmdCmdGdbShow::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 show option 'target-async' to
+// prepare
// and send back the requested information.
// Type: Method.
// Args: vrWords - (R) List of additional parameters used by this option.
@@ -229,21 +235,23 @@ CMICmdCmdGdbShow::GetOptionFn(const CMIU
// MIstatus::failure - Function failed.
// Throws: None.
//--
-bool
-CMICmdCmdGdbShow::OptionFnTargetAsync(const CMIUtilString::VecString_t &vrWords)
-{
- MIunused(vrWords);
-
- // Get async mode
- CMICmnLLDBDebugSessionInfo &rSessionInfo(CMICmnLLDBDebugSessionInfo::Instance());
- const bool bAsyncMode = rSessionInfo.GetDebugger().GetAsync();
-
- m_strValue = bAsyncMode ? "on" : "off";
- return MIstatus::success;
-}
-
-//++ ------------------------------------------------------------------------------------
-// Details: Carry out work to complete the GDB show option 'print' to prepare and send
+bool CMICmdCmdGdbShow::OptionFnTargetAsync(
+ const CMIUtilString::VecString_t &vrWords) {
+ MIunused(vrWords);
+
+ // Get async mode
+ CMICmnLLDBDebugSessionInfo &rSessionInfo(
+ CMICmnLLDBDebugSessionInfo::Instance());
+ const bool bAsyncMode = rSessionInfo.GetDebugger().GetAsync();
+
+ m_strValue = bAsyncMode ? "on" : "off";
+ return MIstatus::success;
+}
+
+//++
+//------------------------------------------------------------------------------------
+// Details: Carry out work to complete the GDB show option 'print' to prepare
+// and send
// back the requested information.
// Type: Method.
// Args: vrWords - (R) List of additional parameters used by this option.
@@ -251,45 +259,48 @@ CMICmdCmdGdbShow::OptionFnTargetAsync(co
// MIstatus::failure - Function failed.
// Throws: None.
//--
-bool
-CMICmdCmdGdbShow::OptionFnPrint(const CMIUtilString::VecString_t &vrWords)
-{
- const bool bAllArgs(vrWords.size() == 1);
- if (!bAllArgs)
- {
- m_bGbbOptionFnHasError = true;
- m_strGdbOptionFnError = MIRSRC(IDS_CMD_ERR_GDBSHOW_OPT_PRINT_BAD_ARGS);
- return MIstatus::failure;
- }
-
- const CMIUtilString strOption(vrWords[0]);
- CMIUtilString strOptionKey;
- bool bOptionValueDefault = false;
- if (CMIUtilString::Compare(strOption, "char-array-as-string"))
- strOptionKey = m_rLLDBDebugSessionInfo.m_constStrPrintCharArrayAsString;
- else if (CMIUtilString::Compare(strOption, "expand-aggregates"))
- strOptionKey = m_rLLDBDebugSessionInfo.m_constStrPrintExpandAggregates;
- else if (CMIUtilString::Compare(strOption, "aggregate-field-names"))
- {
- strOptionKey = m_rLLDBDebugSessionInfo.m_constStrPrintAggregateFieldNames;
- bOptionValueDefault = true;
- }
- else
- {
- m_bGbbOptionFnHasError = true;
- m_strGdbOptionFnError = CMIUtilString::Format(MIRSRC(IDS_CMD_ERR_GDBSHOW_OPT_PRINT_UNKNOWN_OPTION), strOption.c_str());
- return MIstatus::failure;
- }
-
- bool bOptionValue = false;
- bOptionValue = bOptionValueDefault ? !m_rLLDBDebugSessionInfo.SharedDataRetrieve<bool>(strOptionKey, bOptionValue) || bOptionValue
- : m_rLLDBDebugSessionInfo.SharedDataRetrieve<bool>(strOptionKey, bOptionValue) && bOptionValue;
+bool CMICmdCmdGdbShow::OptionFnPrint(
+ const CMIUtilString::VecString_t &vrWords) {
+ const bool bAllArgs(vrWords.size() == 1);
+ if (!bAllArgs) {
+ m_bGbbOptionFnHasError = true;
+ m_strGdbOptionFnError = MIRSRC(IDS_CMD_ERR_GDBSHOW_OPT_PRINT_BAD_ARGS);
+ return MIstatus::failure;
+ }
+
+ const CMIUtilString strOption(vrWords[0]);
+ CMIUtilString strOptionKey;
+ bool bOptionValueDefault = false;
+ if (CMIUtilString::Compare(strOption, "char-array-as-string"))
+ strOptionKey = m_rLLDBDebugSessionInfo.m_constStrPrintCharArrayAsString;
+ else if (CMIUtilString::Compare(strOption, "expand-aggregates"))
+ strOptionKey = m_rLLDBDebugSessionInfo.m_constStrPrintExpandAggregates;
+ else if (CMIUtilString::Compare(strOption, "aggregate-field-names")) {
+ strOptionKey = m_rLLDBDebugSessionInfo.m_constStrPrintAggregateFieldNames;
+ bOptionValueDefault = true;
+ } else {
+ m_bGbbOptionFnHasError = true;
+ m_strGdbOptionFnError = CMIUtilString::Format(
+ MIRSRC(IDS_CMD_ERR_GDBSHOW_OPT_PRINT_UNKNOWN_OPTION),
+ strOption.c_str());
+ return MIstatus::failure;
+ }
+
+ bool bOptionValue = false;
+ bOptionValue = bOptionValueDefault
+ ? !m_rLLDBDebugSessionInfo.SharedDataRetrieve<bool>(
+ strOptionKey, bOptionValue) ||
+ bOptionValue
+ : m_rLLDBDebugSessionInfo.SharedDataRetrieve<bool>(
+ strOptionKey, bOptionValue) &&
+ bOptionValue;
- m_strValue = bOptionValue ? "on" : "off";
- return MIstatus::success;
+ m_strValue = bOptionValue ? "on" : "off";
+ return MIstatus::success;
}
-//++ ------------------------------------------------------------------------------------
+//++
+//------------------------------------------------------------------------------------
// Details: Carry out work to complete the GDB show option 'language' to prepare
// and send back the requested information.
// Type: Method.
@@ -298,24 +309,26 @@ CMICmdCmdGdbShow::OptionFnPrint(const CM
// MIstatus::failure - Function failed.
// Throws: None.
//--
-bool
-CMICmdCmdGdbShow::OptionFnLanguage(const CMIUtilString::VecString_t &vrWords)
-{
- MIunused(vrWords);
-
- // Get current language
- CMICmnLLDBDebugSessionInfo &rSessionInfo(CMICmnLLDBDebugSessionInfo::Instance());
- lldb::SBThread sbThread = rSessionInfo.GetProcess().GetSelectedThread();
- const lldb::SBFrame sbFrame = sbThread.GetSelectedFrame();
- lldb::SBCompileUnit sbCompileUnit = sbFrame.GetCompileUnit();
- const lldb::LanguageType eLanguageType = sbCompileUnit.GetLanguage();
-
- m_strValue = lldb::SBLanguageRuntime::GetNameForLanguageType(eLanguageType);
- return MIstatus::success;
-}
-
-//++ ------------------------------------------------------------------------------------
-// Details: Carry out work to complete the GDB show option to prepare and send back the
+bool CMICmdCmdGdbShow::OptionFnLanguage(
+ const CMIUtilString::VecString_t &vrWords) {
+ MIunused(vrWords);
+
+ // Get current language
+ CMICmnLLDBDebugSessionInfo &rSessionInfo(
+ CMICmnLLDBDebugSessionInfo::Instance());
+ lldb::SBThread sbThread = rSessionInfo.GetProcess().GetSelectedThread();
+ const lldb::SBFrame sbFrame = sbThread.GetSelectedFrame();
+ lldb::SBCompileUnit sbCompileUnit = sbFrame.GetCompileUnit();
+ const lldb::LanguageType eLanguageType = sbCompileUnit.GetLanguage();
+
+ m_strValue = lldb::SBLanguageRuntime::GetNameForLanguageType(eLanguageType);
+ return MIstatus::success;
+}
+
+//++
+//------------------------------------------------------------------------------------
+// Details: Carry out work to complete the GDB show option to prepare and send
+// back the
// requested information.
// Type: Method.
// Args: None.
@@ -323,14 +336,14 @@ CMICmdCmdGdbShow::OptionFnLanguage(const
// MIstatus::failure - Function failed.
// Throws: None.
//--
-bool
-CMICmdCmdGdbShow::OptionFnFallback(const CMIUtilString::VecString_t &vrWords)
-{
- MIunused(vrWords);
-
- // Do nothing - intentional. This is a fallback function to do nothing.
- // This allows the search for gdb-show options to always succeed when the option is not
- // found (implemented).
+bool CMICmdCmdGdbShow::OptionFnFallback(
+ const CMIUtilString::VecString_t &vrWords) {
+ MIunused(vrWords);
+
+ // Do nothing - intentional. This is a fallback function to do nothing.
+ // This allows the search for gdb-show options to always succeed when the
+ // option is not
+ // found (implemented).
- return MIstatus::success;
+ return MIstatus::success;
}
Modified: lldb/trunk/tools/lldb-mi/MICmdCmdGdbShow.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/lldb-mi/MICmdCmdGdbShow.h?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/tools/lldb-mi/MICmdCmdGdbShow.h (original)
+++ lldb/trunk/tools/lldb-mi/MICmdCmdGdbShow.h Tue Sep 6 15:57:50 2016
@@ -9,13 +9,16 @@
// Overview: CMICmdCmdGdbShow 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 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
+// For an introduction to adding a new command see
+// CMICmdCmdSupportInfoMiCmdQuery
// command class as an example.
#pragma once
@@ -23,63 +26,75 @@
// In-house headers:
#include "MICmdBase.h"
-//++ ============================================================================
+//++
+//============================================================================
// Details: MI command class. MI commands derived from the command base class.
// *this class implements MI command "gdb-show".
-// This command does not follow the MI documentation exactly. While *this
+// 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
+// *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
+// 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.
//--
-class CMICmdCmdGdbShow : public CMICmdBase
-{
- // Statics:
- public:
- // Required by the CMICmdFactory when registering *this command
- static CMICmdBase *CreateSelf();
-
- // Methods:
- public:
- /* ctor */ CMICmdCmdGdbShow();
-
- // Overridden:
- public:
- // From CMICmdInvoker::ICmd
- bool Execute() override;
- bool Acknowledge() override;
- bool ParseArgs() override;
- // From CMICmnBase
- /* dtor */ ~CMICmdCmdGdbShow() override;
-
- // Typedefs:
- private:
- typedef bool (CMICmdCmdGdbShow::*FnGdbOptionPtr)(const CMIUtilString::VecString_t &vrWords);
- typedef std::map<CMIUtilString, FnGdbOptionPtr> MapGdbOptionNameToFnGdbOptionPtr_t;
-
- // Methods:
- private:
- bool GetOptionFn(const CMIUtilString &vrGdbOptionName, FnGdbOptionPtr &vrwpFn) const;
- bool OptionFnTargetAsync(const CMIUtilString::VecString_t &vrWords);
- bool OptionFnPrint(const CMIUtilString::VecString_t &vrWords);
- bool OptionFnLanguage(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;
- CMIUtilString m_strValue;
+class CMICmdCmdGdbShow : public CMICmdBase {
+ // Statics:
+public:
+ // Required by the CMICmdFactory when registering *this command
+ static CMICmdBase *CreateSelf();
+
+ // Methods:
+public:
+ /* ctor */ CMICmdCmdGdbShow();
+
+ // Overridden:
+public:
+ // From CMICmdInvoker::ICmd
+ bool Execute() override;
+ bool Acknowledge() override;
+ bool ParseArgs() override;
+ // From CMICmnBase
+ /* dtor */ ~CMICmdCmdGdbShow() override;
+
+ // Typedefs:
+private:
+ typedef bool (CMICmdCmdGdbShow::*FnGdbOptionPtr)(
+ const CMIUtilString::VecString_t &vrWords);
+ typedef std::map<CMIUtilString, FnGdbOptionPtr>
+ MapGdbOptionNameToFnGdbOptionPtr_t;
+
+ // Methods:
+private:
+ bool GetOptionFn(const CMIUtilString &vrGdbOptionName,
+ FnGdbOptionPtr &vrwpFn) const;
+ bool OptionFnTargetAsync(const CMIUtilString::VecString_t &vrWords);
+ bool OptionFnPrint(const CMIUtilString::VecString_t &vrWords);
+ bool OptionFnLanguage(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;
+ CMIUtilString m_strValue;
};
Modified: lldb/trunk/tools/lldb-mi/MICmdCmdGdbThread.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/lldb-mi/MICmdCmdGdbThread.cpp?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/tools/lldb-mi/MICmdCmdGdbThread.cpp (original)
+++ lldb/trunk/tools/lldb-mi/MICmdCmdGdbThread.cpp Tue Sep 6 15:57:50 2016
@@ -14,52 +14,54 @@
#include "MICmnMIResultRecord.h"
#include "MICmnMIValueConst.h"
-//++ ------------------------------------------------------------------------------------
+//++
+//------------------------------------------------------------------------------------
// Details: CMICmdCmdGdbThread constructor.
// Type: Method.
// Args: None.
// Return: None.
// Throws: None.
//--
-CMICmdCmdGdbThread::CMICmdCmdGdbThread()
-{
- // Command factory matches this name with that received from the stdin stream
- m_strMiCmd = "thread";
+CMICmdCmdGdbThread::CMICmdCmdGdbThread() {
+ // 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;
+ // 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()
-{
-}
+CMICmdCmdGdbThread::~CMICmdCmdGdbThread() {}
-//++ ------------------------------------------------------------------------------------
-// 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.
+//++
+//------------------------------------------------------------------------------------
+// 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()
-{
- // Do nothing
+bool CMICmdCmdGdbThread::Execute() {
+ // Do nothing
- return MIstatus::success;
+ return MIstatus::success;
}
-//++ ------------------------------------------------------------------------------------
-// Details: The invoker requires this function. The command prepares a MI Record Result
+//++
+//------------------------------------------------------------------------------------
+// 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.
@@ -67,27 +69,27 @@ CMICmdCmdGdbThread::Execute()
// MIstatus::failure - Functional failed.
// Throws: None.
//--
-bool
-CMICmdCmdGdbThread::Acknowledge()
-{
- 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;
+bool CMICmdCmdGdbThread::Acknowledge() {
+ 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;
+ return MIstatus::success;
}
-//++ ------------------------------------------------------------------------------------
-// Details: Required by the CMICmdFactory when registering *this command. The factory
+//++
+//------------------------------------------------------------------------------------
+// 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()
-{
- return new CMICmdCmdGdbThread();
+CMICmdBase *CMICmdCmdGdbThread::CreateSelf() {
+ return new CMICmdCmdGdbThread();
}
Modified: lldb/trunk/tools/lldb-mi/MICmdCmdGdbThread.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/lldb-mi/MICmdCmdGdbThread.h?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/tools/lldb-mi/MICmdCmdGdbThread.h (original)
+++ lldb/trunk/tools/lldb-mi/MICmdCmdGdbThread.h Tue Sep 6 15:57:50 2016
@@ -9,13 +9,16 @@
// 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 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
+// For an introduction to adding a new command see
+// CMICmdCmdSupportInfoMiCmdQuery
// command class as an example.
#pragma once
@@ -23,26 +26,26 @@
// In-house headers:
#include "MICmdBase.h"
-//++ ============================================================================
+//++
+//============================================================================
// Details: MI command class. MI commands derived from the command base class.
// *this class implements GDB command "thread".
//--
-class CMICmdCmdGdbThread : public CMICmdBase
-{
- // Statics:
- public:
- // Required by the CMICmdFactory when registering *this command
- static CMICmdBase *CreateSelf();
-
- // Methods:
- public:
- /* ctor */ CMICmdCmdGdbThread();
-
- // Overridden:
- public:
- // From CMICmdInvoker::ICmd
- bool Execute() override;
- bool Acknowledge() override;
- // From CMICmnBase
- /* dtor */ ~CMICmdCmdGdbThread() override;
+class CMICmdCmdGdbThread : public CMICmdBase {
+ // Statics:
+public:
+ // Required by the CMICmdFactory when registering *this command
+ static CMICmdBase *CreateSelf();
+
+ // Methods:
+public:
+ /* ctor */ CMICmdCmdGdbThread();
+
+ // Overridden:
+public:
+ // From CMICmdInvoker::ICmd
+ bool Execute() override;
+ bool Acknowledge() override;
+ // From CMICmnBase
+ /* dtor */ ~CMICmdCmdGdbThread() override;
};
More information about the lldb-commits
mailing list