|
From: Nicholas N. <nj...@ca...> - 2004-09-07 22:22:57
|
CVS commit by nethercote:
Arch-abstraction:
- factored out the setting of machine registers used when attaching the
debugger.
M +3 -0 core.h 1.15
M +4 -37 vg_main.c 1.206
M +46 -2 x86/state.c 1.3
--- valgrind/coregrind/core.h #1.14:1.15
@@ -1500,4 +1500,7 @@ extern void VGA_(load_state) ( arch_thre
extern void VGA_(save_state) ( arch_thread_t*, ThreadId tid );
+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,
+ struct user_regs_struct* regs );
/* ---------------------------------------------------------------------
--- valgrind/coregrind/vg_main.c #1.205:1.206
@@ -246,41 +246,8 @@ void VG_(start_debugger) ( Int tid )
Int res;
- if (VG_(is_running_thread)( tid )) {
- regs.cs = VG_(baseBlock)[VGOFF_(m_cs)];
- regs.ss = VG_(baseBlock)[VGOFF_(m_ss)];
- regs.ds = VG_(baseBlock)[VGOFF_(m_ds)];
- regs.es = VG_(baseBlock)[VGOFF_(m_es)];
- regs.fs = VG_(baseBlock)[VGOFF_(m_fs)];
- regs.gs = VG_(baseBlock)[VGOFF_(m_gs)];
- regs.eax = VG_(baseBlock)[VGOFF_(m_eax)];
- regs.ebx = VG_(baseBlock)[VGOFF_(m_ebx)];
- regs.ecx = VG_(baseBlock)[VGOFF_(m_ecx)];
- regs.edx = VG_(baseBlock)[VGOFF_(m_edx)];
- regs.esi = VG_(baseBlock)[VGOFF_(m_esi)];
- regs.edi = VG_(baseBlock)[VGOFF_(m_edi)];
- regs.ebp = VG_(baseBlock)[VGOFF_(m_ebp)];
- regs.esp = VG_(baseBlock)[VGOFF_(m_esp)];
- regs.eflags = VG_(baseBlock)[VGOFF_(m_eflags)];
- regs.eip = VG_(baseBlock)[VGOFF_(m_eip)];
- } else {
- ThreadState* tst = & VG_(threads)[ tid ];
-
- regs.cs = tst->arch.m_cs;
- regs.ss = tst->arch.m_ss;
- regs.ds = tst->arch.m_ds;
- regs.es = tst->arch.m_es;
- regs.fs = tst->arch.m_fs;
- regs.gs = tst->arch.m_gs;
- regs.eax = tst->arch.m_eax;
- regs.ebx = tst->arch.m_ebx;
- regs.ecx = tst->arch.m_ecx;
- regs.edx = tst->arch.m_edx;
- regs.esi = tst->arch.m_esi;
- regs.edi = tst->arch.m_edi;
- regs.ebp = tst->arch.m_ebp;
- regs.esp = tst->arch.m_esp;
- regs.eflags = tst->arch.m_eflags;
- regs.eip = tst->arch.m_eip;
- }
+ if (VG_(is_running_thread)( tid ))
+ VGA_(regs_for_ptrace_from_BB)(®s);
+ else
+ VGA_(regs_for_ptrace_from_tst)(&VG_(threads)[tid].arch, ®s);
if ((res = VG_(waitpid)(pid, &status, 0)) == pid &&
--- valgrind/coregrind/x86/state.c #1.2:1.3
@@ -32,5 +32,5 @@
/*------------------------------------------------------------*/
-/*--- baseBlock setup ---*/
+/*--- baseBlock setup and operations ---*/
/*------------------------------------------------------------*/
@@ -448,4 +447,49 @@ n",
}
+/*------------------------------------------------------------*/
+/*--- Debugger-related operations ---*/
+/*------------------------------------------------------------*/
+
+void VGA_(regs_for_ptrace_from_BB)(struct user_regs_struct* regs)
+{
+ regs->cs = VG_(baseBlock)[VGOFF_(m_cs)];
+ regs->ss = VG_(baseBlock)[VGOFF_(m_ss)];
+ regs->ds = VG_(baseBlock)[VGOFF_(m_ds)];
+ regs->es = VG_(baseBlock)[VGOFF_(m_es)];
+ regs->fs = VG_(baseBlock)[VGOFF_(m_fs)];
+ regs->gs = VG_(baseBlock)[VGOFF_(m_gs)];
+ regs->eax = VG_(baseBlock)[VGOFF_(m_eax)];
+ regs->ebx = VG_(baseBlock)[VGOFF_(m_ebx)];
+ regs->ecx = VG_(baseBlock)[VGOFF_(m_ecx)];
+ regs->edx = VG_(baseBlock)[VGOFF_(m_edx)];
+ regs->esi = VG_(baseBlock)[VGOFF_(m_esi)];
+ regs->edi = VG_(baseBlock)[VGOFF_(m_edi)];
+ regs->ebp = VG_(baseBlock)[VGOFF_(m_ebp)];
+ regs->esp = VG_(baseBlock)[VGOFF_(m_esp)];
+ regs->eflags = VG_(baseBlock)[VGOFF_(m_eflags)];
+ regs->eip = VG_(baseBlock)[VGOFF_(m_eip)];
+}
+
+void VGA_(regs_for_ptrace_from_tst)(arch_thread_t *tst,
+ struct user_regs_struct* regs)
+{
+ regs->cs = tst->m_cs;
+ regs->ss = tst->m_ss;
+ regs->ds = tst->m_ds;
+ regs->es = tst->m_es;
+ regs->fs = tst->m_fs;
+ regs->gs = tst->m_gs;
+ regs->eax = tst->m_eax;
+ regs->ebx = tst->m_ebx;
+ regs->ecx = tst->m_ecx;
+ regs->edx = tst->m_edx;
+ regs->esi = tst->m_esi;
+ regs->edi = tst->m_edi;
+ regs->ebp = tst->m_ebp;
+ regs->esp = tst->m_esp;
+ regs->eflags = tst->m_eflags;
+ regs->eip = tst->m_eip;
+}
+
/*--------------------------------------------------------------------*/
/*--- end ---*/
|