|
From: Nicholas N. <nj...@ca...> - 2004-09-07 22:38:33
|
CVS commit by nethercote:
Arch-abstraction:
- factored out pointercheck setup.
M +2 -0 core.h 1.16
M +2 -31 vg_main.c 1.207
M +28 -0 x86/state.c 1.4
--- valgrind/coregrind/core.h #1.15:1.16
@@ -1500,4 +1500,6 @@ extern void VGA_(load_state) ( arch_thre
extern void VGA_(save_state) ( arch_thread_t*, ThreadId tid );
+extern Bool VGA_(setup_pointercheck) ( void );
+
extern void VGA_(regs_for_ptrace_from_BB) ( struct user_regs_struct* regs );
extern void VGA_(regs_for_ptrace_from_tst) ( arch_thread_t* arch,
--- valgrind/coregrind/vg_main.c #1.206:1.207
@@ -2260,34 +2260,4 @@ Int VG_(helper_offset)(Addr a)
/*====================================================================*/
-/*=== Setup pointercheck ===*/
-/*====================================================================*/
-
-static void setup_pointercheck(void)
-{
- int ret;
-
- if (VG_(clo_pointercheck)) {
- vki_modify_ldt_t ldt = {
- VG_POINTERCHECK_SEGIDX, // entry_number
- VG_(client_base), // base_addr
- (VG_(client_end)-VG_(client_base)) / VKI_BYTES_PER_PAGE, // limit
- 1, // seg_32bit
- 0, // contents: data, RW, non-expanding
- 0, // ! read_exec_only
- 1, // limit_in_pages
- 0, // ! seg not present
- 1, // useable
- };
- ret = VG_(do_syscall)(__NR_modify_ldt, 1, &ldt, sizeof(ldt));
- if (ret < 0) {
- VG_(message)(Vg_UserMsg,
- "Warning: ignoring --pointercheck=yes, "
- "because modify_ldt failed (errno=%d)", -ret);
- VG_(clo_pointercheck) = False;
- }
- }
-}
-
-/*====================================================================*/
/*=== Initialise program data/text, etc. ===*/
/*====================================================================*/
@@ -2794,5 +2764,6 @@ int main(int argc, char **argv)
// p: process_cmd_line_options() [for VG_(clo_pointercheck)]
//--------------------------------------------------------------
- setup_pointercheck();
+ if (VG_(clo_pointercheck))
+ VG_(clo_pointercheck) = VGA_(setup_pointercheck)();
//--------------------------------------------------------------
--- valgrind/coregrind/x86/state.c #1.3:1.4
@@ -448,4 +448,32 @@ n",
/*------------------------------------------------------------*/
+/*--- pointercheck ---*/
+/*------------------------------------------------------------*/
+
+Bool VGA_(setup_pointercheck)(void)
+{
+ vki_modify_ldt_t ldt = {
+ VG_POINTERCHECK_SEGIDX, // entry_number
+ VG_(client_base), // base_addr
+ (VG_(client_end)-VG_(client_base)) / VKI_BYTES_PER_PAGE, // limit
+ 1, // seg_32bit
+ 0, // contents: data, RW, non-expanding
+ 0, // ! read_exec_only
+ 1, // limit_in_pages
+ 0, // ! seg not present
+ 1, // useable
+ };
+ int ret = VG_(do_syscall)(__NR_modify_ldt, 1, &ldt, sizeof(ldt));
+ if (ret < 0) {
+ VG_(message)(Vg_UserMsg,
+ "Warning: ignoring --pointercheck=yes, "
+ "because modify_ldt failed (errno=%d)", -ret);
+ return False;
+ } else {
+ return True;
+ }
+}
+
+/*------------------------------------------------------------*/
/*--- Debugger-related operations ---*/
/*------------------------------------------------------------*/
|