static Short read_Short ( UChar* data )
{
- vg_assert(host_is_little_endian());
Short r = 0;
+ vg_assert(host_is_little_endian());
r = data[0]
| ( ((UInt)data[1]) << 8 );
return r;
static Int read_Int ( UChar* data )
{
- vg_assert(host_is_little_endian());
Int r = 0;
+ vg_assert(host_is_little_endian());
r = data[0]
| ( ((UInt)data[1]) << 8 )
| ( ((UInt)data[2]) << 16 )
static Long read_Long ( UChar* data )
{
- vg_assert(host_is_little_endian());
Long r = 0;
+ vg_assert(host_is_little_endian());
r = data[0]
| ( ((ULong)data[1]) << 8 )
| ( ((ULong)data[2]) << 16 )
static UShort read_UShort ( UChar* data )
{
- vg_assert(host_is_little_endian());
UInt r = 0;
+ vg_assert(host_is_little_endian());
r = data[0]
| ( ((UInt)data[1]) << 8 );
return r;
static UInt read_UInt ( UChar* data )
{
- vg_assert(host_is_little_endian());
UInt r = 0;
+ vg_assert(host_is_little_endian());
r = data[0]
| ( ((UInt)data[1]) << 8 )
| ( ((UInt)data[2]) << 16 )
static ULong read_ULong ( UChar* data )
{
- vg_assert(host_is_little_endian());
ULong r = 0;
+ vg_assert(host_is_little_endian());
r = data[0]
| ( ((ULong)data[1]) << 8 )
| ( ((ULong)data[2]) << 16 )
previously-seen CIE.
*/
while (True) {
+ UChar* ciefde_start;
+ UInt ciefde_len;
+ UInt cie_pointer;
/* Are we done? */
if (data == ehframe + ehframe_sz)
/* Ok, we must be looking at the start of a new CIE or FDE.
Figure out which it is. */
- UChar* ciefde_start = data;
+ ciefde_start = data;
if (VG_(clo_trace_cfi))
VG_(printf)("\ncie/fde.start = %p (ehframe + 0x%x)\n",
ciefde_start, ciefde_start - ehframe);
- UInt ciefde_len = read_UInt(data); data += sizeof(UInt);
+ ciefde_len = read_UInt(data); data += sizeof(UInt);
if (VG_(clo_trace_cfi))
VG_(printf)("cie/fde.length = %d\n", ciefde_len);
goto bad;
}
- UInt cie_pointer = read_UInt(data);
+ cie_pointer = read_UInt(data);
data += sizeof(UInt); /* XXX see XXX below */
if (VG_(clo_trace_cfi))
VG_(printf)("cie.pointer = %d\n", cie_pointer);
/* If cie_pointer is zero, we've got a CIE; else it's an FDE. */
if (cie_pointer == 0) {
- Int this_CIE;
+ Int this_CIE;
+ UChar cie_version;
+ UChar* cie_augmentation;
/* --------- CIE --------- */
if (VG_(clo_trace_cfi))
later when looking at an FDE. */
the_CIEs[this_CIE].offset = ciefde_start - ehframe;
- UChar cie_version = read_UChar(data); data += sizeof(UChar);
+ cie_version = read_UChar(data); data += sizeof(UChar);
if (VG_(clo_trace_cfi))
VG_(printf)("cie.version = %d\n", (Int)cie_version);
if (cie_version != 1) {
goto bad;
}
- UChar* cie_augmentation = data;
+ cie_augmentation = data;
data += 1 + VG_(strlen)(cie_augmentation);
if (VG_(clo_trace_cfi))
VG_(printf)("cie.augment = \"%s\"\n", cie_augmentation);
} else {
UnwindContext ctx, restore_ctx;
- Int cie;
- UInt look_for;
- Bool ok;
+ Int cie;
+ UInt look_for;
+ Bool ok;
+ Addr fde_initloc;
+ UWord fde_arange;
+ UChar* fde_instrs;
+ Int fde_ilen;
/* --------- FDE --------- */
goto bad;
}
- Addr fde_initloc
+ fde_initloc
= read_encoded_Addr(data, the_CIEs[cie].address_encoding,
&nbytes, ehframe, ehframe_addr);
data += nbytes;
if (VG_(clo_trace_cfi))
VG_(printf)("fde.initloc = %p\n", (void*)fde_initloc);
- UWord fde_arange
+ fde_arange
= read_encoded_Addr(data, the_CIEs[cie].address_encoding & 0xf,
&nbytes, ehframe, ehframe_addr);
data += nbytes;
data += nbytes;
}
- UChar* fde_instrs = data;
- Int fde_ilen = ciefde_start + ciefde_len + sizeof(UInt) - data;
+ fde_instrs = data;
+ fde_ilen = ciefde_start + ciefde_len + sizeof(UInt) - data;
if (VG_(clo_trace_cfi)) {
VG_(printf)("fde.instrs = %p\n", fde_instrs);
VG_(printf)("fde.ilen = %d\n", (Int)fde_ilen);
void ML_(addCfiSI) ( SegInfo* si, CfiSI* cfisi )
{
static const Bool debug = False;
+ UInt new_sz, i;
+ CfiSI* new_tab;
if (debug) {
VG_(printf)("adding CfiSI: ");
vg_assert(cfisi->len > 0 && cfisi->len < 2000000);
- UInt new_sz, i;
- CfiSI* new_tab;
-
/* Rule out ones which are completely outside the segment. These
probably indicate some kind of bug, but for the meantime ignore
them. */
OffT off = VG_(lseek)( fd, (OffT)offset, VKI_SEEK_SET);
if (off != 0)
return VG_(mk_SysRes_Error)( VKI_EINVAL );
- SysRes res = VG_(do_syscall3)(__NR_read, fd, (UWord)buf, count );
- return res;
+ return VG_(do_syscall3)(__NR_read, fd, (UWord)buf, count );
}
/* Create and open (-rw------) a tmp file name incorporating said arg.
HChar** cpp;
HChar** ret;
- HChar* preload_tool_path;;
+ HChar* preload_tool_path;
Int envc, i;
/* Alloc space for the vgpreload_core.so path and vgpreload_<tool>.so
Addr anon_start = clstack_start;
Addr resvn_start = anon_start - resvn_size;
SizeT inner_HACK = 0;
+ Bool ok;
vg_assert(VG_IS_PAGE_ALIGNED(anon_size));
vg_assert(VG_IS_PAGE_ALIGNED(resvn_size));
/* Create a shrinkable reservation followed by an anonymous
segment. Together these constitute a growdown stack. */
- Bool ok = VG_(am_create_reservation)(
- resvn_start,
- resvn_size -inner_HACK,
- SmUpper,
- anon_size +inner_HACK
- );
+ ok = VG_(am_create_reservation)(
+ resvn_start,
+ resvn_size -inner_HACK,
+ SmUpper,
+ anon_size +inner_HACK
+ );
vg_assert(ok);
/* allocate a stack - mmap enough space for the stack */
res = VG_(am_mmap_anon_fixed_client)(
results of a run which encompasses multiple processes. */
static void print_preamble(Bool logging_to_fd, const char* toolname)
{
- Int i;
-
+ HChar* xpre = VG_(clo_xml) ? " <line>" : "";
+ HChar* xpost = VG_(clo_xml) ? "</line>" : "";
+ Int i;
+
if (VG_(clo_xml)) {
VG_(message)(Vg_UserMsg, "<?xml version=\"1.0\"?>");
VG_(message)(Vg_UserMsg, "");
VG_(message)(Vg_UserMsg, "");
}
- HChar* xpre = VG_(clo_xml) ? " <line>" : "";
- HChar* xpost = VG_(clo_xml) ? "</line>" : "";
-
if (VG_(clo_verbosity > 0)) {
if (VG_(clo_xml))
static
UInt pszB_to_listNo ( SizeT pszB )
{
- vg_assert(0 == pszB % VG_MIN_MALLOC_SZB);
SizeT n = pszB / VG_MIN_MALLOC_SZB;
+ vg_assert(0 == pszB % VG_MIN_MALLOC_SZB);
// The first 13 lists hold blocks of size VG_MIN_MALLOC_SZB * list_num.
// The final 5 hold bigger blocks.
// avl_insert() which doesn't return a Bool.
void VG_(OSet_Insert)(AvlTree* t, void* e)
{
+ AvlNode* n;
+
vg_assert(t);
// Initialise. Even though OSet_AllocNode zeroes these fields, we should
// do it again in case a node is removed and then re-added to the tree.
- AvlNode* n = node_of_elem(e);
+ n = node_of_elem(e);
n->left = 0;
n->right = 0;
n->balance = 0;
Int cmpres = cmp_key_root(t, n);
if (cmpres < 0) {
+ AvlTree left_subtree;
// Remove from the left subtree
vg_assert(t->root->left);
- AvlTree left_subtree;
// Only need to set the used fields in the subtree.
left_subtree.root = t->root->left;
left_subtree.cmp = t->cmp;
static void run_a_thread_NORETURN ( Word tidW )
{
ThreadId tid = (ThreadId)tidW;
+ VgSchedReturnCode src;
+ Int c;
VG_(debugLog)(1, "syswrap-amd64-linux",
"run_a_thread_NORETURN(tid=%lld): "
(ULong)tidW);
/* Run the thread all the way through. */
- VgSchedReturnCode src = ML_(thread_wrapper)(tid);
+ src = ML_(thread_wrapper)(tid);
VG_(debugLog)(1, "syswrap-amd64-linux",
"run_a_thread_NORETURN(tid=%lld): "
"ML_(thread_wrapper) done\n",
(ULong)tidW);
- Int c = VG_(count_living_threads)();
+ c = VG_(count_living_threads)();
vg_assert(c >= 1); /* stay sane */
if (c == 1) {
} else {
+ ThreadState *tst;
+
VG_(debugLog)(1, "syswrap-amd64-linux",
"run_a_thread_NORETURN(tid=%lld): "
"not last one standing\n",
(ULong)tidW);
/* OK, thread is dead, but others still exist. Just exit. */
- ThreadState *tst = VG_(get_ThreadState)(tid);
+ tst = VG_(get_ThreadState)(tid);
/* This releases the run lock */
VG_(exit_thread)(tid);
*/
void VG_(main_thread_wrapper_NORETURN)(ThreadId tid)
{
+ Addr rsp;
+
VG_(debugLog)(1, "syswrap-amd64-linux",
"entering VG_(main_thread_wrapper_NORETURN)\n");
- Addr rsp = allocstack(tid);
+ rsp = allocstack(tid);
/* If we can't even allocate the first thread's stack, we're hosed.
Give up. */
UWord arg2, UWord arg3 )
{
SysRes r = res;
- vg_assert(!res.isError); /* guaranteed by caller */
Int fd1 = ((Int*)arg3)[0];
Int fd2 = ((Int*)arg3)[1];
+ vg_assert(!res.isError); /* guaranteed by caller */
POST_MEM_WRITE( arg3, 2*sizeof(int) );
if (!ML_(fd_allowed)(fd1, "socketcall.socketpair", tid, True) ||
!ML_(fd_allowed)(fd2, "socketcall.socketpair", tid, True)) {
int poll(struct pollfd *ufds, unsigned int nfds, int timeout)
*/
UInt i;
- *flags |= SfMayBlock;
struct vki_pollfd* ufds = (struct vki_pollfd *)ARG1;
+ *flags |= SfMayBlock;
PRINT("sys_poll ( %p, %d, %d )\n", ARG1,ARG2,ARG3);
PRE_REG_READ3(long, "poll",
struct pollfd *, ufds, unsigned int, nfds, long, timeout);
// scheduler-return-code.
VgSchedReturnCode ML_(thread_wrapper)(Word /*ThreadId*/ tidW)
{
- VG_(debugLog)(1, "core_os",
- "ML_(thread_wrapper)(tid=%lld): entry\n",
- (ULong)tidW);
-
VgSchedReturnCode ret;
ThreadId tid = (ThreadId)tidW;
ThreadState* tst = VG_(get_ThreadState)(tid);
+ VG_(debugLog)(1, "core_os",
+ "ML_(thread_wrapper)(tid=%lld): entry\n",
+ (ULong)tidW);
+
vg_assert(tst->status == VgTs_Init);
/* make sure we get the CPU lock before doing anything significant */
void putSyscallStatusIntoGuestState ( /*IN*/ SyscallStatus* canonical,
/*OUT*/VexGuestArchState* gst_vanilla )
{
- vg_assert(canonical->what == SsSuccess
- || canonical->what == SsFailure);
#if defined(VGP_x86_linux)
VexGuestX86State* gst = (VexGuestX86State*)gst_vanilla;
+ vg_assert(canonical->what == SsSuccess
+ || canonical->what == SsFailure);
if (canonical->what == SsFailure) {
/* This isn't exactly right, in that really a Failure with res
not in the range 1 .. 4095 is unrepresentable in the
}
#elif defined(VGP_amd64_linux)
VexGuestAMD64State* gst = (VexGuestAMD64State*)gst_vanilla;
+ vg_assert(canonical->what == SsSuccess
+ || canonical->what == SsFailure);
if (canonical->what == SsFailure) {
/* This isn't exactly right, in that really a Failure with res
not in the range 1 .. 4095 is unrepresentable in the
VexGuestPPC32State* gst = (VexGuestPPC32State*)gst_vanilla;
UInt old_cr = LibVEX_GuestPPC32_get_CR(gst);
+ vg_assert(canonical->what == SsSuccess
+ || canonical->what == SsFailure);
+
gst->guest_GPR3 = canonical->val;
if (canonical->what == SsFailure) {