#endif
/* Report fatal errors */
+__attribute__((noreturn))
static void barf ( const char *format, ... )
{
va_list vargs;
va_end(vargs);
exit(1);
+ /*NOTREACHED*/
+ assert(0);
}
/* Search the path for the client program */
const char *toolname = NULL;
const char *clientname = NULL;
const char *platform;
+ const char *default_platform;
const char *cp;
char *toolfile;
char launcher_name[PATH_MAX+1];
toolname = "memcheck";
}
- /* Work out what platform to use */
+ /* Select a platform to use if we can't decide that by looking at
+ the executable (eg because it's a shell script). Note that the
+ default_platform is not necessarily either the primary or
+ secondary build target. Instead it's chosen to maximise the
+ chances that /bin/sh will work on it. Hence for a primary
+ target of ppc64-linux we still choose ppc32-linux as the default
+ target, because on most ppc64-linux setups, the basic /bin,
+ /usr/bin, etc, stuff is built in 32-bit mode, not 64-bit
+ mode. */
+ if (0==strcmp(VG_PLATFORM,"x86-linux"))
+ default_platform = "x86-linux";
+ else if (0==strcmp(VG_PLATFORM,"amd64-linux"))
+ default_platform = "amd64-linux";
+ else if (0==strcmp(VG_PLATFORM,"ppc32-linux"))
+ default_platform = "ppc32-linux";
+ else if (0==strcmp(VG_PLATFORM,"ppc64-linux"))
+ default_platform = "ppc32-linux";
+ else
+ barf("Unknown VG_PLATFORM '%s'", VG_PLATFORM);
+
+ /* Work out what platform to use, or use the default platform if
+ not possible. */
if (clientname == NULL) {
- VG_(debugLog)(1, "launcher", "no client specified, defaulting platform to '%s'\n", VG_PLATFORM);
- platform = VG_PLATFORM;
+ VG_(debugLog)(1, "launcher",
+ "no client specified, defaulting platform to '%s'\n",
+ default_platform);
+ platform = default_platform;
} else if ((platform = select_platform(clientname)) != NULL) {
VG_(debugLog)(1, "launcher", "selected platform '%s'\n", platform);
} else {
- VG_(debugLog)(1, "launcher", "no platform detected, defaulting platform to '%s'\n", VG_PLATFORM);
- platform = VG_PLATFORM;
+ VG_(debugLog)(1, "launcher",
+ "no platform detected, defaulting platform to '%s'\n",
+ default_platform);
+ platform = default_platform;
}
/* Figure out the name of this executable (viz, the launcher), so