|
From: <sv...@va...> - 2005-12-27 14:43:34
|
Author: sewardj
Date: 2005-12-27 14:43:31 +0000 (Tue, 27 Dec 2005)
New Revision: 5448
Log:
Merge r5368 (More space for debugger cmd line (Dan Thaler))
Modified:
branches/VALGRIND_3_1_BRANCH/coregrind/m_debugger.c
Modified: branches/VALGRIND_3_1_BRANCH/coregrind/m_debugger.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
--- branches/VALGRIND_3_1_BRANCH/coregrind/m_debugger.c 2005-12-27 14:06:=
03 UTC (rev 5447)
+++ branches/VALGRIND_3_1_BRANCH/coregrind/m_debugger.c 2005-12-27 14:43:=
31 UTC (rev 5448)
@@ -36,6 +36,7 @@
#include "pub_core_libcprint.h"
#include "pub_core_libcproc.h"
#include "pub_core_libcsignal.h"
+#include "pub_core_libcassert.h"
#include "pub_core_options.h"
=20
=20
@@ -142,9 +143,10 @@
continue, quit the debugger. */
void VG_(start_debugger) ( ThreadId tid )
{
- Int pid;
+# define N_BUF 4096
+ Int pid;
=20
- if ((pid =3D VG_(fork)()) =3D=3D 0) {
+ if ((pid =3D VG_(fork)()) =3D=3D 0) {
VG_(ptrace)(VKI_PTRACE_TRACEME, 0, NULL, NULL);
VG_(kill)(VG_(getpid)(), VKI_SIGSTOP);
=20
@@ -159,8 +161,8 @@
VG_(ptrace)(VKI_PTRACE_DETACH, pid, NULL, 0) =3D=3D 0)
{
Char pidbuf[15];
- Char file[30];
- Char buf[100];
+ Char file[50];
+ Char buf[N_BUF];
Char *bufptr;
Char *cmdptr;
=20
@@ -171,6 +173,10 @@
cmdptr =3D VG_(clo_db_command);
=20
while (*cmdptr) {
+ /* each iteration can advance bufptr by at most the length
+ of file[], so the following assertion is generously
+ over-paranoid. */
+ vg_assert(bufptr - buf < N_BUF-15-50-10/*paranoia*/);
switch (*cmdptr) {
case '%':
switch (*++cmdptr) {
@@ -179,20 +185,21 @@
bufptr +=3D VG_(strlen)(file);
cmdptr++;
break;
- case 'p':
- VG_(memcpy)(bufptr, pidbuf, VG_(strlen)(pidbuf));
- bufptr +=3D VG_(strlen)(pidbuf);
- cmdptr++;
- break;
- default:
- *bufptr++ =3D *cmdptr++;
- break;
+ case 'p':
+ VG_(memcpy)(bufptr, pidbuf, VG_(strlen)(pidbuf))=
;
+ bufptr +=3D VG_(strlen)(pidbuf);
+ cmdptr++;
+ break;
+ default:
+ *bufptr++ =3D *cmdptr++;
+ break;
}
break;
default:
*bufptr++ =3D *cmdptr++;
break;
}
+ vg_assert(bufptr - buf < N_BUF-15-50-10/*paranoia*/);
}
=20
*bufptr++ =3D '\0';
@@ -212,6 +219,7 @@
VG_(kill)(pid, VKI_SIGKILL);
VG_(waitpid)(pid, &status, 0);
}
+# undef N_BUF
}
=20
=20
|