Beispiel #1
0
static char *
lookup_symbol (state_t    *state,
	       process_t  *process,
	       uint64_t    address,
	       gboolean    kernel)
{
    const char *sym;

    g_assert (process);

    if (kernel)
    {
	sym = lookup_kernel_symbol (address);
    }
    else
    {
	const map_t *map = process_locate_map (process, address);

	if (!map)
	{
	    sym = make_message (state, "No map [%s]", process->comm);
	}
	else
	{
	    bin_file_t *bin_file = state_get_bin_file (state, map->filename);
	    const bin_symbol_t *bin_sym;

	    address -= map->start;
	    address += map->offset;

	    if (map->inode && !bin_file_check_inode (bin_file, map->inode))
	    {
		/* If the inodes don't match, it's probably because the
		 * file has changed since the process was started.
		 */
		sym = make_message (state, "%s: inode mismatch", map->filename);
	    }
	    else
	    {
		bin_sym = bin_file_lookup_symbol (bin_file, address);

		sym = bin_symbol_get_name (bin_file, bin_sym);
	    }
	}
    }

    if (sym)
	return unique_dup (state->unique_symbols, sym);
    else
	return NULL;
}
Beispiel #2
0
const bin_symbol_t *
bin_file_lookup_symbol (bin_file_t    *bin_file,
                        gulong      address)
{
    GList *list;

#if 0
    g_print ("-=-=-=- \n");

    g_print ("bin file lookup lookup %d\n", address);
#endif

    address -= bin_file->text_offset;

#if 0
    g_print ("lookup %d in %s\n", address, bin_file->filename);
#endif

    for (list = bin_file->elf_files; list != NULL; list = list->next)
    {
        ElfParser *elf = list->data;
        const ElfSym *sym = elf_parser_lookup_symbol (elf, address);

        if (sym)
        {
#if 0
            g_print ("found  %lx => %s\n", address,
                     bin_symbol_get_name (bin_file, sym));
#endif
            return (const bin_symbol_t *)sym;
        }
    }

#if 0
    g_print ("%lx undefined in %s (textoffset %x)\n",
             address + bin_file->text_offset,
             bin_file->filename,
             bin_file->text_offset);
#endif

    return (const bin_symbol_t *)bin_file->undefined_name;
}