mirror of
https://github.com/varun-r-mallya/sysprof.git
synced 2025-12-31 20:36:25 +00:00
Put back the weird loop, and stop pretending I understand this. This time
Tue Apr 5 23:01:02 2005 Søren Sandmann <sandmann@redhat.com> * binfile.c (read_symbols): Put back the weird loop, and stop pretending I understand this. This time use SEC_ALLOC instead of SEC_LOAD.
This commit is contained in:
committed by
Søren Sandmann Pedersen
parent
88c3bbb880
commit
bda89efc68
@ -1,3 +1,9 @@
|
|||||||
|
Tue Apr 5 23:01:02 2005 Søren Sandmann <sandmann@redhat.com>
|
||||||
|
|
||||||
|
* binfile.c (read_symbols): Put back the weird loop, and stop
|
||||||
|
pretending I understand this. This time use SEC_ALLOC instead of
|
||||||
|
SEC_LOAD.
|
||||||
|
|
||||||
Tue Apr 5 20:13:44 2005 Søren Sandmann <sandmann@redhat.com>
|
Tue Apr 5 20:13:44 2005 Søren Sandmann <sandmann@redhat.com>
|
||||||
|
|
||||||
* process.c (process_ensure_map): Add commented out debug spew.
|
* process.c (process_ensure_map): Add commented out debug spew.
|
||||||
|
|||||||
20
binfile.c
20
binfile.c
@ -280,6 +280,8 @@ read_symbols (BinFile *bf)
|
|||||||
int i;
|
int i;
|
||||||
bfd *bfd;
|
bfd *bfd;
|
||||||
GArray *symbols;
|
GArray *symbols;
|
||||||
|
guint load_address;
|
||||||
|
struct bfd_section *sec;
|
||||||
|
|
||||||
bf->symbols = NULL;
|
bf->symbols = NULL;
|
||||||
bf->n_symbols = 0;
|
bf->n_symbols = 0;
|
||||||
@ -305,6 +307,16 @@ read_symbols (BinFile *bf)
|
|||||||
if (!bfd_symbols)
|
if (!bfd_symbols)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
load_address = 0xffffffff;
|
||||||
|
for (sec = bfd->sections; sec != NULL; sec = sec->next)
|
||||||
|
{
|
||||||
|
if (sec->flags & SEC_ALLOC)
|
||||||
|
{
|
||||||
|
if ((gulong)sec->vma < load_address)
|
||||||
|
load_address = sec->vma & ~4095;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
text_section = bfd_get_section_by_name (bfd, ".text");
|
text_section = bfd_get_section_by_name (bfd, ".text");
|
||||||
if (!text_section)
|
if (!text_section)
|
||||||
return;
|
return;
|
||||||
@ -326,7 +338,13 @@ read_symbols (BinFile *bf)
|
|||||||
* - all addresses are already offset by section->vma
|
* - all addresses are already offset by section->vma
|
||||||
* - the section is positioned at section->filepos
|
* - the section is positioned at section->filepos
|
||||||
*/
|
*/
|
||||||
symbol.address = bfd_asymbol_value (bfd_symbols[i]) - text_section->vma + text_section->filepos;
|
#if 0
|
||||||
|
g_print ("file: %s\n", bf->filename);
|
||||||
|
g_print ("vma: %p\n", text_section->vma);
|
||||||
|
g_print ("vma: %p\n", text_section->filepos);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
symbol.address = bfd_asymbol_value (bfd_symbols[i]) - load_address;
|
||||||
name = demangle (bfd, bfd_asymbol_name (bfd_symbols[i]));
|
name = demangle (bfd, bfd_asymbol_name (bfd_symbols[i]));
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
|
|||||||
40
process.c
40
process.c
@ -335,6 +335,9 @@ process_lookup_symbol (Process *process, gulong address)
|
|||||||
|
|
||||||
return &undefined;
|
return &undefined;
|
||||||
}
|
}
|
||||||
|
#if 0
|
||||||
|
g_print ("has map: %s\n", process->cmdline);
|
||||||
|
#endif
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
g_print ("has map: %s\n", process->cmdline);
|
g_print ("has map: %s\n", process->cmdline);
|
||||||
@ -343,7 +346,11 @@ process_lookup_symbol (Process *process, gulong address)
|
|||||||
/* if (map->do_offset) */
|
/* if (map->do_offset) */
|
||||||
/* address -= map->start; */
|
/* address -= map->start; */
|
||||||
|
|
||||||
|
#if 0
|
||||||
/* convert address to file coordinates */
|
/* convert address to file coordinates */
|
||||||
|
g_print ("looking up %p ", address);
|
||||||
|
#endif
|
||||||
|
|
||||||
address -= map->start;
|
address -= map->start;
|
||||||
address += map->offset;
|
address += map->offset;
|
||||||
|
|
||||||
@ -352,41 +359,18 @@ process_lookup_symbol (Process *process, gulong address)
|
|||||||
|
|
||||||
/* g_print ("%s: start: %p, load: %p\n", */
|
/* g_print ("%s: start: %p, load: %p\n", */
|
||||||
/* map->filename, map->start, bin_file_get_load_address (map->bin_file)); */
|
/* map->filename, map->start, bin_file_get_load_address (map->bin_file)); */
|
||||||
|
|
||||||
result = bin_file_lookup_symbol (map->bin_file, address);
|
result = bin_file_lookup_symbol (map->bin_file, address);
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
g_print (" ---> %s\n", result->name);
|
||||||
|
#endif
|
||||||
|
|
||||||
/* g_print ("(%x) %x %x name; %s\n", address, map->start, map->offset, result->name); */
|
/* g_print ("(%x) %x %x name; %s\n", address, map->start, map->offset, result->name); */
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if 0
|
|
||||||
const Symbol *
|
|
||||||
process_lookup_symbol_with_filename (Process *process,
|
|
||||||
int pid,
|
|
||||||
gulong map_start,
|
|
||||||
const char *filename,
|
|
||||||
gulong address)
|
|
||||||
{
|
|
||||||
const Symbol *result;
|
|
||||||
BinFile *bin_file;
|
|
||||||
|
|
||||||
if (!filename)
|
|
||||||
return process_lookup_symbol (process, address);
|
|
||||||
|
|
||||||
bin_file = bin_file_new (filename);
|
|
||||||
|
|
||||||
if (should_offset (filename, pid))
|
|
||||||
address -= map_start;
|
|
||||||
|
|
||||||
result = bin_file_lookup_symbol (bin_file, address);
|
|
||||||
|
|
||||||
bin_file_free (bin_file);
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
const char *
|
const char *
|
||||||
process_get_cmdline (Process *process)
|
process_get_cmdline (Process *process)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user