Check the text segment size of the executable and the process. If

not equal, the command line arguments are wrong. E.g.:

$./gcore /bin/sh 1761

$ ./gcore /usr/tmp/chroot/bin/sh 1761
gcore: The executable /usr/tmp/chroot/bin/sh does not belong to process 1761!
Text segment size (in bytes): executable 303104, process 294912
This commit is contained in:
Wolfram Schneider 1998-08-24 16:25:30 +00:00
parent 7a8e920bb9
commit 63d82ffc0e
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=38522
2 changed files with 18 additions and 2 deletions

View file

@ -42,7 +42,7 @@ static const char copyright[] =
static char sccsid[] = "@(#)gcore.c 8.2 (Berkeley) 9/23/93";
#endif
static const char rcsid[] =
"$Id: gcore.c,v 1.6 1997/07/08 11:04:17 charnier Exp $";
"$Id: gcore.c,v 1.7 1997/11/18 03:50:25 jdp Exp $";
#endif /* not lint */
/*
@ -162,6 +162,14 @@ main(argc, argv)
errx(1, "%s exec header: %s",
argv[0], cnt > 0 ? strerror(EIO) : strerror(errno));
/* check the text segment size of the executable and the process */
if (exec.a_text != ptoa(ki->kp_eproc.e_vm.vm_tsize))
errx(1,
"The executable %s does not belong to process %d!\n"
"Text segment size (in bytes): executable %d, process %d",
argv[0], pid, exec.a_text,
ptoa(ki->kp_eproc.e_vm.vm_tsize));
data_offset = N_DATOFF(exec);
if (sflag && kill(pid, SIGSTOP) < 0)

View file

@ -42,7 +42,7 @@ static const char copyright[] =
static char sccsid[] = "@(#)gcore.c 8.2 (Berkeley) 9/23/93";
#endif
static const char rcsid[] =
"$Id: gcore.c,v 1.6 1997/07/08 11:04:17 charnier Exp $";
"$Id: gcore.c,v 1.7 1997/11/18 03:50:25 jdp Exp $";
#endif /* not lint */
/*
@ -162,6 +162,14 @@ main(argc, argv)
errx(1, "%s exec header: %s",
argv[0], cnt > 0 ? strerror(EIO) : strerror(errno));
/* check the text segment size of the executable and the process */
if (exec.a_text != ptoa(ki->kp_eproc.e_vm.vm_tsize))
errx(1,
"The executable %s does not belong to process %d!\n"
"Text segment size (in bytes): executable %d, process %d",
argv[0], pid, exec.a_text,
ptoa(ki->kp_eproc.e_vm.vm_tsize));
data_offset = N_DATOFF(exec);
if (sflag && kill(pid, SIGSTOP) < 0)