|
From: <sv...@va...> - 2005-04-04 02:41:47
|
Author: njn
Date: 2005-04-04 03:41:42 +0100 (Mon, 04 Apr 2005)
New Revision: 3516
Modified:
trunk/coregrind/amd64-linux/syscalls.c
trunk/coregrind/amd64/signals.c
trunk/coregrind/core.h
trunk/coregrind/stacktrace.c
trunk/coregrind/vg_scheduler.c
trunk/coregrind/vg_signals.c
trunk/coregrind/vg_syscalls.c
trunk/coregrind/x86-linux/syscalls.c
trunk/coregrind/x86/signals.c
Log:
minor cleanup with the stack-related fields in ThreadState:
- removed "stack_base" which wasn't used in any meaningful way
- added "client_" prefix to make it clear they concern the client's stack
- renamed "stack_size" as "client_stack_szB" to make the units clear
Modified: trunk/coregrind/amd64/signals.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/amd64/signals.c 2005-04-03 20:04:52 UTC (rev 3515)
+++ trunk/coregrind/amd64/signals.c 2005-04-04 02:41:42 UTC (rev 3516)
@@ -377,7 +377,7 @@
ThreadId tid =3D tst->tid;
Segment *stackseg =3D NULL;
=20
- if (VG_(extend_stack)(addr, tst->stack_size)) {
+ if (VG_(extend_stack)(addr, tst->client_stack_szB)) {
stackseg =3D VG_(find_segment)(addr);
if (0 && stackseg)
VG_(printf)("frame=3D%p seg=3D%p-%p\n",
Modified: trunk/coregrind/amd64-linux/syscalls.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/amd64-linux/syscalls.c 2005-04-03 20:04:52 UTC (rev 3=
515)
+++ trunk/coregrind/amd64-linux/syscalls.c 2005-04-04 02:41:42 UTC (rev 3=
516)
@@ -364,9 +364,10 @@
only go down to the start of the mmaped segment. */
seg =3D VG_(find_segment)((Addr)rsp);
if (seg) {
- ctst->stack_base =3D seg->addr;
- ctst->stack_highest_word =3D (Addr)PGROUNDUP(rsp);
- ctst->stack_size =3D ctst->stack_highest_word - ctst->stack_base;
+ ctst->client_stack_base =3D seg->addr;
+ ctst->client_stack_highest_word =3D (Addr)PGROUNDUP(rsp);
+ ctst->client_stack_szB =3D ctst->client_stack_highest_word=20
+ - ctst->client_stack_base;
=20
if (debug)
VG_(printf)("tid %d: guessed client stack range %p-%p\n",
@@ -374,8 +375,8 @@
} else {
VG_(message)(Vg_UserMsg, "!? New thread %d starts with RSP(%p) unm=
apped\n",
ctid, rsp);
- ctst->stack_base =3D 0;
- ctst->stack_size =3D 0;
+ ctst->client_stack_base =3D 0;
+ ctst->client_stack_szB =3D 0;
}
=20
if (flags & VKI_CLONE_SETTLS) {
Modified: trunk/coregrind/core.h
=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/core.h 2005-04-03 20:04:52 UTC (rev 3515)
+++ trunk/coregrind/core.h 2005-04-04 02:41:42 UTC (rev 3516)
@@ -596,7 +596,7 @@
post-syscall function. */
void *tool_pre_syscall_value;
=20
- /* Stacks. When a thread slot is freed, we don't deallocate its
+ /* Client stacks. When a thread slot is freed, we don't deallocate i=
ts
stack; we just leave it lying around for the next use of the
slot. If the next use of the slot requires a larger stack,
only then is the old one deallocated and a new one
@@ -608,18 +608,13 @@
=20
/* The allocated size of this thread's stack (permanently zero
if this is ThreadId =3D=3D 0, since we didn't allocate its stack) =
*/
- UInt stack_size;
+ SizeT client_stack_szB;
=20
- /* Address of the lowest word in this thread's stack. NULL means
- not allocated yet.
- */
- Addr stack_base;
-
/* Address of the highest legitimate word in this stack. This is
used for error messages only -- not critical for execution
correctness. Is is set for all stacks, specifically including
ThreadId =3D=3D 0 (the main thread). */
- Addr stack_highest_word;
+ Addr client_stack_highest_word;
=20
/* Alternate signal stack */
vki_stack_t altstack;
Modified: trunk/coregrind/stacktrace.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/stacktrace.c 2005-04-03 20:04:52 UTC (rev 3515)
+++ trunk/coregrind/stacktrace.c 2005-04-04 02:41:42 UTC (rev 3516)
@@ -116,7 +116,7 @@
Addr ip =3D INSTR_PTR(tst->arch);
Addr fp =3D FRAME_PTR(tst->arch);
Addr sp =3D STACK_PTR(tst->arch);
- Addr stack_highest_word =3D tst->stack_highest_word;
+ Addr stack_highest_word =3D tst->client_stack_highest_word;
=20
#ifdef __x86__
/* Nasty little hack to deal with sysinfo syscalls - if libc is
Modified: trunk/coregrind/vg_scheduler.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/vg_scheduler.c 2005-04-03 20:04:52 UTC (rev 3515)
+++ trunk/coregrind/vg_scheduler.c 2005-04-04 02:41:42 UTC (rev 3516)
@@ -144,7 +144,7 @@
if (VG_(threads)[tid].status =3D=3D VgTs_Empty) continue;
=20
if ( p ( STACK_PTR(VG_(threads)[tid].arch),
- VG_(threads)[tid].stack_highest_word, d ) )
+ VG_(threads)[tid].client_stack_highest_word, d ) )
return tid;
}
return VG_INVALID_THREADID;
@@ -350,16 +350,6 @@
vg_assert(VG_(is_running_thread)(tid));
vg_assert(VG_(is_exiting)(tid));
=20
- /* It's stack is now off-limits
-
- XXX Don't do this - the client thread implementation can touch
- the stack after thread death... */
- if (0 && VG_(threads)[tid].stack_base) {
- Segment *seg =3D VG_(find_segment)( VG_(threads)[tid].stack_base )=
;
- if (seg)
- VG_TRACK( die_mem_stack, seg->addr, seg->len );
- }
-
VGA_(cleanup_thread)( &VG_(threads)[tid].arch );
=20
mostly_clear_thread_record(tid);
@@ -627,10 +617,9 @@
VGA_(os_state_init)(&VG_(threads)[i]);
mostly_clear_thread_record(i);
=20
- VG_(threads)[i].status =3D VgTs_Empty;
- VG_(threads)[i].stack_size =3D 0;
- VG_(threads)[i].stack_base =3D (Addr)NULL;
- VG_(threads)[i].stack_highest_word =3D (Addr)NULL;
+ VG_(threads)[i].status =3D VgTs_Empty;
+ VG_(threads)[i].client_stack_szB =3D 0;
+ VG_(threads)[i].client_stack_highest_word =3D (Addr)NULL;
}
=20
tid_main =3D VG_(alloc_ThreadState)();
@@ -638,9 +627,9 @@
VG_(master_tid) =3D tid_main;
=20
/* Initial thread's stack is the original process stack */
- VG_(threads)[tid_main].stack_highest_word =3D VG_(clstk_end) - sizeof=
(UInt);
- VG_(threads)[tid_main].stack_base =3D VG_(clstk_base);
- VG_(threads)[tid_main].stack_size =3D VG_(client_rlimit_stack).rlim_c=
ur;
+ VG_(threads)[tid_main].client_stack_highest_word=20
+ =3D VG_(clstk_end) - sizeof(=
UInt);
+ VG_(threads)[tid_main].client_stack_szB =3D VG_(client_rlimit_stack)=
.rlim_cur;
=20
VG_(atfork)(NULL, NULL, sched_fork_cleanup);
}
Modified: trunk/coregrind/vg_signals.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/vg_signals.c 2005-04-03 20:04:52 UTC (rev 3515)
+++ trunk/coregrind/vg_signals.c 2005-04-04 02:41:42 UTC (rev 3516)
@@ -1842,7 +1842,7 @@
then extend the stack segment.=20
*/
Addr base =3D PGROUNDDN(esp - VGA_STACK_REDZONE_SIZE);
- if (VG_(extend_stack)(base, VG_(threads)[tid].stack_size)) {
+ if (VG_(extend_stack)(base, VG_(threads)[tid].client_stack_szB)) {
if (VG_(clo_trace_signals))
VG_(message)(Vg_DebugMsg,=20
" -> extended stack base to %p", PGROUNDDN(fault));
Modified: trunk/coregrind/vg_syscalls.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/vg_syscalls.c 2005-04-03 20:04:52 UTC (rev 3515)
+++ trunk/coregrind/vg_syscalls.c 2005-04-04 02:41:42 UTC (rev 3516)
@@ -5004,7 +5004,7 @@
SET_RESULT( -VKI_EPERM );
}
else {
- VG_(threads)[tid].stack_size =3D ((struct vki_rlimit *)ARG2)->r=
lim_cur;
+ VG_(threads)[tid].client_stack_szB =3D ((struct vki_rlimit *)A=
RG2)->rlim_cur;
VG_(client_rlimit_stack) =3D *(struct vki_rlimit *)ARG2;
SET_RESULT( 0 );
}
Modified: trunk/coregrind/x86/signals.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/x86/signals.c 2005-04-03 20:04:52 UTC (rev 3515)
+++ trunk/coregrind/x86/signals.c 2005-04-04 02:41:42 UTC (rev 3516)
@@ -397,7 +397,7 @@
ThreadId tid =3D tst->tid;
Segment *stackseg =3D NULL;
=20
- if (VG_(extend_stack)(addr, tst->stack_size)) {
+ if (VG_(extend_stack)(addr, tst->client_stack_szB)) {
stackseg =3D VG_(find_segment)(addr);
if (0 && stackseg)
VG_(printf)("frame=3D%p seg=3D%p-%p\n",
Modified: trunk/coregrind/x86-linux/syscalls.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/x86-linux/syscalls.c 2005-04-03 20:04:52 UTC (rev 351=
5)
+++ trunk/coregrind/x86-linux/syscalls.c 2005-04-04 02:41:42 UTC (rev 351=
6)
@@ -358,9 +358,8 @@
only go down to the start of the mmaped segment. */
seg =3D VG_(find_segment)((Addr)esp);
if (seg) {
- ctst->stack_base =3D seg->addr;
- ctst->stack_highest_word =3D (Addr)PGROUNDUP(esp);
- ctst->stack_size =3D ctst->stack_highest_word - ctst->stack_base;
+ ctst->client_stack_highest_word =3D (Addr)PGROUNDUP(esp);
+ ctst->client_stack_szB =3D ctst->client_stack_highest_word - seg-=
>addr;
=20
if (debug)
VG_(printf)("tid %d: guessed client stack range %p-%p\n",
@@ -368,8 +367,7 @@
} else {
VG_(message)(Vg_UserMsg, "!? New thread %d starts with ESP(%p) unm=
apped\n",
ctid, esp);
- ctst->stack_base =3D 0;
- ctst->stack_size =3D 0;
+ ctst->client_stack_szB =3D 0;
}
=20
if (flags & VKI_CLONE_SETTLS) {
|