|
From: <sv...@va...> - 2005-09-28 01:53:09
|
Author: sewardj
Date: 2005-09-28 02:53:07 +0100 (Wed, 28 Sep 2005)
New Revision: 4804
Log:
Rename m_launcher.c to launcher.c to make clear it's not part of the
normal module scheme -- it's a standalone program.
Added:
trunk/coregrind/launcher.c
Removed:
trunk/coregrind/m_launcher.c
Modified:
trunk/coregrind/Makefile.am
Modified: trunk/coregrind/Makefile.am
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/coregrind/Makefile.am 2005-09-28 01:46:31 UTC (rev 4803)
+++ trunk/coregrind/Makefile.am 2005-09-28 01:53:07 UTC (rev 4804)
@@ -92,7 +92,7 @@
CLEANFILES =3D=20
=20
valgrind_SOURCES =3D \
- m_launcher.c \
+ launcher.c \
m_debuglog.c
=20
libcoregrind_a_SOURCES =3D \
Copied: trunk/coregrind/launcher.c (from rev 4797, trunk/coregrind/m_laun=
cher.c)
Deleted: trunk/coregrind/m_launcher.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/coregrind/m_launcher.c 2005-09-28 01:46:31 UTC (rev 4803)
+++ trunk/coregrind/m_launcher.c 2005-09-28 01:53:07 UTC (rev 4804)
@@ -1,145 +0,0 @@
-
-/*--------------------------------------------------------------------*/
-/*--- Launching valgrind m_launcher.c ---*/
-/*--------------------------------------------------------------------*/
-
-/*
- This file is part of Valgrind, a dynamic binary instrumentation
- framework.
-
- Copyright (C) 2000-2005 Julian Seward=20
- js...@ac...
-
- This program is free software; you can redistribute it and/or
- modify it under the terms of the GNU General Public License as
- published by the Free Software Foundation; either version 2 of the
- License, or (at your option) any later version.
-
- This program is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
- 02111-1307, USA.
-
- The GNU General Public License is contained in the file COPYING.
-*/
-
-/* Note: this is a "normal" program and not part of Valgrind proper,
- and so it doesn't have to conform to Valgrind's arcane rules on
- no-glibc-usage etc. */
-
-#include <errno.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-#include <assert.h>
-
-#include "pub_core_debuglog.h"
-#include "pub_core_libcproc.h" // For VALGRIND_LIB, VALGRIND_LAUNCHER
-
-
-
-#define PATH_MAX 4096 /* POSIX refers to this a lot but I dunno
- where it is defined */
-
-static void barf ( char* str )
-{
- fprintf(stderr, "valgrind: Cannot continue: %s\n", str );
- exit(1);
-}
-
-/* Where we expect to find all our aux files */
-static const char *valgrind_lib =3D VG_LIBDIR;
-
-int main(int argc, char** argv, char** envp)
-{
- int i, j, loglevel, r;
- const char *toolname =3D NULL;
- const char *cp;
- char *toolfile;
- char launcher_name[PATH_MAX+1];
- char* new_line;
- char** new_env;
-
- /* Start the debugging-log system ASAP. First find out how many=20
- "-d"s were specified. This is a pre-scan of the command line.
- At the same time, look for the tool name. */
- loglevel =3D 0;
- for (i =3D 1; i < argc; i++) {
- if (argv[i][0] !=3D '-')
- break;
- if (0 =3D=3D strcmp(argv[i], "--"))=20
- break;
- if (0 =3D=3D strcmp(argv[i], "-d"))=20
- loglevel++;
- if (0 =3D=3D strncmp(argv[i], "--tool=3D", 7))=20
- toolname =3D argv[i] + 7;
- }
-
- /* ... and start the debug logger. Now we can safely emit logging
- messages all through startup. */
- VG_(debugLog_startup)(loglevel, "Stage 1");
-
- /* Make sure we know which tool we're using */
- if (toolname) {
- VG_(debugLog)(1, "launcher", "tool '%s' requested\n", toolname);
- } else {
- VG_(debugLog)(1, "launcher",=20
- "no tool requested, defaulting to 'memcheck'\n");
- toolname =3D "memcheck";
- }
-
- /* Figure out the name of this executable (viz, the launcher), so
- we can tell stage2. stage2 will use the name for recursive
- invokations of valgrind on child processes. */
- memset(launcher_name, 0, PATH_MAX+1);
- r =3D readlink("/proc/self/exe", launcher_name, PATH_MAX);
- if (r =3D=3D -1)
- barf("readlink(\"/proc/self/exe\") failed.");
-
- /* tediously augment the env: VALGRIND_LAUNCHER=3Dlauncher_name */
- new_line =3D malloc(strlen(VALGRIND_LAUNCHER) + 1=20
- + strlen(launcher_name) + 1);
- if (new_line =3D=3D NULL)
- barf("malloc of new_line failed.");
- strcpy(new_line, VALGRIND_LAUNCHER);
- strcat(new_line, "=3D");
- strcat(new_line, launcher_name);
-
- for (j =3D 0; envp[j]; j++)
- ;
- new_env =3D malloc((j+2) * sizeof(char*));
- if (new_env =3D=3D NULL)
- barf("malloc of new_env failed.");
- for (i =3D 0; i < j; i++)
- new_env[i] =3D envp[i];
- new_env[i++] =3D new_line;
- new_env[i++] =3D NULL;
- assert(i =3D=3D j+2);
-
- /* Establish the correct VALGRIND_LIB. */
- cp =3D getenv(VALGRIND_LIB);
-
- if (cp !=3D NULL)
- valgrind_lib =3D cp;
-
- /* Build the stage2 invokation, and execve it. Bye! */
- toolfile =3D malloc(strlen(valgrind_lib) + strlen(toolname) + 2);
- if (toolfile =3D=3D NULL)
- barf("malloc of toolfile failed.");
- sprintf(toolfile, "%s/%s", valgrind_lib, toolname);
-
- VG_(debugLog)(1, "launcher", "launching %s\n", toolfile);
-
- execve(toolfile, argv, new_env);
-
- fprintf(stderr, "valgrind: failed to start tool '%s': %s\n",
- toolname, strerror(errno));
-
- exit(1);
-}
|