Date: Tue, 20 Oct 2009 17:11:03 GMT From: Stanislav Sedov <stas@FreeBSD.org> To: Perforce Change Reviews <perforce@freebsd.org> Subject: PERFORCE change 169620 for review Message-ID: <200910201711.n9KHB3JH085689@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://p4web.freebsd.org/chv.cgi?CH=169620 Change 169620 by stas@stas_yandex on 2009/10/20 17:10:59 - Use "standard" vmmap sysctls instead of compatible one. This allows to avoid the dependency on COMPAT_6 and get rid of hand-crufted 32-bit conversion stuff. Reported by: Robert Jenssen <robertjenssen@ozemail.com.au> Affected files ... .. //depot/projects/valgrind/coregrind/m_aspacemgr/aspacemgr-linux.c#8 edit .. //depot/projects/valgrind/include/vki/vki-freebsd.h#20 edit Differences ... ==== //depot/projects/valgrind/coregrind/m_aspacemgr/aspacemgr-linux.c#8 (text+ko) ==== @@ -3527,67 +3527,6 @@ /* static ... to keep it out of the stack frame. */ static Char procmap_buf[M_PROCMAP_BUF]; - #if defined(VGP_x86_freebsd) - static Bool test_is32on64(void) - { - Int oid[2]; - vki_size_t len; - char machbuf[32]; - static Int is32on64 = -1; - SysRes sres; - - if (is32on64 == -1) { - oid[0] = VKI_CTL_HW; - oid[1] = VKI_HW_MACHINE; - len = sizeof(machbuf); - sres = VG_(do_syscall6)(__NR___sysctl, (UWord)oid, 2, (UWord)machbuf, (UWord)&len -, 0, 0); - if (!sr_isError(sres)) { - machbuf[31] = '\0'; - if (VG_(strcmp)(machbuf, "amd64") == 0) - is32on64 = 1; - else - is32on64 = 0; - } else { - is32on64 = -2; - } - } - if (is32on64 == 1) { - return True; - } else { - return False; - } - } - - static void fix_32on64(vki_size_t *len) - { - struct vki_kinfo_vmentry_32on64 *kve64, t; - struct vki_kinfo_vmentry *kve32; - Int i; - - aspacem_assert(sizeof(struct vki_kinfo_vmentry) < sizeof(struct vki_kinfo_vmentry_32on64)); - kve64 = (struct vki_kinfo_vmentry_32on64 *)procmap_buf; - kve32 = (struct vki_kinfo_vmentry *)procmap_buf; - aspacem_assert(sizeof(kve32->kve_path) == sizeof(kve64->kve_path)); - for (i = 0; i < *len / sizeof(struct vki_kinfo_vmentry_32on64); i++, kve32++, kve64++ -) { - t = *kve64; - aspacem_assert(t.kve_start < 0x100000000ull); - aspacem_assert(t.kve_end < 0x100000000ull); - aspacem_assert(t.kve_structsize == sizeof(struct vki_kinfo_vmentry_32on64)); - kve32->kve_structsize = sizeof(struct vki_kinfo_vmentry); - kve32->kve_start = (void *)(UWord)t.kve_start; - kve32->kve_end = (void *)(UWord)t.kve_end; - kve32->kve_protection = t.kve_protection; - VG_(memcpy)(kve32->kve_path, t.kve_path, sizeof(t.kve_path)); - kve32->kve_offset = t.kve_offset; - kve32->kve_fsid = t.kve_fsid; - kve32->kve_fileid = t.kve_fileid; - } - *len = *len * sizeof(struct vki_kinfo_vmentry) / sizeof(struct vki_kinfo_vmentry_32on64); - } - #endif - static void parse_procselfmaps ( void (*record_mapping)( Addr addr, SizeT len, UInt prot, ULong dev, ULong ino, Off64T offset, @@ -3598,6 +3537,7 @@ Int i; Addr start, endPlusOne, gapStart; UChar* filename; + char *p; UInt prot; ULong foffset, dev, ino; struct vki_kinfo_vmentry *kve; @@ -3616,22 +3556,14 @@ sres = VG_(do_syscall6)(__NR___sysctl, (UWord)oid, 4, (UWord)procmap_buf, (UWord)&len, 0, 0); if (sr_isError(sres)) { - VG_(debugLog)(0, "procselfmaps", "sysctl %ld\n", sr_Err(sres)); + VG_(debugLog)(0, "procselfmaps", "sysctll %ld\n", sr_Err(sres)); ML_(am_exit)(1); } - #if defined(VGP_x86_freebsd) - if (test_is32on64()) - fix_32on64(&len); - #endif - gapStart = Addr_MIN; i = 0; - kve = (struct vki_kinfo_vmentry *)procmap_buf; - for (i = 0; i < (len / sizeof(*kve)); i++, kve++) { - if (kve->kve_structsize != sizeof(*kve)) { - VG_(debugLog)(0, "procselfmaps", "sysctl out of sync\n"); - ML_(am_exit)(1); - } + p = procmap_buf; + while (p < (char *)procmap_buf + len) { + kve = (struct vki_kinfo_vmentry *)p; start = (UWord)kve->kve_start; endPlusOne = (UWord)kve->kve_end; foffset = kve->kve_offset; @@ -3656,6 +3588,7 @@ prot, dev, ino, foffset, filename ); gapStart = endPlusOne; + p += kve->kve_structsize; } if (record_gap && gapStart < Addr_MAX) ==== //depot/projects/valgrind/include/vki/vki-freebsd.h#20 (text+ko) ==== @@ -1887,20 +1887,20 @@ struct vki_kinfo_vmentry { int kve_structsize; int kve_type; - void * kve_start; - void * kve_end; + ULong kve_start; + ULong kve_end; + Off64T kve_offset; + ULong kve_fileid; + UInt kve_fsid; int kve_flags; int kve_resident; int kve_private_resident; int kve_protection; int kve_ref_count; int kve_shadow_count; + int _kve_pad0; + int kve_ispare[16]; char kve_path[VKI_PATH_MAX]; - void * kve_pspare[8]; - Off64T kve_offset; - ULong kve_fileid; - UInt kve_fsid; - int kve_ispare[3]; }; struct vki_kinfo_file { @@ -1922,28 +1922,6 @@ char kf_path[VKI_PATH_MAX]; /* Path to file, if any. */ }; -#if defined(VGP_x86_freebsd) -/* Special case.. adapt to what the 64 bit kernel gives us */ -struct vki_kinfo_vmentry_32on64 { - int kve_structsize; - int kve_type; - ULong kve_start; - ULong kve_end; - int kve_flags; - int kve_resident; - int kve_private_resident; - int kve_protection; - int kve_ref_count; - int kve_shadow_count; - char kve_path[VKI_PATH_MAX]; - ULong kve_pspare[8]; - Off64T kve_offset; - ULong kve_fileid; - UInt kve_fsid; - int kve_ispare[3]; -}; -#endif - //---------------------------------------------------------------------- // From sys/kenv.h //---------------------------------------------------------------------- @@ -1959,7 +1937,7 @@ #define VKI_CTL_KERN 1 #define VKI_CTL_HW 6 #define VKI_KERN_PROC 14 -#define VKI_KERN_PROC_VMMAP 13 +#define VKI_KERN_PROC_VMMAP 32 #define VKI_KERN_PROC_FILEDESC 33 #define VKI_HW_MACHINE 1
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200910201711.n9KHB3JH085689>