-
Notifications
You must be signed in to change notification settings - Fork 40
Open
Description
Chapter: 12
Description: In the Extracting DIE Address Ranges section, Contiguous subsection on page 321, there is a possible type conversion error in high_pc; as_address returns a file_addr, which is being assigned to an uint64_t:
std::uint64_t addr;
if (attr.form() == DW_FORM_addr) {
addr = attr.as_address();
}
else {
addr = low_pc() + attr.as_int();
}Reproduction steps: Building the project after completing the Contiguous subsection results in the following compile errors:
sdb/src/dwarf.cpp: In member function ‘sdb::file_addr sdb::die::high_pc() const’:
sdb/src/dwarf.cpp:390:31: error: cannot convert ‘sdb::file_addr’ to ‘uint64_t’ {aka ‘long unsigned int’} in assignment
390 | addr = attr.as_address();
| ~~~~~~~~~~~~~~~^~
| |
| sdb::file_addr
sdb/src/dwarf.cpp:393:25: error: cannot convert ‘sdb::file_addr’ to ‘uint64_t’ {aka ‘long unsigned int’} in assignment
393 | addr = low_pc() + attr.as_int();
| ~~~~~~~~~^~~~~~~~~~~~~~~
| |
| sdb::file_addr
This gets fixed on page 329, when high_pc is updated to account for range lists.
A possible fix for page 321,following how the function is implemented on page 329, would be:
sdb::file_addr sdb::die::high_pc() const {
auto attr = (*this)[DW_AT_high_pc];
- std::uint64_t addr;
if (attr.form() == DW_FORM_addr) {
- addr = attr.as_address();
+ return attr.as_address();
}
else {
- addr = low_pc() + attr.as_int();
+ return low_pc() + attr.as_int();
}
- return file_addr{
- *cu_->dwarf_info()->elf_file(),
- addr
- };
}Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels