-
Notifications
You must be signed in to change notification settings - Fork 263
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
i#2266: Dump memory layout to json file on annotation (#2267)
Adds a new annotation DRMEMORY_ANNOTATE_DUMP_MEMORY_LAYOUT() which triggers dumping the memory layout to a new file "memlayout.nnnn.log" in the log subdirectory, where "nnnn" is incremented on each successive dump. The file is in JSON format. Exports annotation support by building the required .c file with custom flags as a library, and exports it and the two required header files drmemory_annotations.h and dr_annotations_asm.h. A basic block whose tag matches the address of the symbol "main" in the executable is watched for. Heap allocations prior to that point are marked with a new flag MALLOC_BEFORE_MAIN. The stack pointer at that point is recorded. At dump time, a heap iteration is done, skipping MALLOC_BEFORE_MAIN objects. Each object is placed into a tree. Each thread stack is also placed into a trace; fof the primary thread, only the stack region between the recorded main stack point and the TOS is considered. Both trees are then walked, with each memory region walked in pointer-sized chunks, printing out values and whether values look like pointers to the top or middle of other objects in either tree. This feature and its annotation are disabled if asm-goto is not supported by the compiler (clang<9.0), determined by try-compile. Adds a test "memlayout". Parameterizes runtest.cmake to allow checking memlayout*.json instead of results.txt. CMake is having trouble with square brackets (it always did, but there are many of them in json files), so runtest.cmake now replaces them with angle as a workaround. If jsonlint-php is found, runs it on each generated json file in the test to ensure there are no syntax errors. We install jsonlint on Travis. Documentation will be added later once post-processing is ironed out. Issue: #2266
- Loading branch information
1 parent
4c77bb7
commit af3a792
Showing
20 changed files
with
713 additions
and
78 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
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
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
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
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
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
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
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,24 @@ | ||
/* ********************************************************** | ||
* Copyright (c) 2020 Google, Inc. All rights reserved. | ||
* **********************************************************/ | ||
|
||
/* Dr. Memory: the memory debugger | ||
* | ||
* This library is free software; you can redistribute it and/or | ||
* modify it under the terms of the GNU Lesser General Public | ||
* License as published by the Free Software Foundation; | ||
* version 2.1 of the License, and no later version. | ||
* This library is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
* Library General Public License for more details. | ||
* You should have received a copy of the GNU Lesser General Public | ||
* License along with this library; if not, write to the Free Software | ||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | ||
*/ | ||
|
||
#include "dr_annotations.h" | ||
|
||
DR_DEFINE_ANNOTATION(void, drmemory_dump_memory_layout, (void),) |
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,45 @@ | ||
/* ********************************************************** | ||
* Copyright (c) 2020 Google, Inc. All rights reserved. | ||
* **********************************************************/ | ||
|
||
/* Dr. Memory: the memory debugger | ||
* | ||
* This library is free software; you can redistribute it and/or | ||
* modify it under the terms of the GNU Lesser General Public | ||
* License as published by the Free Software Foundation; | ||
* version 2.1 of the License, and no later version. | ||
* This library is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
* Library General Public License for more details. | ||
* You should have received a copy of the GNU Lesser General Public | ||
* License along with this library; if not, write to the Free Software | ||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | ||
*/ | ||
|
||
#ifndef _ANNOTATIONS_PUBLIC_H_ | ||
#define _ANNOTATIONS_PUBLIC_H_ 1 | ||
|
||
#include "dr_annotations_asm.h" | ||
|
||
/* To simplify project configuration, this pragma excludes the file from GCC warnings. */ | ||
#ifdef __GNUC__ | ||
# pragma GCC system_header | ||
#endif | ||
|
||
#define DRMEMORY_ANNOTATE_DUMP_MEMORY_LAYOUT() \ | ||
DR_ANNOTATION(drmemory_dump_memory_layout) | ||
|
||
#ifdef __cplusplus | ||
extern "C" { | ||
#endif | ||
|
||
DR_DECLARE_ANNOTATION(void, drmemory_dump_memory_layout, (void)); | ||
|
||
#ifdef __cplusplus | ||
} | ||
#endif | ||
|
||
#endif /* _ANNOTATIONS_PUBLIC_H_ */ |
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
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
Oops, something went wrong.