|
From: <sv...@va...> - 2005-08-14 04:12:48
|
Author: njn
Date: 2005-08-14 05:12:40 +0100 (Sun, 14 Aug 2005)
New Revision: 4402
Log:
Partially evaluate m_stacks.c to simplify and shrink it a bit.
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-08-14 00:59:45 UTC (rev 4401)
+++ trunk/coregrind/m_stacks.c 2005-08-14 04:12:40 UTC (rev 4402)
@@ -95,54 +95,21 @@
* stack pointer falls outside the range of the current stack, we search
* the stacks list above for a matching stack.
*/
-static Addr current_stack_start;
-static Addr current_stack_end;
-static UWord current_stack_id;
+static Stack current_stack;
=20
-/* Search for a particular stack by id number. */
-static Bool find_stack_by_id(UWord id, Addr *start, Addr *end)
-{
- Stack *i =3D stacks;
- while(i) {
- if(i->id =3D=3D id) {
- *start =3D i->start;
- *end =3D i->end;
- return True;
- }
- i =3D i->next;
- }
- return False;
-}
-
/* Find what stack an address falls into. */
-static Bool find_stack_by_addr(Addr sp, Addr *start, Addr *end, UWord *i=
d)
+static Stack* find_stack_by_addr(Addr sp)
{
Stack *i =3D stacks;
- while(i) {
- if(sp >=3D i->start && sp <=3D i->end) {
- *start =3D i->start;
- *end =3D i->end;
- *id =3D i->id;
- return True;
+ while (i) {
+ if (sp >=3D i->start && sp <=3D i->end) {
+ return i;
}
i =3D i->next;
}
- return False;
+ return NULL;
}
=20
-/* Change over to a new stack. */
-static Bool set_current_stack(UWord id)
-{
- Addr start, end;
- if (find_stack_by_id(id, &start, &end)) {
- current_stack_id =3D id;
- current_stack_start =3D start;
- current_stack_end =3D end;
- return True;
- }
- return False;
-}
-
/*
* Register a new stack from start - end. This is invoked from the
* VALGRIND_STACK_REGISTER client request, and is also called just befor=
e
@@ -164,8 +131,8 @@
i->next =3D stacks;
stacks =3D i;
=20
- if(i->id =3D=3D 0) {
- set_current_stack(i->id);
+ if (i->id =3D=3D 0) {
+ current_stack =3D *i;
}
=20
return i->id;
@@ -180,7 +147,7 @@
Stack *i =3D stacks;
Stack *prev =3D NULL;
=20
- if(current_stack_id =3D=3D id) {
+ if (current_stack.id =3D=3D id) {
return;
}
=20
@@ -208,12 +175,12 @@
{
Stack *i =3D stacks;
=20
- if (id =3D=3D current_stack_id) {
- current_stack_start =3D start;
- current_stack_end =3D end;
+ if (id =3D=3D current_stack.id) {
+ current_stack.start =3D start;
+ current_stack.end =3D end;
}
=20
- while(i) {
+ while (i) {
if (i->id =3D=3D id) {
i->start =3D start;
i->end =3D end;
@@ -234,14 +201,12 @@
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) {
- Addr start, end;
- UWord new_id;
- Bool found =3D find_stack_by_addr(new_SP, &start, &end, &new_id);
- if (found && new_id !=3D current_stack_id) {
+ if (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) {
/* The stack pointer is now in another stack. Update the curre=
nt
stack information and return without doing anything else. */
- set_current_stack(new_id);
+ current_stack =3D *new_stack;
return;
}
}
|