mirror of
https://github.com/varun-r-mallya/sysprof.git
synced 2025-12-31 20:36:25 +00:00
Check that the inodes match.
Fri Mar 3 22:28:03 2006 Soeren Sandmann <sandmann@redhat.com> * process.c (process_lookup_symbol): Check that the inodes match. * binfile.c (read_symbols): Read the inode of the file * binfile.c (read_symbols): Close the bfd if the symbol table could not be read.
This commit is contained in:
committed by
Søren Sandmann Pedersen
parent
0d6d997f4a
commit
ebb7728768
36
binfile.c
36
binfile.c
@ -32,6 +32,8 @@
|
||||
#include <unistd.h>
|
||||
#include <fcntl.h>
|
||||
#include <stdio.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
static void bfd_nonfatal (const char *string);
|
||||
static void bfd_fatal (const char *string);
|
||||
@ -44,6 +46,7 @@ struct BinFile
|
||||
Symbol *symbols;
|
||||
Symbol undefined;
|
||||
int ref_count;
|
||||
ino_t inode;
|
||||
};
|
||||
|
||||
static bfd *
|
||||
@ -295,6 +298,21 @@ compare_address (const void *a, const void *b)
|
||||
return 1;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
read_inode (const char *filename,
|
||||
ino_t *inode)
|
||||
{
|
||||
struct stat statbuf;
|
||||
|
||||
if (stat (filename, &statbuf) == 0)
|
||||
{
|
||||
*inode = statbuf.st_ino;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static void
|
||||
read_symbols (BinFile *bf)
|
||||
{
|
||||
@ -315,6 +333,12 @@ read_symbols (BinFile *bf)
|
||||
if (!bfd)
|
||||
return;
|
||||
|
||||
if (!read_inode (bf->filename, &bf->inode))
|
||||
{
|
||||
bfd_close (bfd);
|
||||
return;
|
||||
}
|
||||
|
||||
separate_debug_file = find_separate_debug_file (bfd);
|
||||
if (separate_debug_file)
|
||||
{
|
||||
@ -330,7 +354,10 @@ read_symbols (BinFile *bf)
|
||||
bfd_symbols = slurp_symtab (bfd, &n_symbols);
|
||||
|
||||
if (!bfd_symbols)
|
||||
{
|
||||
bfd_close (bfd);
|
||||
return;
|
||||
}
|
||||
|
||||
load_address = 0xffffffff;
|
||||
for (sec = bfd->sections; sec != NULL; sec = sec->next)
|
||||
@ -416,6 +443,12 @@ bin_file_new (const char *filename)
|
||||
return bf;
|
||||
}
|
||||
|
||||
ino_t
|
||||
bin_file_get_inode (BinFile *bin_file)
|
||||
{
|
||||
return bin_file->inode;
|
||||
}
|
||||
|
||||
void
|
||||
bin_file_free (BinFile *bf)
|
||||
{
|
||||
@ -455,6 +488,9 @@ bin_file_lookup_symbol (BinFile *bf,
|
||||
|
||||
if (!bf->symbols || (bf->n_symbols == 0))
|
||||
return &(bf->undefined);
|
||||
|
||||
if (address == 0x0)
|
||||
return &(bf->undefined);
|
||||
|
||||
data = bf->symbols;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user