Changeset 609 for branches/GNU/src/binutils/bfd/dwarf1.c
- Timestamp:
- Aug 16, 2003, 6:59:22 PM (22 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/GNU/src/binutils/bfd/dwarf1.c
-
Property cvs2svn:cvs-rev
changed from
1.1
to1.1.1.2
r608 r609 1 1 /* DWARF 1 find nearest line (_bfd_dwarf1_find_nearest_line). 2 Copyright 1998, 1999, 2000 Free Software Foundation, Inc.2 Copyright 1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc. 3 3 4 4 Written by Gavin Romig-Koch of Cygnus Solutions (gavin@cygnus.com). … … 127 127 #define FORM_FROM_ATTR(attr) ((attr) & 0xF) /* Implicitly specified */ 128 128 129 static struct dwarf1_unit *alloc_dwarf1_unit 130 PARAMS ((struct dwarf1_debug *)); 131 static struct dwarf1_func *alloc_dwarf1_func 132 PARAMS ((struct dwarf1_debug *, struct dwarf1_unit *)); 133 static bfd_boolean parse_die 134 PARAMS ((bfd *, struct die_info *, char *, char *)); 135 static bfd_boolean parse_line_table 136 PARAMS ((struct dwarf1_debug *, struct dwarf1_unit *)); 137 static bfd_boolean parse_functions_in_unit 138 PARAMS ((struct dwarf1_debug *, struct dwarf1_unit *)); 139 static bfd_boolean dwarf1_unit_find_nearest_line 140 PARAMS ((struct dwarf1_debug *, struct dwarf1_unit *, unsigned long, 141 const char **, const char **, unsigned int *)); 142 129 143 /* Return a newly allocated dwarf1_unit. It should be cleared and 130 144 then attached into the 'stash' at 'stash->lastUnit'. */ … … 134 148 struct dwarf1_debug* stash; 135 149 { 136 struct dwarf1_unit* x =137 (struct dwarf1_unit*) bfd_zalloc (stash->abfd, 138 sizeof (struct dwarf1_unit));150 bfd_size_type amt = sizeof (struct dwarf1_unit); 151 152 struct dwarf1_unit* x = (struct dwarf1_unit*) bfd_zalloc (stash->abfd, amt); 139 153 x->prev = stash->lastUnit; 140 154 stash->lastUnit = x; … … 151 165 struct dwarf1_unit* aUnit; 152 166 { 153 struct dwarf1_func* x =154 (struct dwarf1_func*) bfd_zalloc (stash->abfd, 155 sizeof (struct dwarf1_func));167 bfd_size_type amt = sizeof (struct dwarf1_func); 168 169 struct dwarf1_func* x = (struct dwarf1_func*) bfd_zalloc (stash->abfd, amt); 156 170 x->prev = aUnit->func_list; 157 171 aUnit->func_list = x; … … 165 179 points to was pulled from. 166 180 167 Return false if the die is invalidly formatted; trueotherwise. */168 169 static b oolean170 parse_die (abfd, aDieInfo, aDiePtr )181 Return FALSE if the die is invalidly formatted; TRUE otherwise. */ 182 183 static bfd_boolean 184 parse_die (abfd, aDieInfo, aDiePtr, aDiePtrEnd) 171 185 bfd* abfd; 172 186 struct die_info* aDieInfo; 173 187 char* aDiePtr; 188 char* aDiePtrEnd; 174 189 { 175 190 char* this_die = aDiePtr; … … 181 196 aDieInfo->length = bfd_get_32 (abfd, (bfd_byte *) xptr); 182 197 xptr += 4; 183 if (aDieInfo->length == 0) 184 return false; 198 if (aDieInfo->length == 0 199 || (this_die + aDieInfo->length) >= aDiePtrEnd) 200 return FALSE; 185 201 if (aDieInfo->length < 6) 186 202 { 187 203 /* Just padding bytes. */ 188 204 aDieInfo->tag = TAG_padding; 189 return true;205 return TRUE; 190 206 } 191 207 … … 246 262 } 247 263 248 return true;264 return TRUE; 249 265 } 250 266 251 267 /* Parse a dwarf1 line number table for 'aUnit->stmt_list_offset' 252 into 'aUnit->linenumber_table'. Return falseif an error253 occurs; trueotherwise. */254 255 static b oolean268 into 'aUnit->linenumber_table'. Return FALSE if an error 269 occurs; TRUE otherwise. */ 270 271 static bfd_boolean 256 272 parse_line_table (stash, aUnit) 257 273 struct dwarf1_debug* stash; … … 264 280 { 265 281 asection *msec; 266 unsigned longsize;282 bfd_size_type size; 267 283 268 284 msec = bfd_get_section_by_name (stash->abfd, ".line"); 269 285 if (! msec) 270 return false;286 return FALSE; 271 287 272 288 size = bfd_get_section_size_before_reloc (msec); … … 274 290 275 291 if (! stash->line_section) 276 return false; 277 278 if (! bfd_get_section_contents (stash->abfd, msec, stash->line_section, 0, size)) 292 return FALSE; 293 294 if (! bfd_get_section_contents (stash->abfd, msec, stash->line_section, 295 (bfd_vma) 0, size)) 279 296 { 280 297 stash->line_section = 0; 281 return false;298 return FALSE; 282 299 } 283 300 … … 289 306 { 290 307 unsigned long eachLine; 291 292 char* tblend; 308 char *tblend; 293 309 unsigned long base; 310 bfd_size_type amt; 294 311 295 312 /* First comes the length. */ … … 306 323 307 324 /* Allocate an array for the entries. */ 308 a Unit->linenumber_table = (struct linenumber *)309 bfd_alloc (stash->abfd, 310 sizeof (struct linenumber) * aUnit->line_count);325 amt = sizeof (struct linenumber) * aUnit->line_count; 326 aUnit->linenumber_table = ((struct linenumber *) 327 bfd_alloc (stash->abfd, amt)); 311 328 312 329 for (eachLine = 0; eachLine < aUnit->line_count; eachLine++) … … 327 344 } 328 345 329 return true;346 return TRUE; 330 347 } 331 348 … … 333 350 The first child die of 'aUnit' should be in 'aUnit->first_child', 334 351 the result is placed in 'aUnit->func_list'. 335 Return false if error; trueotherwise. */336 337 static b oolean352 Return FALSE if error; TRUE otherwise. */ 353 354 static bfd_boolean 338 355 parse_functions_in_unit (stash, aUnit) 339 356 struct dwarf1_debug* stash; … … 349 366 struct die_info eachDieInfo; 350 367 351 if (! parse_die (stash->abfd, &eachDieInfo, eachDie)) 352 return false; 368 if (! parse_die (stash->abfd, &eachDieInfo, eachDie, 369 stash->debug_section_end)) 370 return FALSE; 353 371 354 372 if (eachDieInfo.tag == TAG_global_subroutine … … 371 389 } 372 390 373 return true;391 return TRUE; 374 392 } 375 393 … … 377 395 Return whether we found the line (or a function) without error. */ 378 396 379 static b oolean397 static bfd_boolean 380 398 dwarf1_unit_find_nearest_line (stash, aUnit, addr, 381 399 filename_ptr, functionname_ptr, … … 388 406 unsigned int *linenumber_ptr; 389 407 { 390 int line_p = false;391 int func_p = false;408 int line_p = FALSE; 409 int func_p = FALSE; 392 410 393 411 if (aUnit->low_pc <= addr && addr < aUnit->high_pc) … … 401 419 { 402 420 if (! parse_line_table (stash, aUnit)) 403 return false;421 return FALSE; 404 422 } 405 423 … … 407 425 { 408 426 if (! parse_functions_in_unit (stash, aUnit)) 409 return false;427 return FALSE; 410 428 } 411 429 … … 417 435 *filename_ptr = aUnit->name; 418 436 *linenumber_ptr = aUnit->linenumber_table[i].linenumber; 419 line_p = true;437 line_p = TRUE; 420 438 break; 421 439 } … … 430 448 { 431 449 *functionname_ptr = eachFunc->name; 432 func_p = true;450 func_p = TRUE; 433 451 break; 434 452 } … … 441 459 442 460 /* The DWARF 1 version of find_nearest line. 443 Return trueif the line is found without error. */444 445 b oolean461 Return TRUE if the line is found without error. */ 462 463 bfd_boolean 446 464 _bfd_dwarf1_find_nearest_line (abfd, section, symbols, offset, 447 465 filename_ptr, functionname_ptr, linenumber_ptr) … … 468 486 { 469 487 asection *msec; 470 unsigned long size;471 472 stash = elf_tdata (abfd)->dwarf1_find_line_info =473 (struct dwarf1_debug*) bfd_zalloc (abfd, sizeof (struct dwarf1_debug));488 bfd_size_type size = sizeof (struct dwarf1_debug); 489 490 stash = elf_tdata (abfd)->dwarf1_find_line_info 491 = (struct dwarf1_debug *) bfd_zalloc (abfd, size); 474 492 475 493 if (! stash) 476 return false;494 return FALSE; 477 495 478 496 msec = bfd_get_section_by_name (abfd, ".debug"); … … 482 500 has been allocated, but contains zeros, this lets 483 501 future calls to this function fail quicker. */ 484 return false;502 return FALSE; 485 503 } 486 504 … … 489 507 490 508 if (! stash->debug_section) 491 return false; 492 493 if (! bfd_get_section_contents (abfd, msec, stash->debug_section, 0, size)) 509 return FALSE; 510 511 if (! bfd_get_section_contents (abfd, msec, stash->debug_section, 512 (bfd_vma) 0, size)) 494 513 { 495 514 stash->debug_section = 0; 496 return false;515 return FALSE; 497 516 } 498 517 … … 506 525 507 526 if (! stash->debug_section) 508 return false;527 return FALSE; 509 528 510 529 /* Look at the previously parsed units to see if any contain … … 523 542 struct die_info aDieInfo; 524 543 525 if (! parse_die (stash->abfd, &aDieInfo, stash->currentDie)) 526 return false; 544 if (! parse_die (stash->abfd, &aDieInfo, stash->currentDie, 545 stash->debug_section_end)) 546 return FALSE; 527 547 528 548 if (aDieInfo.tag == TAG_compile_unit) … … 561 581 } 562 582 563 return false;583 return FALSE; 564 584 } 565 585 -
Property cvs2svn:cvs-rev
changed from
Note:
See TracChangeset
for help on using the changeset viewer.