|
From: <sv...@va...> - 2006-01-17 16:41:40
|
Author: sewardj
Date: 2006-01-17 16:41:34 +0000 (Tue, 17 Jan 2006)
New Revision: 5543
Log:
Make the selection of the default platform a bit more sophisticated,
so it does the right thing on ppc64-linux rigs.
Modified:
trunk/coregrind/launcher.c
Modified: trunk/coregrind/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/launcher.c 2006-01-17 15:09:07 UTC (rev 5542)
+++ trunk/coregrind/launcher.c 2006-01-17 16:41:34 UTC (rev 5543)
@@ -59,6 +59,7 @@
#endif
=20
/* Report fatal errors */
+__attribute__((noreturn))
static void barf ( const char *format, ... )
{
va_list vargs;
@@ -70,6 +71,8 @@
va_end(vargs);
=20
exit(1);
+ /*NOTREACHED*/
+ assert(0);
}
=20
/* Search the path for the client program */
@@ -185,6 +188,7 @@
const char *toolname =3D NULL;
const char *clientname =3D NULL;
const char *platform;
+ const char *default_platform;
const char *cp;
char *toolfile;
char launcher_name[PATH_MAX+1];
@@ -224,15 +228,40 @@
toolname =3D "memcheck";
}
=20
- /* 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=3D=3Dstrcmp(VG_PLATFORM,"x86-linux"))
+ default_platform =3D "x86-linux";
+ else if (0=3D=3Dstrcmp(VG_PLATFORM,"amd64-linux"))
+ default_platform =3D "amd64-linux";
+ else if (0=3D=3Dstrcmp(VG_PLATFORM,"ppc32-linux"))
+ default_platform =3D "ppc32-linux";
+ else if (0=3D=3Dstrcmp(VG_PLATFORM,"ppc64-linux"))
+ default_platform =3D "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 =3D=3D NULL) {
- VG_(debugLog)(1, "launcher", "no client specified, defaulting plat=
form to '%s'\n", VG_PLATFORM);
- platform =3D VG_PLATFORM;
+ VG_(debugLog)(1, "launcher",=20
+ "no client specified, defaulting platform to '%s'=
\n",
+ default_platform);
+ platform =3D default_platform;
} else if ((platform =3D select_platform(clientname)) !=3D NULL) {
VG_(debugLog)(1, "launcher", "selected platform '%s'\n", platform)=
;
} else {
- VG_(debugLog)(1, "launcher", "no platform detected, defaulting pla=
tform to '%s'\n", VG_PLATFORM);
- platform =3D VG_PLATFORM;
+ VG_(debugLog)(1, "launcher",=20
+ "no platform detected, defaulting platform to '%s=
'\n",
+ default_platform);
+ platform =3D default_platform;
}
=20
/* Figure out the name of this executable (viz, the launcher), so
|
|
From: Tom H. <to...@co...> - 2006-01-17 16:53:12
|
In message <200...@ja...>
sv...@va... wrote:
> Make the selection of the default platform a bit more sophisticated,
> so it does the right thing on ppc64-linux rigs.
Hmm. The default platform is not normally supposed to kick in just
because you valgrinded a script - in that case it should read the #!
line and find the interpreter and check if it is 32 or 64 bit.
The default platform is mainly used when no client is given (so if
you use --help for example) and was chosen to maximise the chance
that an appropriate valgrind tool existed.
It is also used if platform detection fails for a client, but that
should only happen on an error - client doesn't exist etc - in which
case the tool is just going to print an error and exit anyway.
Tom
--
Tom Hughes (to...@co...)
http://www.compton.nu/
|
|
From: Julian S. <js...@ac...> - 2006-01-17 17:13:39
|
On Tuesday 17 January 2006 16:52, Tom Hughes wrote:
> In message <200...@ja...>
>
> sv...@va... wrote:
> > Make the selection of the default platform a bit more sophisticated,
> > so it does the right thing on ppc64-linux rigs.
>
> Hmm. The default platform is not normally supposed to kick in just
> because you valgrinded a script - in that case it should read the #!
> line and find the interpreter and check if it is 32 or 64 bit.
That's definitely so if the script starts #!. Problem is it was failing
none/tests/shell_valid2. That's a valid script but it doesn't have a
#! line, so what was happening was that the launcher was selecting
ppc64-linux as the default target, then starting V, which decided it
needs to run /bin/sh, which is a 32-bit executable.
On all platforms so far {x86,amd64,ppc32}-linux, /bin/sh has the
same 'flavour' as the platform name (specifically, on amd64 it is
a 64-bit binary), so using VG_PLATFORM worked ok. But on ppc64-linux
it's a 32-bit binary (typically) and so we wind up with a 64-bit Valgrind
trying to run a 32-bit executable, which fails.
The only effect of this change is that on ppc64-linux, the default
platform is chosen to be ppc32-linux.
J
|