I have a log file with 3 kinds of entries: memory allocation, freeing and realloc'ing
Each of them looks like this:
memory allocation
0x12e8eb00 200 bytes allocated as request from filename.c function_name 122 1215683985
| |
| |--- amount of memory allocated
|
|----- starting address of allocated memory
memory reallocation
0x9420be0 realloc 0x94214c0 4448 bytes allocated as request from filename.c function_name 213 1215683975
| | |-- amount of memory requested
| |
| |---- address after realloc
|
|------- address before realloc
0x9420c60 freed from filename.c function_name 430 1448619662727
|
|
|----- address being freed
the file has been sorted on first field - i.e. memory addresses.
I want a script that can delete consecutive lines that correspond to allocation and free requests of the same address.
address1 100 bytes allocated ....
address1 freed from ...
address2 100 bytes allocated ....
address2 freed from ...
address3 100 bytes allocated ....
address4 100 bytes allocated ....
address4 freed from ...
address5 100 bytes allocated ....
Output from the above file should be
address3 100 bytes allocated ....
address5 100 bytes allocated ....
Note that there may be more than one space character separating any two words, but all words are space separated - no tabs.
A perl or a bash script would do.
Start Free Trial