173427c57Sahl /*
273427c57Sahl  * CDDL HEADER START
373427c57Sahl  *
473427c57Sahl  * The contents of this file are subject to the terms of the
573427c57Sahl  * Common Development and Distribution License (the "License").
673427c57Sahl  * You may not use this file except in compliance with the License.
773427c57Sahl  *
873427c57Sahl  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
973427c57Sahl  * or http://www.opensolaris.org/os/licensing.
1073427c57Sahl  * See the License for the specific language governing permissions
1173427c57Sahl  * and limitations under the License.
1273427c57Sahl  *
1373427c57Sahl  * When distributing Covered Code, include this CDDL HEADER in each
1473427c57Sahl  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
1573427c57Sahl  * If applicable, add the following below this CDDL HEADER, with the
1673427c57Sahl  * fields enclosed by brackets "[]" replaced with your own identifying
1773427c57Sahl  * information: Portions Copyright [yyyy] [name of copyright owner]
1873427c57Sahl  *
1973427c57Sahl  * CDDL HEADER END
2073427c57Sahl  */
2173427c57Sahl 
2273427c57Sahl /*
2373427c57Sahl  * Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
2473427c57Sahl  * Use is subject to license terms.
2596d600cbSRichard Lowe  *
2696d600cbSRichard Lowe  * Copyright 2011, Richard Lowe
2773427c57Sahl  */
2873427c57Sahl 
2973427c57Sahl #include <alloca.h>
3073427c57Sahl #include <stdio.h>
3173427c57Sahl #include <unistd.h>
3296d600cbSRichard Lowe #include <err.h>
3373427c57Sahl #include <sys/systeminfo.h>
3473427c57Sahl 
3573427c57Sahl int
main(int argc,char ** argv)3673427c57Sahl main(int argc, char **argv)
3773427c57Sahl {
3896d600cbSRichard Lowe 	int i, ac;
3973427c57Sahl 	char **av, **p;
4096d600cbSRichard Lowe 	char isaname[16];
4173427c57Sahl 
4273427c57Sahl 	ac = argc + 3;
4373427c57Sahl 	av = p = alloca(sizeof (char *) * ac);
4473427c57Sahl 
4596d600cbSRichard Lowe 	*p++ = "/usr/java/bin/java";
4673427c57Sahl 	*p++ = "-jar";
4773427c57Sahl 	*p++ = "/opt/SUNWdtrt/lib/java/jdtrace.jar";
4873427c57Sahl 
4973427c57Sahl 	argc--;
5073427c57Sahl 	argv++;
5173427c57Sahl 
5273427c57Sahl 	for (i = 0; i < argc; i++) {
5373427c57Sahl 		p[i] = argv[i];
5473427c57Sahl 	}
5573427c57Sahl 	p[i] = NULL;
5673427c57Sahl 
5796d600cbSRichard Lowe 	if (sysinfo(SI_ARCHITECTURE_64, isaname, sizeof (isaname)) != -1)
58*9850293dSJohn Levon 		(void) asprintf(av, "/usr/java/bin/%s/java", isaname);
5973427c57Sahl 
6096d600cbSRichard Lowe 	(void) execv(av[0], av);
6196d600cbSRichard Lowe 	err(1, "exec failed");
6273427c57Sahl }
63