| OLD | NEW |
| 1 // Copyright (c) 2006, Google Inc. | 1 // Copyright (c) 2006, Google Inc. |
| 2 // All rights reserved. | 2 // All rights reserved. |
| 3 // | 3 // |
| 4 // Redistribution and use in source and binary forms, with or without | 4 // Redistribution and use in source and binary forms, with or without |
| 5 // modification, are permitted provided that the following conditions are | 5 // modification, are permitted provided that the following conditions are |
| 6 // met: | 6 // met: |
| 7 // | 7 // |
| 8 // * Redistributions of source code must retain the above copyright | 8 // * Redistributions of source code must retain the above copyright |
| 9 // notice, this list of conditions and the following disclaimer. | 9 // notice, this list of conditions and the following disclaimer. |
| 10 // * Redistributions in binary form must reproduce the above | 10 // * Redistributions in binary form must reproduce the above |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 98 // success. Otherwise, returns false. | 98 // success. Otherwise, returns false. |
| 99 bool GetSectionHeaderByName(int fd, const char *name, size_t name_len, | 99 bool GetSectionHeaderByName(int fd, const char *name, size_t name_len, |
| 100 ElfW(Shdr) *out); | 100 ElfW(Shdr) *out); |
| 101 | 101 |
| 102 _END_GOOGLE_NAMESPACE_ | 102 _END_GOOGLE_NAMESPACE_ |
| 103 | 103 |
| 104 #endif /* __ELF__ */ | 104 #endif /* __ELF__ */ |
| 105 | 105 |
| 106 _START_GOOGLE_NAMESPACE_ | 106 _START_GOOGLE_NAMESPACE_ |
| 107 | 107 |
| 108 // Restrictions on the callbacks that follow: |
| 109 // - The callbacks must not use heaps but only use stacks. |
| 110 // - The callbacks must be async-signal-safe. |
| 111 |
| 108 // Installs a callback function, which will be called right before a symbol name | 112 // Installs a callback function, which will be called right before a symbol name |
| 109 // is printed. The callback is intended to be used for showing a file name and a | 113 // is printed. The callback is intended to be used for showing a file name and a |
| 110 // line number preceding a symbol name. | 114 // line number preceding a symbol name. |
| 111 // "fd" is a file descriptor of the object file containing the program | 115 // "fd" is a file descriptor of the object file containing the program |
| 112 // counter "pc". The callback function should write output to "out" | 116 // counter "pc". The callback function should write output to "out" |
| 113 // and return the size of the output written. On error, the callback | 117 // and return the size of the output written. On error, the callback |
| 114 // function should return -1. | 118 // function should return -1. |
| 115 typedef int (*SymbolizeCallback)(int fd, void *pc, char *out, size_t out_size, | 119 typedef int (*SymbolizeCallback)(int fd, void *pc, char *out, size_t out_size, |
| 116 uint64 relocation); | 120 uint64 relocation); |
| 117 void InstallSymbolizeCallback(SymbolizeCallback callback); | 121 void InstallSymbolizeCallback(SymbolizeCallback callback); |
| 118 | 122 |
| 123 // Installs a callback function, which will be called instead of |
| 124 // OpenObjectFileContainingPcAndGetStartAddress. The callback is expected |
| 125 // to searches for the object file (from /proc/self/maps) that contains |
| 126 // the specified pc. If found, sets |start_address| to the start address |
| 127 // of where this object file is mapped in memory, sets the module base |
| 128 // address into |base_address|, copies the object file name into |
| 129 // |out_file_name|, and attempts to open the object file. If the object |
| 130 // file is opened successfully, returns the file descriptor. Otherwise, |
| 131 // returns -1. |out_file_name_size| is the size of the file name buffer |
| 132 // (including the null-terminator). |
| 133 typedef int (*SymbolizeOpenObjectFileCallback)(uint64_t pc, |
| 134 uint64_t &start_address, |
| 135 uint64_t &base_address, |
| 136 char *out_file_name, |
| 137 int out_file_name_size); |
| 138 void InstallSymbolizeOpenObjectFileCallback( |
| 139 SymbolizeOpenObjectFileCallback callback); |
| 140 |
| 119 _END_GOOGLE_NAMESPACE_ | 141 _END_GOOGLE_NAMESPACE_ |
| 120 | 142 |
| 121 #endif | 143 #endif |
| 122 | 144 |
| 123 _START_GOOGLE_NAMESPACE_ | 145 _START_GOOGLE_NAMESPACE_ |
| 124 | 146 |
| 125 // Symbolizes a program counter. On success, returns true and write the | 147 // Symbolizes a program counter. On success, returns true and write the |
| 126 // symbol name to "out". The symbol name is demangled if possible | 148 // symbol name to "out". The symbol name is demangled if possible |
| 127 // (supports symbols generated by GCC 3.x or newer). Otherwise, | 149 // (supports symbols generated by GCC 3.x or newer). Otherwise, |
| 128 // returns false. | 150 // returns false. |
| 129 bool Symbolize(void *pc, char *out, int out_size); | 151 bool Symbolize(void *pc, char *out, int out_size); |
| 130 | 152 |
| 131 _END_GOOGLE_NAMESPACE_ | 153 _END_GOOGLE_NAMESPACE_ |
| 132 | 154 |
| 133 #endif // BASE_SYMBOLIZE_H_ | 155 #endif // BASE_SYMBOLIZE_H_ |
| OLD | NEW |