aboutsummaryrefslogtreecommitdiffstats
path: root/elff/elff_api.cc
diff options
context:
space:
mode:
Diffstat (limited to 'elff/elff_api.cc')
-rw-r--r--elff/elff_api.cc84
1 files changed, 84 insertions, 0 deletions
diff --git a/elff/elff_api.cc b/elff/elff_api.cc
new file mode 100644
index 0000000..46b2ad1
--- /dev/null
+++ b/elff/elff_api.cc
@@ -0,0 +1,84 @@
+/* Copyright (C) 2007-2010 The Android Open Source Project
+**
+** This software is licensed under the terms of the GNU General Public
+** License version 2, as published by the Free Software Foundation, and
+** may be copied, distributed, and modified under those terms.
+**
+** This program is distributed in the hope that it will be useful,
+** but WITHOUT ANY WARRANTY; without even the implied warranty of
+** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+** GNU General Public License for more details.
+*/
+
+/*
+ * Contains implementation of routines that encapsulte an API for parsing
+ * an ELF file containing debugging information in DWARF format.
+ */
+
+#include "elff_api.h"
+#include "elf_file.h"
+#include "dwarf_defs.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+ELFF_HANDLE
+elff_init(const char* elf_file_path)
+{
+ ElfFile* elf_file = ElfFile::Create(elf_file_path);
+ return reinterpret_cast<ELFF_HANDLE>(elf_file);
+}
+
+void
+elff_close(ELFF_HANDLE handle)
+{
+ if (handle != NULL) {
+ delete reinterpret_cast<ElfFile*>(handle);
+ }
+}
+
+int
+elff_is_exec(ELFF_HANDLE handle)
+{
+ assert(handle != NULL);
+ if (handle == NULL) {
+ _set_errno(EINVAL);
+ return -1;
+ }
+ return reinterpret_cast<ElfFile*>(handle)->is_exec();
+}
+
+int
+elff_get_pc_address_info(ELFF_HANDLE handle,
+ uint64_t address,
+ Elf_AddressInfo* address_info)
+{
+ assert(handle != NULL && address_info != NULL);
+ if (handle == NULL || address_info == NULL) {
+ _set_errno(EINVAL);
+ return -1;
+ }
+
+ if (reinterpret_cast<ElfFile*>(handle)->get_pc_address_info(address,
+ address_info)) {
+ return 0;
+ } else {
+ return -1;
+ }
+}
+
+void
+elff_free_pc_address_info(ELFF_HANDLE handle, Elf_AddressInfo* address_info)
+{
+ assert(handle != NULL && address_info != NULL);
+ if (handle == NULL || address_info == NULL) {
+ return;
+ }
+ reinterpret_cast<ElfFile*>(handle)->free_pc_address_info(address_info);
+}
+
+#ifdef __cplusplus
+} /* end of extern "C" */
+#endif
+