1 //===-- DWARFDebugMacinfoEntry.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 "DWARFDebugMacinfoEntry.h"
12 #include "lldb/Core/Stream.h"
14 using namespace lldb_private;
17 DWARFDebugMacinfoEntry::DWARFDebugMacinfoEntry() :
25 DWARFDebugMacinfoEntry::~DWARFDebugMacinfoEntry()
30 DWARFDebugMacinfoEntry::GetCString() const
35 case DW_MACINFO_start_file:
36 case DW_MACINFO_end_file:
47 DWARFDebugMacinfoEntry::Dump(Stream *s) const
51 s->PutCString(DW_MACINFO_value_to_name(m_type_code));
55 case DW_MACINFO_define:
56 s->Printf(" line:%u #define %s\n", (uint32_t)m_line, m_op2.cstr);
59 case DW_MACINFO_undef:
60 s->Printf(" line:%u #undef %s\n", (uint32_t)m_line, m_op2.cstr);
64 s->Printf(" line:%u str: '%s'\n", (uint32_t)m_line, m_op2.cstr);
67 case DW_MACINFO_start_file:
68 s->Printf(" line:%u file index: '%u'\n", (uint32_t)m_line, (uint32_t)m_op2.file_idx);
71 case DW_MACINFO_end_file:
77 s->PutCString(" END\n");
83 DWARFDebugMacinfoEntry::Extract(const DataExtractor& mac_info_data, lldb::offset_t* offset_ptr)
85 if (mac_info_data.ValidOffset(*offset_ptr))
87 m_type_code = mac_info_data.GetU8(offset_ptr);
92 case DW_MACINFO_define:
93 case DW_MACINFO_undef:
95 // Arg 1: operand encodes the line number of the source line on which
96 // the relevant defining or undefining pre-processor directives
98 m_line = mac_info_data.GetULEB128(offset_ptr);
99 // Arg 2: define string
100 m_op2.cstr = mac_info_data.GetCStr(offset_ptr);
103 case DW_MACINFO_start_file:
105 // Op 1: line number of the source line on which the inclusion
106 // pre-processor directive occurred.
107 m_line = mac_info_data.GetULEB128(offset_ptr);
108 // Op 2: a source file name index to a file number in the statement
109 // information table for the relevant compilation unit.
110 m_op2.file_idx = mac_info_data.GetULEB128(offset_ptr);
113 case 0: // End of list
114 case DW_MACINFO_end_file:
116 m_line = DW_INVALID_OFFSET;
120 // Vendor specific entries always have a ULEB128 and a string
121 m_line = mac_info_data.GetULEB128(offset_ptr);
122 m_op2.cstr = mac_info_data.GetCStr(offset_ptr);