summaryrefslogtreecommitdiff
path: root/src/binary.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/binary.c')
-rw-r--r--src/binary.c23
1 files changed, 19 insertions, 4 deletions
diff --git a/src/binary.c b/src/binary.c
index 862a4d0..b7ee15a 100644
--- a/src/binary.c
+++ b/src/binary.c
@@ -25,6 +25,7 @@
#include <fcntl.h>
+#include <stdlib.h>
#include <unistd.h>
#include <sys/mman.h>
#include <sys/stat.h>
@@ -165,14 +166,23 @@ void fill_snippet(GtkSnippet *snippet)
- comments_count = get_dwarf_comments(dformat, &comments, &offsets);
+ //comments_count = get_dwarf_comments(dformat, &comments, &offsets);
+
+ comments = NULL;
+ offsets = NULL;
+ comments_count = 0;
+
+ get_elf_symbol_comments(format, &comments, &offsets, &comments_count);
comments_list = (code_line_info **)calloc(comments_count, sizeof(code_line_info *));
for (i = 0; i < comments_count; i++)
comments_list[i] = create_code_line_info(offsets[i], NULL, strdup(comments[i]));
- i = 0;
+
+ qsort(comments_list, comments_count, sizeof(code_line_info *), compare_code_line_info);
+
+
find_exe_section(format, ".text", &pos, &len, &base);
@@ -187,6 +197,9 @@ void fill_snippet(GtkSnippet *snippet)
offset = base;
+ for (i = 0; i < comments_count; i++)
+ if (comments_list[i]->offset >= base) break;
+
gtk_snippet_set_processor(snippet, proc);
@@ -206,7 +219,7 @@ void fill_snippet(GtkSnippet *snippet)
offset = base + pos;
/* Si on a un commentaire pour cette ligne... */
- if (comments_count > 0 && offsets[i] == offset)
+ if (i < comments_count && comments_list[i]->offset == offset)
{
list = (code_line_info **)realloc(list, ++list_len * sizeof(code_line_info *));
list[list_len - 1] = comments_list[i++];
@@ -232,8 +245,10 @@ void fill_snippet(GtkSnippet *snippet)
/* TODO: free() */
}
- ret = munmap(bin_data, length);
+ /****
+ ret = munmap(bin_data, length);
+ ****/
/*
gtk_snippet_build_content(snippet);