summaryrefslogtreecommitdiff
path: root/Userland
diff options
context:
space:
mode:
authorItamar <itamar8910@gmail.com>2021-06-18 15:59:24 +0300
committerAndreas Kling <kling@serenityos.org>2021-06-19 14:51:18 +0200
commit98a774a68d7cf7572e2033a4b56bf2f3231541a9 (patch)
tree4fb8c665782adaa56c51e955b5071f92d3964250 /Userland
parent0d89f70b66dc4758acb00e6df6ed83527292495c (diff)
downloadserenity-98a774a68d7cf7572e2033a4b56bf2f3231541a9.zip
LibDebug: Add LineProgram::get_directory_and_file(size_t)
This function returns the directory path & filename for a given file index.
Diffstat (limited to 'Userland')
-rw-r--r--Userland/Libraries/LibDebug/Dwarf/LineProgram.cpp9
-rw-r--r--Userland/Libraries/LibDebug/Dwarf/LineProgram.h6
2 files changed, 15 insertions, 0 deletions
diff --git a/Userland/Libraries/LibDebug/Dwarf/LineProgram.cpp b/Userland/Libraries/LibDebug/Dwarf/LineProgram.cpp
index b0d7d24b17..e1d6da2406 100644
--- a/Userland/Libraries/LibDebug/Dwarf/LineProgram.cpp
+++ b/Userland/Libraries/LibDebug/Dwarf/LineProgram.cpp
@@ -290,4 +290,13 @@ void LineProgram::run_program()
}
}
+LineProgram::DirectoryAndFile LineProgram::get_directory_and_file(size_t file_index) const
+{
+ VERIFY(file_index < m_source_files.size());
+ auto file_entry = m_source_files[file_index];
+ VERIFY(file_entry.directory_index < m_source_directories.size());
+ auto directory_entry = m_source_directories[file_entry.directory_index];
+ return { directory_entry, file_entry.name };
+}
+
}
diff --git a/Userland/Libraries/LibDebug/Dwarf/LineProgram.h b/Userland/Libraries/LibDebug/Dwarf/LineProgram.h
index b69234cd54..abac23a313 100644
--- a/Userland/Libraries/LibDebug/Dwarf/LineProgram.h
+++ b/Userland/Libraries/LibDebug/Dwarf/LineProgram.h
@@ -116,6 +116,12 @@ public:
const Vector<LineInfo>& lines() const { return m_lines; }
+ struct DirectoryAndFile {
+ FlyString directory;
+ FlyString filename;
+ };
+ DirectoryAndFile get_directory_and_file(size_t file_index) const;
+
private:
void parse_unit_header();
void parse_source_directories();