[Gc] Dump blocks with debugging information.

Boehm, Hans hans.boehm at hp.com
Mon Jun 30 10:59:10 PDT 2008


Is this single-threaded?  Is there a danger of a block being deallocated while this is running?

Does p look reasonable and hhdr just turns out to be null?  Or is something else going on?  (GC_find_header() can be used to get the header from a debugger.)

I don't immediately see why this shouldn't work, aside from the fact that some of this code is generally sloppy about locking.  The collector itself should invoke it with the allocation lock held, but it's meant to be invocable from a debugger.

Hans

> -----Original Message-----
> From: gc-bounces at napali.hpl.hp.com
> [mailto:gc-bounces at napali.hpl.hp.com] On Behalf Of S M Ryan
> Sent: Sunday, June 29, 2008 2:12 AM
> To: Boehm-gc
> Subject: [Gc] Dump blocks with debugging information.
>
> I'm trying to dump all active blocks along with the debugging
> information in GC 6.7. Seems a straightforward task, but I
> can't find any routines to do it except GC_FIND_LEAKS which
> is not what I want.
> I tried to piece together code, but it insist on crapping out
> near the top of dumpblock.
>
> This has to be possible. Is there some way to do so?
>
> #include "private/gc_priv.h"
> #include "private/dbg_mlc.h"
>
> static void dumpblock(struct hblk *p, word dummy) {
>         register hdr * hhdr = HDR(p);
>         register size_t bytes = WORDS_TO_BYTES(hhdr -> hb_sz);
>
> //      craps out near here because p or hhdr are invalid
> //      even though this is a straight copy from
> GC_print_block_list >>
> GC_print_block_descr
> //      and the GC_print_block_list works fine
>
>         GC_err_printf3("(%lu:%lu,%lu)", (unsigned long)(hhdr
> -> hb_obj_kind),
>                         (unsigned long)bytes,
>                         (unsigned long)(GC_n_set_marks(hhdr)));
>         if (hhdr -> hb_obj_kind == PTRFREE) {
>                 GC_err_printf0(" atomic object at ");
>         } else {
>                 GC_err_printf0(" composite object at ");
>         }
>         register oh * ohdr = (oh *)GC_base(p);
>         if (GC_HAS_DEBUG_INFO(p)) {
>                 GC_err_printf1("0x%lx (", ((unsigned
> long)ohdr + sizeof(oh)));
>                 GC_err_puts(ohdr -> oh_string);
>                 #   ifdef SHORT_DBG_HDRS
>                         GC_err_printf1(":%ld, ", (unsigned
> long)(ohdr -> oh_int));
>                 #   else
>                         GC_err_printf2(":%ld, sz=%ld, ",
> (unsigned long)(ohdr -> oh_int),
>                                                 (unsigned
> long)(ohdr -> oh_sz));
>                 #   endif
>                 GC_print_type((ptr_t)(ohdr + 1));
>                 GC_err_puts(")\n");
>                 PRINT_CALL_CHAIN(ohdr);
>         } else {
>                 ptr_t base = GC_base(p);
>                 GC_err_printf2("start: 0x%lx, appr. length:
> %ld", base, GC_size (base));
>         }
>         GC_err_printf0("\n");
> }
>
> static void dumpallblocks(void) {
>         GC_err_printf0("=======================================\n");
>         GC_print_block_list(); // this works fine
>         GC_apply_to_all_blocks(dumpblock, (word)0);
>         GC_err_printf0("---------------------------------------\n");
> }
>
> _______________________________________________
> Gc mailing list
> Gc at linux.hpl.hp.com
> http://www.hpl.hp.com/hosted/linux/mail-archives/gc/
>



More information about the Gc mailing list