|
From: <sv...@va...> - 2005-11-10 14:24:14
|
Author: tom
Date: 2005-11-10 14:24:08 +0000 (Thu, 10 Nov 2005)
New Revision: 5069
Log:
Add some extra debugging to the stack management module and simply
it a bit - there is no need to keep a full copy of the current stack
descriptor as we can just keep a pointer to it.
Modified:
trunk/coregrind/m_stacks.c
Modified: trunk/coregrind/m_stacks.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/m_stacks.c 2005-11-10 13:15:31 UTC (rev 5068)
+++ trunk/coregrind/m_stacks.c 2005-11-10 14:24:08 UTC (rev 5069)
@@ -29,6 +29,7 @@
*/
=20
#include "pub_core_basics.h"
+#include "pub_core_debuglog.h"
#include "pub_core_libcprint.h"
#include "pub_core_mallocfree.h"
#include "pub_core_options.h"
@@ -95,7 +96,7 @@
* stack pointer falls outside the range of the current stack, we search
* the stacks list above for a matching stack.
*/
-static Stack current_stack;
+static Stack *current_stack;
=20
/* Find what stack an address falls into. */
static Stack* find_stack_by_addr(Addr sp)
@@ -119,8 +120,6 @@
{
Stack *i;
=20
- if (0) VG_(printf)("REGISTER STACK %p %p\n", start,end);
-
if (start > end) {
Addr t =3D end;
end =3D start;
@@ -135,9 +134,11 @@
stacks =3D i;
=20
if (i->id =3D=3D 0) {
- current_stack =3D *i;
+ current_stack =3D i;
}
=20
+ VG_(debugLog)(2, "stacks", "register %p-%p as stack %d\n", start, end=
, i->id);
+
return i->id;
}
=20
@@ -150,8 +151,10 @@
Stack *i =3D stacks;
Stack *prev =3D NULL;
=20
- if (current_stack.id =3D=3D id) {
- return;
+ VG_(debugLog)(2, "stacks", "deregister stack %d\n", id);
+
+ if (current_stack->id =3D=3D id) {
+ current_stack =3D NULL;
}
=20
while(i) {
@@ -178,13 +181,10 @@
{
Stack *i =3D stacks;
=20
- if (id =3D=3D current_stack.id) {
- current_stack.start =3D start;
- current_stack.end =3D end;
- }
-
while (i) {
if (i->id =3D=3D id) {
+ VG_(debugLog)(2, "stacks", "change stack %d from %p-%p to %p-%p=
\n",
+ id, i->start, i->end, start, end);
i->start =3D start;
i->end =3D end;
return;
@@ -204,12 +204,13 @@
Word delta =3D (Word)new_SP - (Word)old_SP;
=20
/* Check if the stack pointer is still in the same stack as before. *=
/
- if (new_SP < current_stack.start || new_SP > current_stack.end) {
+ if (current_stack =3D=3D NULL ||
+ new_SP < current_stack->start || new_SP > current_stack->end) {
Stack* new_stack =3D find_stack_by_addr(new_SP);
- if (new_stack && new_stack->id !=3D current_stack.id) {
+ if (new_stack && new_stack->id !=3D current_stack->id) {
/* The stack pointer is now in another stack. Update the curre=
nt
stack information and return without doing anything else. */
- current_stack =3D *new_stack;
+ current_stack =3D new_stack;
return;
}
}
|