/* Predicate used in sanity checks elsewhere - returns true if any
jump-site is an actual chained jump */
-Bool VG_(is_chained_jumpsite)(Addr a)
+__attribute__((unused))
+static Bool is_chained_jumpsite(Addr a)
{
UChar *cp = (UChar *)a;
/* Predicate used in sanity checks elsewhere - returns true if all
jump-sites are calls to VG_(patch_me) */
-Bool VG_(is_unchained_jumpsite)(Addr a)
+static Bool is_unchained_jumpsite(Addr a)
{
UChar *cp = (UChar *)a;
Int delta = ((Addr)&VG_(patch_me)) - (a + VG_PATCHME_CALLSZ);
Int delta = ((Addr)&VG_(patch_me)) - (a + VG_PATCHME_CALLSZ);
UChar *cp = (UChar *)a;
- if (VG_(is_unchained_jumpsite)(a))
+ if (is_unchained_jumpsite(a))
return; /* don't write unnecessarily */
if (!is_fresh_jumpsite(cp))
#define PGROUNDUP(p) ROUNDUP(p, VKI_BYTES_PER_PAGE)
-/* ---------------------------------------------------------------------
- Basic types
- ------------------------------------------------------------------ */
-
-/* Just pray that gcc's constant folding works properly ... */
-#define BITS(bit7,bit6,bit5,bit4,bit3,bit2,bit1,bit0) \
- ( ((bit7) << 7) | ((bit6) << 6) | ((bit5) << 5) | ((bit4) << 4) \
- | ((bit3) << 3) | ((bit2) << 2) | ((bit1) << 1) | (bit0))
-
/* ---------------------------------------------------------------------
Command-line-settable options
------------------------------------------------------------------ */
extern void VG_(intercept_libc_freeres_wrapper)(Addr);
/* ---------------------------------------------------------------------
- Debugging and profiling stuff
+ Profiling stuff
------------------------------------------------------------------ */
-/* Create a log file into which messages can be dumped. */
-extern void VG_(startup_logging) ( void );
-extern void VG_(shutdown_logging)( void );
-
extern void VGP_(init_profiling) ( void );
extern void VGP_(done_profiling) ( void );
struct {
Bool libc_freeres;
Bool core_errors;
-
Bool skin_errors;
Bool basic_block_discards;
Bool shadow_regs;
extern void VG_(show_all_arena_stats) ( void );
extern Bool VG_(is_empty_arena) ( ArenaId aid );
-/* Returns True if aa is inside any block mmap'd /dev/zero
- by our low-level memory manager. */
-extern Bool VG_(is_inside_segment_mmapd_by_low_level_MM)( Addr aa );
-
-
/* ---------------------------------------------------------------------
Exports of vg_intercept.c
------------------------------------------------------------------ */
#define VG_LDT_ENTRY_SIZE 8
/* Alloc & copy, and dealloc. */
-extern VgLdtEntry*
- VG_(allocate_LDT_for_thread) ( VgLdtEntry* parent_ldt );
-extern void
- VG_(deallocate_LDT_for_thread) ( VgLdtEntry* ldt );
-extern void
- VG_(clear_TLS_for_thread) ( VgLdtEntry* tls );
+extern VgLdtEntry* VG_(allocate_LDT_for_thread) ( VgLdtEntry* parent_ldt );
+extern void VG_(deallocate_LDT_for_thread) ( VgLdtEntry* ldt );
+extern void VG_(clear_TLS_for_thread) ( VgLdtEntry* tls );
/* Simulate the modify_ldt syscall. */
extern Int VG_(sys_modify_ldt) ( ThreadId tid,
/* Fake system calls for signal handling. */
extern void VG_(do__NR_sigaltstack) ( ThreadId tid );
extern void VG_(do__NR_sigaction) ( ThreadId tid );
-extern void VG_(do__NR_sigprocmask) ( ThreadId tid,
- Int how,
+extern void VG_(do__NR_sigprocmask) ( ThreadId tid, Int how,
vki_ksigset_t* set,
vki_ksigset_t* oldset );
-extern void VG_(do_pthread_sigmask_SCSS_upd) ( ThreadId tid,
- Int how,
+extern void VG_(do_pthread_sigmask_SCSS_upd) ( ThreadId tid, Int how,
vki_ksigset_t* set,
vki_ksigset_t* oldset );
-extern void VG_(send_signal_to_thread) ( ThreadId thread,
- Int signo );
-
-extern void VG_(do_sigpending) ( ThreadId tid, vki_ksigset_t* set );
+extern void VG_(send_signal_to_thread) ( ThreadId thread, Int signo );
/* Modify the current thread's state once we have detected it is
extern Char* VG_(arena_strdup) ( ArenaId aid, const Char* s);
extern Int VG_(fcntl) ( Int fd, Int cmd, Int arg );
-extern Int VG_(select)( Int n,
- vki_fd_set* readfds,
- vki_fd_set* writefds,
- vki_fd_set* exceptfds,
- struct vki_timeval * timeout );
extern Int VG_(poll)( struct vki_pollfd *, UInt nfds, Int timeout);
-extern Int VG_(nanosleep)( const struct vki_timespec *req,
- struct vki_timespec *rem );
/* system/mman.h */
extern void* VG_(mmap)( void* start, UInt length, UInt prot, UInt flags,
extern Int VG_(connect_via_socket)( UChar* str );
/* Environment manipulations */
-extern Char **VG_(env_clone) ( Char **oldenv );
-extern Char* VG_(env_getenv) ( Char **env, Char* varname );
extern Char **VG_(env_setenv) ( Char ***envp, const Char* varname, const Char *val );
extern void VG_(env_unsetenv) ( Char **env, const Char *varname );
extern void VG_(send_bytes_to_logging_sink) ( Char* msg, Int nbytes );
-/* ---------------------------------------------------------------------
- Definitions for the JITter (vg_translate.c, vg_to_ucode.c,
- vg_from_ucode.c).
- ------------------------------------------------------------------ */
-
-#define VG_IS_FLAG_SUBSET(set1,set2) \
- (( ((FlagSet)set1) & ((FlagSet)set2) ) == ((FlagSet)set1) )
-
-#define VG_UNION_FLAG_SETS(set1,set2) \
- ( ((FlagSet)set1) | ((FlagSet)set2) )
-
/* ---------------------------------------------------------------------
Exports of vg_demangle.c
------------------------------------------------------------------ */
extern void VG_(unchain_jumpsite) ( Addr jumpsite );
extern Addr VG_(get_jmp_dest) ( Addr jumpsite );
-extern Bool VG_(is_unchained_jumpsite) ( Addr jumpsite );
-extern Bool VG_(is_chained_jumpsite) ( Addr jumpsite );
/* ---------------------------------------------------------------------
Exports of vg_to_ucode.c
extern
void VG_(parse_procselfmaps) (
void (*record_mapping)( Addr addr, UInt len, Char rr, Char ww, Char xx,
- UInt dev, UInt ino, ULong foff, const UChar *filename )
-);
+ UInt dev, UInt ino, ULong foff,
+ const UChar *filename ) );
/* ---------------------------------------------------------------------
extern Bool VG_(is_object_file) ( const void *hdr );
extern void VG_(mini_stack_dump) ( Addr eips[], UInt n_eips );
extern SegInfo * VG_(read_seg_symbols) ( Segment *seg );
-extern void VG_(unload_symbols) ( Addr start, UInt length );
extern void VG_(symtab_incref) ( SegInfo * );
extern void VG_(symtab_decref) ( SegInfo *, Addr a, UInt len );
extern void VG_(setup_code_redirect_table) ( void );
/* Redirection machinery */
-extern void VG_(add_redirect_sym)(const Char *from_lib, const Char *from_sym,
- const Char *to_lib, const Char *to_sym);
-extern void VG_(add_redirect_addr)(const Char *from_lib, const Char *from_sym,
- Addr to_addr);
-extern Addr VG_(code_redirect) (Addr orig);
+extern Addr VG_(code_redirect) ( Addr orig );
/* ---------------------------------------------------------------------
Exports of vg_main.c
extern Int VG_(vg_argc);
extern Char **VG_(vg_argv);
-/* Indicates presence, and holds address of client's sysinfo page, a
- feature of some modern kernels used to provide vsyscalls, etc. */
-extern Bool VG_(sysinfo_page_exists);
-extern Addr VG_(sysinfo_page_addr);
-
-/* Walk through a colon separated list variable, removing entries
- which match pattern. */
-extern void VG_(mash_colon_env)(Char *varp, const Char *pattern);
-
/* Something of a function looking for a home ... start up debugger. */
extern void VG_(start_debugger) ( Int tid );
-/* VG_(bbs_done) in include/vg_skin.h */
-
-/* 64-bit counter for the number of bbs to go before a debug exit. */
-extern ULong VG_(bbs_to_go);
-
/* Counts downwards in vg_run_innerloop. */
extern UInt VG_(dispatch_ctr);
extern UInt VG_(num_scheduling_events_MINOR);
extern UInt VG_(num_scheduling_events_MAJOR);
-/* Insert and extract the D flag from eflags */
-UInt VG_(insertDflag)(UInt eflags, Int d);
-Int VG_(extractDflag)(UInt eflags);
-
/* ---------------------------------------------------------------------
Exports of vg_memory.c
------------------------------------------------------------------ */
We try to encode everything we know about a particular segment here.
*/
-#define SF_FIXED (1 << 0) /* client asked for MAP_FIXED */
-#define SF_SHARED (1 << 1) /* shared */
-#define SF_SHM (1 << 2) /* SYSV SHM (also SF_SHARED) */
-#define SF_MMAP (1 << 3) /* mmap memory */
-#define SF_FILE (1 << 4) /* mapping is backed by a file */
-#define SF_STACK (1 << 5) /* is a stack */
-#define SF_GROWDOWN (1 << 6) /* segment grows down */
-#define SF_GROWUP (1 << 7) /* segment grows up */
-#define SF_EXEC (1 << 8) /* segment created by exec */
-#define SF_DYNLIB (1 << 9) /* mapped from dynamic library */
-#define SF_NOSYMS (1 << 10) /* don't load syms, even if present */
-#define SF_BRK (1 << 11) /* brk segment */
-#define SF_CORE (1 << 12) /* allocated by core on behalf of the client */
-#define SF_VALGRIND (1 << 13) /* a valgrind-internal mapping - not in client*/
-#define SF_CODE (1 << 14) /* segment contains cached code */
+#define SF_FIXED (1 << 0) // client asked for MAP_FIXED
+#define SF_SHARED (1 << 1) // shared
+#define SF_SHM (1 << 2) // SYSV SHM (also SF_SHARED)
+#define SF_MMAP (1 << 3) // mmap memory
+#define SF_FILE (1 << 4) // mapping is backed by a file
+#define SF_STACK (1 << 5) // is a stack
+#define SF_GROWDOWN (1 << 6) // segment grows down
+#define SF_GROWUP (1 << 7) // segment grows up
+#define SF_EXEC (1 << 8) // segment created by exec
+#define SF_DYNLIB (1 << 9) // mapped from dynamic library
+#define SF_NOSYMS (1 << 10) // don't load syms, even if present
+#define SF_BRK (1 << 11) // brk segment
+#define SF_CORE (1 << 12) // allocated by core on behalf of the client
+#define SF_VALGRIND (1 << 13) // a valgrind-internal mapping - not in client
+#define SF_CODE (1 << 14) // segment contains cached code
struct _Segment {
UInt prot; /* VKI_PROT_* */
extern void VG_(proxy_waitsig) ( void );
extern void VG_(proxy_wait_sys) (ThreadId tid, Bool restart);
-extern void VG_(proxy_shutdown) ( void ); /* shut down the syscall workers */
-extern Int VG_(proxy_resfd) ( void ); /* FD something can select on to know
- a syscall finished */
+extern void VG_(proxy_shutdown) ( void ); // shut down the syscall workers
+extern Int VG_(proxy_resfd) ( void ); // FD something can select on to know
+ // a syscall finished
/* Sanity-check the whole proxy-LWP machinery */
void VG_(proxy_sanity)(void);
extern void VG_(proxy_handlesig)( const vki_ksiginfo_t *siginfo,
const struct vki_sigcontext *sigcontext );
-/* Get the PID/TID of the ProxyLWP. */
-extern Int VG_(proxy_id)(ThreadId tid);
-
-
/* ---------------------------------------------------------------------
Exports of vg_syscalls.c
------------------------------------------------------------------ */
extern Bool VG_(pre_syscall) ( ThreadId tid );
extern void VG_(post_syscall)( ThreadId tid, Bool restart );
-extern void VG_(restart_syscall) ( ThreadId tid );
extern Bool VG_(is_kerror) ( Int res );
extern void VG_(init_preopened_fds) ( void );
extern void VG_(fd_stats) ( void );
+/* Walk through a colon separated list variable, removing entries
+ which match pattern. */
+extern void VG_(mash_colon_env)(Char *varp, const Char *pattern);
+
/* ---------------------------------------------------------------------
Exports of vg_transtab.c
------------------------------------------------------------------ */
/* The fast-cache for tt-lookup. */
extern Addr VG_(tt_fast)[VG_TT_FAST_SIZE];
-extern void VG_(get_tt_tc_used) ( UInt* tt_used, UInt* tc_used );
-
extern void VG_(add_to_trans_tab) ( Addr orig_addr, Int orig_size,
Addr trans_addr, Int trans_size,
UShort jumps[VG_MAX_JUMPS]);
extern void VG_(sanity_check_tc_tt) ( void );
extern Addr VG_(search_transtab) ( Addr original_addr );
-
-
/* ---------------------------------------------------------------------
Exports of vg_syscall.S
------------------------------------------------------------------ */
SSE/fxsave/fxrestor features. */
Bool VG_(have_ssestate);
-/* Indicates presence, and holds address of client's sysinfo page, a
- feature of some modern kernels used to provide vsyscalls, etc. */
-Bool VG_(sysinfo_page_exists) = False;
-Addr VG_(sysinfo_page_addr) = 0;
-
/* stage1 (main) executable */
Int VG_(vgexecfd) = -1;
for (auxp = client_auxv; auxp[0] != VKI_AT_NULL; auxp += 2) {
switch(auxp[0]) {
case VKI_AT_SYSINFO:
- VG_(sysinfo_page_exists) = True;
auxp[1] = (Int)(VG_(client_trampoline_code) + VG_(tramp_syscall_offset));
- VG_(sysinfo_page_addr) = auxp[1];
break;
}
}
static Int baB_off = 0;
-UInt VG_(insertDflag)(UInt eflags, Int d)
-{
- vg_assert(d == 1 || d == -1);
- eflags &= ~EFlagD;
-
- if (d < 0)
- eflags |= EFlagD;
-
- return eflags;
-}
-
-Int VG_(extractDflag)(UInt eflags)
-{
- Int ret;
-
- if (eflags & EFlagD)
- ret = -1;
- else
- ret = 1;
-
- return ret;
-}
-
/* Returns the offset, in words. */
static Int alloc_BaB ( Int words )
{
//--------------------------------------------------------------
switch (src) {
case VgSrc_ExitSyscall: /* the normal way out */
- vg_assert(VG_(last_run_tid) > 0
- && VG_(last_run_tid) < VG_N_THREADS);
+ vg_assert(VG_(last_run_tid) > 0 && VG_(last_run_tid) < VG_N_THREADS);
VG_(proxy_shutdown)();
/* The thread's %EBX at the time it did __NR_exit() will hold
}
-/* Returns True if aa is inside any segment mmap'd /dev/zero
- by our low-level memory manager. */
-Bool VG_(is_inside_segment_mmapd_by_low_level_MM)( Addr aa )
-{
- ArenaId ar;
- Superblock* sb;
-
- ensure_mm_init();
-
- for (ar = 0; ar < VG_N_ARENAS; ar++) {
- for (sb = vg_arena[ar].sblocks; sb; sb = sb->next) {
- Addr sb_first_word = (Addr)sb;
- Addr sb_last_word
- = (Addr)&(sb->payload_words[sb->n_payload_words-1]);
- if (aa >= sb_first_word && aa <= sb_last_word)
- return True;
- }
- }
- return False;
-}
-
-
/*------------------------------------------------------------*/
/*--- Superblock management stuff ---*/
/*------------------------------------------------------------*/
/*--------------------------------------------------------------------*/
/*--- For sending error/informative messages. ---*/
-/*--- vg_message.c ---*/
+/*--- vg_messages.c ---*/
/*--------------------------------------------------------------------*/
/*
}
}
-
-void VG_(startup_logging) ( void )
-{
-}
-
-void VG_(shutdown_logging) ( void )
-{
-}
-
/*--------------------------------------------------------------------*/
-/*--- end vg_message.c ---*/
+/*--- end vg_messages.c ---*/
/*--------------------------------------------------------------------*/
return VG_(is_kerror)(res) ? -1 : res;
}
-/* Returns -1 on error. */
-Int VG_(select)( Int n,
- vki_fd_set* readfds,
- vki_fd_set* writefds,
- vki_fd_set* exceptfds,
- struct vki_timeval * timeout )
-{
- Int res;
- UInt args[5];
- args[0] = n;
- args[1] = (UInt)readfds;
- args[2] = (UInt)writefds;
- args[3] = (UInt)exceptfds;
- args[4] = (UInt)timeout;
- res = VG_(do_syscall)(__NR_select, (UInt)(&(args[0])) );
- return VG_(is_kerror)(res) ? -1 : res;
-}
-
Int VG_(poll)( struct vki_pollfd *ufds, UInt nfds, Int timeout)
{
Int res = VG_(do_syscall)(__NR_poll, ufds, nfds, timeout);
return res;
}
-/* Returns -1 on error, 0 if ok, 1 if interrupted. */
-Int VG_(nanosleep)( const struct vki_timespec *req,
- struct vki_timespec *rem )
-{
- Int res;
- res = VG_(do_syscall)(__NR_nanosleep, (UInt)req, (UInt)rem);
- if (res == -VKI_EINVAL) return -1;
- if (res == -VKI_EINTR) return 1;
- return 0;
-}
-
/* ---------------------------------------------------------------------
printf implementation. The key function, vg_vprintf(), emits chars
report);
VG_(printf)("In the bug report, send all the above text, the valgrind\n");
VG_(printf)("version, and what Linux distro you are using. Thanks.\n\n");
- VG_(shutdown_logging)();
VG_(exit)(1);
}
------------------------------------------------------------------ */
/* clone the environment */
-Char **VG_(env_clone) ( Char **oldenv )
+static Char **env_clone ( Char **oldenv )
{
Char **oldenvp;
Char **newenvp;
return oldenv;
}
-Char* VG_(env_getenv) ( Char **env, Char* varname )
+/* We do getenv without libc's help by snooping around in
+ VG_(client_envp) as determined at startup time. */
+Char *VG_(getenv)(Char *varname)
{
Int i, n;
n = VG_(strlen)(varname);
- for (i = 0; env[i] != NULL; i++) {
- Char* s = env[i];
+ for (i = 0; VG_(client_envp)[i] != NULL; i++) {
+ Char* s = VG_(client_envp)[i];
if (VG_(strncmp)(varname, s, n) == 0 && s[n] == '=') {
return & s[n+1];
}
return NULL;
}
-/* We do getenv without libc's help by snooping around in
- VG_(client_envp) as determined at startup time. */
-Char *VG_(getenv)(Char *varname)
-{
- return VG_(env_getenv)(VG_(client_envp), varname);
-}
-
/* Support for getrlimit. */
Int VG_(getrlimit) (Int resource, struct vki_rlimit *rlim)
{
Char* ld_library_path_str = NULL;
Char* buf;
- envp = VG_(env_clone)(VG_(client_envp));
+ envp = env_clone(VG_(client_envp));
for (i = 0; envp[i] != NULL; i++) {
if (VG_(strncmp)(envp[i], "LD_PRELOAD=", 11) == 0)
}
#undef CHECK_NOT
-#undef INVALID_Bool
}
/*--------------------------------------------------------------------*/
}
/* Get the PID/TID of the ProxyLWP. */
-Int VG_(proxy_id)(ThreadId tid)
+__attribute__((unused))
+static Int proxy_id(ThreadId tid)
{
ThreadState *tst = VG_(get_ThreadState)(tid);
- ProxyLWP *proxy = tst->proxy;
-
- return proxy->lwp;
+ return tst->proxy->lwp;
}
/*--------------------------------------------------------------------*/
return vg_tid_last_in_baseBlock;
}
+static UInt insertDflag(UInt eflags, Int d)
+{
+ vg_assert(d == 1 || d == -1);
+ eflags &= ~EFlagD;
+ if (d < 0) eflags |= EFlagD;
+ return eflags;
+}
+
+static Int extractDflag(UInt eflags)
+{
+ return ( eflags & EFlagD ? -1 : 1 );
+}
+
/* Copy the saved state of a thread into VG_(baseBlock), ready for it
to be run. */
void VG_(load_thread_state) ( ThreadId tid )
VG_(baseBlock)[VGOFF_(m_eflags)]
= VG_(threads)[tid].m_eflags & ~EFlagD;
VG_(baseBlock)[VGOFF_(m_dflag)]
- = VG_(extractDflag)(VG_(threads)[tid].m_eflags);
+ = extractDflag(VG_(threads)[tid].m_eflags);
VG_(baseBlock)[VGOFF_(m_eip)] = VG_(threads)[tid].m_eip;
for (i = 0; i < VG_SIZE_OF_SSESTATE_W; i++)
VG_(threads)[tid].m_ebp = VG_(baseBlock)[VGOFF_(m_ebp)];
VG_(threads)[tid].m_esp = VG_(baseBlock)[VGOFF_(m_esp)];
VG_(threads)[tid].m_eflags
- = VG_(insertDflag)(VG_(baseBlock)[VGOFF_(m_eflags)],
- VG_(baseBlock)[VGOFF_(m_dflag)]);
+ = insertDflag(VG_(baseBlock)[VGOFF_(m_eflags)],
+ VG_(baseBlock)[VGOFF_(m_dflag)]);
VG_(threads)[tid].m_eip = VG_(baseBlock)[VGOFF_(m_eip)];
for (i = 0; i < VG_SIZE_OF_SSESTATE_W; i++)
= VG_(search_transtab) ( VG_(threads)[tid].m_eip );
if (trans_addr == (Addr)0) {
/* Not found; we need to request a translation. */
- create_translation_for(
- tid, VG_(threads)[tid].m_eip );
+ create_translation_for( tid, VG_(threads)[tid].m_eip );
trans_addr = VG_(search_transtab) ( VG_(threads)[tid].m_eip );
if (trans_addr == (Addr)0)
VG_(core_panic)("VG_TRC_INNER_FASTMISS: missing tt_fast entry");
return True;
}
+// Forward declaration
+static void add_redirect_addr(const Char *from_lib, const Char *from_sym,
+ Addr to_addr);
+
static
void handle_intercept( SegInfo* si, Char* symbol, Elf32_Sym* sym)
{
while(*func != ':') func--;
*func = '\0';
- VG_(add_redirect_addr)(lib, func+1, si->offset + sym->st_value);
+ add_redirect_addr(lib, func+1, si->offset + sym->st_value);
VG_(free)(lib);
}
accuracy of error messages, but we need to do it in order to
maintain the no-overlapping invariant.
*/
-void VG_(unload_symbols) ( Addr start, UInt length )
+static void unload_symbols ( Addr start, UInt length )
{
SegInfo *prev, *curr;
{
vg_assert(si->ref >= 1);
if (--si->ref == 0)
- VG_(unload_symbols)(si->start, si->size);
+ unload_symbols(si->start, si->size);
}
void VG_(symtab_incref)(SegInfo *si)
}
/* Redirect a lib/symbol reference to a function at lib/symbol */
-void VG_(add_redirect_sym)(const Char *from_lib, const Char *from_sym,
- const Char *to_lib, const Char *to_sym)
+static void add_redirect_sym(const Char *from_lib, const Char *from_sym,
+ const Char *to_lib, const Char *to_sym)
{
CodeRedirect *redir = VG_(SkipNode_Alloc)(&sk_resolved_redir);
}
/* Redirect a lib/symbol reference to a function at lib/symbol */
-void VG_(add_redirect_addr)(const Char *from_lib, const Char *from_sym,
- Addr to_addr)
+static void add_redirect_addr(const Char *from_lib, const Char *from_sym,
+ Addr to_addr)
{
CodeRedirect *redir = VG_(SkipNode_Alloc)(&sk_resolved_redir);
Int i;
for(i = 0; i < sizeof(redirects)/sizeof(*redirects); i++) {
- VG_(add_redirect_sym)("soname:libc.so.6", redirects[i].from,
- "soname:libpthread.so.0", redirects[i].to);
+ add_redirect_sym("soname:libc.so.6", redirects[i].from,
+ "soname:libpthread.so.0", redirects[i].to);
}
/* Redirect _dl_sysinfo_int80, which is glibc's default system call
routine, to the routine in our trampoline page so that the
special sysinfo unwind hack in vg_execontext.c will kick in.
*/
- VG_(add_redirect_addr)("soname:ld-linux.so.2", "_dl_sysinfo_int80",
- VG_(client_trampoline_code)+VG_(tramp_syscall_offset));
+ add_redirect_addr("soname:ld-linux.so.2", "_dl_sysinfo_int80",
+ VG_(client_trampoline_code)+VG_(tramp_syscall_offset));
/* Overenthusiastic use of PLT bypassing by the glibc people also
means we need to patch the following functions to our own
implementations of said, in mac_replace_strmem.c.
*/
- VG_(add_redirect_sym)("soname:libc.so.6", "stpcpy",
- "*vgpreload_memcheck.so*", "stpcpy");
- VG_(add_redirect_sym)("soname:libc.so.6", "strnlen",
- "*vgpreload_memcheck.so*", "strnlen");
-
- VG_(add_redirect_sym)("soname:ld-linux.so.2", "stpcpy",
- "*vgpreload_memcheck.so*", "stpcpy");
- VG_(add_redirect_sym)("soname:ld-linux.so.2", "strchr",
- "*vgpreload_memcheck.so*", "strchr");
+ add_redirect_sym("soname:libc.so.6", "stpcpy",
+ "*vgpreload_memcheck.so*", "stpcpy");
+ add_redirect_sym("soname:libc.so.6", "strnlen",
+ "*vgpreload_memcheck.so*", "strnlen");
+ add_redirect_sym("soname:ld-linux.so.2", "stpcpy",
+ "*vgpreload_memcheck.so*", "stpcpy");
+ add_redirect_sym("soname:ld-linux.so.2", "strchr",
+ "*vgpreload_memcheck.so*", "strchr");
}
/*------------------------------------------------------------*/
return syscall_done;
}
+static void restart_syscall(ThreadId tid)
+{
+ ThreadState* tst;
+ tst = VG_(get_ThreadState)(tid);
+
+ vg_assert(tst != NULL);
+ vg_assert(tst->status == VgTs_WaitSys);
+ vg_assert(tst->syscallno != -1);
+
+ tst->m_eax = tst->syscallno;
+ tst->m_eip -= 2; /* sizeof(int $0x80) */
+
+ /* Make sure our caller is actually sane, and we're really backing
+ back over a syscall.
+
+ int $0x80 == CD 80
+ */
+ {
+ UChar *p = (UChar *)tst->m_eip;
+
+ if (p[0] != 0xcd || p[1] != 0x80)
+ VG_(message)(Vg_DebugMsg,
+ "?! restarting over syscall at %p %02x %02x\n",
+ tst->m_eip, p[0], p[1]);
+
+ vg_assert(p[0] == 0xcd && p[1] == 0x80);
+ }
+}
void VG_(post_syscall) ( ThreadId tid, Bool restart )
{
if (restart) {
restarted = True;
- VG_(restart_syscall)(tid);
+ restart_syscall(tid);
} else
tst->m_eax = -VKI_EINTR;
}
VGP_POPCC(VgpCoreSysWrap);
}
-void VG_(restart_syscall)(ThreadId tid)
-{
- ThreadState* tst;
- tst = VG_(get_ThreadState)(tid);
-
- vg_assert(tst != NULL);
- vg_assert(tst->status == VgTs_WaitSys);
- vg_assert(tst->syscallno != -1);
-
- tst->m_eax = tst->syscallno;
- tst->m_eip -= 2; /* sizeof(int $0x80) */
-
- /* Make sure our caller is actually sane, and we're really backing
- back over a syscall.
-
- int $0x80 == CD 80
- */
- {
- UChar *p = (UChar *)tst->m_eip;
-
- if (p[0] != 0xcd || p[1] != 0x80)
- VG_(message)(Vg_DebugMsg,
- "?! restarting over syscall at %p %02x %02x\n",
- tst->m_eip, p[0], p[1]);
-
- vg_assert(p[0] == 0xcd && p[1] == 0x80);
- }
-}
-
/*--------------------------------------------------------------------*/
/*--- end vg_syscalls.c ---*/
/*--------------------------------------------------------------------*/
/*--- Basics ---*/
/*------------------------------------------------------------*/
+#define VG_IS_FLAG_SUBSET(set1,set2) \
+ (( ((FlagSet)set1) & ((FlagSet)set2) ) == ((FlagSet)set1) )
+
+#define VG_UNION_FLAG_SETS(set1,set2) \
+ ( ((FlagSet)set1) | ((FlagSet)set2) )
+
/* This one is called by the core */
UCodeBlock* VG_(alloc_UCodeBlock) ( void )
{