git://git.jankratochvil.net
/
llgdb.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Add command-line parameter -p|--pid.
[llgdb.git]
/
src
/
LLGDBMain.cpp
diff --git
a/src/LLGDBMain.cpp
b/src/LLGDBMain.cpp
index
39dac35
..
506fe50
100644
(file)
--- a/
src/LLGDBMain.cpp
+++ b/
src/LLGDBMain.cpp
@@
-345,6
+345,7
@@
static char *completion_entry_function(const char *text, int matches) {
static std::deque<std::string> opt_iex, opt_ex;
static std::optional<std::string> opt_exec, opt_core;
static std::deque<std::string> opt_iex, opt_ex;
static std::optional<std::string> opt_exec, opt_core;
+static std::optional<lldb::pid_t> opt_pid;
static std::vector<std::string> opt_args;
std::string string_quote(std::string &&str) {
static std::vector<std::string> opt_args;
std::string string_quote(std::string &&str) {
@@
-376,6
+377,11
@@
std::optional<std::string> next_arg() {
}
return cmd;
}
}
return cmd;
}
+ if (opt_pid) {
+ std::string retval = (boost::format("attach %1%") % *opt_pid).str();
+ opt_pid.reset();
+ return retval;
+ }
if (!opt_ex.empty()) {
std::string retval = opt_ex.front();
opt_ex.pop_front();
if (!opt_ex.empty()) {
std::string retval = opt_ex.front();
opt_ex.pop_front();
@@
-391,6
+397,10
@@
int main(int argc, char **argv) {
for (int argi = 1; argi < argc; ++argi) {
std::string arg = argv[argi];
for (int argi = 1; argi < argc; ++argi) {
std::string arg = argv[argi];
+ auto str_to_pid = [](const std::string &str){
+ lldb::pid_t pid_test = atoi(str.c_str());
+ return (boost::format("%1%") % pid_test).str() != str || pid_test <= 0 ? 0 : pid_test;
+ };
if (arg == "-iex") {
const char *cmd = argv[++argi];
assert(cmd);
if (arg == "-iex") {
const char *cmd = argv[++argi];
assert(cmd);
@@
-410,8
+420,14
@@
int main(int argc, char **argv) {
arg = argv[argi];
opt_args.push_back(std::move(arg));
}
arg = argv[argi];
opt_args.push_back(std::move(arg));
}
+ } else if (arg == "-p" || arg == "--pid") {
+ opt_pid = str_to_pid(argv[++argi]);
+ if (opt_pid == 0)
+ error(1,0,"Invalid PID: %s",argv[argi]);
} else if (!opt_exec)
opt_exec=std::move(arg);
} else if (!opt_exec)
opt_exec=std::move(arg);
+ else if (!opt_pid && str_to_pid(arg) > 0)
+ opt_pid = str_to_pid(arg);
else if (!opt_core)
opt_core=std::move(arg);
else
else if (!opt_core)
opt_core=std::move(arg);
else