int* __errno_location ( void )
{
int tid;
- ensure_valgrind("__errno_location");
+ /* ensure_valgrind("__errno_location"); */
VALGRIND_MAGIC_SEQUENCE(tid, 0 /* default */,
VG_USERREQ__PTHREAD_GET_THREADID,
0, 0, 0, 0);
Bool isWriteableLack;
/* ALL */
ThreadId tid;
+ /* ALL */
+ /* These record %EIP, %ESP and %EBP at the error point. They
+ are only used to make GDB-attaching convenient; there is no
+ other purpose; specifically they are not used to do
+ comparisons between errors. */
+ UInt m_eip;
+ UInt m_esp;
+ UInt m_ebp;
}
ErrContext;
clear_AddrInfo ( &ec->addrinfo );
ec->syscall_param = NULL;
ec->isWriteableLack = False;
+ ec->m_eip = 0xDEADB00F;
+ ec->m_esp = 0xDEADBE0F;
+ ec->m_ebp = 0xDEADB0EF;
ec->tid = VG_INVALID_THREADID;
}
vg_n_errs_shown++;
/* Perhaps we want a GDB attach at this point? */
if (vg_is_GDB_attach_requested()) {
- VG_(swizzle_esp_then_start_GDB)();
+ VG_(swizzle_esp_then_start_GDB)(
+ ec->m_eip, ec->m_esp, ec->m_ebp);
}
} else {
vg_n_errs_suppressed++;
ec.ekind = ValueErr;
ec.size = size;
ec.tid = VG_(get_current_tid)();
+ ec.m_eip = VG_(baseBlock)[VGOFF_(m_eip)];
+ ec.m_esp = VG_(baseBlock)[VGOFF_(m_esp)];
+ ec.m_ebp = VG_(baseBlock)[VGOFF_(m_ebp)];
VG_(maybe_add_context) ( &ec );
}
ec.size = size;
ec.addr = a;
ec.tid = VG_(get_current_tid)();
+ ec.m_eip = VG_(baseBlock)[VGOFF_(m_eip)];
+ ec.m_esp = VG_(baseBlock)[VGOFF_(m_esp)];
+ ec.m_ebp = VG_(baseBlock)[VGOFF_(m_ebp)];
VG_(describe_addr) ( a, &ec.addrinfo );
VG_(maybe_add_context) ( &ec );
}
ec.ekind = FreeErr;
ec.addr = a;
ec.tid = tst->tid;
+ ec.m_eip = tst->m_eip;
+ ec.m_esp = tst->m_esp;
+ ec.m_ebp = tst->m_ebp;
VG_(describe_addr) ( a, &ec.addrinfo );
VG_(maybe_add_context) ( &ec );
}
ec.ekind = FreeMismatchErr;
ec.addr = a;
ec.tid = tst->tid;
+ ec.m_eip = tst->m_eip;
+ ec.m_esp = tst->m_esp;
+ ec.m_ebp = tst->m_ebp;
VG_(describe_addr) ( a, &ec.addrinfo );
VG_(maybe_add_context) ( &ec );
}
ec.axskind = ExecAxs;
ec.addr = a;
ec.tid = tst->tid;
+ ec.m_eip = tst->m_eip;
+ ec.m_esp = tst->m_esp;
+ ec.m_ebp = tst->m_ebp;
VG_(describe_addr) ( a, &ec.addrinfo );
VG_(maybe_add_context) ( &ec );
}
ec.ekind = ParamErr;
ec.addr = a;
ec.tid = tst->tid;
+ ec.m_eip = tst->m_eip;
+ ec.m_esp = tst->m_esp;
+ ec.m_ebp = tst->m_ebp;
VG_(describe_addr) ( a, &ec.addrinfo );
ec.syscall_param = msg;
ec.isWriteableLack = isWriteLack;
ec.ekind = UserErr;
ec.addr = a;
ec.tid = tst->tid;
+ ec.m_eip = tst->m_eip;
+ ec.m_esp = tst->m_esp;
+ ec.m_ebp = tst->m_ebp;
VG_(describe_addr) ( a, &ec.addrinfo );
ec.isWriteableLack = isWriteLack;
VG_(maybe_add_context) ( &ec );
extern void VG_(shutdown);
extern void VG_(switch_to_real_CPU) ( void );
-extern void VG_(swizzle_esp_then_start_GDB) ( void );
+extern void VG_(swizzle_esp_then_start_GDB) ( Addr m_eip_at_error,
+ Addr m_esp_at_error,
+ Addr m_ebp_at_error );
/* ---------------------------------------------------------------------
int* __errno_location ( void )
{
int tid;
- ensure_valgrind("__errno_location");
+ /* ensure_valgrind("__errno_location"); */
VALGRIND_MAGIC_SEQUENCE(tid, 0 /* default */,
VG_USERREQ__PTHREAD_GET_THREADID,
0, 0, 0, 0);
/*--- %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:
# 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
### 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
Bool isWriteableLack;
/* ALL */
ThreadId tid;
+ /* ALL */
+ /* These record %EIP, %ESP and %EBP at the error point. They
+ are only used to make GDB-attaching convenient; there is no
+ other purpose; specifically they are not used to do
+ comparisons between errors. */
+ UInt m_eip;
+ UInt m_esp;
+ UInt m_ebp;
}
ErrContext;
clear_AddrInfo ( &ec->addrinfo );
ec->syscall_param = NULL;
ec->isWriteableLack = False;
+ ec->m_eip = 0xDEADB00F;
+ ec->m_esp = 0xDEADBE0F;
+ ec->m_ebp = 0xDEADB0EF;
ec->tid = VG_INVALID_THREADID;
}
vg_n_errs_shown++;
/* Perhaps we want a GDB attach at this point? */
if (vg_is_GDB_attach_requested()) {
- VG_(swizzle_esp_then_start_GDB)();
+ VG_(swizzle_esp_then_start_GDB)(
+ ec->m_eip, ec->m_esp, ec->m_ebp);
}
} else {
vg_n_errs_suppressed++;
ec.ekind = ValueErr;
ec.size = size;
ec.tid = VG_(get_current_tid)();
+ ec.m_eip = VG_(baseBlock)[VGOFF_(m_eip)];
+ ec.m_esp = VG_(baseBlock)[VGOFF_(m_esp)];
+ ec.m_ebp = VG_(baseBlock)[VGOFF_(m_ebp)];
VG_(maybe_add_context) ( &ec );
}
ec.size = size;
ec.addr = a;
ec.tid = VG_(get_current_tid)();
+ ec.m_eip = VG_(baseBlock)[VGOFF_(m_eip)];
+ ec.m_esp = VG_(baseBlock)[VGOFF_(m_esp)];
+ ec.m_ebp = VG_(baseBlock)[VGOFF_(m_ebp)];
VG_(describe_addr) ( a, &ec.addrinfo );
VG_(maybe_add_context) ( &ec );
}
ec.ekind = FreeErr;
ec.addr = a;
ec.tid = tst->tid;
+ ec.m_eip = tst->m_eip;
+ ec.m_esp = tst->m_esp;
+ ec.m_ebp = tst->m_ebp;
VG_(describe_addr) ( a, &ec.addrinfo );
VG_(maybe_add_context) ( &ec );
}
ec.ekind = FreeMismatchErr;
ec.addr = a;
ec.tid = tst->tid;
+ ec.m_eip = tst->m_eip;
+ ec.m_esp = tst->m_esp;
+ ec.m_ebp = tst->m_ebp;
VG_(describe_addr) ( a, &ec.addrinfo );
VG_(maybe_add_context) ( &ec );
}
ec.axskind = ExecAxs;
ec.addr = a;
ec.tid = tst->tid;
+ ec.m_eip = tst->m_eip;
+ ec.m_esp = tst->m_esp;
+ ec.m_ebp = tst->m_ebp;
VG_(describe_addr) ( a, &ec.addrinfo );
VG_(maybe_add_context) ( &ec );
}
ec.ekind = ParamErr;
ec.addr = a;
ec.tid = tst->tid;
+ ec.m_eip = tst->m_eip;
+ ec.m_esp = tst->m_esp;
+ ec.m_ebp = tst->m_ebp;
VG_(describe_addr) ( a, &ec.addrinfo );
ec.syscall_param = msg;
ec.isWriteableLack = isWriteLack;
ec.ekind = UserErr;
ec.addr = a;
ec.tid = tst->tid;
+ ec.m_eip = tst->m_eip;
+ ec.m_esp = tst->m_esp;
+ ec.m_ebp = tst->m_ebp;
VG_(describe_addr) ( a, &ec.addrinfo );
ec.isWriteableLack = isWriteLack;
VG_(maybe_add_context) ( &ec );
extern void VG_(shutdown);
extern void VG_(switch_to_real_CPU) ( void );
-extern void VG_(swizzle_esp_then_start_GDB) ( void );
+extern void VG_(swizzle_esp_then_start_GDB) ( Addr m_eip_at_error,
+ Addr m_esp_at_error,
+ Addr m_ebp_at_error );
/* ---------------------------------------------------------------------
int* __errno_location ( void )
{
int tid;
- ensure_valgrind("__errno_location");
+ /* ensure_valgrind("__errno_location"); */
VALGRIND_MAGIC_SEQUENCE(tid, 0 /* default */,
VG_USERREQ__PTHREAD_GET_THREADID,
0, 0, 0, 0);
/*--- %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:
# 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
### 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