|
From: <sv...@va...> - 2005-06-17 03:06:33
|
Author: njn
Date: 2005-06-17 04:06:27 +0100 (Fri, 17 Jun 2005)
New Revision: 3919
Log:
Renamed VG_(mark_from_registers) to the more general
VG_(apply_to_GP_regs). Moved it into m_machine.
Modified:
trunk/coregrind/amd64/state.c
trunk/coregrind/core.h
trunk/coregrind/m_machine.c
trunk/coregrind/m_scheduler/scheduler.c
trunk/coregrind/x86/state.c
trunk/include/pub_tool_aspacemgr.h
trunk/include/pub_tool_machine.h
trunk/include/tool.h
trunk/memcheck/mac_leakcheck.c
Modified: trunk/coregrind/amd64/state.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/state.c 2005-06-16 13:14:51 UTC (rev 3918)
+++ trunk/coregrind/amd64/state.c 2005-06-17 03:06:27 UTC (rev 3919)
@@ -86,35 +86,6 @@
=20
=20
/*------------------------------------------------------------*/
-/*--- Thread stuff ---*/
-/*------------------------------------------------------------*/
-
-void VGA_(mark_from_registers)(ThreadId tid, void (*marker)(Addr))
-{
- ThreadState *tst =3D VG_(get_ThreadState)(tid);
- ThreadArchState *arch =3D &tst->arch;
-
- /* XXX ask tool about validity? */
- (*marker)(arch->vex.guest_RAX);
- (*marker)(arch->vex.guest_RCX);
- (*marker)(arch->vex.guest_RDX);
- (*marker)(arch->vex.guest_RBX);
- (*marker)(arch->vex.guest_RSI);
- (*marker)(arch->vex.guest_RDI);
- (*marker)(arch->vex.guest_RSP);
- (*marker)(arch->vex.guest_RBP);
- (*marker)(arch->vex.guest_R8);
- (*marker)(arch->vex.guest_R9);
- (*marker)(arch->vex.guest_R10);
- (*marker)(arch->vex.guest_R11);
- (*marker)(arch->vex.guest_R12);
- (*marker)(arch->vex.guest_R13);
- (*marker)(arch->vex.guest_R14);
- (*marker)(arch->vex.guest_R15);
-}
-
-
-/*------------------------------------------------------------*/
/*--- Debugger-related operations ---*/
/*------------------------------------------------------------*/
=20
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-06-16 13:14:51 UTC (rev 3918)
+++ trunk/coregrind/core.h 2005-06-17 03:06:27 UTC (rev 3919)
@@ -101,9 +101,6 @@
// For attaching the debugger
extern Int VGA_(ptrace_setregs_from_tst) ( Int pid, ThreadArchState* ar=
ch );
=20
-// Used by leakcheck
-extern void VGA_(mark_from_registers)(ThreadId tid, void (*marker)(Addr)=
);
-
/* ---------------------------------------------------------------------
Finally - autoconf-generated settings
------------------------------------------------------------------ */
Modified: trunk/coregrind/m_machine.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_machine.c 2005-06-16 13:14:51 UTC (rev 3918)
+++ trunk/coregrind/m_machine.c 2005-06-17 03:06:27 UTC (rev 3919)
@@ -32,6 +32,7 @@
#include "pub_core_libcassert.h"
#include "pub_core_libcbase.h"
#include "pub_core_machine.h"
+#include "pub_core_scheduler.h"
=20
#define INSTR_PTR(regs) ((regs).vex.VGA_INSTR_PTR)
#define STACK_PTR(regs) ((regs).vex.VGA_STACK_PTR)
@@ -94,6 +95,54 @@
}
=20
=20
+static void apply_to_GPs_of_tid(VexGuestArchState* vex, void (*f)(Addr))
+{
+#if defined(VGA_x86)
+ (*f)(vex->guest_EAX);
+ (*f)(vex->guest_ECX);
+ (*f)(vex->guest_EDX);
+ (*f)(vex->guest_EBX);
+ (*f)(vex->guest_ESI);
+ (*f)(vex->guest_EDI);
+ (*f)(vex->guest_ESP);
+ (*f)(vex->guest_EBP);
+#elif defined(VGA_amd64)
+ (*f)(vex->guest_RAX);
+ (*f)(vex->guest_RCX);
+ (*f)(vex->guest_RDX);
+ (*f)(vex->guest_RBX);
+ (*f)(vex->guest_RSI);
+ (*f)(vex->guest_RDI);
+ (*f)(vex->guest_RSP);
+ (*f)(vex->guest_RBP);
+ (*f)(vex->guest_R8);
+ (*f)(vex->guest_R9);
+ (*f)(vex->guest_R10);
+ (*f)(vex->guest_R11);
+ (*f)(vex->guest_R12);
+ (*f)(vex->guest_R13);
+ (*f)(vex->guest_R14);
+ (*f)(vex->guest_R15);
+#else
+# error Unknown arch
+#endif
+}
+
+
+void VG_(apply_to_GP_regs)(void (*f)(UWord))
+{
+ ThreadId tid;
+
+ for (tid =3D 1; tid < VG_N_THREADS; tid++) {
+ if (VG_(is_valid_tid)(tid)) {
+ ThreadState* tst =3D VG_(get_ThreadState)(tid);
+ apply_to_GPs_of_tid(&(tst->arch.vex), f);
+ }
+ }
+}
+
+
+
/*--------------------------------------------------------------------*/
/*--- end ---*/
/*--------------------------------------------------------------------*/
Modified: trunk/coregrind/m_scheduler/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/m_scheduler/scheduler.c 2005-06-16 13:14:51 UTC (rev =
3918)
+++ trunk/coregrind/m_scheduler/scheduler.c 2005-06-17 03:06:27 UTC (rev =
3919)
@@ -164,17 +164,6 @@
return VG_INVALID_THREADID;
}
=20
-void VG_(mark_from_registers)(void (*mark_addr)(Addr))
-{
- ThreadId tid;
-
- for(tid =3D 1; tid < VG_N_THREADS; tid++) {
- if (!VG_(is_valid_tid)(tid))
- continue;
- VGA_(mark_from_registers)(tid, mark_addr);
- }
-}
-
/* Print the scheduler status. */
void VG_(pp_sched_status) ( void )
{
Modified: trunk/coregrind/x86/state.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/state.c 2005-06-16 13:14:51 UTC (rev 3918)
+++ trunk/coregrind/x86/state.c 2005-06-17 03:06:27 UTC (rev 3919)
@@ -132,27 +132,6 @@
}
=20
/*------------------------------------------------------------*/
-/*--- Thread stuff ---*/
-/*------------------------------------------------------------*/
-
-void VGA_(mark_from_registers)(ThreadId tid, void (*marker)(Addr))
-{
- ThreadState *tst =3D VG_(get_ThreadState)(tid);
- ThreadArchState *arch =3D &tst->arch;
-
- /* XXX ask tool about validity? */
- (*marker)(arch->vex.guest_EAX);
- (*marker)(arch->vex.guest_ECX);
- (*marker)(arch->vex.guest_EDX);
- (*marker)(arch->vex.guest_EBX);
- (*marker)(arch->vex.guest_ESI);
- (*marker)(arch->vex.guest_EDI);
- (*marker)(arch->vex.guest_ESP);
- (*marker)(arch->vex.guest_EBP);
-}
-
-
-/*------------------------------------------------------------*/
/*--- Debugger-related operations ---*/
/*------------------------------------------------------------*/
=20
Modified: trunk/include/pub_tool_aspacemgr.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/include/pub_tool_aspacemgr.h 2005-06-16 13:14:51 UTC (rev 3918)
+++ trunk/include/pub_tool_aspacemgr.h 2005-06-17 03:06:27 UTC (rev 3919)
@@ -49,7 +49,9 @@
/* Calls into the core used by leak-checking */
=20
/* Calls "add_rootrange" with each range of memory which looks like a
- plausible source of root pointers. */
+ plausible source of root pointers. This is very Memcheck-specific --
+ it's used in leak detection.
+*/
extern void VG_(find_root_memory)(void (*add_rootrange)(Addr addr, SizeT=
sz));
=20
#endif // __PUB_TOOL_ASPACEMGR
Modified: trunk/include/pub_tool_machine.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/include/pub_tool_machine.h 2005-06-16 13:14:51 UTC (rev 3918)
+++ trunk/include/pub_tool_machine.h 2005-06-17 03:06:27 UTC (rev 3919)
@@ -64,6 +64,12 @@
extern void VG_(set_shadow_regs_area) ( ThreadId tid, OffT guest_state_o=
ffset,
SizeT size, const UChar* area );
=20
+// Apply a function 'f' to all the general purpose registers in all the
+// current threads.
+// This is very Memcheck-specific -- it's used to find the roots when
+// doing leak checking.
+extern void VG_(apply_to_GP_regs)(void (*f)(UWord val));
+
#endif // __PUB_TOOL_MACHINE
=20
/*--------------------------------------------------------------------*/
Modified: trunk/include/tool.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/include/tool.h 2005-06-16 13:14:51 UTC (rev 3918)
+++ trunk/include/tool.h 2005-06-17 03:06:27 UTC (rev 3919)
@@ -78,9 +78,6 @@
not expected to return. */
extern void VG_(set_fault_catcher)(void (*catcher)(Int sig, Addr addr));
=20
-/* Calls "mark_addr" with register values (which may or may not be point=
ers) */
-extern void VG_(mark_from_registers)(void (*mark_addr)(Addr addr));
-
/* ------------------------------------------------------------------ */
/* other, randomly useful functions */
extern Bool VG_(has_cpuid) ( void );
Modified: trunk/memcheck/mac_leakcheck.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/memcheck/mac_leakcheck.c 2005-06-16 13:14:51 UTC (rev 3918)
+++ trunk/memcheck/mac_leakcheck.c 2005-06-17 03:06:27 UTC (rev 3919)
@@ -37,6 +37,7 @@
#include "pub_tool_libcassert.h"
#include "pub_tool_libcprint.h"
#include "pub_tool_libcsignal.h"
+#include "pub_tool_machine.h"
=20
/* Define to debug the memory-leak-detector. */
#define VG_DEBUG_LEAKCHECK 0
@@ -684,7 +685,7 @@
VG_(find_root_memory)(lc_scan_memory);
=20
/* Push registers onto mark stack */
- VG_(mark_from_registers)(lc_markstack_push);
+ VG_(apply_to_GP_regs)(lc_markstack_push);
=20
/* Keep walking the heap until everything is found */
lc_do_leakcheck(-1);
|