X-Git-Url: https://git.llucax.com/software/dgc/cdgc.git/blobdiff_plain/3f06cf8417c07b73c6e9671f379ec6f942f63866..6a3232d8f1c52377e792b4f4e18fd75f2a3b0f60:/rt/gc/cdgc/stats.d?ds=sidebyside diff --git a/rt/gc/cdgc/stats.d b/rt/gc/cdgc/stats.d index 314b509..036d748 100644 --- a/rt/gc/cdgc/stats.d +++ b/rt/gc/cdgc/stats.d @@ -123,6 +123,8 @@ struct MallocInfo double timestamp = -1.0; /// Time spent in the malloc() call (in seconds). double time = -1.0; + /// Address of the pointer returned by malloc. + void* ptr = null; /// Memory requested by the malloc() call (in bytes). size_t size = 0; /// Memory attributes as BlkAttr flags. @@ -235,17 +237,25 @@ private: { if (this.mallocs_file is null) return; + auto ptrmap = this.malloc_info.ptrmap; + auto ptrmask_offset = (ptrmap[0] - 1) / (size_t.sizeof * 8) + 1; cstdio.fprintf(this.mallocs_file, - "%f,%f,%zu,%zu,%zu,%zu,%zu,%p\n", - //0 1 2 3 4 5 6 7 + "%f,%f,%p,%zu,%zu,%zu,%zu,%zu,%p,%zu,%0*zX,%0*zX\n", + //0 1 2 3 4 5 6 7 8 9 10 11 this.malloc_info.timestamp, // 0 this.malloc_info.time, // 1 - this.malloc_info.size, // 2 - this.malloc_info.collected ? 1u : 0u, // 3 - this.malloc_info.attr & .gc.BlkAttr.FINALIZE, // 4 - this.malloc_info.attr & .gc.BlkAttr.NO_SCAN, // 5 - this.malloc_info.attr & .gc.BlkAttr.NO_MOVE, // 6 - this.malloc_info.ptrmap); // 7 + this.malloc_info.ptr, // 2 + this.malloc_info.size, // 3 + this.malloc_info.collected ? 1u : 0u, // 4 + this.malloc_info.attr & .gc.BlkAttr.FINALIZE, // 5 + this.malloc_info.attr & .gc.BlkAttr.NO_SCAN, // 6 + this.malloc_info.attr & .gc.BlkAttr.NO_MOVE, // 7 + ptrmap, // 8 + ptrmap[0] * size_t.sizeof, // 9 + size_t.sizeof, // fill length + ptrmap[1], // 10 + size_t.sizeof, // fill length + ptrmap[1 + ptrmask_offset]); // 11 // TODO: make it an option cstdio.fflush(this.mallocs_file); } @@ -291,8 +301,10 @@ public: this_.active = true; this_.mallocs_file = this_.start_file( options.malloc_stats_file.ptr, - "Timestamp,Time,Size,Collection triggered," - "Finalize,No scan,No move,Pointer map\n"); + "Timestamp,Time,Pointer,Size,Collection triggered," + "Finalize,No scan,No move,Pointer map,Type size," + "Pointer map scan bitmask (first word, hexa)," + "Pointer map pointer bitmask (first word, hexa)\n"); } // collection if (options.collect_stats_file[0] != '\0') { @@ -338,7 +350,7 @@ public: } /// Inform the end of an allocation. - void malloc_finished() + void malloc_finished(void* ptr) { if (!this.active) return; @@ -348,6 +360,7 @@ public: this.malloc_info.time = now - this.malloc_info.time; if (collected) this.malloc_info.collected = true; + this.malloc_info.ptr = ptr; this.print_malloc(); if (!collected) return;