summaryrefslogtreecommitdiff
path: root/src/gui/status.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui/status.c')
-rw-r--r--src/gui/status.c102
1 files changed, 102 insertions, 0 deletions
diff --git a/src/gui/status.c b/src/gui/status.c
index c29a69e..2633ba6 100644
--- a/src/gui/status.c
+++ b/src/gui/status.c
@@ -25,6 +25,7 @@
#include "status.h"
+#include <ctype.h>
#include <string.h>
@@ -76,6 +77,8 @@ static void update_status_info_for_view(GStatusInfo *, GtkViewPanel *);
/* Imprime la position du parcours courant dans le statut. */
static void track_caret_address_on_buffer_views(GtkBufferView *, vmpa_t, GStatusInfo *);
+/* Concentre l'attention de l'ensemble sur une adresse donnée. */
+static void focus_address_in_status_info(GStatusInfo *, GLoadedBinary *, const vmpa2t *);
@@ -108,6 +111,7 @@ static void g_status_info_class_init(GStatusInfoClass *klass)
editem = G_EDITOR_ITEM_CLASS(klass);
editem->update_view = (update_item_view_fc)update_status_info_for_view;
+ editem->focus_addr = (focus_addr_fc)focus_address_in_status_info;
}
@@ -318,3 +322,101 @@ static void track_caret_address_on_buffer_views(GtkBufferView *view, vmpa_t addr
free(msg);
}
+
+
+/******************************************************************************
+* *
+* Paramètres : info = composant réactif à mettre à jour. *
+* binary = binaire contenant l'adresse à représenter. *
+* addr = adresse mémoire à mettre en avant. *
+* *
+* Description : Concentre l'attention de l'ensemble sur une adresse donnée. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static void focus_address_in_status_info(GStatusInfo *info, GLoadedBinary *binary, const vmpa2t *addr)
+{
+ GExeFormat *format; /* Format associé au binaire */
+ GArchProcessor *proc; /* Architecture du binaire */
+ MemoryDataSize msize; /* Taille du bus d'adresses */
+ char *msg; /* Message à transmettre */
+ VMPA_BUFFER(tmp); /* Traduction d'adresses */
+ GBinSymbol *symbol; /* Symbole présent à l'adresse */
+ phys_t diff; /* Décallage de l'adresse */
+ const char *label; /* Description d'un symbole */
+ GBinPortion *portions; /* Portions binaires existantes*/
+ GBinPortion *portion; /* Zone mémoire d'appartenance */
+ size_t len; /* Caractère à faire basculer */
+
+ format = g_loaded_binary_get_format(binary);
+ proc = get_arch_processor_from_format(format);
+ msize = g_arch_processor_get_memory_size(proc);
+
+ msg = strdup(_("Localisation:"));
+
+ /* Adresses de base */
+
+ msg = stradd(msg, " phys:");
+ vmpa2_phys_to_string(addr, msize, tmp, NULL);
+ msg = stradd(msg, tmp);
+
+ msg = stradd(msg, " virt:");
+ vmpa2_virt_to_string(addr, msize, tmp, NULL);
+ msg = stradd(msg, tmp);
+
+ /* Symbole présent ? */
+
+ if (g_binary_format_resolve_symbol(G_BIN_FORMAT(format), addr, &symbol, &diff))
+ {
+ label = g_binary_symbol_to_string(symbol);
+
+ if (label != NULL)
+ {
+ msg = stradd(msg, _(" at "));
+ msg = stradd(msg, label);
+ msg = stradd(msg, _("+"));
+
+ snprintf(tmp, VMPA_MAX_SIZE, "0x%x", diff);
+ msg = stradd(msg, tmp);
+
+ }
+
+ g_object_unref(G_OBJECT(symbol));
+
+ }
+
+ /* Zone d'appartenance */
+
+ portions = g_exe_format_get_portions(format);
+
+ portion = g_binary_portion_find_at_addr(portions, addr, (GdkRectangle []) { });
+
+ label = g_binary_portion_get_desc(portion);
+
+ msg = stradd(msg, _(" ("));
+
+ /**
+ * Pas très propre : on bascule de majuscule en minuscule ici...
+ * FIXME ?
+ */
+
+ len = strlen(msg);
+ msg = stradd(msg, label);
+ msg[len] = tolower(msg[len]);
+
+ msg = stradd(msg, _(")"));
+
+ /* Impression */
+
+ if (info->msg_id > 0)
+ gtk_extended_status_bar_remove(GTK_EXT_STATUS_BAR(G_EDITOR_ITEM(info)->widget), info->msg_id);
+
+ info->msg_id = gtk_extended_status_bar_push(GTK_EXT_STATUS_BAR(G_EDITOR_ITEM(info)->widget), msg, FALSE);
+
+ free(msg);
+
+}