summaryrefslogtreecommitdiff
path: root/src/gtkext
diff options
context:
space:
mode:
Diffstat (limited to 'src/gtkext')
-rw-r--r--src/gtkext/gtkgraphview.c97
1 files changed, 26 insertions, 71 deletions
diff --git a/src/gtkext/gtkgraphview.c b/src/gtkext/gtkgraphview.c
index 543f2d7..67fb577 100644
--- a/src/gtkext/gtkgraphview.c
+++ b/src/gtkext/gtkgraphview.c
@@ -28,6 +28,7 @@
#include "gtkbufferview.h"
#include "gtkviewpanel-int.h"
#include "graph/layout.h"
+#include "../analysis/blocks/flow.h"
#include "../gui/editem.h"
@@ -92,8 +93,10 @@ static void gtk_graph_view_cache_glance(GtkGraphView *, cairo_t *);
/* Supprime tout contenu de l'afficheur de code en graphique. */
static void gtk_graph_view_reset(GtkGraphView *);
-/* Liste d'éléments du graphique à placer. */
-static GtkViewPanel **gtk_graph_view_load_nodes(GtkGraphView *, GLoadedBinary *, vmpa_t, vmpa_t);
+/* Définit la liste complète des éléments du futur graphique. *
+* *
+* Retour : Liste d'éléments du graphique à placer. */
+static GtkViewPanel **gtk_graph_view_load_nodes(GtkGraphView *, GLoadedBinary *, const GBinRoutine *);
@@ -381,7 +384,7 @@ static void gtk_graph_view_define_main_address(GtkGraphView *view, vmpa_t addr)
view->end = end;
view->children = gtk_graph_view_load_nodes(view, GTK_VIEW_PANEL(view)->binary,
- start, end);
+ routines[i]);
view->allocs = (GtkAllocation *)calloc(view->children_count,
sizeof(GtkAllocation));
@@ -650,10 +653,8 @@ static void gtk_graph_view_reset(GtkGraphView *view)
/******************************************************************************
* *
-* Paramètres : view = composant d'affichage GTK à mettre à jour. *
-* binary = contenu binaire à l'origine des lignes. *
-* start = première adresse à traiter. *
-* end = première adresse hors cadre de l'opération. *
+* Paramètres : view = composant d'affichage GTK à mettre à jour. *
+* routine = routine à présenter via ledit composant. *
* *
* Description : Définit la liste complète des éléments du futur graphique. *
* *
@@ -663,94 +664,48 @@ static void gtk_graph_view_reset(GtkGraphView *view)
* *
******************************************************************************/
-static GtkViewPanel **gtk_graph_view_load_nodes(GtkGraphView *view, GLoadedBinary *binary, vmpa_t start, vmpa_t end)
+static GtkViewPanel **gtk_graph_view_load_nodes(GtkGraphView *view, GLoadedBinary *binary, const GBinRoutine *routine)
{
GtkViewPanel **result; /* Liste à retourner */
- size_t *count; /* Nombre d'éléments créés. */
- GArchInstruction *list; /* Liste des instructions */
GCodeBuffer *buffer; /* Tampon brut à découper */
bool *addr; /* Affichage des adresses ? */
bool *code; /* Affichage du binaire ? */
+ size_t *count; /* Nombre d'éléments créés. */
+ GInstrBlock *main_block; /* Premier bloc rattaché */
+ GInstrBlock **blocks; /* Liste des blocs basiques */
+ size_t i; /* Boucle de parcours */
vmpa_t first; /* Début d'un groupe de lignes */
- GArchInstruction *iter; /* Boucle de parcours */
vmpa_t last; /* Fin d'un groupe de lignes */
GBufferView *subview; /* Partie affichée du tampon */
- result = NULL;
-
- count = &view->children_count;
- *count = 0;
-
- list = g_loaded_binary_get_instructions(binary);
buffer = g_loaded_binary_get_disassembled_buffer(binary);
addr = GTK_VIEW_PANEL(view)->display_addr;
code = GTK_VIEW_PANEL(view)->display_code;
- first = start;
- last = first;
-
- for (iter = g_arch_instruction_find_by_address(list, start, true);
- iter != NULL;
- iter = g_arch_instruction_get_next_iter(list, iter, end))
- {
- if (first != VMPA_MAX && g_arch_instruction_has_sources(iter))
- {
- result = (GtkViewPanel **)realloc(result, ++(*count) * sizeof(GtkViewPanel *));
-
- result[*count - 1] = GTK_VIEW_PANEL(gtk_block_view_new());
- gtk_widget_show(GTK_WIDGET(result[*count - 1]));
- gtk_view_panel_attach_binary(result[*count - 1], binary, addr, code);
-
- gtk_view_panel_show_border(result[*count - 1], true);
-
- subview = g_buffer_view_new(buffer);
- g_buffer_view_restrict(subview, first, last);
- gtk_buffer_view_attach_buffer(GTK_BUFFER_VIEW(result[*count - 1]),
- subview, addr, code);
-
- first = VMPA_MAX;
-
- }
-
- g_arch_instruction_get_location(iter, NULL, NULL, &last);
- if (first == VMPA_MAX) first = last;
-
- if (g_arch_instruction_has_destinations(iter) || g_arch_instruction_is_return(iter))
- {
- result = (GtkViewPanel **)realloc(result, ++(*count) * sizeof(GtkViewPanel *));
-
- result[*count - 1] = GTK_VIEW_PANEL(gtk_block_view_new());
- gtk_widget_show(GTK_WIDGET(result[*count - 1]));
- gtk_view_panel_attach_binary(result[*count - 1], binary, addr, code);
-
- gtk_view_panel_show_border(result[*count - 1], true);
-
- subview = g_buffer_view_new(buffer);
- g_buffer_view_restrict(subview, first, last);
- gtk_buffer_view_attach_buffer(GTK_BUFFER_VIEW(result[*count - 1]),
- subview, addr, code);
+ count = &view->children_count;
- first = VMPA_MAX;
+ main_block = g_binary_routine_get_basic_blocks(routine);
- }
+ blocks = NULL;
+ *count = 0;
+ g_instr_block_list_all_blocks(main_block, &blocks, count);
- }
+ result = (GtkViewPanel **)calloc(*count, sizeof(GtkViewPanel *));
- if (first != VMPA_MAX)
+ for (i = 0; i < *count; i++)
{
- result = (GtkViewPanel **)realloc(result, ++(*count) * sizeof(GtkViewPanel *));
+ result[i] = GTK_VIEW_PANEL(gtk_block_view_new());
+ gtk_widget_show(GTK_WIDGET(result[i]));
+ gtk_view_panel_attach_binary(result[i], binary, addr, code);
- result[*count - 1] = GTK_VIEW_PANEL(gtk_block_view_new());
- gtk_widget_show(GTK_WIDGET(result[*count - 1]));
- gtk_view_panel_attach_binary(result[*count - 1], binary, addr, code);
+ gtk_view_panel_show_border(result[i], true);
- gtk_view_panel_show_border(result[*count - 1], true);
+ g_flow_block_get_boundary_addresses(G_FLOW_BLOCK(blocks[i]), &first, &last);
subview = g_buffer_view_new(buffer);
g_buffer_view_restrict(subview, first, last);
- gtk_buffer_view_attach_buffer(GTK_BUFFER_VIEW(result[*count - 1]),
- subview, addr, code);
+ gtk_buffer_view_attach_buffer(GTK_BUFFER_VIEW(result[i]), subview, addr, code);
}