/* DWARF 1 find nearest line (_bfd_dwarf1_find_nearest_line).
- Copyright 1998, 1999, 2000, 2001 Free Software Foundation, Inc.
+ Copyright 1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
Written by Gavin Romig-Koch of Cygnus Solutions (gavin@cygnus.com).
/* Find the form of an attr, from the attr field. */
#define FORM_FROM_ATTR(attr) ((attr) & 0xF) /* Implicitly specified */
-static struct dwarf1_unit *alloc_dwarf1_unit PARAMS ((struct dwarf1_debug *));
+static struct dwarf1_unit *alloc_dwarf1_unit
+ PARAMS ((struct dwarf1_debug *));
static struct dwarf1_func *alloc_dwarf1_func
PARAMS ((struct dwarf1_debug *, struct dwarf1_unit *));
-static boolean parse_die PARAMS ((bfd *, struct die_info *, char *, char *));
-static boolean parse_line_table
+static bfd_boolean parse_die
+ PARAMS ((bfd *, struct die_info *, char *, char *));
+static bfd_boolean parse_line_table
PARAMS ((struct dwarf1_debug *, struct dwarf1_unit *));
-static boolean parse_functions_in_unit
+static bfd_boolean parse_functions_in_unit
PARAMS ((struct dwarf1_debug *, struct dwarf1_unit *));
-static boolean dwarf1_unit_find_nearest_line
+static bfd_boolean dwarf1_unit_find_nearest_line
PARAMS ((struct dwarf1_debug *, struct dwarf1_unit *, unsigned long,
const char **, const char **, unsigned int *));
alloc_dwarf1_unit (stash)
struct dwarf1_debug* stash;
{
- struct dwarf1_unit* x =
- (struct dwarf1_unit*) bfd_zalloc (stash->abfd,
- sizeof (struct dwarf1_unit));
+ bfd_size_type amt = sizeof (struct dwarf1_unit);
+
+ struct dwarf1_unit* x = (struct dwarf1_unit*) bfd_zalloc (stash->abfd, amt);
x->prev = stash->lastUnit;
stash->lastUnit = x;
struct dwarf1_debug* stash;
struct dwarf1_unit* aUnit;
{
- struct dwarf1_func* x =
- (struct dwarf1_func*) bfd_zalloc (stash->abfd,
- sizeof (struct dwarf1_func));
+ bfd_size_type amt = sizeof (struct dwarf1_func);
+
+ struct dwarf1_func* x = (struct dwarf1_func*) bfd_zalloc (stash->abfd, amt);
x->prev = aUnit->func_list;
aUnit->func_list = x;
'abfd' must be the bfd from which the section that 'aDiePtr'
points to was pulled from.
- Return false if the die is invalidly formatted; true otherwise. */
+ Return FALSE if the die is invalidly formatted; TRUE otherwise. */
-static boolean
+static bfd_boolean
parse_die (abfd, aDieInfo, aDiePtr, aDiePtrEnd)
bfd* abfd;
struct die_info* aDieInfo;
xptr += 4;
if (aDieInfo->length == 0
|| (this_die + aDieInfo->length) >= aDiePtrEnd)
- return false;
+ return FALSE;
if (aDieInfo->length < 6)
{
/* Just padding bytes. */
aDieInfo->tag = TAG_padding;
- return true;
+ return TRUE;
}
/* Then the tag. */
}
}
- return true;
+ return TRUE;
}
/* Parse a dwarf1 line number table for 'aUnit->stmt_list_offset'
- into 'aUnit->linenumber_table'. Return false if an error
- occurs; true otherwise. */
+ into 'aUnit->linenumber_table'. Return FALSE if an error
+ occurs; TRUE otherwise. */
-static boolean
+static bfd_boolean
parse_line_table (stash, aUnit)
struct dwarf1_debug* stash;
struct dwarf1_unit* aUnit;
if (stash->line_section == 0)
{
asection *msec;
- unsigned long size;
+ bfd_size_type size;
msec = bfd_get_section_by_name (stash->abfd, ".line");
if (! msec)
- return false;
+ return FALSE;
size = bfd_get_section_size_before_reloc (msec);
stash->line_section = (char *) bfd_alloc (stash->abfd, size);
if (! stash->line_section)
- return false;
+ return FALSE;
- if (! bfd_get_section_contents (stash->abfd, msec, stash->line_section, 0, size))
+ if (! bfd_get_section_contents (stash->abfd, msec, stash->line_section,
+ (bfd_vma) 0, size))
{
stash->line_section = 0;
- return false;
+ return FALSE;
}
stash->line_section_end = stash->line_section + size;
if (xptr < stash->line_section_end)
{
unsigned long eachLine;
-
- char* tblend;
+ char *tblend;
unsigned long base;
+ bfd_size_type amt;
/* First comes the length. */
tblend = bfd_get_32 (stash->abfd, (bfd_byte *) xptr) + xptr;
aUnit->line_count = (tblend - xptr) / 10;
/* Allocate an array for the entries. */
- aUnit->linenumber_table = (struct linenumber *)
- bfd_alloc (stash->abfd,
- sizeof (struct linenumber) * aUnit->line_count);
+ amt = sizeof (struct linenumber) * aUnit->line_count;
+ aUnit->linenumber_table = ((struct linenumber *)
+ bfd_alloc (stash->abfd, amt));
for (eachLine = 0; eachLine < aUnit->line_count; eachLine++)
{
}
}
- return true;
+ return TRUE;
}
/* Parse each function die in a compilation unit 'aUnit'.
The first child die of 'aUnit' should be in 'aUnit->first_child',
the result is placed in 'aUnit->func_list'.
- Return false if error; true otherwise. */
+ Return FALSE if error; TRUE otherwise. */
-static boolean
+static bfd_boolean
parse_functions_in_unit (stash, aUnit)
struct dwarf1_debug* stash;
struct dwarf1_unit* aUnit;
if (! parse_die (stash->abfd, &eachDieInfo, eachDie,
stash->debug_section_end))
- return false;
+ return FALSE;
if (eachDieInfo.tag == TAG_global_subroutine
|| eachDieInfo.tag == TAG_subroutine
break;
}
- return true;
+ return TRUE;
}
/* Find the nearest line to 'addr' in 'aUnit'.
Return whether we found the line (or a function) without error. */
-static boolean
+static bfd_boolean
dwarf1_unit_find_nearest_line (stash, aUnit, addr,
filename_ptr, functionname_ptr,
linenumber_ptr)
const char **functionname_ptr;
unsigned int *linenumber_ptr;
{
- int line_p = false;
- int func_p = false;
+ int line_p = FALSE;
+ int func_p = FALSE;
if (aUnit->low_pc <= addr && addr < aUnit->high_pc)
{
if (! aUnit->linenumber_table)
{
if (! parse_line_table (stash, aUnit))
- return false;
+ return FALSE;
}
if (! aUnit->func_list)
{
if (! parse_functions_in_unit (stash, aUnit))
- return false;
+ return FALSE;
}
for (i = 0; i < aUnit->line_count; i++)
{
*filename_ptr = aUnit->name;
*linenumber_ptr = aUnit->linenumber_table[i].linenumber;
- line_p = true;
+ line_p = TRUE;
break;
}
}
&& addr < eachFunc->high_pc)
{
*functionname_ptr = eachFunc->name;
- func_p = true;
+ func_p = TRUE;
break;
}
}
}
/* The DWARF 1 version of find_nearest line.
- Return true if the line is found without error. */
+ Return TRUE if the line is found without error. */
-boolean
+bfd_boolean
_bfd_dwarf1_find_nearest_line (abfd, section, symbols, offset,
filename_ptr, functionname_ptr, linenumber_ptr)
bfd *abfd;
if (! stash)
{
asection *msec;
- unsigned long size;
+ bfd_size_type size = sizeof (struct dwarf1_debug);
- stash = elf_tdata (abfd)->dwarf1_find_line_info =
- (struct dwarf1_debug*) bfd_zalloc (abfd, sizeof (struct dwarf1_debug));
+ stash = elf_tdata (abfd)->dwarf1_find_line_info
+ = (struct dwarf1_debug *) bfd_zalloc (abfd, size);
if (! stash)
- return false;
+ return FALSE;
msec = bfd_get_section_by_name (abfd, ".debug");
if (! msec)
/* No dwarf1 info. Note that at this point the stash
has been allocated, but contains zeros, this lets
future calls to this function fail quicker. */
- return false;
+ return FALSE;
}
size = bfd_get_section_size_before_reloc (msec);
stash->debug_section = (char *) bfd_alloc (abfd, size);
if (! stash->debug_section)
- return false;
+ return FALSE;
- if (! bfd_get_section_contents (abfd, msec, stash->debug_section, 0, size))
+ if (! bfd_get_section_contents (abfd, msec, stash->debug_section,
+ (bfd_vma) 0, size))
{
stash->debug_section = 0;
- return false;
+ return FALSE;
}
stash->debug_section_end = stash->debug_section + size;
or that an error occured while setting up the stash. */
if (! stash->debug_section)
- return false;
+ return FALSE;
/* Look at the previously parsed units to see if any contain
the addr. */
if (! parse_die (stash->abfd, &aDieInfo, stash->currentDie,
stash->debug_section_end))
- return false;
+ return FALSE;
if (aDieInfo.tag == TAG_compile_unit)
{
stash->currentDie += aDieInfo.length;
}
- return false;
+ return FALSE;
}
/* EOF */