summaryrefslogtreecommitdiff
path: root/src/analysis/db/items
diff options
context:
space:
mode:
Diffstat (limited to 'src/analysis/db/items')
-rw-r--r--src/analysis/db/items/bookmark.c71
1 files changed, 52 insertions, 19 deletions
diff --git a/src/analysis/db/items/bookmark.c b/src/analysis/db/items/bookmark.c
index 266b04c..819528d 100644
--- a/src/analysis/db/items/bookmark.c
+++ b/src/analysis/db/items/bookmark.c
@@ -34,6 +34,7 @@
#include "../collection-int.h"
#include "../item-int.h"
+#include "../../../glibext/gbinarycursor.h"
@@ -206,6 +207,9 @@ static void g_db_bookmark_class_init(GDbBookmarkClass *klass)
static void g_db_bookmark_init(GDbBookmark *bookmark)
{
+ init_vmpa(&bookmark->addr, VMPA_NO_PHYSICAL, VMPA_NO_VIRTUAL);
+
+ init_dynamic_rle_string(&bookmark->comment, NULL);
}
@@ -440,37 +444,60 @@ static void g_db_bookmark_build_label(GDbBookmark *bookmark)
static bool g_db_bookmark_run(GDbBookmark *bookmark, GLoadedBinary *binary, bool *prev, bool set)
{
- return false;
-#if 0
bool result; /* Bilan à faire remonter */
- GCodeBuffer *buffer; /* Tampon de lignes à traiter */
+ GBufferCache *cache; /* Tampon d'impression colorée */
+ GLineCursor *cursor; /* Emplacement dans un tampon */
+ size_t index; /* Indice de ligne à traiter */
GBufferLine *line; /* Ligne de tampon à marquer */
- result = true;
+ result = false;
+
+ cache = g_loaded_binary_get_disassembled_cache(binary);
+ if (cache == NULL) goto exit;
+
+ g_buffer_cache_lock(cache);
+
+ /* Recherche de la ligne concernée */
+
+ cursor = g_binary_cursor_new();
+ g_binary_cursor_update(G_BINARY_CURSOR(cursor), &bookmark->addr);
- buffer = g_loaded_binary_get_disassembled_buffer(binary);
+ index = g_buffer_cache_find_index_by_cursor(cache, cursor, true);
- line = g_code_buffer_find_line_by_addr(buffer, &bookmark->addr, BLF_HAS_CODE, NULL);
- if (line == NULL)
+ g_object_unref(G_OBJECT(cursor));
+
+ line = g_buffer_cache_find_line_by_index(cache, index);
+
+ /* Application du changement */
+
+ result = (line != NULL);
+
+ if (result)
{
- result = false;
- goto exit;
- }
+ *prev = g_buffer_line_get_flags(line) & BLF_BOOKMARK;
- *prev = g_buffer_line_get_flags(line) & BLF_BOOKMARK;
+ if (set)
+ g_buffer_line_add_flag(line, BLF_BOOKMARK);
- if (set)
- g_buffer_line_add_flag(line, BLF_BOOKMARK);
+ else
+ g_buffer_line_remove_flag(line, BLF_BOOKMARK);
- else
- g_buffer_line_remove_flag(line, BLF_BOOKMARK);
+ g_object_unref(G_OBJECT(line));
+
+ g_buffer_cache_throw_update_at_index(cache, index);
+
+ }
- g_object_unref(G_OBJECT(line));
+ /* Sortie */
+
+ g_buffer_cache_unlock(cache);
+
+ g_object_unref(G_OBJECT(cache));
exit:
return result;
-#endif
+
}
@@ -490,8 +517,11 @@ static bool g_db_bookmark_run(GDbBookmark *bookmark, GLoadedBinary *binary, bool
static bool g_db_bookmark_apply(GDbBookmark *bookmark, GLoadedBinary *binary)
{
bool result; /* Bilan à faire remonter */
+ DbItemFlags flags; /* Propriétés de l'élément */
- result = g_db_bookmark_run(bookmark, binary, &bookmark->prev_state, true);
+ flags = g_db_item_get_flags(G_DB_ITEM(bookmark));
+
+ result = g_db_bookmark_run(bookmark, binary, &bookmark->prev_state, (flags & DIF_ERASER) == 0);
return result;
@@ -514,9 +544,12 @@ static bool g_db_bookmark_apply(GDbBookmark *bookmark, GLoadedBinary *binary)
static bool g_db_bookmark_cancel(GDbBookmark *bookmark, GLoadedBinary *binary)
{
bool result; /* Bilan à faire remonter */
+ DbItemFlags flags; /* Propriétés de l'élément */
+
+ flags = g_db_item_get_flags(G_DB_ITEM(bookmark));
if (!bookmark->prev_state)
- result = g_db_bookmark_run(bookmark, binary, (bool []) { 0 }, false);
+ result = g_db_bookmark_run(bookmark, binary, (bool []) { 0 }, (flags & DIF_ERASER) != 0);
else
result = true;