llvm-project/lldb/source/Utility/State.cpp

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

111 lines
2.5 KiB
C++
Raw Normal View History

//===-- State.cpp ---------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
#include "lldb/Utility/State.h"
using namespace lldb;
using namespace lldb_private;
const char *lldb_private::StateAsCString(StateType state) {
switch (state) {
case eStateInvalid:
return "invalid";
case eStateUnloaded:
return "unloaded";
Added support for attaching to a remote debug server with the new command: (lldb) process connect <remote-url> Currently when you specify a file with the file command it helps us to find a process plug-in that is suitable for debugging. If you specify a file you can rely upon this to find the correct debugger plug-in: % lldb a.out Current executable set to 'a.out' (x86_64). (lldb) process connect connect://localhost:2345 ... If you don't specify a file, you will need to specify the plug-in name that you wish to use: % lldb (lldb) process connect --plugin process.gdb-remote connect://localhost:2345 Other connection URL examples: (lldb) process connect connect://localhost:2345 (lldb) process connect tcp://127.0.0.1 (lldb) process connect file:///dev/ttyS1 We are currently treating the "connect://host:port" as a way to do raw socket connections. If there is a URL for this already, please let me know and we will adopt it. So now you can connect to a remote debug server with the ProcessGDBRemote plug-in. After connection, it will ask for the pid info using the "qC" packet and if it responds with a valid process ID, it will be equivalent to attaching. If it response with an error or invalid process ID, the LLDB process will be in a new state: eStateConnected. This allows us to then download a program or specify the program to run (using the 'A' packet), or specify a process to attach to (using the "vAttach" packets), or query info about the processes that might be available. llvm-svn: 124846
2011-02-04 09:58:07 +08:00
case eStateConnected:
return "connected";
case eStateAttaching:
return "attaching";
case eStateLaunching:
return "launching";
case eStateStopped:
return "stopped";
case eStateRunning:
return "running";
case eStateStepping:
return "stepping";
case eStateCrashed:
return "crashed";
case eStateDetached:
return "detached";
case eStateExited:
return "exited";
case eStateSuspended:
return "suspended";
}
return "unknown";
}
const char *lldb_private::GetPermissionsAsCString(uint32_t permissions) {
switch (permissions) {
case 0:
return "---";
case ePermissionsWritable:
return "-w-";
case ePermissionsReadable:
return "r--";
case ePermissionsExecutable:
return "--x";
case ePermissionsReadable | ePermissionsWritable:
return "rw-";
case ePermissionsReadable | ePermissionsExecutable:
return "r-x";
case ePermissionsWritable | ePermissionsExecutable:
return "-wx";
case ePermissionsReadable | ePermissionsWritable | ePermissionsExecutable:
return "rwx";
default:
break;
}
return "???";
}
bool lldb_private::StateIsRunningState(StateType state) {
switch (state) {
case eStateAttaching:
case eStateLaunching:
case eStateRunning:
case eStateStepping:
return true;
Added support for attaching to a remote debug server with the new command: (lldb) process connect <remote-url> Currently when you specify a file with the file command it helps us to find a process plug-in that is suitable for debugging. If you specify a file you can rely upon this to find the correct debugger plug-in: % lldb a.out Current executable set to 'a.out' (x86_64). (lldb) process connect connect://localhost:2345 ... If you don't specify a file, you will need to specify the plug-in name that you wish to use: % lldb (lldb) process connect --plugin process.gdb-remote connect://localhost:2345 Other connection URL examples: (lldb) process connect connect://localhost:2345 (lldb) process connect tcp://127.0.0.1 (lldb) process connect file:///dev/ttyS1 We are currently treating the "connect://host:port" as a way to do raw socket connections. If there is a URL for this already, please let me know and we will adopt it. So now you can connect to a remote debug server with the ProcessGDBRemote plug-in. After connection, it will ask for the pid info using the "qC" packet and if it responds with a valid process ID, it will be equivalent to attaching. If it response with an error or invalid process ID, the LLDB process will be in a new state: eStateConnected. This allows us to then download a program or specify the program to run (using the 'A' packet), or specify a process to attach to (using the "vAttach" packets), or query info about the processes that might be available. llvm-svn: 124846
2011-02-04 09:58:07 +08:00
case eStateConnected:
case eStateDetached:
case eStateInvalid:
case eStateUnloaded:
case eStateStopped:
case eStateCrashed:
case eStateExited:
case eStateSuspended:
break;
}
return false;
}
bool lldb_private::StateIsStoppedState(StateType state, bool must_exist) {
switch (state) {
case eStateInvalid:
Added support for attaching to a remote debug server with the new command: (lldb) process connect <remote-url> Currently when you specify a file with the file command it helps us to find a process plug-in that is suitable for debugging. If you specify a file you can rely upon this to find the correct debugger plug-in: % lldb a.out Current executable set to 'a.out' (x86_64). (lldb) process connect connect://localhost:2345 ... If you don't specify a file, you will need to specify the plug-in name that you wish to use: % lldb (lldb) process connect --plugin process.gdb-remote connect://localhost:2345 Other connection URL examples: (lldb) process connect connect://localhost:2345 (lldb) process connect tcp://127.0.0.1 (lldb) process connect file:///dev/ttyS1 We are currently treating the "connect://host:port" as a way to do raw socket connections. If there is a URL for this already, please let me know and we will adopt it. So now you can connect to a remote debug server with the ProcessGDBRemote plug-in. After connection, it will ask for the pid info using the "qC" packet and if it responds with a valid process ID, it will be equivalent to attaching. If it response with an error or invalid process ID, the LLDB process will be in a new state: eStateConnected. This allows us to then download a program or specify the program to run (using the 'A' packet), or specify a process to attach to (using the "vAttach" packets), or query info about the processes that might be available. llvm-svn: 124846
2011-02-04 09:58:07 +08:00
case eStateConnected:
case eStateAttaching:
case eStateLaunching:
case eStateRunning:
case eStateStepping:
case eStateDetached:
break;
case eStateUnloaded:
case eStateExited:
return !must_exist;
case eStateStopped:
case eStateCrashed:
case eStateSuspended:
return true;
}
return false;
}