summaryrefslogtreecommitdiff
path: root/src/analysis/disass/output.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/analysis/disass/output.c')
-rw-r--r--src/analysis/disass/output.c55
1 files changed, 36 insertions, 19 deletions
diff --git a/src/analysis/disass/output.c b/src/analysis/disass/output.c
index 5a74d92..421cfb6 100644
--- a/src/analysis/disass/output.c
+++ b/src/analysis/disass/output.c
@@ -24,6 +24,9 @@
#include "output.h"
+#include <assert.h>
+
+
#include <i18n.h>
@@ -67,6 +70,8 @@ void print_disassembled_instructions(GBufferCache *cache, GCodingLanguage *lang,
bool expect_outro; /* Fin de zone de code définie */
+ size_t comment_count; /* Quantité de commentaires */
+ size_t comment_index; /* Indice du commantaire actif */
GDbComment *comment; /* Commentaire à ajouter */
const vmpa2t *caddr; /* Localisation du commentaire */
@@ -137,11 +142,22 @@ void print_disassembled_instructions(GBufferCache *cache, GCodingLanguage *lang,
expect_outro = false;
- comment = g_preload_info_pop_comment(info);
+ g_preload_info_lock_comments(info);
- if (comment != NULL)
+ comment_count = _g_preload_info_count_comments(info);
+ comment_index = 0;
+
+ if (comment_index < comment_count)
+ {
+ comment = _g_preload_info_grab_comment(info, comment_index);
caddr = g_db_comment_get_address(comment);
+ comment_index++;
+
+ }
+
+ else
+ comment = NULL;
/*
if (comment != NULL)
@@ -306,32 +322,29 @@ void print_disassembled_instructions(GBufferCache *cache, GCodingLanguage *lang,
{
compared = cmp_vmpa(iaddr, caddr);
- if (compared == 0)
+ if (compared >= 0)
{
- if (g_loaded_binary_add_to_collection(binary, G_DB_ITEM(comment)))
+ if (compared == 0)
g_db_item_apply(G_DB_ITEM(comment), binary);
else
- g_object_unref(G_OBJECT(comment));
-
- }
-
- else if (compared > 0)
- {
- log_variadic_message(LMT_BAD_BINARY,
- _("Unable to find a proper location for comment '%s' @ 0x%08x"),
- g_db_comment_get_text(comment), get_phy_addr(caddr));
+ log_variadic_message(LMT_BAD_BINARY,
+ _("Unable to find a proper location for comment '%s' @ 0x%08x"),
+ g_db_comment_get_text(comment), get_phy_addr(caddr));
g_object_unref(G_OBJECT(comment));
- }
+ if (comment_index < comment_count)
+ {
+ comment = _g_preload_info_grab_comment(info, comment_index);
+ caddr = g_db_comment_get_address(comment);
- if (compared >= 0)
- {
- comment = g_preload_info_pop_comment(info);
+ comment_index++;
- if (comment != NULL)
- caddr = g_db_comment_get_address(comment);
+ }
+
+ else
+ comment = NULL;
}
@@ -343,6 +356,10 @@ void print_disassembled_instructions(GBufferCache *cache, GCodingLanguage *lang,
}
+ assert(comment_index == comment_count);
+
+ g_preload_info_unlock_comments(info);
+
gtk_status_stack_remove_activity(status, id);
g_arch_processor_unlock(proc);