File indexing completed on 2024-05-12 05:43:27

0001 /*
0002     Copyright (C) 2015 Volker Krause <vkrause@kde.org>
0003 
0004     This program is free software; you can redistribute it and/or modify it
0005     under the terms of the GNU Library General Public License as published by
0006     the Free Software Foundation; either version 2 of the License, or (at your
0007     option) any later version.
0008 
0009     This program is distributed in the hope that it will be useful, but WITHOUT
0010     ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
0011     FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
0012     License for more details.
0013 
0014     You should have received a copy of the GNU General Public License
0015     along with this program.  If not, see <https://www.gnu.org/licenses/>.
0016 */
0017 
0018 #include "dwarfline.h"
0019 
0020 #include <cassert>
0021 
0022 DwarfLine::DwarfLine(Dwarf_Line line) :
0023     m_line(line)
0024 {
0025     assert(line);
0026 }
0027 
0028 bool DwarfLine::isNull() const
0029 {
0030     return m_line == nullptr;
0031 }
0032 
0033 Dwarf_Unsigned DwarfLine::line() const
0034 {
0035     Dwarf_Unsigned n = 0;
0036     if (dwarf_lineno(m_line, &n, nullptr) == DW_DLV_OK)
0037         return n;
0038     return 0;
0039 }
0040 
0041 Dwarf_Signed DwarfLine::column() const
0042 {
0043     Dwarf_Signed n = 0;
0044     if (dwarf_lineoff(m_line, &n, nullptr) == DW_DLV_OK)
0045         return n;
0046     return 0;
0047 }
0048 
0049 Dwarf_Addr DwarfLine::address() const
0050 {
0051     Dwarf_Addr addr = 0;
0052     if (dwarf_lineaddr(m_line, &addr, nullptr) == DW_DLV_OK)
0053         return addr;
0054     return 0;
0055 }
0056 
0057 Dwarf_Line DwarfLine::handle() const
0058 {
0059     return m_line;
0060 }