diff options
Diffstat (limited to 'gdb/testsuite/gdb.base/foll-exec.c')
-rw-r--r-- | gdb/testsuite/gdb.base/foll-exec.c | 26 |
1 files changed, 19 insertions, 7 deletions
diff --git a/gdb/testsuite/gdb.base/foll-exec.c b/gdb/testsuite/gdb.base/foll-exec.c index 639698c..1ae171f 100644 --- a/gdb/testsuite/gdb.base/foll-exec.c +++ b/gdb/testsuite/gdb.base/foll-exec.c @@ -20,36 +20,48 @@ #include <unistd.h> #include <string.h> +#include <limits.h> + int global_i = 100; -int main (void) +int main (int argc, char ** argv) { int local_j = global_i + 1; int local_k = local_j + 1; + char prog[PATH_MAX]; + int len; printf ("foll-exec is about to execlp(execd-prog)...\n"); - execlp (BASEDIR "/execd-prog", - BASEDIR "/execd-prog", + strcpy (prog, argv[0]); + len = strlen (prog); + /* Replace "foll-exec" with "execd-prog". */ + memcpy (prog + len - 9, "execd-prog", 10); + prog[len + 1] = 0; + + execlp (prog, /* tbreak-execlp */ + prog, "execlp arg1 from foll-exec", (char *) 0); printf ("foll-exec is about to execl(execd-prog)...\n"); - execl (BASEDIR "/execd-prog", /* tbreak-execl */ - BASEDIR "/execd-prog", + execl (prog, /* tbreak-execl */ + prog, "execl arg1 from foll-exec", "execl arg2 from foll-exec", (char *) 0); { static char * argv[] = { - (char *) BASEDIR "/execd-prog", + (char *) "", (char *) "execv arg1 from foll-exec", (char *) 0}; + argv[0] = prog; + printf ("foll-exec is about to execv(execd-prog)...\n"); - execv (BASEDIR "/execd-prog", argv); /* tbreak-execv */ + execv (prog, argv); /* tbreak-execv */ } } |