From 35805421ec71fda7823ab4efb364d22f873c60e1 Mon Sep 17 00:00:00 2001 From: sewardj Date: Sun, 21 Apr 2002 13:05:34 +0000 Subject: Make the GDB-attach stuff thread-aware, and work (at least partially) when running multithreaded. Can still cause crashes (assertion failures) when GDB exits. I think it that's due to my use of libc's system() call; should roll my own. git-svn-id: svn://svn.valgrind.org/valgrind/trunk@111 a5019735-40e9-0310-863c-91ae7b9d1cf9 --- vg_startup.S | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) (limited to 'vg_startup.S') diff --git a/vg_startup.S b/vg_startup.S index 1215e687..1a3b60fc 100644 --- a/vg_startup.S +++ b/vg_startup.S @@ -175,6 +175,12 @@ VG_(switch_to_real_CPU): /*--- %esp/%ebp and then start up GDB. ---*/ /*------------------------------------------------------------*/ +/* +extern void VG_(swizzle_esp_then_start_GDB) ( Addr m_eip_at_error, + Addr m_esp_at_error, + Addr m_ebp_at_error ); +*/ + /*--- This is clearly not re-entrant! ---*/ .data vg_ebp_saved_over_GDB_start: @@ -190,12 +196,15 @@ VG_(swizzle_esp_then_start_GDB): # remember the simulators current stack/frame pointers movl %ebp, vg_ebp_saved_over_GDB_start movl %esp, vg_esp_saved_over_GDB_start - - movl $VG_(baseBlock), %ebx - # fetch %ESP into %esp - movl VGOFF_(m_esp), %esi - movl (%ebx, %esi, 4), %esp + # get args into regs + movl 44(%esp), %eax # client %EBP + movl 40(%esp), %ebx # client %ESP + movl 36(%esp), %ecx # client %EIP + + # Now thatn we don't need to refer to simulators stack any more, + # put %ESP into %esp + movl %ebx, %esp ### %esp now refers to clients stack ### mess with the clients stack to make it look as if it @@ -203,14 +212,10 @@ VG_(swizzle_esp_then_start_GDB): ### as if the top (currently executing) stack frame of the ### client is missing. - # push %EIP, via %eax. This is a faked-up return address. - movl VGOFF_(m_eip), %esi - movl (%ebx, %esi, 4), %eax - pushl %eax + # push %EIP. This is a faked-up return address. + pushl %ecx - # push %EBP, via %eax. This is a faked %ebp-chain pointer. - movl VGOFF_(m_ebp), %esi - movl (%ebx, %esi, 4), %eax + # push %EBP. This is a faked %ebp-chain pointer. pushl %eax movl %esp, %ebp -- cgit v1.2.3