-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Changed d-scripts and processing logic to only trace malloc/free/realloc/calloc and abandoned tracing new/delete
- Loading branch information
Showing
14 changed files
with
2,583 additions
and
420 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
for REP in 1 2 3 4 5; do | ||
for SLTIME in 10 20 40 ; do | ||
echo tracing process:$1 for :$SLTIME seconds. Repetition:$REP | ||
|
||
./trace-memalloc.d $1 > ./trace-memalloc.$SLTIME.$REP & | ||
dtracepid=$! | ||
|
||
echo started dtrace process, pid:$dtracepid | ||
sleep $SLTIME | ||
kill -SIGINT $dtracepid | ||
echo sent interrupt signal to dtrace process | ||
wait $dtracepid | ||
echo dtrace finished | ||
done | ||
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
for REP in 1 2 3 4 5; do | ||
for SLTIME in 0010 0020 0040 0080 0160 0320 0640 1280 2560; do | ||
echo tracing process:$1 for :$SLTIME seconds. Repetition:$REP | ||
|
||
./trace-memalloc-proc.d $1 > ./trace-memalloc-proc.$SLTIME.$REP & | ||
dtracepid=$! | ||
|
||
echo started dtrace process, pid:$dtracepid | ||
sleep $SLTIME | ||
kill -SIGINT $dtracepid | ||
echo sent interrupt signal to dtrace process | ||
wait $dtracepid | ||
echo dtrace finished | ||
done | ||
done |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,110 @@ | ||
#!/usr/sbin/dtrace -s | ||
|
||
/* | ||
* Dtrace script that logs the number of times call stacks allocated or freed memory | ||
* The output of the script is further processed as described in | ||
* https://github.com/ppissias/DTLeakAnalyzer | ||
* | ||
* Adapt the aggsize, aggsize and bufsize parameters accordingly if needed. | ||
* Author Petros Pissias | ||
*/ | ||
|
||
#pragma D option quiet | ||
#pragma D option aggrate=100us | ||
#pragma D option aggsize=100m | ||
#pragma D option bufpolicy=fill | ||
#pragma D option bufsize=100m | ||
|
||
|
||
#!/usr/sbin/dtrace -s | ||
|
||
pid$1::malloc:entry | ||
{ | ||
self->trace = 1; | ||
self->size = arg0; | ||
} | ||
|
||
pid$1::malloc:return | ||
/self->trace == 1/ | ||
{ | ||
@allocstacks[ustack(50)] = count(); | ||
@counts["created"] = count(); | ||
counts["pending"]++; | ||
|
||
self->trace = 0; | ||
self->size = 0; | ||
} | ||
|
||
|
||
pid$1::realloc:entry | ||
{ | ||
self->trace = 1; | ||
self->size = arg1; | ||
self->oldptr = arg0; | ||
} | ||
|
||
pid$1::realloc:return | ||
/ (self->trace == 1) && (self->size == 0)/ | ||
{ | ||
/* this is same as free, size=0 */ | ||
@deallocstacks[ustack(50)] = count(); | ||
@counts["deleted"] = count(); | ||
counts["pending"]--; | ||
|
||
self->trace = 0; | ||
self->size = 0; | ||
self->oldptr = 0; | ||
} | ||
|
||
pid$1::realloc:return | ||
/ (self->trace == 1) && (self->size > 0)/ | ||
{ | ||
/* this is a deallocation and a new allocation */ | ||
@deallocstacks[ustack(50)] = count(); | ||
@allocstacks[ustack(50)] = count(); | ||
|
||
self->trace = 0; | ||
self->size = 0; | ||
self->oldptr = 0; | ||
} | ||
|
||
pid$1::calloc:entry | ||
{ | ||
self->trace = 1; | ||
self->size = arg1; | ||
self->nelements = arg0; | ||
} | ||
|
||
pid$1::calloc:return | ||
/self->trace == 1/ | ||
{ | ||
/* log the memory allocation */ | ||
@allocstacks[ustack(50)] = count(); | ||
@counts["created"] = count(); | ||
counts["pending"]++; | ||
|
||
self->trace = 0; | ||
self->size = 0; | ||
self->nelements = 0; | ||
} | ||
|
||
|
||
|
||
pid$1::free:entry | ||
{ | ||
@deallocstacks[ustack(50)] = count(); | ||
@counts["deleted"] = count(); | ||
counts["pending"]--; | ||
} | ||
|
||
END | ||
{ | ||
printf("== FINISHED ==\n\n"); | ||
printf("== allocation stacks ==\n\n"); | ||
printa(@allocstacks); | ||
printf("\n== deallocation stacks ==\n\n"); | ||
printa(@deallocstacks); | ||
printf("\n== mem allocations vs deletions ==\n\n"); | ||
printa(@counts); | ||
printf("number of allocations - number of deallocations: %d",counts["pending"]); | ||
} |
Oops, something went wrong.