blob: 08f38c1ab0a30db4a69461305331ad28d8fa50cc [file] [log] [blame]
florian695dde82015-04-06 14:29:45 +00001/* -*- mode: C; c-basic-offset: 3; -*- */
sewardj45f4e7c2005-09-27 19:20:21 +00002
3/*--------------------------------------------------------------------*/
4/*--- Launching valgrind m_launcher.c ---*/
5/*--------------------------------------------------------------------*/
6
7/*
8 This file is part of Valgrind, a dynamic binary instrumentation
9 framework.
10
sewardj0f157dd2013-10-18 14:27:36 +000011 Copyright (C) 2000-2013 Julian Seward
sewardj45f4e7c2005-09-27 19:20:21 +000012 jseward@acm.org
13
14 This program is free software; you can redistribute it and/or
15 modify it under the terms of the GNU General Public License as
16 published by the Free Software Foundation; either version 2 of the
17 License, or (at your option) any later version.
18
19 This program is distributed in the hope that it will be useful, but
20 WITHOUT ANY WARRANTY; without even the implied warranty of
21 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
22 General Public License for more details.
23
24 You should have received a copy of the GNU General Public License
25 along with this program; if not, write to the Free Software
26 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
27 02111-1307, USA.
28
29 The GNU General Public License is contained in the file COPYING.
30*/
31
32/* Note: this is a "normal" program and not part of Valgrind proper,
33 and so it doesn't have to conform to Valgrind's arcane rules on
34 no-glibc-usage etc. */
35
tom5c46da82010-04-29 09:01:21 +000036/* Include valgrind headers before system headers to avoid problems
37 with the system headers #defining things which are used as names
38 of structure members in vki headers. */
39
40#include "pub_core_debuglog.h"
41#include "pub_core_vki.h" // Avoids warnings from
42 // pub_core_libcfile.h
43#include "pub_core_libcproc.h" // For VALGRIND_LIB, VALGRIND_LAUNCHER
44#include "pub_core_ume.h"
45
tomfb7bcde2005-11-07 15:24:38 +000046#include <assert.h>
47#include <ctype.h>
48#include <elf.h>
sewardj45f4e7c2005-09-27 19:20:21 +000049#include <errno.h>
tomfb7bcde2005-11-07 15:24:38 +000050#include <fcntl.h>
sewardj45f4e7c2005-09-27 19:20:21 +000051#include <stdio.h>
52#include <stdlib.h>
53#include <string.h>
54#include <unistd.h>
sewardj45f4e7c2005-09-27 19:20:21 +000055
toma879a472005-12-19 12:27:42 +000056#ifndef EM_X86_64
njn81e60b22005-12-19 17:01:14 +000057#define EM_X86_64 62 // elf.h doesn't define this on some older systems
58#endif
toma879a472005-12-19 12:27:42 +000059
sewardjf0c12502014-01-12 12:54:00 +000060#ifndef EM_AARCH64
61#define EM_AARCH64 183 // ditto
62#endif
63
sewardjed12bf22014-09-01 21:17:01 +000064#ifndef EM_PPC64
65#define EM_PPC64 21 // ditto
66#endif
67
sewardj112711a2015-04-10 12:30:09 +000068#ifndef EM_TILEGX
69#define EM_TILEGX 191
70#endif
71
tomfb7bcde2005-11-07 15:24:38 +000072/* Report fatal errors */
sewardj8813eef2006-01-17 16:41:34 +000073__attribute__((noreturn))
tomfb7bcde2005-11-07 15:24:38 +000074static void barf ( const char *format, ... )
sewardj45f4e7c2005-09-27 19:20:21 +000075{
tomfb7bcde2005-11-07 15:24:38 +000076 va_list vargs;
77
78 va_start(vargs, format);
79 fprintf(stderr, "valgrind: Cannot continue: ");
80 vfprintf(stderr, format, vargs);
81 fprintf(stderr, "\n");
82 va_end(vargs);
83
sewardj45f4e7c2005-09-27 19:20:21 +000084 exit(1);
sewardj8813eef2006-01-17 16:41:34 +000085 /*NOTREACHED*/
86 assert(0);
sewardj45f4e7c2005-09-27 19:20:21 +000087}
88
tomfb7bcde2005-11-07 15:24:38 +000089/* Search the path for the client program */
90static const char *find_client(const char *clientname)
91{
florianb593be32013-09-30 18:36:31 +000092 char *fullname;
tomfb7bcde2005-11-07 15:24:38 +000093 const char *path = getenv("PATH");
94 const char *colon;
95
florianb593be32013-09-30 18:36:31 +000096 assert(clientname != NULL);
97
98 if (path == NULL) return clientname;
99
florian1ae53532013-01-26 16:32:18 +0000100 /* Make the size of the FULLNAME buffer large enough. */
101 unsigned need = strlen(path) + strlen("/") + strlen(clientname) + 1;
102
103 fullname = malloc(need);
104 if (fullname == NULL)
105 barf("malloc of fullname failed.");
106
tomfb7bcde2005-11-07 15:24:38 +0000107 while (path)
108 {
109 if ((colon = strchr(path, ':')) == NULL)
110 {
111 strcpy(fullname, path);
112 path = NULL;
113 }
114 else
115 {
florian1ae53532013-01-26 16:32:18 +0000116 strncpy(fullname, path, colon - path);
tomfb7bcde2005-11-07 15:24:38 +0000117 fullname[colon - path] = '\0';
118 path = colon + 1;
119 }
120
121 strcat(fullname, "/");
122 strcat(fullname, clientname);
123
124 if (access(fullname, R_OK|X_OK) == 0)
125 return fullname;
126 }
florianb593be32013-09-30 18:36:31 +0000127 free(fullname);
tomfb7bcde2005-11-07 15:24:38 +0000128
129 return clientname;
130}
131
132/* Examine the client and work out which platform it is for */
133static const char *select_platform(const char *clientname)
134{
135 int fd;
florian19f91bb2012-11-10 22:29:54 +0000136 char header[4096];
njn58899e82009-06-30 06:06:14 +0000137 ssize_t n_bytes;
tomfb7bcde2005-11-07 15:24:38 +0000138 const char *platform = NULL;
139
tom1edc55a2009-08-20 07:56:45 +0000140 VG_(debugLog)(2, "launcher", "selecting platform for '%s'\n", clientname);
141
tomfb7bcde2005-11-07 15:24:38 +0000142 if (strchr(clientname, '/') == NULL)
143 clientname = find_client(clientname);
144
tom1edc55a2009-08-20 07:56:45 +0000145 VG_(debugLog)(2, "launcher", "selecting platform for '%s'\n", clientname);
146
tomfb7bcde2005-11-07 15:24:38 +0000147 if ((fd = open(clientname, O_RDONLY)) < 0)
148 return NULL;
149 // barf("open(%s): %s", clientname, strerror(errno));
150
tom1edc55a2009-08-20 07:56:45 +0000151 VG_(debugLog)(2, "launcher", "opened '%s'\n", clientname);
152
njn58899e82009-06-30 06:06:14 +0000153 n_bytes = read(fd, header, sizeof(header));
tomfb7bcde2005-11-07 15:24:38 +0000154 close(fd);
njn58899e82009-06-30 06:06:14 +0000155 if (n_bytes < 2) {
njn33e57a72009-06-29 06:57:30 +0000156 return NULL;
157 }
tomfb7bcde2005-11-07 15:24:38 +0000158
sewardj6431e302009-08-27 23:22:39 +0000159 VG_(debugLog)(2, "launcher", "read %ld bytes from '%s'\n",
160 (long int)n_bytes, clientname);
tom1edc55a2009-08-20 07:56:45 +0000161
tomfb7bcde2005-11-07 15:24:38 +0000162 if (header[0] == '#' && header[1] == '!') {
njn58899e82009-06-30 06:06:14 +0000163 int i = 2;
tomfb7bcde2005-11-07 15:24:38 +0000164
florian695dde82015-04-06 14:29:45 +0000165 STATIC_ASSERT(VKI_BINPRM_BUF_SIZE < sizeof header);
166 if (n_bytes > VKI_BINPRM_BUF_SIZE)
167 n_bytes = VKI_BINPRM_BUF_SIZE - 1;
168 header[n_bytes] = '\0';
169 char *eol = strchr(header, '\n');
170 if (eol != NULL)
171 *eol = '\0';
172
njn58899e82009-06-30 06:06:14 +0000173 // Skip whitespace.
florian695dde82015-04-06 14:29:45 +0000174 while (header[i] == ' '|| header[i] == '\t')
njn58899e82009-06-30 06:06:14 +0000175 i++;
tomfb7bcde2005-11-07 15:24:38 +0000176
njn58899e82009-06-30 06:06:14 +0000177 // Get the interpreter name.
florian695dde82015-04-06 14:29:45 +0000178 const char *interp = header + i;
179
180 if (header[i] == '\0') {
181 // No interpreter was found; fall back to default shell
182# if defined(VGPV_arm_linux_android) \
183 || defined(VGPV_x86_linux_android) \
184 || defined(VGPV_mips32_linux_android) \
185 || defined(VGPV_arm64_linux_android)
186 interp = "/system/bin/sh";
187# else
188 interp = "/bin/sh";
189# endif
190 } else {
191 while (header[i]) {
192 if (header[i] == ' ' || header[i] == '\t') break;
193 i++;
194 }
195 header[i] = '\0';
njn58899e82009-06-30 06:06:14 +0000196 }
tomfb7bcde2005-11-07 15:24:38 +0000197
198 platform = select_platform(interp);
tomfb7bcde2005-11-07 15:24:38 +0000199
njn58899e82009-06-30 06:06:14 +0000200 } else if (n_bytes >= SELFMAG && memcmp(header, ELFMAG, SELFMAG) == 0) {
201
202 if (n_bytes >= sizeof(Elf32_Ehdr) && header[EI_CLASS] == ELFCLASS32) {
cerion21082042005-12-06 19:07:08 +0000203 const Elf32_Ehdr *ehdr = (Elf32_Ehdr *)header;
tomfb7bcde2005-11-07 15:24:38 +0000204
cerion21082042005-12-06 19:07:08 +0000205 if (header[EI_DATA] == ELFDATA2LSB) {
206 if (ehdr->e_machine == EM_386 &&
tom4ff8f6c2009-08-18 14:12:48 +0000207 (ehdr->e_ident[EI_OSABI] == ELFOSABI_SYSV ||
208 ehdr->e_ident[EI_OSABI] == ELFOSABI_LINUX)) {
cerion21082042005-12-06 19:07:08 +0000209 platform = "x86-linux";
210 }
sewardj59570ff2010-01-01 11:59:33 +0000211 else
212 if (ehdr->e_machine == EM_ARM &&
213 (ehdr->e_ident[EI_OSABI] == ELFOSABI_SYSV ||
214 ehdr->e_ident[EI_OSABI] == ELFOSABI_LINUX)) {
215 platform = "arm-linux";
216 }
sewardj5db15402012-06-07 09:13:21 +0000217 else
218 if (ehdr->e_machine == EM_MIPS &&
219 (ehdr->e_ident[EI_OSABI] == ELFOSABI_SYSV ||
220 ehdr->e_ident[EI_OSABI] == ELFOSABI_LINUX)) {
221 platform = "mips32-linux";
222 }
cerion21082042005-12-06 19:07:08 +0000223 }
224 else if (header[EI_DATA] == ELFDATA2MSB) {
225 if (ehdr->e_machine == EM_PPC &&
tom4ff8f6c2009-08-18 14:12:48 +0000226 (ehdr->e_ident[EI_OSABI] == ELFOSABI_SYSV ||
227 ehdr->e_ident[EI_OSABI] == ELFOSABI_LINUX)) {
cerion21082042005-12-06 19:07:08 +0000228 platform = "ppc32-linux";
229 }
sewardj5db15402012-06-07 09:13:21 +0000230 else
231 if (ehdr->e_machine == EM_MIPS &&
232 (ehdr->e_ident[EI_OSABI] == ELFOSABI_SYSV ||
233 ehdr->e_ident[EI_OSABI] == ELFOSABI_LINUX)) {
234 platform = "mips32-linux";
235 }
cerion21082042005-12-06 19:07:08 +0000236 }
sewardj59570ff2010-01-01 11:59:33 +0000237
njn58899e82009-06-30 06:06:14 +0000238 } else if (n_bytes >= sizeof(Elf64_Ehdr) && header[EI_CLASS] == ELFCLASS64) {
cerion21082042005-12-06 19:07:08 +0000239 const Elf64_Ehdr *ehdr = (Elf64_Ehdr *)header;
240
241 if (header[EI_DATA] == ELFDATA2LSB) {
242 if (ehdr->e_machine == EM_X86_64 &&
tom4ff8f6c2009-08-18 14:12:48 +0000243 (ehdr->e_ident[EI_OSABI] == ELFOSABI_SYSV ||
244 ehdr->e_ident[EI_OSABI] == ELFOSABI_LINUX)) {
cerion21082042005-12-06 19:07:08 +0000245 platform = "amd64-linux";
petarj4df0bfc2013-02-27 23:17:33 +0000246 } else if (ehdr->e_machine == EM_MIPS &&
247 (ehdr->e_ident[EI_OSABI] == ELFOSABI_SYSV ||
248 ehdr->e_ident[EI_OSABI] == ELFOSABI_LINUX)) {
249 platform = "mips64-linux";
sewardj112711a2015-04-10 12:30:09 +0000250 } else if (ehdr->e_machine == EM_TILEGX &&
251 (ehdr->e_ident[EI_OSABI] == ELFOSABI_SYSV ||
252 ehdr->e_ident[EI_OSABI] == ELFOSABI_LINUX)) {
253 platform = "tilegx-linux";
sewardjf0c12502014-01-12 12:54:00 +0000254 } else if (ehdr->e_machine == EM_AARCH64 &&
255 (ehdr->e_ident[EI_OSABI] == ELFOSABI_SYSV ||
256 ehdr->e_ident[EI_OSABI] == ELFOSABI_LINUX)) {
257 platform = "arm64-linux";
carll582d5822014-08-07 23:35:54 +0000258 } else if (ehdr->e_machine == EM_PPC64 &&
259 (ehdr->e_ident[EI_OSABI] == ELFOSABI_SYSV ||
260 ehdr->e_ident[EI_OSABI] == ELFOSABI_LINUX)) {
261 platform = "ppc64le-linux";
cerion21082042005-12-06 19:07:08 +0000262 }
263 } else if (header[EI_DATA] == ELFDATA2MSB) {
dejanj9c6b05d2013-12-27 09:06:55 +0000264# if !defined(VGPV_arm_linux_android) \
265 && !defined(VGPV_x86_linux_android) \
sewardj26ed4192014-11-04 17:44:21 +0000266 && !defined(VGPV_mips32_linux_android) \
267 && !defined(VGPV_arm64_linux_android)
cerion21082042005-12-06 19:07:08 +0000268 if (ehdr->e_machine == EM_PPC64 &&
tom4ff8f6c2009-08-18 14:12:48 +0000269 (ehdr->e_ident[EI_OSABI] == ELFOSABI_SYSV ||
270 ehdr->e_ident[EI_OSABI] == ELFOSABI_LINUX)) {
carllcae0cc22014-08-07 23:17:29 +0000271 platform = "ppc64be-linux";
sewardjca8d94a2011-07-12 10:59:27 +0000272 }
273 else
274 if (ehdr->e_machine == EM_S390 &&
275 (ehdr->e_ident[EI_OSABI] == ELFOSABI_SYSV ||
276 ehdr->e_ident[EI_OSABI] == ELFOSABI_LINUX)) {
sewardjb5b87402011-03-07 16:05:35 +0000277 platform = "s390x-linux";
petarj4df0bfc2013-02-27 23:17:33 +0000278 } else if (ehdr->e_machine == EM_MIPS &&
279 (ehdr->e_ident[EI_OSABI] == ELFOSABI_SYSV ||
280 ehdr->e_ident[EI_OSABI] == ELFOSABI_LINUX)) {
281 platform = "mips64-linux";
cerion21082042005-12-06 19:07:08 +0000282 }
sewardjca8d94a2011-07-12 10:59:27 +0000283# endif
cerion21082042005-12-06 19:07:08 +0000284 }
tomfb7bcde2005-11-07 15:24:38 +0000285 }
286 }
287
tom1edc55a2009-08-20 07:56:45 +0000288 VG_(debugLog)(2, "launcher", "selected platform '%s'\n",
289 platform ? platform : "unknown");
290
tomfb7bcde2005-11-07 15:24:38 +0000291 return platform;
292}
293
sewardj45f4e7c2005-09-27 19:20:21 +0000294/* Where we expect to find all our aux files */
295static const char *valgrind_lib = VG_LIBDIR;
296
297int main(int argc, char** argv, char** envp)
298{
299 int i, j, loglevel, r;
300 const char *toolname = NULL;
tomfb7bcde2005-11-07 15:24:38 +0000301 const char *clientname = NULL;
302 const char *platform;
sewardj8813eef2006-01-17 16:41:34 +0000303 const char *default_platform;
sewardj45f4e7c2005-09-27 19:20:21 +0000304 const char *cp;
305 char *toolfile;
florian0c89e9b2014-10-09 19:22:44 +0000306 const char *launcher_name;
sewardj45f4e7c2005-09-27 19:20:21 +0000307 char* new_line;
308 char** new_env;
309
310 /* Start the debugging-log system ASAP. First find out how many
311 "-d"s were specified. This is a pre-scan of the command line.
312 At the same time, look for the tool name. */
313 loglevel = 0;
314 for (i = 1; i < argc; i++) {
tomfb7bcde2005-11-07 15:24:38 +0000315 if (argv[i][0] != '-') {
316 clientname = argv[i];
sewardj45f4e7c2005-09-27 19:20:21 +0000317 break;
tomfb7bcde2005-11-07 15:24:38 +0000318 }
319 if (0 == strcmp(argv[i], "--")) {
320 if (i+1 < argc)
321 clientname = argv[i+1];
sewardj45f4e7c2005-09-27 19:20:21 +0000322 break;
tomfb7bcde2005-11-07 15:24:38 +0000323 }
sewardj45f4e7c2005-09-27 19:20:21 +0000324 if (0 == strcmp(argv[i], "-d"))
325 loglevel++;
326 if (0 == strncmp(argv[i], "--tool=", 7))
327 toolname = argv[i] + 7;
328 }
329
330 /* ... and start the debug logger. Now we can safely emit logging
331 messages all through startup. */
332 VG_(debugLog_startup)(loglevel, "Stage 1");
333
334 /* Make sure we know which tool we're using */
335 if (toolname) {
336 VG_(debugLog)(1, "launcher", "tool '%s' requested\n", toolname);
337 } else {
338 VG_(debugLog)(1, "launcher",
339 "no tool requested, defaulting to 'memcheck'\n");
340 toolname = "memcheck";
341 }
342
sewardj8813eef2006-01-17 16:41:34 +0000343 /* Select a platform to use if we can't decide that by looking at
344 the executable (eg because it's a shell script). Note that the
345 default_platform is not necessarily either the primary or
346 secondary build target. Instead it's chosen to maximise the
347 chances that /bin/sh will work on it. Hence for a primary
348 target of ppc64-linux we still choose ppc32-linux as the default
349 target, because on most ppc64-linux setups, the basic /bin,
350 /usr/bin, etc, stuff is built in 32-bit mode, not 64-bit
351 mode. */
sewardjf0c12502014-01-12 12:54:00 +0000352 if ((0==strcmp(VG_PLATFORM,"x86-linux")) ||
353 (0==strcmp(VG_PLATFORM,"amd64-linux")) ||
354 (0==strcmp(VG_PLATFORM,"ppc32-linux")) ||
carllcae0cc22014-08-07 23:17:29 +0000355 (0==strcmp(VG_PLATFORM,"ppc64be-linux")) ||
carll582d5822014-08-07 23:35:54 +0000356 (0==strcmp(VG_PLATFORM,"ppc64le-linux")) ||
sewardjf0c12502014-01-12 12:54:00 +0000357 (0==strcmp(VG_PLATFORM,"arm-linux")) ||
358 (0==strcmp(VG_PLATFORM,"arm64-linux")) ||
359 (0==strcmp(VG_PLATFORM,"s390x-linux")) ||
sewardj112711a2015-04-10 12:30:09 +0000360 (0==strcmp(VG_PLATFORM,"tilegx-linux")) ||
petarj4df0bfc2013-02-27 23:17:33 +0000361 (0==strcmp(VG_PLATFORM,"mips32-linux")) ||
362 (0==strcmp(VG_PLATFORM,"mips64-linux")))
njn4f350d12009-02-06 05:34:19 +0000363 default_platform = VG_PLATFORM;
sewardj8813eef2006-01-17 16:41:34 +0000364 else
365 barf("Unknown VG_PLATFORM '%s'", VG_PLATFORM);
366
367 /* Work out what platform to use, or use the default platform if
368 not possible. */
tomfb7bcde2005-11-07 15:24:38 +0000369 if (clientname == NULL) {
sewardj8813eef2006-01-17 16:41:34 +0000370 VG_(debugLog)(1, "launcher",
371 "no client specified, defaulting platform to '%s'\n",
372 default_platform);
373 platform = default_platform;
tomfb7bcde2005-11-07 15:24:38 +0000374 } else if ((platform = select_platform(clientname)) != NULL) {
375 VG_(debugLog)(1, "launcher", "selected platform '%s'\n", platform);
376 } else {
sewardj8813eef2006-01-17 16:41:34 +0000377 VG_(debugLog)(1, "launcher",
378 "no platform detected, defaulting platform to '%s'\n",
379 default_platform);
380 platform = default_platform;
tomfb7bcde2005-11-07 15:24:38 +0000381 }
382
sewardj45f4e7c2005-09-27 19:20:21 +0000383 /* Figure out the name of this executable (viz, the launcher), so
384 we can tell stage2. stage2 will use the name for recursive
njn58899e82009-06-30 06:06:14 +0000385 invocations of valgrind on child processes. */
florian0c89e9b2014-10-09 19:22:44 +0000386 unsigned bufsiz = 0;
387 char *buf = NULL;
388
389 while (42) {
390 bufsiz += 500;
391 buf = realloc(buf, bufsiz);
392 if (buf == NULL)
393 barf("realloc of buf failed.");
394 r = readlink("/proc/self/exe", buf, bufsiz);
395 if (r == -1) {
396 /* If /proc/self/exe can't be followed, don't give up. Instead
397 continue with an empty string for VALGRIND_LAUNCHER. In the
398 sys_execve wrapper, this is tested, and if found to be empty,
399 fail the execve. */
400 fprintf(stderr, "valgrind: warning (non-fatal): "
401 "readlink(\"/proc/self/exe\") failed.\n");
402 fprintf(stderr, "valgrind: continuing, however --trace-children=yes "
403 "will not work.\n");
404 launcher_name = "";
405 break;
406 }
407 if (r == bufsiz) continue; // buffer to small; retry
408
409 assert(r < bufsiz); // paranoia
410
411 buf[r] = '\0';
412 launcher_name = buf;
413 break;
sewardj98e68a42005-10-04 23:07:33 +0000414 }
sewardj45f4e7c2005-09-27 19:20:21 +0000415
416 /* tediously augment the env: VALGRIND_LAUNCHER=launcher_name */
417 new_line = malloc(strlen(VALGRIND_LAUNCHER) + 1
418 + strlen(launcher_name) + 1);
419 if (new_line == NULL)
420 barf("malloc of new_line failed.");
421 strcpy(new_line, VALGRIND_LAUNCHER);
422 strcat(new_line, "=");
423 strcat(new_line, launcher_name);
424
425 for (j = 0; envp[j]; j++)
426 ;
427 new_env = malloc((j+2) * sizeof(char*));
428 if (new_env == NULL)
429 barf("malloc of new_env failed.");
430 for (i = 0; i < j; i++)
431 new_env[i] = envp[i];
432 new_env[i++] = new_line;
433 new_env[i++] = NULL;
434 assert(i == j+2);
435
436 /* Establish the correct VALGRIND_LIB. */
437 cp = getenv(VALGRIND_LIB);
438
439 if (cp != NULL)
440 valgrind_lib = cp;
441
njn58899e82009-06-30 06:06:14 +0000442 /* Build the stage2 invocation, and execve it. Bye! */
tomfb7bcde2005-11-07 15:24:38 +0000443 toolfile = malloc(strlen(valgrind_lib) + strlen(toolname) + strlen(platform) + 3);
sewardj45f4e7c2005-09-27 19:20:21 +0000444 if (toolfile == NULL)
445 barf("malloc of toolfile failed.");
njn6bf365c2009-02-11 00:35:45 +0000446 sprintf(toolfile, "%s/%s-%s", valgrind_lib, toolname, platform);
sewardj45f4e7c2005-09-27 19:20:21 +0000447
448 VG_(debugLog)(1, "launcher", "launching %s\n", toolfile);
449
450 execve(toolfile, argv, new_env);
451
tomfb7bcde2005-11-07 15:24:38 +0000452 fprintf(stderr, "valgrind: failed to start tool '%s' for platform '%s': %s\n",
453 toolname, platform, strerror(errno));
sewardj45f4e7c2005-09-27 19:20:21 +0000454
455 exit(1);
456}