Skip to content

Commit

Permalink
[gc] add trace_pmc_flags_dump
Browse files Browse the repository at this point in the history
and use it within trace_pmc_dump and #1108, coro in wrong gen
  • Loading branch information
Reini Urban committed Nov 8, 2014
1 parent b61b242 commit a45eaad
Show file tree
Hide file tree
Showing 7 changed files with 142 additions and 30 deletions.
5 changes: 5 additions & 0 deletions include/parrot/runcore_trace.h
Expand Up @@ -38,6 +38,9 @@ void trace_op_dump(PARROT_INTERP,
void trace_pmc_dump(PARROT_INTERP, ARGIN_NULLOK(PMC *pmc))
__attribute__nonnull__(1);

void trace_pmc_flags_dump(PARROT_INTERP, ARGIN_NULLOK(PMC *pmc))
__attribute__nonnull__(1);

#define ASSERT_ARGS_trace_key_dump __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
PARROT_ASSERT_ARG(interp) \
, PARROT_ASSERT_ARG(key))
Expand All @@ -51,6 +54,8 @@ void trace_pmc_dump(PARROT_INTERP, ARGIN_NULLOK(PMC *pmc))
, PARROT_ASSERT_ARG(pc))
#define ASSERT_ARGS_trace_pmc_dump __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
PARROT_ASSERT_ARG(interp))
#define ASSERT_ARGS_trace_pmc_flags_dump __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
PARROT_ASSERT_ARG(interp))
/* Don't modify between HEADERIZER BEGIN / HEADERIZER END. Your changes will be lost. */
/* HEADERIZER END: src/runcore/trace.c */

Expand Down
11 changes: 10 additions & 1 deletion src/call/context.c
Expand Up @@ -885,9 +885,18 @@ Parrot_pcc_reuse_continuation(PARROT_INTERP, ARGIN(PMC *call_context), ARGIN_NUL

if (!reuse) {
c->continuation = Parrot_pmc_new(interp, enum_class_Continuation);
PARROT_ASSERT(PMC_data(c->continuation));
#ifndef NDEBUG
if (Interp_trace_TEST(interp, PARROT_TRACE_CORO_STATE_FLAG))
Parrot_io_eprintf(interp, "# continuation not reused\n");
}
else {
if (Interp_trace_TEST(interp, PARROT_TRACE_CORO_STATE_FLAG))
Parrot_io_eprintf(interp, "# continuation reused\n");
#endif
}

/*Parrot_Continuation_set_pointer(interp, c->continuation, next);*/
/* inlined VTABLE_set_pointer(interp, c->continuation, next) */
SETATTR_Continuation_address(interp, c->continuation, next);
/* needed */
SETATTR_Continuation_runloop_id(interp, c->continuation, interp->current_runloop_id);
Expand Down
12 changes: 9 additions & 3 deletions src/gc/gc_gms.c
Expand Up @@ -109,6 +109,9 @@ TBD
#include "parrot/list.h" /* only for MEMORY_DEBUG */
#include "gc_private.h"
#include "fixed_allocator.h"
#ifdef MEMORY_DEBUG
# include "parrot/runcore_trace.h"
#endif

#ifdef THREAD_DEBUG
# define PARROT_GC_ASSERT_INTERP(pmc, interp) \
Expand Down Expand Up @@ -2267,9 +2270,12 @@ gc_gms_check_sanity(PARROT_INTERP)
if (i < 3) /* too many objects in gen3 */
GC_DEBUG_DETAIL_3("GC live pmc %-21s gen %ld at %p\n",
pmc->vtable->whoami->strstart, gen, pmc);
if (gen != i)
fprintf(stderr, "GC live pmc %-21s gen %ld != %ld at %p\n",
pmc->vtable->whoami->strstart, gen, i, pmc);
if (gen != i) {
fprintf(stderr, "GC live pmc %-21s gen %ld != %ld\n",
pmc->vtable->whoami->strstart, gen, i);
trace_pmc_dump(interp, pmc);
fprintf(stderr, "\n");
}
PARROT_ASSERT((gen == i)
|| !"Object from wrong generation");

Expand Down
25 changes: 17 additions & 8 deletions src/gc/gc_inf.c
Expand Up @@ -52,12 +52,14 @@ static void* gc_inf_allocate_fixed_size_storage(PARROT_INTERP, size_t size);

PARROT_MALLOC
PARROT_CAN_RETURN_NULL
static void * gc_inf_allocate_memory_chunk(PARROT_INTERP, size_t size);
static void * gc_inf_allocate_memory_chunk(PARROT_INTERP, size_t size)
__attribute__nonnull__(1);

PARROT_MALLOC
PARROT_CAN_RETURN_NULL
static void * gc_inf_allocate_memory_chunk_zeroed(PARROT_INTERP,
size_t size);
size_t size)
__attribute__nonnull__(1);

PARROT_MALLOC
PARROT_CAN_RETURN_NULL
Expand Down Expand Up @@ -88,7 +90,9 @@ static void gc_inf_free_fixed_size_storage(PARROT_INTERP,
size_t size,
ARGFREE(void *data));

static void gc_inf_free_memory_chunk(PARROT_INTERP, ARGFREE(void *data));
static void gc_inf_free_memory_chunk(PARROT_INTERP, ARGFREE(void *data))
__attribute__nonnull__(1);

static void gc_inf_free_pmc_attributes(PARROT_INTERP, ARGMOD(PMC *pmc))
__attribute__nonnull__(2)
FUNC_MODIFIES(*pmc);
Expand All @@ -109,7 +113,8 @@ PARROT_MALLOC
PARROT_CAN_RETURN_NULL
static void * gc_inf_reallocate_memory_chunk(PARROT_INTERP,
ARGFREE(void *from),
size_t size);
size_t size)
__attribute__nonnull__(1);

PARROT_MALLOC
PARROT_CANNOT_RETURN_NULL
Expand All @@ -131,9 +136,11 @@ static void gc_inf_reallocate_string_storage(PARROT_INTERP,
__attribute__unused__ int _ASSERT_ARGS_CHECK = (0)
#define ASSERT_ARGS_gc_inf_allocate_fixed_size_storage \
__attribute__unused__ int _ASSERT_ARGS_CHECK = (0)
#define ASSERT_ARGS_gc_inf_allocate_memory_chunk __attribute__unused__ int _ASSERT_ARGS_CHECK = (0)
#define ASSERT_ARGS_gc_inf_allocate_memory_chunk __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
PARROT_ASSERT_ARG(interp))
#define ASSERT_ARGS_gc_inf_allocate_memory_chunk_zeroed \
__attribute__unused__ int _ASSERT_ARGS_CHECK = (0)
__attribute__unused__ int _ASSERT_ARGS_CHECK = (\
PARROT_ASSERT_ARG(interp))
#define ASSERT_ARGS_gc_inf_allocate_pmc_attributes \
__attribute__unused__ int _ASSERT_ARGS_CHECK = (\
PARROT_ASSERT_ARG(pmc))
Expand All @@ -146,7 +153,8 @@ static void gc_inf_reallocate_string_storage(PARROT_INTERP,
#define ASSERT_ARGS_gc_inf_free_bufferlike_header __attribute__unused__ int _ASSERT_ARGS_CHECK = (0)
#define ASSERT_ARGS_gc_inf_free_fixed_size_storage \
__attribute__unused__ int _ASSERT_ARGS_CHECK = (0)
#define ASSERT_ARGS_gc_inf_free_memory_chunk __attribute__unused__ int _ASSERT_ARGS_CHECK = (0)
#define ASSERT_ARGS_gc_inf_free_memory_chunk __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
PARROT_ASSERT_ARG(interp))
#define ASSERT_ARGS_gc_inf_free_pmc_attributes __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
PARROT_ASSERT_ARG(pmc))
#define ASSERT_ARGS_gc_inf_free_pmc_header __attribute__unused__ int _ASSERT_ARGS_CHECK = (0)
Expand All @@ -157,7 +165,8 @@ static void gc_inf_reallocate_string_storage(PARROT_INTERP,
__attribute__unused__ int _ASSERT_ARGS_CHECK = (\
PARROT_ASSERT_ARG(buffer))
#define ASSERT_ARGS_gc_inf_reallocate_memory_chunk \
__attribute__unused__ int _ASSERT_ARGS_CHECK = (0)
__attribute__unused__ int _ASSERT_ARGS_CHECK = (\
PARROT_ASSERT_ARG(interp))
#define ASSERT_ARGS_gc_inf_reallocate_memory_chunk_zeroed \
__attribute__unused__ int _ASSERT_ARGS_CHECK = (0)
#define ASSERT_ARGS_gc_inf_reallocate_string_storage \
Expand Down
25 changes: 17 additions & 8 deletions src/gc/gc_ms.c
Expand Up @@ -61,11 +61,13 @@ static Parrot_Buffer * gc_ms_allocate_bufferlike_header(PARROT_INTERP,

PARROT_MALLOC
PARROT_CAN_RETURN_NULL
static void * gc_ms_allocate_memory_chunk(PARROT_INTERP, size_t size);
static void * gc_ms_allocate_memory_chunk(PARROT_INTERP, size_t size)
__attribute__nonnull__(1);

PARROT_MALLOC
PARROT_CAN_RETURN_NULL
static void * gc_ms_allocate_memory_chunk_zeroed(PARROT_INTERP, size_t size);
static void * gc_ms_allocate_memory_chunk_zeroed(PARROT_INTERP, size_t size)
__attribute__nonnull__(1);

PARROT_CANNOT_RETURN_NULL
static void * gc_ms_allocate_pmc_attributes(PARROT_INTERP, ARGMOD(PMC *pmc))
Expand Down Expand Up @@ -118,7 +120,9 @@ static void gc_ms_free_bufferlike_header(PARROT_INTERP,
__attribute__nonnull__(2)
FUNC_MODIFIES(*obj);

static void gc_ms_free_memory_chunk(PARROT_INTERP, ARGFREE(void *data));
static void gc_ms_free_memory_chunk(PARROT_INTERP, ARGFREE(void *data))
__attribute__nonnull__(1);

static void gc_ms_free_pmc_header(PARROT_INTERP, ARGMOD(PMC *pmc))
__attribute__nonnull__(1)
__attribute__nonnull__(2)
Expand Down Expand Up @@ -187,7 +191,8 @@ PARROT_MALLOC
PARROT_CAN_RETURN_NULL
static void * gc_ms_reallocate_memory_chunk(PARROT_INTERP,
ARGFREE(void *from),
size_t size);
size_t size)
__attribute__nonnull__(1);

PARROT_MALLOC
PARROT_CANNOT_RETURN_NULL
Expand Down Expand Up @@ -266,9 +271,11 @@ static void Parrot_gc_initialize_fixed_size_pools(PARROT_INTERP,
#define ASSERT_ARGS_gc_ms_allocate_bufferlike_header \
__attribute__unused__ int _ASSERT_ARGS_CHECK = (\
PARROT_ASSERT_ARG(interp))
#define ASSERT_ARGS_gc_ms_allocate_memory_chunk __attribute__unused__ int _ASSERT_ARGS_CHECK = (0)
#define ASSERT_ARGS_gc_ms_allocate_memory_chunk __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
PARROT_ASSERT_ARG(interp))
#define ASSERT_ARGS_gc_ms_allocate_memory_chunk_zeroed \
__attribute__unused__ int _ASSERT_ARGS_CHECK = (0)
__attribute__unused__ int _ASSERT_ARGS_CHECK = (\
PARROT_ASSERT_ARG(interp))
#define ASSERT_ARGS_gc_ms_allocate_pmc_attributes __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
PARROT_ASSERT_ARG(interp) \
, PARROT_ASSERT_ARG(pmc))
Expand All @@ -295,7 +302,8 @@ static void Parrot_gc_initialize_fixed_size_pools(PARROT_INTERP,
#define ASSERT_ARGS_gc_ms_free_bufferlike_header __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
PARROT_ASSERT_ARG(interp) \
, PARROT_ASSERT_ARG(obj))
#define ASSERT_ARGS_gc_ms_free_memory_chunk __attribute__unused__ int _ASSERT_ARGS_CHECK = (0)
#define ASSERT_ARGS_gc_ms_free_memory_chunk __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
PARROT_ASSERT_ARG(interp))
#define ASSERT_ARGS_gc_ms_free_pmc_header __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
PARROT_ASSERT_ARG(interp) \
, PARROT_ASSERT_ARG(pmc))
Expand Down Expand Up @@ -329,7 +337,8 @@ static void Parrot_gc_initialize_fixed_size_pools(PARROT_INTERP,
, PARROT_ASSERT_ARG(pool))
#define ASSERT_ARGS_gc_ms_pool_init __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
PARROT_ASSERT_ARG(pool))
#define ASSERT_ARGS_gc_ms_reallocate_memory_chunk __attribute__unused__ int _ASSERT_ARGS_CHECK = (0)
#define ASSERT_ARGS_gc_ms_reallocate_memory_chunk __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
PARROT_ASSERT_ARG(interp))
#define ASSERT_ARGS_gc_ms_reallocate_memory_chunk_zeroed \
__attribute__unused__ int _ASSERT_ARGS_CHECK = (0)
#define ASSERT_ARGS_gc_ms_sweep_cb __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
Expand Down
25 changes: 17 additions & 8 deletions src/gc/gc_ms2.c
Expand Up @@ -93,12 +93,14 @@ static void* gc_ms2_allocate_fixed_size_storage(PARROT_INTERP, size_t size)

PARROT_MALLOC
PARROT_CAN_RETURN_NULL
static void * gc_ms2_allocate_memory_chunk(PARROT_INTERP, size_t size);
static void * gc_ms2_allocate_memory_chunk(PARROT_INTERP, size_t size)
__attribute__nonnull__(1);

PARROT_MALLOC
PARROT_CAN_RETURN_NULL
static void * gc_ms2_allocate_memory_chunk_zeroed(PARROT_INTERP,
size_t size);
size_t size)
__attribute__nonnull__(1);

PARROT_MALLOC
PARROT_CAN_RETURN_NULL
Expand Down Expand Up @@ -154,7 +156,9 @@ static void gc_ms2_free_fixed_size_storage(PARROT_INTERP,
__attribute__nonnull__(1)
__attribute__nonnull__(3);

static void gc_ms2_free_memory_chunk(PARROT_INTERP, ARGFREE(void *data));
static void gc_ms2_free_memory_chunk(PARROT_INTERP, ARGFREE(void *data))
__attribute__nonnull__(1);

static void gc_ms2_free_pmc_attributes(PARROT_INTERP, ARGMOD(PMC *pmc))
__attribute__nonnull__(1)
__attribute__nonnull__(2)
Expand Down Expand Up @@ -226,7 +230,8 @@ PARROT_MALLOC
PARROT_CAN_RETURN_NULL
static void * gc_ms2_reallocate_memory_chunk(PARROT_INTERP,
ARGFREE(void *from),
size_t size);
size_t size)
__attribute__nonnull__(1);

PARROT_MALLOC
PARROT_CANNOT_RETURN_NULL
Expand Down Expand Up @@ -271,9 +276,11 @@ static void gc_ms2_unblock_GC_sweep(PARROT_INTERP)
#define ASSERT_ARGS_gc_ms2_allocate_fixed_size_storage \
__attribute__unused__ int _ASSERT_ARGS_CHECK = (\
PARROT_ASSERT_ARG(interp))
#define ASSERT_ARGS_gc_ms2_allocate_memory_chunk __attribute__unused__ int _ASSERT_ARGS_CHECK = (0)
#define ASSERT_ARGS_gc_ms2_allocate_memory_chunk __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
PARROT_ASSERT_ARG(interp))
#define ASSERT_ARGS_gc_ms2_allocate_memory_chunk_zeroed \
__attribute__unused__ int _ASSERT_ARGS_CHECK = (0)
__attribute__unused__ int _ASSERT_ARGS_CHECK = (\
PARROT_ASSERT_ARG(interp))
#define ASSERT_ARGS_gc_ms2_allocate_pmc_attributes \
__attribute__unused__ int _ASSERT_ARGS_CHECK = (\
PARROT_ASSERT_ARG(interp) \
Expand Down Expand Up @@ -304,7 +311,8 @@ static void gc_ms2_unblock_GC_sweep(PARROT_INTERP)
__attribute__unused__ int _ASSERT_ARGS_CHECK = (\
PARROT_ASSERT_ARG(interp) \
, PARROT_ASSERT_ARG(data))
#define ASSERT_ARGS_gc_ms2_free_memory_chunk __attribute__unused__ int _ASSERT_ARGS_CHECK = (0)
#define ASSERT_ARGS_gc_ms2_free_memory_chunk __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
PARROT_ASSERT_ARG(interp))
#define ASSERT_ARGS_gc_ms2_free_pmc_attributes __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
PARROT_ASSERT_ARG(interp) \
, PARROT_ASSERT_ARG(pmc))
Expand Down Expand Up @@ -346,7 +354,8 @@ static void gc_ms2_unblock_GC_sweep(PARROT_INTERP)
PARROT_ASSERT_ARG(interp) \
, PARROT_ASSERT_ARG(str))
#define ASSERT_ARGS_gc_ms2_reallocate_memory_chunk \
__attribute__unused__ int _ASSERT_ARGS_CHECK = (0)
__attribute__unused__ int _ASSERT_ARGS_CHECK = (\
PARROT_ASSERT_ARG(interp))
#define ASSERT_ARGS_gc_ms2_reallocate_memory_chunk_zeroed \
__attribute__unused__ int _ASSERT_ARGS_CHECK = (0)
#define ASSERT_ARGS_gc_ms2_reallocate_string_storage \
Expand Down
69 changes: 67 additions & 2 deletions src/runcore/trace.c
@@ -1,5 +1,5 @@
/*
Copyright (C) 2001-2010, Parrot Foundation.
Copyright (C) 2001-2014, Parrot Foundation.
=head1 NAME
Expand Down Expand Up @@ -101,6 +101,71 @@ trace_class_name(PARROT_INTERP, ARGIN(const PMC* pmc))
}


/*
=item C<void trace_pmc_flags_dump(PARROT_INTERP, PMC *pmc)>
Pretty prints PMC flags to C<stderr>.
=cut
*/

void
trace_pmc_flags_dump(PARROT_INTERP, ARGIN_NULLOK(PMC *pmc))
{
ASSERT_ARGS(trace_pmc_flags_dump)
Interp * const debugger = debugger_or_interp(interp);
UINTVAL i;
UINTVAL flags = pmc->flags;
struct flag_names_decl {
UINTVAL flag;
const char *name;
} flags_names[] = {
{ 1<<0, "private0" },
{ 1<<1, "private1" },
{ 1<<2, "private2" },
{ 1<<3, "private3" },
{ 1<<4, "private4" },
{ 1<<5, "private5" },
{ 1<<6, "private6" },
{ 1<<7, "private7" },
{ 1<<8, "is_string" },
{ 1<<9, "is_PMC" },
{ 1<<10, "is_string_copy" },
{ 1<<11, "is_shared" },
{ 1<<12, "constant" },
{ 1<<13, "external" },
{ 1<<14, "sysmem" },
{ 1<<15, "is_COWable" },
{ 1<<16, "live" },
{ 1<<17, "free" },
{ 1<<18, "custom_mark" },
{ 1<<19, "custom_destroy" },
{ 1<<20, "report" },
{ 1<<21, "is_new" },
{ 1<<22, "gen0" },
{ 1<<23, "gen1" },
{ 1<<24, "gen2" },
{ 1<<25, "dirty" },
{ 1<<26, "need_wb" },
{ 1<<27, "soil_root" },
{ 1<<28, "needs_early_gc" }, /* timely destruction */
{ 1<<29, "is_class" },
{ 1<<30, "is_object" },
};

if (!pmc || PMC_IS_NULL(pmc)) {
return;
}
Parrot_io_eprintf(debugger, " (");
for (i=0; i < sizeof (flags_names) / sizeof (flags_names[0]); i++) {
if (flags & flags_names[i].flag)
Parrot_io_eprintf(debugger, "%s,", flags_names[i].name);
}
Parrot_io_eprintf(debugger, ")");
}

/*
=item C<void trace_pmc_dump(PARROT_INTERP, PMC *pmc)>
Expand Down Expand Up @@ -186,9 +251,9 @@ trace_pmc_dump(PARROT_INTERP, ARGIN_NULLOK(PMC *pmc))
Parrot_io_eprintf(debugger, "%S=PMC(%#p)",
VTABLE_name(interp, pmc), pmc);
}
trace_pmc_flags_dump(interp, pmc);
}


/*
=item C<int trace_key_dump(PARROT_INTERP, PMC *key)>
Expand Down

0 comments on commit a45eaad

Please sign in to comment.