njn | 009af89 | 2004-12-01 11:54:07 +0000 | [diff] [blame] | 1 | ------------------------------------------------------------------- |
| 2 | Guide to the directory structure |
| 3 | ------------------------------------------------------------------- |
| 4 | Valgrind has 2 main levels of genericity. |
| 5 | |
| 6 | 1. Multiple tools, plus the core. |
| 7 | 2. Multiple architectures, OSes, and platforms (arch/OS combinations). |
| 8 | |
| 9 | This requires a moderately complex directory structure. This file is a |
| 10 | guide to where different things live. |
| 11 | |
| 12 | |
| 13 | Basic layout |
| 14 | ------------ |
| 15 | 1. Core stuff lives in: |
| 16 | - include/ for declarations that must be seen by tools |
| 17 | - coregrind/ for code that need not be seen by tools |
| 18 | - coregrind/demangle/ the demangler |
| 19 | |
| 20 | Tool stuff lives in: |
| 21 | - $TOOL/ main files |
| 22 | - $TOOL/tests regression tests |
| 23 | - $TOOL/docs documentation |
| 24 | |
| 25 | Other stuff lives in: |
| 26 | - docs/ main, non-tool-specific docs |
| 27 | - tests/ regression test machinery |
| 28 | - nightly/ overnight test stuff (should be in tests/) |
| 29 | - auxprogs/ auxiliary programs |
| 30 | |
| 31 | 2. Generic things go in the directory specified in (1). |
| 32 | |
| 33 | Arch-specific, OS-specific, or platform-specific things go within a |
| 34 | subdirectory of the directory specified by step (1) above. |
| 35 | |
| 36 | For example: |
| 37 | - Cachegrind's main generic code goes in cachegrind/. |
| 38 | - Cachegrind's x86-specific code goes in cachegrind/x86/. |
| 39 | - Cachegrind's x86-specific tests go in cachegrind/tests/x86/. |
| 40 | - x86/Linux-specific declarations that must be visible to tools go in |
| 41 | include/x86-linux/. |
| 42 | |
| 43 | |
| 44 | Guide to headers |
| 45 | ---------------- |
| 46 | Finding declarations in headers is not always easy. The above rules dictate |
| 47 | which directory something should go in. As well as that, there are some things |
| 48 | that must be visible in both C and assembly code files, but most things only be |
| 49 | visible in C files; things that must be both C-visible and asm-visible go in |
| 50 | files called *_asm.h. |
| 51 | |
| 52 | The most important header files are (at the time of writing): |
| 53 | - include/tool.h (auto-generated from tool.h.base + toolfuncs.def) |
| 54 | - include/tool_asm.h |
| 55 | - $ARCH/tool_arch.h |
| 56 | - $OS/vki.h |
| 57 | - $PLATFORM/vki*.h |
| 58 | - coregrind/{core.h,core_asm.h} |
| 59 | - $ARCH/{core_arch.h,core_arch_asm.h} |
| 60 | - $OS/core_os.h |
| 61 | - $PLATFORM/{core_platform.h,vki_unistd.h} |
| 62 | |
| 63 | There are a few others, but that is most of them. |
| 64 | |
| 65 | Having read the above text, it should be clear what is found in each of them. |
| 66 | For example, coregrind/core_asm.h contains all the generic |
| 67 | (non-arch/OS/platform-specific) declarations which should not be seen by |
| 68 | tools and must be visible to both C and asm code. |
| 69 | |
| 70 | When searching for something, rgrep is very useful. If you don't have a |
| 71 | version of rgrep, use a command something like this: |
| 72 | |
| 73 | find . -name '*.h' | xargs grep <pattern> |
| 74 | |
| 75 | The comment at the top of coregrind/core.h has some additional information |
| 76 | about the exact hierarchy of the header files, but those details aren't |
| 77 | important for just finding and placing things. |
| 78 | |