35 #define SHELL_FILE "/bin/sh" 46 const char *shell_file);
56 return const_cast<char **
> (&
m_argv[0]);
73 const char *shell_file);
106 m_argv.push_back (exec_file);
108 for (
size_t cur_pos = 0; cur_pos < args_copy.size ();)
111 std::size_t pos = args_copy.find_first_not_of (
" \t\n", cur_pos);
113 if (pos != std::string::npos)
117 std::size_t next_sep = args_copy.find_first_of (
" \t\n", cur_pos);
119 if (next_sep == std::string::npos)
123 next_sep = args_copy.size ();
128 args_copy[next_sep++] =
'\0';
131 m_argv.push_back (&args_copy[cur_pos]);
147 size_t shell_file_len = strlen (shell_file);
153 if (shell_file_len < 3)
156 if (shell_file[shell_file_len - 3] ==
'c' 157 && shell_file[shell_file_len - 2] ==
's' 158 && shell_file[shell_file_len - 1] ==
'h')
168 const char *shell_file)
170 if (shell_file == NULL)
181 const char *shell_file)
208 const char *p = exec_file;
226 need_to_quote =
true;
230 need_to_quote =
false;
242 for (p = exec_file; *p !=
'\0'; ++p)
246 else if (*p ==
'!' && escape_bang)
262 m_argv.push_back (shell_file);
275 static const char *ret;
277 ret = getenv (
"SHELL");
288 char **env,
void (*traceme_fun) (),
289 void (*init_trace_fun) (
int),
void (*pre_trace_fun) (),
290 const char *shell_file_arg,
291 void (*exec_fun)(
const char *file,
char *
const *
argv,
297 const char *shell_file;
298 const char *exec_file;
302 const char *inferior_cwd;
307 if (exec_file_arg == NULL)
310 exec_file = exec_file_arg;
317 shell_file = shell_file_arg;
320 if (shell_file == NULL)
329 execv_argv child_argv (exec_file, allargs, shell_file);
349 if (inferior_cwd != NULL)
354 inferior_cwd = expanded_inferior_cwd.c_str ();
360 if (pre_trace_fun != NULL)
374 #if !(defined(__UCLIBC__) && defined(HAS_NOMMU)) 375 if (pre_trace_fun || debug_fork)
394 if (inferior_cwd != NULL)
396 if (chdir (inferior_cwd) < 0)
435 if (exec_fun != NULL)
436 (*exec_fun) (
argv[0], &
argv[0], env);
444 for (i = 1;
argv[i] != NULL; i++)
461 (*init_trace_fun) (
pid);
476 int pending_execs = ntraps;
477 int terminal_initted = 0;
503 memset (&ws, 0,
sizeof (ws));
506 if (last_waitstatus != NULL)
507 *last_waitstatus = ws;
508 if (last_ptid != NULL)
509 *last_ptid = event_ptid;
530 error (
_(
"During startup program terminated with signal %s, %s."),
539 error (
_(
"During startup program exited with code %d."),
542 error (
_(
"During startup program exited normally."));
566 if (!terminal_initted)
580 terminal_initted = 1;
583 if (--pending_execs == 0)
602 warning (
"Could not trace the inferior process.\nError: ");
ptid_t startup_inferior(pid_t pid, int ntraps, struct target_waitstatus *last_waitstatus, ptid_t *last_ptid)
static char * exec_wrapper
ptid_t target_wait(ptid_t ptid, struct target_waitstatus *status, int options)
mach_port_t mach_port_t name mach_port_t mach_port_t name kern_return_t int int rusage_t pid_t pid
int target_supports_multi_process(void)
static bool escape_bang_in_quoted_argument(const char *shell_file)
void warning(const char *fmt,...)
char * get_exec_file(int err)
void * memset(T *s, int c, size_t n)=delete
union target_waitstatus::@174 value
void prefork_hook(const char *args)
void init_for_shell(const char *exec_file, const std::string &allargs, const char *shell_file)
void switch_to_thread(ptid_t ptid)
execv_argv(const char *exec_file, const std::string &allargs, const char *shell_file)
static const char * get_startup_shell()
ptid_t pid_to_ptid(int pid)
DISABLE_COPY_AND_ASSIGN(execv_argv)
const char * get_exec_wrapper()
void trace_start_error(const char *fmt,...)
void target_mourn_inferior(ptid_t ptid)
void restore_original_signals_state(void)
const char * gdb_signal_to_name(enum gdb_signal)
void close_most_fds(void)
const char * get_inferior_cwd()
void target_continue(ptid_t ptid, enum gdb_signal signal)
void trace_start_error_with_name(const char *string)
void void void void void void void void void perror_with_name(const char *string) ATTRIBUTE_NORETURN
void postfork_hook(pid_t pid)
pid_t fork_inferior(const char *exec_file_arg, const std::string &allargs, char **env, void(*traceme_fun)(), void(*init_trace_fun)(int), void(*pre_trace_fun)(), const char *shell_file_arg, void(*exec_fun)(const char *file, char *const *argv, char *const *env))
enum target_waitkind kind
void init_for_no_shell(const char *exec_file, const std::string &allargs)
char * safe_strerror(int)
std::string gdb_tilde_expand(const char *dir)
static void shell_command(const char *arg, int from_tty)
const char * gdb_signal_to_string(enum gdb_signal)
void void vwarning(const char *fmt, va_list args) ATTRIBUTE_PRINTF(1
void error(const char *fmt,...)
std::vector< const char * > m_argv
void target_continue_no_signal(ptid_t ptid)
void postfork_child_hook()