1 //===-- DWARFLocationList.cpp -----------------------------------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 #include "DWARFLocationList.h"
12 #include "lldb/Core/Stream.h"
14 #include "DWARFCompileUnit.h"
15 #include "DWARFDebugInfo.h"
16 #include "DWARFLocationDescription.h"
18 using namespace lldb_private;
21 DWARFLocationList::Dump(Stream &s, const DWARFCompileUnit* cu, const DataExtractor& debug_loc_data, lldb::offset_t offset)
23 uint64_t start_addr, end_addr;
24 uint32_t addr_size = DWARFCompileUnit::GetAddressByteSize(cu);
25 s.SetAddressByteSize(DWARFCompileUnit::GetAddressByteSize(cu));
26 dw_addr_t base_addr = cu ? cu->GetBaseAddress() : 0;
27 while (debug_loc_data.ValidOffset(offset))
29 start_addr = debug_loc_data.GetMaxU64(&offset,addr_size);
30 end_addr = debug_loc_data.GetMaxU64(&offset,addr_size);
32 if (start_addr == 0 && end_addr == 0)
38 s.AddressRange (start_addr + base_addr,
40 cu->GetAddressByteSize(),
43 uint32_t loc_length = debug_loc_data.GetU16(&offset);
45 DataExtractor locationData(debug_loc_data, offset, loc_length);
46 // if ( dump_flags & DWARFDebugInfo::eDumpFlag_Verbose ) *ostrm_ptr << " ( ";
47 print_dwarf_expression (s, locationData, addr_size, 4, false);
55 DWARFLocationList::Extract(const DataExtractor& debug_loc_data, lldb::offset_t* offset_ptr, DataExtractor& location_list_data)
57 // Initialize with no data just in case we don't find anything
58 location_list_data.Clear();
60 size_t loc_list_length = Size(debug_loc_data, *offset_ptr);
61 if (loc_list_length > 0)
63 location_list_data.SetData(debug_loc_data, *offset_ptr, loc_list_length);
64 *offset_ptr += loc_list_length;
72 DWARFLocationList::Size(const DataExtractor& debug_loc_data, lldb::offset_t offset)
74 const dw_offset_t debug_loc_offset = offset;
76 while (debug_loc_data.ValidOffset(offset))
78 dw_addr_t start_addr = debug_loc_data.GetAddress(&offset);
79 dw_addr_t end_addr = debug_loc_data.GetAddress(&offset);
81 if (start_addr == 0 && end_addr == 0)
84 uint16_t loc_length = debug_loc_data.GetU16(&offset);
88 if (offset > debug_loc_offset)
89 return offset - debug_loc_offset;