这篇教程C++ vg_assert函数代码示例写得很实用,希望能帮到您。
本文整理汇总了C++中vg_assert函数的典型用法代码示例。如果您正苦于以下问题:C++ vg_assert函数的具体用法?C++ vg_assert怎么用?C++ vg_assert使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。 在下文中一共展示了vg_assert函数的23个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。 示例1: VG_void VG_(map_file_segment)(Addr addr, UInt len, UInt prot, UInt flags, UInt dev, UInt ino, ULong off, const Char *filename){ Segment *s; static const Bool debug = False || mem_debug; Bool recycled; if (debug) VG_(printf)("map_file_segment(%p, %d, %x, %x, %4x, %d, %ld, %s)/n", addr, len, prot, flags, dev, ino, off, filename); /* Everything must be page-aligned */ vg_assert((addr & (VKI_BYTES_PER_PAGE-1)) == 0); len = PGROUNDUP(len); /* First look to see what already exists around here */ s = VG_(SkipList_Find)(&sk_segments, &addr); if (s != NULL && s->addr == addr && s->len == len) { /* This probably means we're just updating the flags */ recycled = True; recycleseg(s); /* If we had a symtab, but the new mapping is incompatible, then free up the old symtab in preparation for a new one. */ if (s->symtab != NULL && (!(s->flags & SF_FILE) || !(flags & SF_FILE) || s->dev != dev || s->ino != ino || s->offset != off)) { VG_(symtab_decref)(s->symtab, s->addr, s->len); s->symtab = NULL; } } else { recycled = False; VG_(unmap_range)(addr, len); s = VG_(SkipNode_Alloc)(&sk_segments); s->addr = addr; s->len = len; s->symtab = NULL; } s->flags = flags; s->prot = prot; s->dev = dev; s->ino = ino; s->offset = off; if (filename != NULL) s->filename = VG_(arena_strdup)(VG_AR_CORE, filename); else s->filename = NULL; if (debug) { Segment *ts; for(ts = VG_(SkipNode_First)(&sk_segments); ts != NULL; ts = VG_(SkipNode_Next)(&sk_segments, ts)) VG_(printf)("list: %8p->%8p ->%d (0x%x) prot=%x flags=%x/n", ts, ts->addr, ts->len, ts->len, ts->prot, ts->flags); VG_(printf)("inserting s=%p addr=%p len=%d/n", s, s->addr, s->len); } if (!recycled) VG_(SkipList_Insert)(&sk_segments, s); /* If this mapping is of the beginning of a file, isn't part of Valgrind, is at least readable and seems to contain an object file, then try reading symbols from it. */ if ((flags & (SF_MMAP|SF_NOSYMS)) == SF_MMAP && s->symtab == NULL) { if (off == 0 && filename != NULL && (prot & (VKI_PROT_READ|VKI_PROT_EXEC)) == (VKI_PROT_READ|VKI_PROT_EXEC) && len >= VKI_BYTES_PER_PAGE && s->symtab == NULL && VG_(is_object_file)((void *)addr)) { s->symtab = VG_(read_seg_symbols)(s); if (s->symtab != NULL) { s->flags |= SF_DYNLIB; } } else if (flags & SF_MMAP) { const SegInfo *info; /* Otherwise see if an existing symtab applies to this Segment */ for(info = VG_(next_seginfo)(NULL); info != NULL; info = VG_(next_seginfo)(info)) { if (VG_(seg_overlaps)(s, VG_(seg_start)(info), VG_(seg_size)(info))) { s->symtab = (SegInfo *)info; VG_(symtab_incref)((SegInfo *)info); }//.........这里部分代码省略.........
开发者ID:svn2github,项目名称:valgrind-3,代码行数:101,
示例2: ML_/* Read a symbol table (nlist). Add the resulting candidate symbols to 'syms'; the caller will post-process them and hand them off to ML_(addSym) itself. */staticvoid read_symtab( /*OUT*/XArray* /* DiSym */ syms, struct _DebugInfo* di, struct NLIST* o_symtab, UInt o_symtab_count, UChar* o_strtab, UInt o_strtab_sz ){ Int i; Addr sym_addr; DiSym risym; UChar* name; static UChar* s_a_t_v = NULL; /* do not make non-static */ for (i = 0; i < o_symtab_count; i++) { struct NLIST *nl = o_symtab+i; if ((nl->n_type & N_TYPE) == N_SECT) { sym_addr = di->text_bias + nl->n_value; /*} else if ((nl->n_type & N_TYPE) == N_ABS) { GrP fixme don't ignore absolute symbols? sym_addr = nl->n_value; */ } else { continue; } if (di->trace_symtab) VG_(printf)("nlist raw: avma %010lx %s/n", sym_addr, o_strtab + nl->n_un.n_strx ); /* If no part of the symbol falls within the mapped range, ignore it. */ if (sym_addr <= di->text_avma || sym_addr >= di->text_avma+di->text_size) { continue; } /* skip names which point outside the string table; following these risks segfaulting Valgrind */ name = o_strtab + nl->n_un.n_strx; if (name < o_strtab || name >= o_strtab + o_strtab_sz) continue; /* skip nameless symbols; these appear to be common, but useless */ if (*name == 0) continue; risym.tocptr = 0; risym.addr = sym_addr; risym.size = // let canonicalize fix it di->text_avma+di->text_size - sym_addr; risym.name = ML_(addStr)(di, name, -1); risym.isText = True; // Lots of user function names get prepended with an underscore. Eg. the // function 'f' becomes the symbol '_f'. And the "below main" // function is called "start". So we skip the leading underscore, and // if we see 'start' and --show-below-main=no, we rename it as // "start_according_to_valgrind", which makes it easy to spot later // and display as "(below main)". if (risym.name[0] == '_') { risym.name++; } else if (!VG_(clo_show_below_main) && VG_STREQ(risym.name, "start")) { if (s_a_t_v == NULL) s_a_t_v = ML_(addStr)(di, "start_according_to_valgrind", -1); vg_assert(s_a_t_v); risym.name = s_a_t_v; } vg_assert(risym.name); VG_(addToXA)( syms, &risym ); }}
开发者ID:svn2github,项目名称:valgrind-3,代码行数:74,
示例3: state//.........这里部分代码省略......... retrieving shadow flags is not ok */ if (set == 0) eflags = LibVEX_GuestX86_get_eflags (x86); else eflags = 0; VG_(transfer) (&eflags, buf, dir, size, mod); break; } else { *mod = False; //GDBTD? how do we store eflags in libvex_guest_x86.h ??? } break; case 10: VG_(transfer) (&x86->guest_CS, buf, dir, size, mod); break; case 11: VG_(transfer) (&x86->guest_SS, buf, dir, size, mod); break; case 12: VG_(transfer) (&x86->guest_DS, buf, dir, size, mod); break; case 13: VG_(transfer) (&x86->guest_ES, buf, dir, size, mod); break; case 14: VG_(transfer) (&x86->guest_FS, buf, dir, size, mod); break; case 15: VG_(transfer) (&x86->guest_GS, buf, dir, size, mod); break; case 16: case 17: case 18: case 19: /* register 16 to 23 are float registers 80 bits but 64 bits in valgrind */ case 20: case 21: case 22: case 23: { if (dir == valgrind_to_gdbserver) { UChar fpreg80[10]; convert_f64le_to_f80le ((UChar *)&x86->guest_FPREG[regno-16], fpreg80); VG_(transfer) (&fpreg80, buf, dir, sizeof(fpreg80), mod); } else { ULong fpreg64; convert_f80le_to_f64le (buf, (UChar *)&fpreg64); VG_(transfer) (&x86->guest_FPREG[regno-16], &fpreg64, dir, sizeof(fpreg64), mod); } break; } case 24: if (dir == valgrind_to_gdbserver) { // vex only models the rounding bits (see libvex_guest_x86.h) UWord value = 0x037f; value |= x86->guest_FPROUND << 10; VG_(transfer)(&value, buf, dir, size, mod); } else { *mod = False; // GDBTD???? VEX { "fctrl", 1152, 32 }, } break; case 25: if (dir == valgrind_to_gdbserver) { UWord value = x86->guest_FC3210; value |= (x86->guest_FTOP & 7) << 11; VG_(transfer)(&value, buf, dir, size, mod); } else { *mod = False; // GDBTD???? VEX { "fstat", 1184, 32 }, } break; case 26: if (dir == valgrind_to_gdbserver) { // vex doesn't model these precisely UWord value = ((x86->guest_FPTAG[0] ? 0 : 3) << 0) | ((x86->guest_FPTAG[1] ? 0 : 3) << 2) | ((x86->guest_FPTAG[2] ? 0 : 3) << 4) | ((x86->guest_FPTAG[3] ? 0 : 3) << 6) | ((x86->guest_FPTAG[4] ? 0 : 3) << 8) | ((x86->guest_FPTAG[5] ? 0 : 3) << 10) | ((x86->guest_FPTAG[6] ? 0 : 3) << 12) | ((x86->guest_FPTAG[7] ? 0 : 3) << 14); VG_(transfer)(&value, buf, dir, size, mod); } else { *mod = False; // GDBTD???? VEX { "ftag", 1216, 32 }, } break; case 27: *mod = False; break; // GDBTD???? VEX { "fiseg", 1248, 32 }, case 28: *mod = False; break; // GDBTD???? VEX { "fioff", 1280, 32 }, case 29: *mod = False; break; // GDBTD???? VEX { "foseg", 1312, 32 }, case 30: *mod = False; break; // GDBTD???? VEX { "fooff", 1344, 32 }, case 31: *mod = False; break; // GDBTD???? VEX { "fop", 1376, 32 }, case 32: VG_(transfer) (&x86->guest_XMM0, buf, dir, size, mod); break; case 33: VG_(transfer) (&x86->guest_XMM1, buf, dir, size, mod); break; case 34: VG_(transfer) (&x86->guest_XMM2, buf, dir, size, mod); break; case 35: VG_(transfer) (&x86->guest_XMM3, buf, dir, size, mod); break; case 36: VG_(transfer) (&x86->guest_XMM4, buf, dir, size, mod); break; case 37: VG_(transfer) (&x86->guest_XMM5, buf, dir, size, mod); break; case 38: VG_(transfer) (&x86->guest_XMM6, buf, dir, size, mod); break; case 39: VG_(transfer) (&x86->guest_XMM7, buf, dir, size, mod); break; case 40: if (dir == valgrind_to_gdbserver) { // vex only models the rounding bits (see libvex_guest_x86.h) UWord value = 0x1f80; value |= x86->guest_SSEROUND << 13; VG_(transfer)(&value, buf, dir, size, mod); } else { *mod = False; // GDBTD???? VEX { "mxcsr", 2432, 32 }, } break; case 41: *mod = False; break; // GDBTD???? VEX { "orig_eax", 2464, 32 }, default: vg_assert(0); }}
开发者ID:MarcelHB,项目名称:valgrind-fitin,代码行数:101,
示例4: VG_/* Start debugger and get it to attach to this process. Called if the user requests this service after an error has been shown, so she can poke around and look at parameters, memory, etc. You can't meaningfully get the debugger to continue the program, though; to continue, quit the debugger. */void VG_(start_debugger) ( ThreadId tid ){# define N_BUF 4096 Int pid; if ((pid = VG_(fork)()) == 0) { VG_(ptrace)(VKI_PTRACE_TRACEME, 0, NULL, NULL); VG_(kill)(VG_(getpid)(), VKI_SIGSTOP); } else if (pid > 0) { Int status; Int res; if ((res = VG_(waitpid)(pid, &status, 0)) == pid && WIFSTOPPED(status) && WSTOPSIG(status) == VKI_SIGSTOP && ptrace_setregs(pid, &(VG_(threads)[tid].arch.vex)) == 0 && VG_(kill)(pid, VKI_SIGSTOP) == 0 && VG_(ptrace)(VKI_PTRACE_DETACH, pid, NULL, 0) == 0) { Char pidbuf[15]; Char file[50]; Char buf[N_BUF]; Char *bufptr; Char *cmdptr; VG_(sprintf)(pidbuf, "%d", pid); VG_(sprintf)(file, "/proc/%d/fd/%d", pid, VG_(cl_exec_fd)); bufptr = buf; cmdptr = VG_(clo_db_command); while (*cmdptr) { /* each iteration can advance bufptr by at most the length of file[], so the following assertion is generously over-paranoid. */ vg_assert(bufptr - buf < N_BUF-15-50-10/*paranoia*/); switch (*cmdptr) { case '%': switch (*++cmdptr) { case 'f': VG_(memcpy)(bufptr, file, VG_(strlen)(file)); bufptr += VG_(strlen)(file); cmdptr++; break; case 'p': VG_(memcpy)(bufptr, pidbuf, VG_(strlen)(pidbuf)); bufptr += VG_(strlen)(pidbuf); cmdptr++; break; default: *bufptr++ = *cmdptr++; break; } break; default: *bufptr++ = *cmdptr++; break; } vg_assert(bufptr - buf < N_BUF-15-50-10/*paranoia*/); } *bufptr++ = '/0'; VG_(message)(Vg_UserMsg, "starting debugger with cmd: %s", buf); res = VG_(system)(buf); if (res == 0) { VG_(message)(Vg_UserMsg, ""); VG_(message)(Vg_UserMsg, "Debugger has detached. Valgrind regains control. We continue."); } else { VG_(message)(Vg_UserMsg, "Apparently failed!"); VG_(message)(Vg_UserMsg, ""); } } VG_(kill)(pid, VKI_SIGKILL); VG_(waitpid)(pid, &status, 0); }# undef N_BUF}
开发者ID:svn2github,项目名称:valgrind-3,代码行数:85,
示例5: mul_MaybeULongstatic MaybeULong mul_MaybeULong ( MaybeULong mul1, MaybeULong mul2 ) { if (!mul1.b) { vg_assert(mul1.ul == 0); return mul1; } if (!mul2.b) { vg_assert(mul2.ul == 0); return mul2; } mul1.ul *= mul2.ul; return mul1;}
开发者ID:sabinaya,项目名称:valgrind-variant,代码行数:6,
示例6: ML_XArray* /*HChar*/ ML_(describe_type)( /*OUT*/PtrdiffT* residual_offset, XArray* /* of TyEnt */ tyents, UWord ty_cuOff, PtrdiffT offset ){ TyEnt* ty; XArray* xa = VG_(newXA)( ML_(dinfo_zalloc), "di.tytypes.dt.1", ML_(dinfo_free), sizeof(HChar) ); vg_assert(xa); ty = ML_(TyEnts__index_by_cuOff)(tyents, NULL, ty_cuOff); while (True) { vg_assert(ty); vg_assert(ML_(TyEnt__is_type)(ty)); switch (ty->tag) { /* These are all atomic types; there is nothing useful we can do. */ case Te_TyEnum: case Te_TyFn: case Te_TyVoid: case Te_TyPtr: case Te_TyRef: case Te_TyPtrMbr: case Te_TyRvalRef: case Te_TyBase: goto done; case Te_TyStOrUn: { Word i; GXResult res; MaybeULong mul; XArray* fieldRs; UWord fieldR; TyEnt* field = NULL; PtrdiffT offMin = 0, offMax1 = 0; if (!ty->Te.TyStOrUn.isStruct) goto done; fieldRs = ty->Te.TyStOrUn.fieldRs; if ((!fieldRs) || VG_(sizeXA)(fieldRs) == 0) goto done; for (i = 0; i < VG_(sizeXA)( fieldRs ); i++ ) { fieldR = *(UWord*)VG_(indexXA)( fieldRs, i ); field = ML_(TyEnts__index_by_cuOff)(tyents, NULL, fieldR); vg_assert(field); vg_assert(field->tag == Te_Field); vg_assert(field->Te.Field.nLoc < 0 || (field->Te.Field.nLoc > 0 && field->Te.Field.pos.loc)); if (field->Te.Field.nLoc == -1) { res.kind = GXR_Addr; res.word = field->Te.Field.pos.offset; } else { /* Re data_bias in this call, we should really send in a legitimate value. But the expression is expected to be a constant expression, evaluation of which will not need to use DW_OP_addr and hence we can avoid the trouble of plumbing the data bias through to this point (if, indeed, it has any meaning; from which DebugInfo would we take the data bias? */ res = ML_(evaluate_Dwarf3_Expr)( field->Te.Field.pos.loc, field->Te.Field.nLoc, NULL/*fbGX*/, NULL/*RegSummary*/, 0/*data_bias*/, True/*push_initial_zero*/); if (0) { VG_(printf)("QQQ "); ML_(pp_GXResult)(res); VG_(printf)("/n"); } } if (res.kind != GXR_Addr) continue; mul = ML_(sizeOfType)( tyents, field->Te.Field.typeR ); if (mul.b != True) goto done; /* size of field is unknown (?!) */ offMin = res.word; offMax1 = offMin + (PtrdiffT)mul.ul; if (offMin == offMax1) continue; vg_assert(offMin < offMax1); if (offset >= offMin && offset < offMax1) break; } /* Did we find a suitable field? */ vg_assert(i >= 0 && i <= VG_(sizeXA)( fieldRs )); if (i == VG_(sizeXA)( fieldRs )) goto done; /* No. Give up. */ /* Yes. 'field' is it. */ vg_assert(field); if (!field->Te.Field.name) goto done; VG_(addBytesToXA)( xa, ".", 1 ); VG_(addBytesToXA)( xa, field->Te.Field.name, VG_(strlen)(field->Te.Field.name) ); offset -= offMin; ty = ML_(TyEnts__index_by_cuOff)(tyents, NULL, field->Te.Field.typeR ); tl_assert(ty); if (ty->tag == Te_UNKNOWN) goto done;//.........这里部分代码省略.........
开发者ID:sabinaya,项目名称:valgrind-variant,代码行数:101,
示例7: VG_/* Should we trace into this child executable (across execve etc) ? This involves considering --trace-children=, --trace-children-skip=, --trace-children-skip-by-arg=, and the name of the executable. 'child_argv' must not include the name of the executable itself; iow child_argv[0] must be the first arg, if any, for the child. */Bool VG_(should_we_trace_this_child) ( HChar* child_exe_name, HChar** child_argv ){ // child_exe_name is pulled out of the guest's space. We // should be at least marginally cautious with it, lest it // explode or burst into flames unexpectedly. if (child_exe_name == NULL || VG_(strlen)(child_exe_name) == 0) return VG_(clo_trace_children); // we know narfink // If --trace-children=no, the answer is simply NO. if (! VG_(clo_trace_children)) return False; // Otherwise, look for other reasons to say NO. First, // see if the exe name matches any of the patterns specified // by --trace-children-skip=. if (VG_(clo_trace_children_skip)) { HChar const* last = VG_(clo_trace_children_skip); HChar const* name = child_exe_name; while (*last) { Bool matches; HChar* patt; HChar const* first = consume_commas(last); last = consume_field(first); if (first == last) break; vg_assert(last > first); /* copy the candidate string into a temporary malloc'd block so we can use VG_(string_match) on it. */ patt = VG_(calloc)("m_options.swttc.1", last - first + 1, 1); VG_(memcpy)(patt, first, last - first); vg_assert(patt[last-first] == 0); matches = VG_(string_match)(patt, name); VG_(free)(patt); if (matches) return False; } } // Check if any of the args match any of the patterns specified // by --trace-children-skip-by-arg=. if (VG_(clo_trace_children_skip_by_arg) && child_argv != NULL) { HChar const* last = VG_(clo_trace_children_skip_by_arg); while (*last) { Int i; Bool matches; HChar* patt; HChar const* first = consume_commas(last); last = consume_field(first); if (first == last) break; vg_assert(last > first); /* copy the candidate string into a temporary malloc'd block so we can use VG_(string_match) on it. */ patt = VG_(calloc)("m_options.swttc.1", last - first + 1, 1); VG_(memcpy)(patt, first, last - first); vg_assert(patt[last-first] == 0); for (i = 0; child_argv[i]; i++) { matches = VG_(string_match)(patt, child_argv[i]); if (matches) { VG_(free)(patt); return False; } } VG_(free)(patt); } } // --trace-children=yes, and this particular executable isn't // excluded return True;}
开发者ID:lu-zero,项目名称:valgrind,代码行数:78,
示例8: mul_MaybeUWordstatic MaybeUWord mul_MaybeUWord ( MaybeUWord muw1, MaybeUWord muw2 ) { if (!muw1.b) { vg_assert(muw1.w == 0); return muw1; } if (!muw2.b) { vg_assert(muw2.w == 0); return muw2; } muw1.w *= muw2.w; return muw1;}
开发者ID:eeight,项目名称:tdheap,代码行数:6,
示例9: VG_void* VG_(client_realloc) ( ThreadState* tst, void* p, UInt new_size ){ ShadowChunk *sc; ShadowChunk **prev_chunks_next_ptr; UInt i; VGP_PUSHCC(VgpCliMalloc); vg_cmalloc_n_frees ++; vg_cmalloc_n_mallocs ++; vg_cmalloc_bs_mallocd += new_size; if (! needs_shadow_chunks()) { vg_assert(p != NULL && new_size != 0); p = VG_(arena_realloc) ( VG_AR_CLIENT, p, VG_(clo_alignment), new_size ); VGP_POPCC(VgpCliMalloc); return p; } else { /* First try and find the block. */ sc = getShadowChunk ( (Addr)p, &prev_chunks_next_ptr ); if (sc == NULL) { VG_TRACK( bad_free, tst, (Addr)p ); /* Perhaps we should return to the program regardless. */ VGP_POPCC(VgpCliMalloc); return NULL; } /* check if its a matching free() / delete / delete [] */ if (Vg_AllocMalloc != sc->allockind) { /* can not realloc a range that was allocated with new or new [] */ VG_TRACK( mismatched_free, tst, (Addr)p ); /* but keep going anyway */ } if (sc->size == new_size) { /* size unchanged */ VGP_POPCC(VgpCliMalloc); return p; } else if (sc->size > new_size) { /* new size is smaller */ VG_TRACK( die_mem_heap, sc->data+new_size, sc->size-new_size ); sc->size = new_size; VGP_POPCC(VgpCliMalloc);# ifdef DEBUG_CLIENTMALLOC VG_(printf)("[m %d, f %d (%d)] client_realloc_smaller ( %p, %d ) = %p/n", count_malloclists(), 0/*count_freelist()*/, 0/*vg_freed_list_volume*/, p, new_size, p );# endif return p; } else { /* new size is bigger */ Addr p_new; /* Get new memory */ vg_assert(VG_(clo_alignment) >= 4); if (VG_(clo_alignment) == 4) p_new = (Addr)VG_(arena_malloc)(VG_AR_CLIENT, new_size); else p_new = (Addr)VG_(arena_malloc_aligned)(VG_AR_CLIENT, VG_(clo_alignment), new_size); /* First half kept and copied, second half new, red zones as normal */ VG_TRACK( ban_mem_heap, p_new-VG_AR_CLIENT_REDZONE_SZB, VG_AR_CLIENT_REDZONE_SZB ); VG_TRACK( copy_mem_heap, (Addr)p, p_new, sc->size ); VG_TRACK( new_mem_heap, p_new+sc->size, new_size-sc->size, /*inited=*/False ); VG_TRACK( ban_mem_heap, p_new+new_size, VG_AR_CLIENT_REDZONE_SZB ); /* Copy from old to new */ for (i = 0; i < sc->size; i++) ((UChar*)p_new)[i] = ((UChar*)p)[i]; /* Free old memory */ die_and_free_mem ( tst, sc, prev_chunks_next_ptr ); /* this has to be after die_and_free_mem, otherwise the former succeeds in shorting out the new block, not the old, in the case when both are on the same list. */ addShadowChunk ( tst, p_new, new_size, Vg_AllocMalloc ); VGP_POPCC(VgpCliMalloc);# ifdef DEBUG_CLIENTMALLOC VG_(printf)("[m %d, f %d (%d)] client_realloc_bigger ( %p, %d ) = %p/n", count_malloclists(), 0/*count_freelist()*/, 0/*vg_freed_list_volume*/, p, new_size, (void*)p_new );# endif return (void*)p_new; } }}
开发者ID:svn2github,项目名称:valgrind-3,代码行数:99,
示例10: VG_/* returns: 0 = success, non-0 is failure */Int VG_(load_script)(Int fd, const HChar* name, ExeInfo* info){ Char hdr[4096]; Int len = 4096; Int eol; Char* interp; Char* end; Char* cp; Char* arg = NULL; SysRes res; // Read the first part of the file. res = VG_(pread)(fd, hdr, len, 0); if (sr_isError(res)) { VG_(close)(fd); return VKI_EACCES; } else { len = sr_Res(res); } vg_assert('#' == hdr[0] && '!' == hdr[1]); end = hdr + len; interp = hdr + 2; while (interp < end && VG_(isspace)(*interp)) interp++; vg_assert(*interp == '/'); /* absolute path only for interpreter */ /* skip over interpreter name */ for (cp = interp; cp < end && !VG_(isspace)(*cp); cp++) ; eol = (*cp == '/n'); *cp++ = '/0'; if (!eol && cp < end) { /* skip space before arg */ while (cp < end && VG_(isspace)(*cp) && *cp != '/n') cp++; /* arg is from here to eol */ arg = cp; while (cp < end && *cp != '/n') cp++; *cp = '/0'; } info->interp_name = VG_(strdup)("ume.ls.1", interp); vg_assert(NULL != info->interp_name); if (arg != NULL && *arg != '/0') { info->interp_args = VG_(strdup)("ume.ls.2", arg); vg_assert(NULL != info->interp_args); } if (info->argv && info->argv[0] != NULL) info->argv[0] = (char *)name; VG_(args_the_exename) = name; if (0) VG_(printf)("#! script: interp_name=/"%s/" interp_args=/"%s/"/n", info->interp_name, info->interp_args); return VG_(do_exec_inner)(interp, info);}
开发者ID:AmesianX,项目名称:pathgrind,代码行数:68,
示例11: VG_//.........这里部分代码省略......... if (!VG_IS_PAGE_ALIGNED(arg1)) { /* zap any misaligned addresses. */ /* SuSV3 says misaligned addresses only cause the MAP_FIXED case to fail. Here, we catch them all. */ return VG_(mk_SysRes_Error)( VKI_EINVAL ); } if (!VG_IS_PAGE_ALIGNED(arg6)) { /* zap any misaligned offsets. */ /* SuSV3 says: The off argument is constrained to be aligned and sized according to the value returned by sysconf() when passed _SC_PAGESIZE or _SC_PAGE_SIZE. */ return VG_(mk_SysRes_Error)( VKI_EINVAL ); } /* Figure out what kind of allocation constraints there are (fixed/hint/any), and ask aspacem what we should do. */ mreq.start = arg1; mreq.len = arg2; if (arg4 & VKI_MAP_FIXED) { mreq.rkind = MFixed; } else if (arg1 != 0) { mreq.rkind = MHint; } else { mreq.rkind = MAny; } if ((VKI_SHMLBA > VKI_PAGE_SIZE) && (VKI_MAP_SHARED & arg4) && !(VKI_MAP_FIXED & arg4)) mreq.len = arg2 + VKI_SHMLBA - VKI_PAGE_SIZE; /* Enquire ... */ advised = VG_(am_get_advisory)( &mreq, True/*client*/, &mreq_ok ); if ((VKI_SHMLBA > VKI_PAGE_SIZE) && (VKI_MAP_SHARED & arg4) && !(VKI_MAP_FIXED & arg4)) advised = VG_ROUNDUP(advised, VKI_SHMLBA); if (!mreq_ok) { /* Our request was bounced, so we'd better fail. */ return VG_(mk_SysRes_Error)( VKI_EINVAL ); } /* Otherwise we're OK (so far). Install aspacem's choice of address, and let the mmap go through. */ sres = VG_(am_do_mmap_NO_NOTIFY)(advised, arg2, arg3, arg4 | VKI_MAP_FIXED, arg5, arg6); /* A refinement: it may be that the kernel refused aspacem's choice of address. If we were originally asked for a hinted mapping, there is still a last chance: try again at any address. Hence: */ if (mreq.rkind == MHint && sr_isError(sres)) { mreq.start = 0; mreq.len = arg2; mreq.rkind = MAny; advised = VG_(am_get_advisory)( &mreq, True/*client*/, &mreq_ok ); if (!mreq_ok) { /* Our request was bounced, so we'd better fail. */ return VG_(mk_SysRes_Error)( VKI_EINVAL ); } /* and try again with the kernel */ sres = VG_(am_do_mmap_NO_NOTIFY)(advised, arg2, arg3, arg4 | VKI_MAP_FIXED, arg5, arg6); } if (!sr_isError(sres)) { ULong di_handle; /* Notify aspacem. */ notify_core_of_mmap( (Addr)sr_Res(sres), /* addr kernel actually assigned */ arg2, /* length */ arg3, /* prot */ arg4, /* the original flags value */ arg5, /* fd */ arg6 /* offset */ ); /* Load symbols? */ di_handle = VG_(di_notify_mmap)( (Addr)sr_Res(sres), False/*allow_SkFileV*/, (Int)arg5 ); /* Notify the tool. */ notify_tool_of_mmap( (Addr)sr_Res(sres), /* addr kernel actually assigned */ arg2, /* length */ arg3, /* prot */ di_handle /* so the tool can refer to the read debuginfo later, if it wants. */ ); } /* Stay sane */ if (!sr_isError(sres) && (arg4 & VKI_MAP_FIXED)) vg_assert(sr_Res(sres) == arg1); return sres;}
开发者ID:Grindland,项目名称:valgrind-android,代码行数:101,
示例12: do_clonestatic SysRes do_clone (ThreadId ptid, UInt flags, Addr sp, Int * parent_tidptr, Int * child_tidptr, Addr child_tls) { const Bool debug = False; ThreadId ctid = VG_ (alloc_ThreadState) (); ThreadState * ptst = VG_ (get_ThreadState) (ptid); ThreadState * ctst = VG_ (get_ThreadState) (ctid); UInt ret = 0; UWord * stack; SysRes res; vki_sigset_t blockall, savedmask; VG_ (sigfillset) (&blockall); vg_assert (VG_ (is_running_thread) (ptid)); vg_assert (VG_ (is_valid_tid) (ctid)); stack = (UWord *) ML_ (allocstack) (ctid); if (stack == NULL) { res = VG_ (mk_SysRes_Error) (VKI_ENOMEM); goto out; } setup_child (&ctst->arch, &ptst->arch); /* on MIPS we need to set V0 and A3 to zero */ ctst->arch.vex.guest_r2 = 0; ctst->arch.vex.guest_r7 = 0; if (sp != 0) ctst->arch.vex.guest_r29 = sp; ctst->os_state.parent = ptid; ctst->sig_mask = ptst->sig_mask; ctst->tmp_sig_mask = ptst->sig_mask; /* Start the child with its threadgroup being the same as the parent's. This is so that any exit_group calls that happen after the child is created but before it sets its os_state.threadgroup field for real (in thread_wrapper in syswrap-linux.c), really kill the new thread. a.k.a this avoids a race condition in which the thread is unkillable (via exit_group) because its threadgroup is not set. The race window is probably only a few hundred or a few thousand cycles long. See #226116. */ ctst->os_state.threadgroup = ptst->os_state.threadgroup; ML_(guess_and_register_stack) (sp, ctst); VG_TRACK (pre_thread_ll_create, ptid, ctid); if (flags & VKI_CLONE_SETTLS) { if (debug) VG_(printf)("clone child has SETTLS: tls at %#lx/n", child_tls); ctst->arch.vex.guest_r27 = child_tls; res = sys_set_tls(ctid, child_tls); if (sr_isError(res)) goto out; ctst->arch.vex.guest_r27 = child_tls; } flags &= ~VKI_CLONE_SETTLS; VG_ (sigprocmask) (VKI_SIG_SETMASK, &blockall, &savedmask); /* Create the new thread */ ret = do_syscall_clone_mips_linux (ML_ (start_thread_NORETURN), stack, flags, &VG_ (threads)[ctid], child_tidptr, parent_tidptr, 0 /*child_tls*/); /* High half word64 is syscall return value. Low half is the entire CR, from which we need to extract CR0.SO. */ if (debug) VG_(printf)("ret: 0x%x/n", ret); res = VG_ (mk_SysRes_mips32_linux) (/*val */ ret, 0, /*errflag */ 0); VG_ (sigprocmask) (VKI_SIG_SETMASK, &savedmask, NULL); out: if (sr_isError (res)) { VG_(cleanup_thread) (&ctst->arch); ctst->status = VgTs_Empty; VG_TRACK (pre_thread_ll_exit, ctid); } ptst->arch.vex.guest_r2 = 0; return res;}
开发者ID:Grindland,项目名称:valgrind-android,代码行数:87,
示例13: gdbserver_process_exit_encounteredvoid gdbserver_process_exit_encountered (unsigned char status, Int code){ vg_assert (status == 'W' || status == 'X'); exit_status_to_report = status; exit_code_to_report = code;}
开发者ID:lu-zero,项目名称:valgrind,代码行数:6,
示例14: signals/* Do initial consistency checks on some of the definitions to do with signals (vki_sigset_t and vki_sigaction_{toK,fromK}_t). This stuff is fragile enough that it's important to check at startup that the world looks like what we expect it to look like. The most important thing is to check that the definition of signal sets for this platform is right. A signal set consists of some number _VKI_NSIG_WORDS of 32- or 64-bit words. Because the kernel itself has some indexing scheme to set/clear individual bits in the set, we must make sure we use the same layout/scheme: where this requirement bites us is in the VG_(sigfillset) etc functions in m_libcsignal.c. So we check carefully here that it's all sensible.*/void VG_(vki_do_initial_consistency_checks) ( void ){ /* --- Platform-independent checks on signal sets --- */ vki_sigset_t set; // Set's size must agree with _VKI_NSIG vg_assert( 8 * sizeof(set) == _VKI_NSIG ); // Set's word size must agree with _VKI_NSIG_BPW vg_assert( 8 * sizeof(set.sig[0]) == _VKI_NSIG_BPW ); // The set elements are 32- or 64-bit vg_assert( _VKI_NSIG_BPW == 32 || _VKI_NSIG_BPW == 64 ); /* --- Platform-specific checks on signal sets --- */# if defined(VGO_linux) /* nothing to check */# elif defined(VGP_x86_darwin) || defined(VGP_amd64_darwin) vg_assert(_VKI_NSIG == NSIG); vg_assert(_VKI_NSIG == 32); vg_assert(_VKI_NSIG_WORDS == 1); vg_assert(sizeof(sigset_t) /* defined by Darwin */ == sizeof(vki_sigset_t) /* what we actually use */);# else# error "Unknown plat"# endif /* --- Platform-specific checks on sigactions --- */# if defined(VGO_linux) /* the toK- and fromK- forms are identical */ vg_assert( sizeof(vki_sigaction_toK_t) == sizeof(vki_sigaction_fromK_t) );# elif defined(VGO_darwin) /* the toK- and fromK- forms differ by one function-pointer field (sa_tramp) */ vg_assert( sizeof(vki_sigaction_toK_t) == sizeof(vki_sigaction_fromK_t) + sizeof(void*) ); vg_assert(sizeof(struct sigaction) == sizeof(vki_sigaction_fromK_t)); vg_assert(sizeof(struct __sigaction) == sizeof(vki_sigaction_toK_t)); { struct __sigaction t1; vki_sigaction_toK_t t2; struct sigaction f1; vki_sigaction_fromK_t f2; vg_assert(sizeof(t1.sa_handler) == sizeof(t2.ksa_handler)); vg_assert(sizeof(t1.sa_tramp) == sizeof(t2.sa_tramp)); vg_assert(sizeof(t1.sa_mask) == sizeof(t2.sa_mask)); vg_assert(sizeof(t1.sa_flags) == sizeof(t2.sa_flags)); vg_assert(sizeof(f1.sa_handler) == sizeof(f2.ksa_handler)); vg_assert(sizeof(f1.sa_mask) == sizeof(f2.sa_mask)); vg_assert(sizeof(f1.sa_flags) == sizeof(f2.sa_flags));# if 0 vg_assert(offsetof(t1,sa_handler) == offsetof(t2.ksa_handler)); vg_assert(offsetof(t1.sa_tramp) == offsetof(t2.sa_tramp)); vg_assert(offsetof(t1.sa_mask) == offsetof(t2.sa_mask)); vg_assert(offsetof(t1.sa_flags) == offsetof(t2.sa_flags)); vg_assert(offsetof(f1.sa_handler) == offsetof(f2.ksa_handler)); vg_assert(offsetof(f1.sa_mask) == offsetof(f2.sa_mask)); vg_assert(offsetof(f1.sa_flags) == offsetof(f2.sa_flags));# endif } /* also .. */ /* VKI_SET_SIGMASK is hardwired into syscall-x86-darwin.S and syscall-amd64-darwin.S */ vg_assert(VKI_SIG_SETMASK == 3);# else# error "Unknown OS" # endif}
开发者ID:PDi-Communication-Systems-Inc,项目名称:lollipop_external_valgrind,代码行数:83,
示例15: setup_client_stackstatic Addr setup_client_stack( void* init_sp, char** orig_envp, const ExeInfo* info, Addr clstack_end, SizeT clstack_max_size ){ char **cpp; char *strtab; /* string table */ char *stringbase; Addr *ptr; unsigned stringsize; /* total size of strings in bytes */ unsigned auxsize; /* total size of auxv in bytes */ Int argc; /* total argc */ Int envc; /* total number of env vars */ unsigned stacksize; /* total client stack size */ Addr client_SP; /* client stack base (initial SP) */ Addr clstack_start; Int i; Bool have_exename; vg_assert(VG_IS_PAGE_ALIGNED(clstack_end+1)); vg_assert( VG_(args_for_client) ); /* ==================== compute sizes ==================== */ /* first of all, work out how big the client stack will be */ stringsize = 0; auxsize = 0; have_exename = VG_(args_the_exename) != NULL; /* paste on the extra args if the loader needs them (ie, the #! interpreter and its argument) */ argc = 0; if (info->interp_name != NULL) { argc++; stringsize += VG_(strlen)(info->interp_name) + 1; } if (info->interp_args != NULL) { argc++; stringsize += VG_(strlen)(info->interp_args) + 1; } /* now scan the args we're given... */ if (have_exename) stringsize += VG_(strlen)( VG_(args_the_exename) ) + 1; for (i = 0; i < VG_(sizeXA)( VG_(args_for_client) ); i++) { argc++; stringsize += VG_(strlen)( * (HChar**) VG_(indexXA)( VG_(args_for_client), i )) + 1; } /* ...and the environment */ envc = 0; for (cpp = orig_envp; cpp && *cpp; cpp++) { envc++; stringsize += VG_(strlen)(*cpp) + 1; } /* Darwin executable_path + NULL */ auxsize += 2 * sizeof(Word); if (info->executable_path) { stringsize += 1 + VG_(strlen)(info->executable_path); } /* Darwin mach_header */ if (info->dynamic) auxsize += sizeof(Word); /* OK, now we know how big the client stack is */ stacksize = sizeof(Word) + /* argc */ (have_exename ? sizeof(char **) : 0) + /* argc[0] == exename */ sizeof(char **)*argc + /* argv */ sizeof(char **) + /* terminal NULL */ sizeof(char **)*envc + /* envp */ sizeof(char **) + /* terminal NULL */ auxsize + /* auxv */ VG_ROUNDUP(stringsize, sizeof(Word)); /* strings (aligned) */ if (0) VG_(printf)("stacksize = %d/n", stacksize); /* client_SP is the client's stack pointer */ client_SP = clstack_end - stacksize; client_SP = VG_ROUNDDN(client_SP, 32); /* make stack 32 byte aligned */ /* base of the string table (aligned) */ stringbase = strtab = (char *)clstack_end - VG_ROUNDUP(stringsize, sizeof(int)); /* The max stack size */ clstack_max_size = VG_PGROUNDUP(clstack_max_size); /* Darwin stack is chosen by the ume loader */ clstack_start = clstack_end - clstack_max_size; /* Record stack extent -- needed for stack-change code. */ /* GrP fixme really? */ VG_(clstk_base) = clstack_start;//.........这里部分代码省略.........
开发者ID:cherry-wb,项目名称:SmartFuzz,代码行数:101,
示例16: transfer_registerstaticvoid transfer_register (ThreadId tid, int abs_regno, void * buf, transfer_direction dir, int size, Bool *mod){ ThreadState* tst = VG_(get_ThreadState)(tid); int set = abs_regno / num_regs; int regno = abs_regno % num_regs; *mod = False; VexGuestARMState* arm = (VexGuestARMState*) get_arch (set, tst); switch (regno) { case 0: VG_(transfer) (&arm->guest_R0, buf, dir, size, mod); break; case 1: VG_(transfer) (&arm->guest_R1, buf, dir, size, mod); break; case 2: VG_(transfer) (&arm->guest_R2, buf, dir, size, mod); break; case 3: VG_(transfer) (&arm->guest_R3, buf, dir, size, mod); break; case 4: VG_(transfer) (&arm->guest_R4, buf, dir, size, mod); break; case 5: VG_(transfer) (&arm->guest_R5, buf, dir, size, mod); break; case 6: VG_(transfer) (&arm->guest_R6, buf, dir, size, mod); break; case 7: VG_(transfer) (&arm->guest_R7, buf, dir, size, mod); break; case 8: VG_(transfer) (&arm->guest_R8, buf, dir, size, mod); break; case 9: VG_(transfer) (&arm->guest_R9, buf, dir, size, mod); break; case 10: VG_(transfer) (&arm->guest_R10, buf, dir, size, mod); break; case 11: VG_(transfer) (&arm->guest_R11, buf, dir, size, mod); break; case 12: VG_(transfer) (&arm->guest_R12, buf, dir, size, mod); break; case 13: VG_(transfer) (&arm->guest_R13, buf, dir, size, mod); break; case 14: VG_(transfer) (&arm->guest_R14, buf, dir, size, mod); break; case 15: { VG_(transfer) (&arm->guest_R15T, buf, dir, size, mod); if (dir == gdbserver_to_valgrind && *mod) { arm->guest_R15T = thumb_pc(arm->guest_R15T); } break; } case 16: case 17: case 18: case 19: case 20: case 21: case 22: case 23: case 24: *mod = False; break; case 25: { UInt cpsr = LibVEX_GuestARM_get_cpsr (arm); if (dir == valgrind_to_gdbserver) { VG_(transfer) (&cpsr, buf, dir, size, mod); } else {# if 0 UInt newcpsr; VG_(transfer) (&newcpsr, buf, dir, size, mod); *mod = newcpsr != cpsr; LibVEX_GuestARM_put_flags (newcpsr, arm);# else *mod = False;# endif } break; } case 26: VG_(transfer) (&arm->guest_D0, buf, dir, size, mod); break; case 27: VG_(transfer) (&arm->guest_D1, buf, dir, size, mod); break; case 28: VG_(transfer) (&arm->guest_D2, buf, dir, size, mod); break; case 29: VG_(transfer) (&arm->guest_D3, buf, dir, size, mod); break; case 30: VG_(transfer) (&arm->guest_D4, buf, dir, size, mod); break; case 31: VG_(transfer) (&arm->guest_D5, buf, dir, size, mod); break; case 32: VG_(transfer) (&arm->guest_D6, buf, dir, size, mod); break; case 33: VG_(transfer) (&arm->guest_D7, buf, dir, size, mod); break; case 34: VG_(transfer) (&arm->guest_D8, buf, dir, size, mod); break; case 35: VG_(transfer) (&arm->guest_D9, buf, dir, size, mod); break; case 36: VG_(transfer) (&arm->guest_D10, buf, dir, size, mod); break; case 37: VG_(transfer) (&arm->guest_D11, buf, dir, size, mod); break; case 38: VG_(transfer) (&arm->guest_D12, buf, dir, size, mod); break; case 39: VG_(transfer) (&arm->guest_D13, buf, dir, size, mod); break; case 40: VG_(transfer) (&arm->guest_D14, buf, dir, size, mod); break; case 41: VG_(transfer) (&arm->guest_D15, buf, dir, size, mod); break; case 42: VG_(transfer) (&arm->guest_D16, buf, dir, size, mod); break; case 43: VG_(transfer) (&arm->guest_D17, buf, dir, size, mod); break; case 44: VG_(transfer) (&arm->guest_D18, buf, dir, size, mod); break; case 45: VG_(transfer) (&arm->guest_D19, buf, dir, size, mod); break; case 46: VG_(transfer) (&arm->guest_D20, buf, dir, size, mod); break; case 47: VG_(transfer) (&arm->guest_D21, buf, dir, size, mod); break; case 48: VG_(transfer) (&arm->guest_D22, buf, dir, size, mod); break; case 49: VG_(transfer) (&arm->guest_D23, buf, dir, size, mod); break; case 50: VG_(transfer) (&arm->guest_D24, buf, dir, size, mod); break; case 51: VG_(transfer) (&arm->guest_D25, buf, dir, size, mod); break; case 52: VG_(transfer) (&arm->guest_D26, buf, dir, size, mod); break; case 53: VG_(transfer) (&arm->guest_D27, buf, dir, size, mod); break; case 54: VG_(transfer) (&arm->guest_D28, buf, dir, size, mod); break; case 55: VG_(transfer) (&arm->guest_D29, buf, dir, size, mod); break; case 56: VG_(transfer) (&arm->guest_D30, buf, dir, size, mod); break; case 57: VG_(transfer) (&arm->guest_D31, buf, dir, size, mod); break; case 58: VG_(transfer) (&arm->guest_FPSCR, buf, dir, size, mod); break; default: vg_assert(0); }}
开发者ID:qtekfun,项目名称:htcDesire820Kernel,代码行数:100,
示例17: HT_ResetItervoid HT_ResetIter(HashTable * table) { vg_assert(table); table->iterNode = NULL; table->iterChain = 0; table->iterOK = True;}
开发者ID:coder-chenzhi,项目名称:aprof,代码行数:6,
示例18: VG_/* Top-level entry point to the error management subsystem. All detected errors are notified here; this routine decides if/when the user should see the error. */void VG_(maybe_record_error) ( ThreadId tid, ErrorKind ekind, Addr a, Char* s, void* extra ){ Error err; Error* p; Error* p_prev; UInt extra_size; VgRes exe_res = Vg_MedRes; static Bool stopping_message = False; static Bool slowdown_message = False; static Int n_errs_shown = 0; /* After M_COLLECT_NO_ERRORS_AFTER_SHOWN different errors have been found, or M_COLLECT_NO_ERRORS_AFTER_FOUND total errors have been found, just refuse to collect any more. This stops the burden of the error-management system becoming excessive in extremely buggy programs, although it does make it pretty pointless to continue the Valgrind run after this point. */ if (VG_(clo_error_limit) && (n_errs_shown >= M_COLLECT_NO_ERRORS_AFTER_SHOWN || n_errs_found >= M_COLLECT_NO_ERRORS_AFTER_FOUND) && !VG_(clo_xml)) { if (!stopping_message) { VG_(message)(Vg_UserMsg, ""); if (n_errs_shown >= M_COLLECT_NO_ERRORS_AFTER_SHOWN) { VG_(message)(Vg_UserMsg, "More than %d different errors detected. " "I'm not reporting any more.", M_COLLECT_NO_ERRORS_AFTER_SHOWN ); } else { VG_(message)(Vg_UserMsg, "More than %d total errors detected. " "I'm not reporting any more.", M_COLLECT_NO_ERRORS_AFTER_FOUND ); } VG_(message)(Vg_UserMsg, "Final error counts will be inaccurate. Go fix your program!"); VG_(message)(Vg_UserMsg, "Rerun with --error-limit=no to disable this cutoff. Note"); VG_(message)(Vg_UserMsg, "that errors may occur in your program without prior warning from"); VG_(message)(Vg_UserMsg, "Valgrind, because errors are no longer being displayed."); VG_(message)(Vg_UserMsg, ""); stopping_message = True; } return; } /* After M_COLLECT_ERRORS_SLOWLY_AFTER different errors have been found, be much more conservative about collecting new ones. */ if (n_errs_shown >= M_COLLECT_ERRORS_SLOWLY_AFTER && !VG_(clo_xml)) { exe_res = Vg_LowRes; if (!slowdown_message) { VG_(message)(Vg_UserMsg, ""); VG_(message)(Vg_UserMsg, "More than %d errors detected. Subsequent errors", M_COLLECT_ERRORS_SLOWLY_AFTER); VG_(message)(Vg_UserMsg, "will still be recorded, but in less detail than before."); slowdown_message = True; } } /* Build ourselves the error */ construct_error ( &err, tid, ekind, a, s, extra, NULL ); /* First, see if we've got an error record matching this one. */ p = errors; p_prev = NULL; while (p != NULL) { if (eq_Error(exe_res, p, &err)) { /* Found it. */ p->count++; if (p->supp != NULL) { /* Deal correctly with suppressed errors. */ p->supp->count++; n_errs_suppressed++; } else { n_errs_found++; } /* Move p to the front of the list so that future searches for it are faster. */ if (p_prev != NULL) { vg_assert(p_prev->next == p); p_prev->next = p->next; p->next = errors; errors = p; } return; }//.........这里部分代码省略.........
开发者ID:githubzenganiu,项目名称:toekn,代码行数:101,
示例19: do_clone/* When a client clones, we need to keep track of the new thread. This means: 1. allocate a ThreadId+ThreadState+stack for the thread 2. initialize the thread's new VCPU state 3. create the thread using the same args as the client requested, but using the scheduler entrypoint for EIP, and a separate stack for ESP. */static SysRes do_clone ( ThreadId ptid, ULong flags, Addr rsp, Long* parent_tidptr, Long* child_tidptr, Addr tlsaddr ){ static const Bool debug = False; ThreadId ctid = VG_(alloc_ThreadState)(); ThreadState* ptst = VG_(get_ThreadState)(ptid); ThreadState* ctst = VG_(get_ThreadState)(ctid); UWord* stack; SysRes res; Long rax; vki_sigset_t blockall, savedmask; VG_(sigfillset)(&blockall); vg_assert(VG_(is_running_thread)(ptid)); vg_assert(VG_(is_valid_tid)(ctid)); stack = (UWord*)ML_(allocstack)(ctid); if (stack == NULL) { res = VG_(mk_SysRes_Error)( VKI_ENOMEM ); goto out; } /* Copy register state Both parent and child return to the same place, and the code following the clone syscall works out which is which, so we don't need to worry about it. The parent gets the child's new tid returned from clone, but the child gets 0. If the clone call specifies a NULL rsp for the new thread, then it actually gets a copy of the parent's rsp. */ setup_child( &ctst->arch, &ptst->arch ); /* Make sys_clone appear to have returned Success(0) in the child. */ ctst->arch.vex.guest_RAX = 0; if (rsp != 0) ctst->arch.vex.guest_RSP = rsp; ctst->os_state.parent = ptid; /* inherit signal mask */ ctst->sig_mask = ptst->sig_mask; ctst->tmp_sig_mask = ptst->sig_mask; /* Start the child with its threadgroup being the same as the parent's. This is so that any exit_group calls that happen after the child is created but before it sets its os_state.threadgroup field for real (in thread_wrapper in syswrap-linux.c), really kill the new thread. a.k.a this avoids a race condition in which the thread is unkillable (via exit_group) because its threadgroup is not set. The race window is probably only a few hundred or a few thousand cycles long. See #226116. */ ctst->os_state.threadgroup = ptst->os_state.threadgroup; ML_(guess_and_register_stack) (rsp, ctst); /* Assume the clone will succeed, and tell any tool that wants to know that this thread has come into existence. If the clone fails, we'll send out a ll_exit notification for it at the out: label below, to clean up. */ vg_assert(VG_(owns_BigLock_LL)(ptid)); VG_TRACK ( pre_thread_ll_create, ptid, ctid ); if (flags & VKI_CLONE_SETTLS) { if (debug) VG_(printf)("clone child has SETTLS: tls at %#lx/n", tlsaddr); ctst->arch.vex.guest_FS_CONST = tlsaddr; } flags &= ~VKI_CLONE_SETTLS; /* start the thread with everything blocked */ VG_(sigprocmask)(VKI_SIG_SETMASK, &blockall, &savedmask); /* Create the new thread */ rax = do_syscall_clone_amd64_linux( ML_(start_thread_NORETURN), stack, flags, &VG_(threads)[ctid], child_tidptr, parent_tidptr, NULL );//.........这里部分代码省略.........
开发者ID:Grindland,项目名称:valgrind-master-mirror,代码行数:101,
示例20: False//.........这里部分代码省略......... } // Fat header is always BIG-ENDIAN fh_be = (struct fat_header *)ii->img; fh.magic = VG_(ntohl)(fh_be->magic); fh.nfat_arch = VG_(ntohl)(fh_be->nfat_arch); if (fh.magic == FAT_MAGIC) { // Look for a good architecture. struct fat_arch *arch_be; struct fat_arch arch; Int f; if (ii->img_szB < sizeof(struct fat_header) + fh.nfat_arch * sizeof(struct fat_arch)) { ML_(symerr)(di, True, "Invalid Mach-O file (1 too small)."); goto unmap_and_fail; } for (f = 0, arch_be = (struct fat_arch *)(fh_be+1); f < fh.nfat_arch; f++, arch_be++) { Int cputype;# if defined(VGA_ppc) cputype = CPU_TYPE_POWERPC;# elif defined(VGA_ppc64) cputype = CPU_TYPE_POWERPC64;# elif defined(VGA_x86) cputype = CPU_TYPE_X86;# elif defined(VGA_amd64) cputype = CPU_TYPE_X86_64;# else# error "unknown architecture"# endif arch.cputype = VG_(ntohl)(arch_be->cputype); arch.cpusubtype = VG_(ntohl)(arch_be->cpusubtype); arch.offset = VG_(ntohl)(arch_be->offset); arch.size = VG_(ntohl)(arch_be->size); if (arch.cputype == cputype) { if (ii->img_szB < arch.offset + arch.size) { ML_(symerr)(di, True, "Invalid Mach-O file (2 too small)."); goto unmap_and_fail; } ii->macho_img = ii->img + arch.offset; ii->macho_img_szB = arch.size; break; } } if (f == fh.nfat_arch) { ML_(symerr)(di, True, "No acceptable architecture found in fat file."); goto unmap_and_fail; } } /* Sanity check what we found. */ /* assured by logic above */ vg_assert(ii->img_szB >= sizeof(struct fat_header)); if (ii->macho_img_szB < sizeof(struct MACH_HEADER)) { ML_(symerr)(di, True, "Invalid Mach-O file (3 too small)."); goto unmap_and_fail; } if (ii->macho_img_szB > ii->img_szB) { ML_(symerr)(di, True, "Invalid Mach-O file (thin bigger than fat)."); goto unmap_and_fail; } if (ii->macho_img >= ii->img && ii->macho_img + ii->macho_img_szB <= ii->img + ii->img_szB) { /* thin entirely within fat, as expected */ } else { ML_(symerr)(di, True, "Invalid Mach-O file (thin not inside fat)."); goto unmap_and_fail; } mh = (struct MACH_HEADER *)ii->macho_img; if (mh->magic != MAGIC) { ML_(symerr)(di, True, "Invalid Mach-O file (bad magic)."); goto unmap_and_fail; } if (ii->macho_img_szB < sizeof(struct MACH_HEADER) + mh->sizeofcmds) { ML_(symerr)(di, True, "Invalid Mach-O file (4 too small)."); goto unmap_and_fail; } } vg_assert(ii->img); vg_assert(ii->macho_img); vg_assert(ii->img_szB > 0); vg_assert(ii->macho_img_szB > 0); vg_assert(ii->macho_img >= ii->img); vg_assert(ii->macho_img + ii->macho_img_szB <= ii->img + ii->img_szB); return True; /* success */ /*NOTREACHED*/ unmap_and_fail: unmap_image(ii); return False; /* bah! */}
开发者ID:svn2github,项目名称:valgrind-3,代码行数:101,
示例21: VG_/* EXPORTED */void VG_(sigframe_create)( ThreadId tid, Addr sp_top_of_frame, const vki_siginfo_t *siginfo, void *handler, UInt flags, const vki_sigset_t *mask, void *restorer ){ struct vg_sig_private *priv; Addr sp; ThreadState *tst; Int sigNo = siginfo->si_signo; Addr faultaddr; /* Stack must be 16-byte aligned */ sp_top_of_frame &= ~0xf; if (flags & VKI_SA_SIGINFO) { sp = sp_top_of_frame - sizeof(struct rt_sigframe); } else { sp = sp_top_of_frame - sizeof(struct nonrt_sigframe); } tst = VG_(get_ThreadState)(tid); if (!extend(tst, sp, sp_top_of_frame - sp)) return; vg_assert(VG_IS_16_ALIGNED(sp)); /* Set up the stack chain pointer */ VG_TRACK( pre_mem_write, Vg_CoreSignal, tid, "signal handler frame", sp, sizeof(UWord) ); *(Addr *)sp = tst->arch.vex.guest_GPR1; VG_TRACK( post_mem_write, Vg_CoreSignal, tid, sp, sizeof(UWord) ); faultaddr = (Addr)siginfo->_sifields._sigfault._addr; if (sigNo == VKI_SIGILL && siginfo->si_code > 0) faultaddr = tst->arch.vex.guest_CIA; if (flags & VKI_SA_SIGINFO) { struct rt_sigframe *frame = (struct rt_sigframe *) sp; struct vki_ucontext *ucp = &frame->ucontext; VG_TRACK( pre_mem_write, Vg_CoreSignal, tid, "signal frame siginfo", (Addr)&frame->siginfo, sizeof(frame->siginfo) ); VG_(memcpy)(&frame->siginfo, siginfo, sizeof(*siginfo)); VG_TRACK( post_mem_write, Vg_CoreSignal, tid, (Addr)&frame->siginfo, sizeof(frame->siginfo) ); VG_TRACK( pre_mem_write, Vg_CoreSignal, tid, "signal frame ucontext", (Addr)ucp, offsetof(struct vki_ucontext, uc_pad) ); ucp->uc_flags = 0; ucp->uc_link = 0; ucp->uc_stack = tst->altstack; VG_TRACK( post_mem_write, Vg_CoreSignal, tid, (Addr)ucp, offsetof(struct vki_ucontext, uc_pad) ); VG_TRACK( pre_mem_write, Vg_CoreSignal, tid, "signal frame ucontext", (Addr)&ucp->uc_regs, sizeof(ucp->uc_regs) + sizeof(ucp->uc_sigmask) ); ucp->uc_regs = &ucp->uc_mcontext; ucp->uc_sigmask = tst->sig_mask; VG_TRACK( post_mem_write, Vg_CoreSignal, tid, (Addr)&ucp->uc_regs, sizeof(ucp->uc_regs) + sizeof(ucp->uc_sigmask) ); stack_mcontext(&ucp->uc_mcontext, tst, __NR_rt_sigreturn, faultaddr); priv = &frame->priv; SET_SIGNAL_GPR(tid, 4, (Addr) &frame->siginfo); SET_SIGNAL_GPR(tid, 5, (Addr) ucp); /* the kernel sets this, though it doesn't seem to be in the ABI */ SET_SIGNAL_GPR(tid, 6, (Addr) &frame->siginfo); } else {
开发者ID:MShudrak,项目名称:flayer,代码行数:78,
示例22: read_symbol_table/* 'cand' is a bunch of candidate symbols obtained by reading nlist-style symbol table entries. Their ends may overlap, so sort them and truncate them accordingly. The code in this routine is copied almost verbatim from read_symbol_table() in readxcoff.c. */static void tidy_up_cand_syms ( /*MOD*/XArray* /* of DiSym */ syms, Bool trace_symtab ){ Word nsyms, i, j, k, m; nsyms = VG_(sizeXA)(syms); VG_(setCmpFnXA)(syms, cmp_DiSym_by_start_then_name); VG_(sortXA)(syms); /* We only know for sure the start addresses (actual VMAs) of symbols, and an overestimation of their end addresses. So sort by start address, then clip each symbol so that its end address does not overlap with the next one along. There is a small refinement: if a group of symbols have the same address, treat them as a group: find the next symbol along that has a higher start address, and clip all of the group accordingly. This clips the group as a whole so as not to overlap following symbols. This leaves prefersym() in storage.c, which is not nlist-specific, to later decide which of the symbols in the group to keep. Another refinement is that we need to get rid of symbols which, after clipping, have identical starts, ends, and names. So the sorting uses the name as a secondary key. */ for (i = 0; i < nsyms; i++) { for (k = i+1; k < nsyms && ((DiSym*)VG_(indexXA)(syms,i))->addr == ((DiSym*)VG_(indexXA)(syms,k))->addr; k++) ; /* So now [i .. k-1] is a group all with the same start address. Clip their ending addresses so they don't overlap [k]. In the normal case (no overlaps), k == i+1. */ if (k < nsyms) { DiSym* next = (DiSym*)VG_(indexXA)(syms,k); for (m = i; m < k; m++) { DiSym* here = (DiSym*)VG_(indexXA)(syms,m); vg_assert(here->addr < next->addr); if (here->addr + here->size > next->addr) here->size = next->addr - here->addr; } } i = k-1; vg_assert(i <= nsyms); } j = 0; if (nsyms > 0) { j = 1; for (i = 1; i < nsyms; i++) { DiSym *s_j1, *s_j, *s_i; vg_assert(j <= i); s_j1 = (DiSym*)VG_(indexXA)(syms, j-1); s_j = (DiSym*)VG_(indexXA)(syms, j); s_i = (DiSym*)VG_(indexXA)(syms, i); if (s_i->addr != s_j1->addr || s_i->size != s_j1->size || 0 != VG_(strcmp)(s_i->name, s_j1->name)) { *s_j = *s_i; j++; } else { if (trace_symtab) VG_(printf)("nlist cleanup: dump duplicate avma %010lx %s/n", s_i->addr, s_i->name ); } } } vg_assert(j >= 0 && j <= nsyms); VG_(dropTailXA)(syms, nsyms - j);}
开发者ID:svn2github,项目名称:valgrind-3,代码行数:79,
示例23: VG_/* EXPORTED */void VG_(sigframe_create)( ThreadId tid, Addr sp_top_of_frame, const vki_siginfo_t *siginfo, const struct vki_ucontext *siguc, void *handler, UInt flags, const vki_sigset_t *mask, void *restorer ){ Addr sp; ThreadState* tst = VG_(get_ThreadState)(tid); Int sigNo = siginfo->si_signo; struct vg_sig_private *priv; /* Stack must be 8-byte aligned */ sp_top_of_frame &= ~0xf; if (flags & VKI_SA_SIGINFO) { sp = sp_top_of_frame - sizeof(struct rt_sigframe); } else { sp = sp_top_of_frame - sizeof(struct sigframe); } tst = VG_(get_ThreadState)(tid); if (!extend(tst, sp, sp_top_of_frame - sp)) return; vg_assert(VG_IS_8_ALIGNED(sp)); if (flags & VKI_SA_SIGINFO) { struct rt_sigframe *frame = (struct rt_sigframe *) sp; struct vki_ucontext *ucp = &frame->rs_uc; if (VG_(clo_trace_signals)) VG_(printf)("rt_sigframe/n"); /* Create siginfo. */ VG_TRACK( pre_mem_write, Vg_CoreSignal, tid, "signal frame siginfo", (Addr)&frame->rs_info, sizeof(frame->rs_info) ); VG_(memcpy)(&frame->rs_info, siginfo, sizeof(*siginfo)); VG_TRACK( post_mem_write, Vg_CoreSignal, tid, (Addr)&frame->rs_info, sizeof(frame->rs_info) ); /* Create the ucontext. */ VG_TRACK( pre_mem_write, Vg_CoreSignal, tid, "signal frame ucontext", (Addr)ucp, offsetof(struct vki_ucontext, uc_mcontext) ); ucp->uc_flags = 0; ucp->uc_link = 0; ucp->uc_stack = tst->altstack; VG_TRACK( post_mem_write, Vg_CoreSignal, tid, (Addr)ucp, offsetof(struct vki_ucontext, uc_mcontext) ); struct vki_sigcontext *scp = &(frame->rs_uc.uc_mcontext); setup_sigcontext2(tst, &(scp), siginfo); ucp->uc_sigmask = tst->sig_mask; priv = &frame->priv; /* * Arguments to signal handler: * * a0 = signal number * a1 = 0 (should be cause) * a2 = pointer to ucontext * * $25 and c0_epc point to the signal handler, $29 points to * the struct rt_sigframe. */ tst->arch.vex.guest_r4 = siginfo->si_signo; tst->arch.vex.guest_r5 = (Addr) &frame->rs_info; tst->arch.vex.guest_r6 = (Addr) &frame->rs_uc; tst->arch.vex.guest_r29 = (Addr) frame; tst->arch.vex.guest_r25 = (Addr) handler; if (flags & VKI_SA_RESTORER) { tst->arch.vex.guest_r31 = (Addr) restorer; } else { tst->arch.vex.guest_r31 = (Addr)&VG_(mips32_linux_SUBST_FOR_rt_sigreturn); } } else { if (VG_(clo_trace_signals))
开发者ID:Zekom,项目名称:valgrind,代码行数:96,
注:本文中的vg_assert函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 C++ vg_current_context函数代码示例 C++ vgSeti函数代码示例 |