63 #include "../support-lean/compress.h" 76 std::string fname = virtual_name.substr( 1, virtual_name.size()-2 );
79 std::set<std::string>::iterator it;
80 for(it = directorySet.begin(); it != directorySet.end(); ++it) {
81 std::string dir = *it;
86 if (stat(path.c_str(), &buffer) == 0) {
108 std::string virtual_path(pathname);
111 if (real_path.empty()) {
112 std::cerr <<
"Warning: cannot find kernel symbols file " << pathname <<
113 " ds: "<< directorySet.size() << std::endl;
114 perror(
"LinuxKernelSymbols");
118 FILE *fp_in = fopen(real_path.c_str(),
"r");
125 FILE *fp_deflate = tmpfile();
126 if (fp_deflate ==
NULL) {
127 std::cerr <<
"Error: cannot create temporary file" << std::endl;
131 FILE *fp_out = fp_deflate;
148 char *line = (
char *)
malloc(len);
151 if (getline(&line, &len, fp) == EOF)
160 int result = sscanf(line,
"%p %c %s %s\n", &addr, &type, name, module);
162 if (result < 3)
break;
168 if (strlen(module) > 0) {
170 strcat(name, module);
173 binding = ((type ==
't') ?
197 if (pathname ==
NULL)
200 bool prefix_correct = pathname[0] ==
'<';
201 bool suffix_correct = pathname[strlen(pathname)-1] ==
'>';
204 return prefix_correct && suffix_correct && name_correct;
211 if (m_kernelSymbol) {
212 return m_kernelSymbol;
215 return m_kernelSymbol;
266 int main(
int argc,
char **argv)
274 sscanf(argv[1],
"%lx", &addr);
277 bool result = (sym != 0);
278 if (result) name = sym->
name();
279 std::cout <<
"Lookup " << std::hex <<
"0x" << addr << std::dec
280 <<
" (" << result <<
")" <<
" --> " << name << std::endl;
static std::string getKernelFilename(const std::set< std::string > &directorySet, std::string virtual_name)
#define LINUX_KERNEL_NAME
void coalesce(SimpleSymbolsCoalesceCallback coalesce)
SimpleSymbol * find(uint64_t vma)
void add(uint64_t addr, SimpleSymbolKind kind, SimpleSymbolBinding binding, const char *name)
const char * unified_name()
#define LINUX_KERNEL_NAME_REAL
int main(int argc, char *argv[])
const std::string & name() const
bool parse(const std::set< std::string > &directorySet, const char *pathname)
#define LINUX_KERNEL_SYMBOL_FILE
SimpleSymbolsCoalesceCallback chooseHighestBinding
void *MONITOR_EXT_WRAP_NAME() malloc(size_t bytes)
enum compress_e compress_inflate(FILE *source, FILE *dest)
#define KERNEL_SYMBOLS_DIRECTORY
bool match(const char *pathname)
const std::string & name()