public inbox for frysk-cvs@sourceware.org help / color / mirror / Atom feed
From: cagney@sourceware.org To: frysk-cvs@sourceware.org Subject: [SCM] master: Immediatly unmap the unwind-info image when notified its free by libunwind. Date: Sat, 24 May 2008 20:47:00 -0000 [thread overview] Message-ID: <20080524204757.24227.qmail@sourceware.org> (raw) The branch, master has been updated via 68021418975e2fa86f8189b61f67f437796a9b96 (commit) from 9e513ef98a772fee06a688072310aad9011494dc (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email. - Log ----------------------------------------------------------------- commit 68021418975e2fa86f8189b61f67f437796a9b96 Author: Andrew Cagney <cagney@redhat.com> Date: Sat May 24 16:47:08 2008 -0400 Immediatly unmap the unwind-info image when notified its free by libunwind. This leverages a change to libunwind to notify the eh-frame supplier that libunwind's dwarf code has finished using the information. When so notified the eh-frame data image is freed; previously the code was relying on the garbage collector to release this memory. frysk-sys/lib/unwind/ChangeLog 2008-05-24 Andrew Cagney <cagney@redhat.com> * cni/UnwindH.hxx (image_put_unwind_info): New. (struct image): New. (fillProcInfoFromImage): Create an image and pass to unw_get_unwind_table. 2008-05-24 Andrew Cagney <cagney@redhat.com> * NEWS: Mention reduced memory footprint. ----------------------------------------------------------------------- Summary of changes: NEWS | 14 ++++--- frysk-sys/lib/unwind/ChangeLog | 5 ++ frysk-sys/lib/unwind/cni/UnwindH.hxx | 78 ++++++++++++++++++++++----------- frysk-top/ChangeLog | 4 ++ 4 files changed, 69 insertions(+), 32 deletions(-) First 500 lines of diff: diff --git a/NEWS b/NEWS index e3f0e39..f980797 100644 --- a/NEWS +++ b/NEWS @@ -11,6 +11,14 @@ multi-process, and multi-threaded systems while they are running. -- +Release 0.4, ????-??-?? + +-> Smaller memory foot-print when generating stack backtraces. + Frysk has been changed to more aggressively release memory + allocated by the unwinder. + +-- + Release 0.3, 2008-05-09 - Exported a prototype of low level watchpoint api on IA32,X8664 @@ -29,18 +37,12 @@ Release 0.3, 2008-05-09 - Imported a newer version of upstream elfutils. - Fixed breakpoints to work correctly through forks. --- - -Post-Release 0.2 Updates: - -> 2004-04-24 - New support in FHPD: sysroot Frysk now also supports finding libraries in a special system directory heirarchy as well as the previously supported source files and debuginfo files. This is specified via the -sysroot option. --- - -> 2004-04-16 - New command in FHPD: watch Use to set watchpoints on expressions or variables. This stops diff --git a/frysk-sys/lib/unwind/ChangeLog b/frysk-sys/lib/unwind/ChangeLog index 4c93d20..f8dd2a1 100644 --- a/frysk-sys/lib/unwind/ChangeLog +++ b/frysk-sys/lib/unwind/ChangeLog @@ -1,5 +1,10 @@ 2008-05-24 Andrew Cagney <cagney@redhat.com> + * cni/UnwindH.hxx (image_put_unwind_info): New. + (struct image): New. + (fillProcInfoFromImage): Create an image and pass to + unw_get_unwind_table. + * Unwind.java (createElfImageFromVDSO): Delete. (createProcInfoFromElfImage): Delete. (fillProcInfoFromVDSO): New. diff --git a/frysk-sys/lib/unwind/cni/UnwindH.hxx b/frysk-sys/lib/unwind/cni/UnwindH.hxx index dda792f..1b55b66 100644 --- a/frysk-sys/lib/unwind/cni/UnwindH.hxx +++ b/frysk-sys/lib/unwind/cni/UnwindH.hxx @@ -587,25 +587,48 @@ get_eh_frame_hdr_addr(unw_proc_info_t *pi, char *image, size_t size, /** * The following are local memory image address space memory accessors - * used by unw_get_unwind_table to access the eh_frame_hdr. The arg - * pointer is the base address, addr is the offset from the base - * address. + * used by unw_get_unwind_table and run_cfi_program to access and + * interpret the eh_frame_hdr. The arg pointer contains an image + * descriptor, ADDR is the offset into the eh-frame table within the + * image. */ +struct image { + int magic; + void *bytes; + size_t size; + char *table; +}; +const int IMAGE_MAGIC = 0xfeed; static int image_access_mem(unw_addr_space_t as, unw_word_t addr, - unw_word_t *val, int write, void *baseAddress) { + unw_word_t *val, int write, void *arg) { + struct image *image = (struct image*) arg; + if (image->magic != IMAGE_MAGIC) { + throw new RuntimeException(JvNewStringUTF("bad image magic number")); + } // Writing is not supported if (write) return -UNW_EINVAL; else - *val = *(unw_word_t *) ((char *)baseAddress + addr); - + *val = *(unw_word_t *) (image->table + addr); return UNW_ESUCCESS; } +static void +image_put_unwind_info(::unw_addr_space_t as, ::unw_proc_info_t *proc_info, + void *arg) { + struct image *image = (struct image*) arg; + if (image->magic != IMAGE_MAGIC) { + fprintf(stderr, "corrupt image pointer\n"); + throw new RuntimeException(JvNewStringUTF("bad image magic number")); + } + munmap(image->bytes, image->size); + ::free(image); +} + static unw_accessors_t image_accessors = { - NULL, NULL, NULL, image_access_mem, NULL, NULL, NULL, NULL + NULL, image_put_unwind_info, NULL, image_access_mem, NULL, NULL, NULL, NULL }; static jint @@ -614,36 +637,47 @@ fillProcInfoFromImage(frysk::rsl::Log* fine, jlong unwProcInfo, jlong ip, jboolean needUnwindInfo, - void *image, + void *bytes, long size, long segbase) { unw_proc_info_t *procInfo = (::unw_proc_info_t *) unwProcInfo; logf(fine, "fillProcInfoFromImage" - " %s unwProcInfo %lx, ip %lx, image %p, size %ld, segBase %lx", - name, (long) unwProcInfo, (long)ip, image, size, segbase); + " %s unwProcInfo %lx, ip %lx, bytes %p, size %ld, segBase %lx", + name, (long) unwProcInfo, (long)ip, bytes, size, segbase); unw_word_t peh_vaddr = 0; char *eh_table_hdr = get_eh_frame_hdr_addr(procInfo, - (char *) image, + (char *) bytes, size, segbase, &peh_vaddr); if (eh_table_hdr == NULL) { logf(fine, "get_eh_frame_hdr failed"); - munmap(image, size); + munmap(bytes, size); + return -UNW_ENOINFO; + } + + struct image *image = new struct image(); + if (image == NULL) { + munmap(bytes, size); return -UNW_ENOINFO; } + image->magic = IMAGE_MAGIC; + image->bytes = bytes; + image->size = size; int ret; - if (procInfo->format == UNW_INFO_FORMAT_REMOTE_TABLE) + if (procInfo->format == UNW_INFO_FORMAT_REMOTE_TABLE) { + // address adjustment + image->table = eh_table_hdr - peh_vaddr; ret = unw_get_unwind_table((unw_word_t) ip, procInfo, (int) needUnwindInfo, &image_accessors, // virtual address peh_vaddr, - // address adjustment - eh_table_hdr - peh_vaddr); - else + image); + } else { + image->table = eh_table_hdr; ret = unw_get_unwind_table((unw_word_t) ip, procInfo, (int) needUnwindInfo, @@ -651,16 +685,8 @@ fillProcInfoFromImage(frysk::rsl::Log* fine, // virtual address 0, // address adjustment - eh_table_hdr); - - // FIXME: The munmap can't be done until after the step code has - // finished with the proc-info. For moment ack around this by - // creating an ElfImage object that does the unmap in the finaliser. - // Of course this A) leaves many mmaped objects around; and B) has a - // race where the object could be unmapped before step has finished - // with it. - new ElfImage((jlong) image, (jlong) size); - // munmap(image, size); + image); + } logf(fine, "Post unw_get_unwind_table %d", ret); return ret; } diff --git a/frysk-top/ChangeLog b/frysk-top/ChangeLog index 243104d..1eb6691 100644 --- a/frysk-top/ChangeLog +++ b/frysk-top/ChangeLog @@ -1,3 +1,7 @@ +2008-05-24 Andrew Cagney <cagney@redhat.com> + + * NEWS: Mention reduced memory footprint. + 2008-05-12 Rick Moseley <rmoseley@redhat.com> * Update NEWS file for release 0.3. hooks/post-receive -- frysk system monitor/debugger
reply other threads:[~2008-05-24 20:47 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20080524204757.24227.qmail@sourceware.org \ --to=cagney@sourceware.org \ --cc=frysk-cvs@sourceware.org \ --cc=frysk@sourceware.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).