Fix dwarf_ranges handling of lowpc == pc, it's not correct to jump the gun and not check the high-pc. I think I erroneously added this in c94b03ae6e. Discovered as part of #123.
This commit is contained in:
parent
4884c4e99b
commit
7c9b24ca72
@ -385,13 +385,9 @@ namespace libdwarf {
|
|||||||
|
|
||||||
template<typename F>
|
template<typename F>
|
||||||
// callback should return true to keep going
|
// callback should return true to keep going
|
||||||
void dwarf_ranges(int version, optional<Dwarf_Addr> pc, F callback) const {
|
void dwarf_ranges(int version, F callback) const {
|
||||||
Dwarf_Addr lowpc = (std::numeric_limits<Dwarf_Addr>::max)();
|
Dwarf_Addr lowpc = (std::numeric_limits<Dwarf_Addr>::max)();
|
||||||
if(wrap(dwarf_lowpc, die, &lowpc) == DW_DLV_OK) {
|
if(wrap(dwarf_lowpc, die, &lowpc) == DW_DLV_OK) {
|
||||||
if(pc.has_value() && pc.unwrap() == lowpc) {
|
|
||||||
callback(lowpc, lowpc + 1);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
Dwarf_Addr highpc = 0;
|
Dwarf_Addr highpc = 0;
|
||||||
enum Dwarf_Form_Class return_class;
|
enum Dwarf_Form_Class return_class;
|
||||||
if(wrap(dwarf_highpc_b, die, &highpc, nullptr, &return_class) == DW_DLV_OK) {
|
if(wrap(dwarf_highpc_b, die, &highpc, nullptr, &return_class) == DW_DLV_OK) {
|
||||||
@ -412,7 +408,7 @@ namespace libdwarf {
|
|||||||
|
|
||||||
std::vector<std::pair<Dwarf_Addr, Dwarf_Addr>> get_rangelist_entries(int version) const {
|
std::vector<std::pair<Dwarf_Addr, Dwarf_Addr>> get_rangelist_entries(int version) const {
|
||||||
std::vector<std::pair<Dwarf_Addr, Dwarf_Addr>> vec;
|
std::vector<std::pair<Dwarf_Addr, Dwarf_Addr>> vec;
|
||||||
dwarf_ranges(version, nullopt, [&vec] (Dwarf_Addr low, Dwarf_Addr high) {
|
dwarf_ranges(version, [&vec] (Dwarf_Addr low, Dwarf_Addr high) {
|
||||||
// Simple coalescing optimization:
|
// Simple coalescing optimization:
|
||||||
// Sometimes the range list entries are really continuous: [100, 200), [200, 300)
|
// Sometimes the range list entries are really continuous: [100, 200), [200, 300)
|
||||||
// Other times there's just one byte of separation [300, 399), [400, 500)
|
// Other times there's just one byte of separation [300, 399), [400, 500)
|
||||||
@ -431,7 +427,7 @@ namespace libdwarf {
|
|||||||
|
|
||||||
Dwarf_Bool pc_in_die(int version, Dwarf_Addr pc) const {
|
Dwarf_Bool pc_in_die(int version, Dwarf_Addr pc) const {
|
||||||
bool found = false;
|
bool found = false;
|
||||||
dwarf_ranges(version, pc, [&found, pc] (Dwarf_Addr low, Dwarf_Addr high) {
|
dwarf_ranges(version, [&found, pc] (Dwarf_Addr low, Dwarf_Addr high) {
|
||||||
if(pc >= low && pc < high) {
|
if(pc >= low && pc < high) {
|
||||||
found = true;
|
found = true;
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user