diff options
author | Cyrille Bagard <nocbos@gmail.com> | 2020-09-21 22:23:47 (GMT) |
---|---|---|
committer | Cyrille Bagard <nocbos@gmail.com> | 2020-09-21 22:23:47 (GMT) |
commit | 76fb13178cf6be94b8e01675b37f7cb1b92f7709 (patch) | |
tree | a6e6bbc6dde169add608097ceb5658fcb904bd08 /src/analysis | |
parent | dfe76faf21e254c02c86a1b0b1f8ca8fc07fe027 (diff) |
Defined lock mechanism for buffer caches.
Diffstat (limited to 'src/analysis')
-rw-r--r-- | src/analysis/binary.c | 4 | ||||
-rw-r--r-- | src/analysis/db/items/bookmark.c | 4 | ||||
-rw-r--r-- | src/analysis/db/items/comment.c | 11 | ||||
-rw-r--r-- | src/analysis/db/items/switcher.c | 4 | ||||
-rw-r--r-- | src/analysis/disass/block.c | 9 | ||||
-rw-r--r-- | src/analysis/disass/disassembler.c | 4 | ||||
-rw-r--r-- | src/analysis/disass/output.c | 2 | ||||
-rw-r--r-- | src/analysis/routine.c | 4 |
8 files changed, 34 insertions, 8 deletions
diff --git a/src/analysis/binary.c b/src/analysis/binary.c index 2eafda9..95d2133 100644 --- a/src/analysis/binary.c +++ b/src/analysis/binary.c @@ -1733,6 +1733,8 @@ static void on_binary_processor_changed(GArchProcessor *proc, GArchInstruction * if (binary->disass_cache != NULL) { + g_buffer_cache_wlock(binary->disass_cache); + range = g_arch_instruction_get_range(instr); if (added) @@ -1799,6 +1801,8 @@ static void on_binary_processor_changed(GArchProcessor *proc, GArchInstruction * } + g_buffer_cache_wunlock(binary->disass_cache); + } } diff --git a/src/analysis/db/items/bookmark.c b/src/analysis/db/items/bookmark.c index a3da5b3..0a64c89 100644 --- a/src/analysis/db/items/bookmark.c +++ b/src/analysis/db/items/bookmark.c @@ -537,7 +537,7 @@ static bool g_db_bookmark_run(GDbBookmark *bookmark, GLoadedBinary *binary, bool cache = g_loaded_binary_get_disassembly_cache(binary); if (cache == NULL) goto exit; - g_buffer_cache_lock(cache); + g_buffer_cache_wlock(cache); /* Recherche de la ligne concernée */ @@ -565,7 +565,7 @@ static bool g_db_bookmark_run(GDbBookmark *bookmark, GLoadedBinary *binary, bool /* Sortie */ - g_buffer_cache_unlock(cache); + g_buffer_cache_wunlock(cache); g_object_unref(G_OBJECT(cache)); diff --git a/src/analysis/db/items/comment.c b/src/analysis/db/items/comment.c index 136b62b..bdff3a6 100644 --- a/src/analysis/db/items/comment.c +++ b/src/analysis/db/items/comment.c @@ -731,11 +731,12 @@ static bool g_db_comment_run(GDbComment *comment, GLoadedBinary *binary, bool ap const mrange_t *range; /* Emplacement d'instruction */ size_t linked; /* Indice lié à traiter */ - result = true; + result = false; cache = g_loaded_binary_get_disassembly_cache(binary); + if (cache == NULL) goto exit; - g_buffer_cache_lock(cache); + g_buffer_cache_wlock(cache) switch (comment->type) { @@ -813,10 +814,14 @@ static bool g_db_comment_run(GDbComment *comment, GLoadedBinary *binary, bool ap } - g_buffer_cache_unlock(cache); + g_buffer_cache_wunlock(cache); g_object_unref(G_OBJECT(cache)); + result = true; + + exit: + return result; } diff --git a/src/analysis/db/items/switcher.c b/src/analysis/db/items/switcher.c index 3ae9358..090b8ce 100644 --- a/src/analysis/db/items/switcher.c +++ b/src/analysis/db/items/switcher.c @@ -611,7 +611,7 @@ static bool g_db_switcher_run(GDbSwitcher *switcher, GLoadedBinary *binary, ImmO cursor = g_binary_cursor_new(); g_binary_cursor_update(G_BINARY_CURSOR(cursor), &switcher->addr); - g_buffer_cache_lock(cache); + g_buffer_cache_wlock(cache); index = g_buffer_cache_find_index_by_cursor(cache, cursor, true); @@ -630,7 +630,7 @@ static bool g_db_switcher_run(GDbSwitcher *switcher, GLoadedBinary *binary, ImmO exit_gui: - g_buffer_cache_unlock(cache); + g_buffer_cache_wunlock(cache); g_object_unref(G_OBJECT(cache)); diff --git a/src/analysis/disass/block.c b/src/analysis/disass/block.c index a141d68..ea1441f 100644 --- a/src/analysis/disass/block.c +++ b/src/analysis/disass/block.c @@ -574,12 +574,17 @@ static char *g_basic_block_build_tooltip(const GBasicBlock *block) if (label != NULL) { cache = g_buffer_cache_new(NULL, DLC_COUNT, DLC_ASSEMBLY_LABEL); + + g_buffer_cache_wlock(cache); + g_buffer_cache_append(cache, G_LINE_GENERATOR(symbol), BLF_NONE); line = g_buffer_cache_find_line_by_index(cache, 0); name = g_buffer_line_get_text(line, DLC_ASSEMBLY_LABEL, DLC_COUNT, true); g_object_unref(G_OBJECT(line)); + g_buffer_cache_wunlock(cache); + g_object_unref(G_OBJECT(cache)); /* Suppression de la fin de l'étiquette... */ @@ -640,6 +645,8 @@ static char *g_basic_block_build_tooltip(const GBasicBlock *block) proc = g_loaded_binary_get_processor(block->binary); cache = g_loaded_binary_get_disassembly_cache(block->binary); + g_buffer_cache_rlock(cache); + iter = g_arch_processor_get_iter_from_address(proc, get_mrange_addr(&range)); if (iter == NULL) goto no_iter; @@ -789,6 +796,8 @@ static char *g_basic_block_build_tooltip(const GBasicBlock *block) no_iter: + g_buffer_cache_runlock(cache); + g_object_unref(G_OBJECT(cache)); g_object_unref(G_OBJECT(proc)); diff --git a/src/analysis/disass/disassembler.c b/src/analysis/disass/disassembler.c index 0b81180..4056c59 100644 --- a/src/analysis/disass/disassembler.c +++ b/src/analysis/disass/disassembler.c @@ -413,6 +413,8 @@ void output_disassembly(GLoadedBinary *binary, GProcContext *context, GtkStatusS g_width_tracker_set_column_min_width(tracker, DLC_ASSEMBLY_LABEL, offset); g_object_unref(G_OBJECT(tracker)); + g_buffer_cache_wlock(*cache); + /** * Impression du prologue. */ @@ -468,6 +470,8 @@ void output_disassembly(GLoadedBinary *binary, GProcContext *context, GtkStatusS * Nettoyage avant sortie. */ + g_buffer_cache_wunlock(*cache); + g_object_unref(G_OBJECT(lang)); g_object_unref(G_OBJECT(content)); g_object_unref(G_OBJECT(format)); diff --git a/src/analysis/disass/output.c b/src/analysis/disass/output.c index f2e423c..ffff64a 100644 --- a/src/analysis/disass/output.c +++ b/src/analysis/disass/output.c @@ -324,7 +324,7 @@ void print_disassembled_instructions(GBufferCache *cache, GCodingLanguage *lang, if (compared >= 0) { if (compared == 0) - g_db_item_apply(G_DB_ITEM(comment), binary); + /* FIXME *** g_db_item_apply(G_DB_ITEM(comment), binary) */; else log_variadic_message(LMT_BAD_BINARY, diff --git a/src/analysis/routine.c b/src/analysis/routine.c index aca47ee..422e7de 100644 --- a/src/analysis/routine.c +++ b/src/analysis/routine.c @@ -1105,6 +1105,8 @@ char *g_binary_routine_build_tooltip(const GBinRoutine *routine, const GLoadedBi proc = g_loaded_binary_get_processor(binary); cache = g_loaded_binary_get_disassembly_cache(binary); + g_buffer_cache_rlock(cache); + /* Parcours des instructions */ srange = g_binary_symbol_get_range(G_BIN_SYMBOL(routine)); @@ -1315,6 +1317,8 @@ char *g_binary_routine_build_tooltip(const GBinRoutine *routine, const GLoadedBi gbrbt_no_iter: + g_buffer_cache_runlock(cache); + g_object_unref(G_OBJECT(cache)); g_object_unref(G_OBJECT(proc)); |