diff options
author | Cyrille Bagard <nocbos@gmail.com> | 2012-07-01 11:52:52 (GMT) |
---|---|---|
committer | Cyrille Bagard <nocbos@gmail.com> | 2012-07-01 11:52:52 (GMT) |
commit | 5dcd05f19ac62f6ff922176cd0ae6f8839910f2e (patch) | |
tree | 6fbf5798a57ab6874b68b6ea523619481013c814 /src/gtkext | |
parent | 51dff92af8ca82ac1cce3f74be70c3705ca88683 (diff) |
Built the graph view when defining a target address.
git-svn-id: svn://svn.gna.org/svn/chrysalide/trunk@247 abbe820e-26c8-41b2-8c08-b7b2b41f8b0a
Diffstat (limited to 'src/gtkext')
-rw-r--r-- | src/gtkext/gtkgraphview.c | 78 | ||||
-rw-r--r-- | src/gtkext/gtkviewpanel-int.h | 4 | ||||
-rw-r--r-- | src/gtkext/gtkviewpanel.c | 6 |
3 files changed, 80 insertions, 8 deletions
diff --git a/src/gtkext/gtkgraphview.c b/src/gtkext/gtkgraphview.c index 263ab7d..8366c1f 100644 --- a/src/gtkext/gtkgraphview.c +++ b/src/gtkext/gtkgraphview.c @@ -27,6 +27,7 @@ #include "gtkblockview.h" #include "gtkbufferview.h" #include "gtkviewpanel-int.h" +#include "../graph/layout.h" @@ -41,7 +42,7 @@ struct _GtkGraphView vmpa_t start; /* Début de la portion vue */ vmpa_t end; /* Fin de la portion affichée */ - GtkBlockView **childs; /* Liste des sous-blocs */ + GtkViewPanel **childs; /* Liste des sous-blocs */ size_t childs_count; /* Taille de cette liste */ GtkLinkRenderer **links; /* Liste des liens graphiques */ @@ -73,6 +74,9 @@ static void gtk_graph_view_size_allocate(GtkWidget *, GtkAllocation *); /* Met à jour l'affichage de la vue sous forme graphique. */ static gboolean gtk_graph_view_expose(GtkWidget *, GdkEventExpose *, GtkGraphView *); +/* Réagit à la sélection externe d'une adresse. */ +static void gtk_graph_view_define_main_address(GtkGraphView *, vmpa_t); + /* Indique la position d'affichage d'une adresse donnée. */ static bool gtk_graph_view_get_address_coordinates(const GtkGraphView *, vmpa_t, gint *, gint *); @@ -82,6 +86,9 @@ static void gtk_graph_view_scroll(GtkGraphView *); /* 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 *, GOpenidaBinary *, vmpa_t, vmpa_t); + /* Détermine le type du composant d'affichage en graphique. */ @@ -132,6 +139,7 @@ static void gtk_graph_view_init(GtkGraphView *view) viewpanel = GTK_VIEW_PANEL(view); + viewpanel->define = (define_address_fc)gtk_graph_view_define_main_address; viewpanel->get_coordinates = (get_addr_coordinates_fc)gtk_graph_view_get_address_coordinates; viewpanel->scroll = (scroll_fc)gtk_graph_view_scroll; @@ -287,6 +295,61 @@ static gboolean gtk_graph_view_expose(GtkWidget *widget, GdkEventExpose *event, /****************************************************************************** * * +* Paramètres : view = composant GTK à mettre à jour. * +* addr = adresse sélectionnée de manière externe. * +* * +* Description : Réagit à la sélection externe d'une adresse. * +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ + +static void gtk_graph_view_define_main_address(GtkGraphView *view, vmpa_t addr) +{ + GExeFormat *format; /* Type de fichier chargé */ + GBinRoutine **routines; /* Liste des routines trouvées */ + size_t routines_count; /* Nombre de ces routines */ + size_t i; /* Boucle de parcours */ + vmpa_t start; /* Début d'une routine */ + vmpa_t end; /* Fin d'une routine */ + + if (!(view->start <= addr && addr < view->end)) + { + gtk_graph_view_reset(view); + + format = g_openida_binary_get_format(GTK_VIEW_PANEL(view)->binary); + routines = g_binary_format_get_routines(G_BIN_FORMAT(format), &routines_count); + + for (i = 0; i < routines_count; i++) + { + start = g_binary_routine_get_address(routines[i]); + end = start + g_binary_routine_get_size(routines[i]); + + if (start <= addr && addr < end) + { + view->start = start; + view->end = end; + + view->childs = gtk_graph_view_load_nodes(view, GTK_VIEW_PANEL(view)->binary, + start, end); + + build_graph_view(view, view->childs, view->childs_count); + + break; + + } + + } + + } + +} + + +/****************************************************************************** +* * * Paramètres : view = composant GTK à consulter. * * addr = adresse à présenter à l'écran. * * x = position horizontale au sein du composant. [OUT] * @@ -495,6 +558,7 @@ static GtkViewPanel **gtk_graph_view_load_nodes(GtkGraphView *view, GOpenidaBina code = g_openida_binary_display_code_in_text(binary); first = start; + last = first; for (iter = g_arch_instruction_find_by_address(list, start, true); iter != NULL; @@ -505,11 +569,13 @@ static GtkViewPanel **gtk_graph_view_load_nodes(GtkGraphView *view, GOpenidaBina result = (GtkViewPanel **)realloc(result, ++(*count) * sizeof(GtkViewPanel *)); result[*count - 1] = GTK_VIEW_PANEL(gtk_block_view_new()); + gtk_widget_show(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, size_t first, size_t last); + g_buffer_view_restrict(subview, first, last); gtk_buffer_view_attach_buffer(GTK_BUFFER_VIEW(result[*count - 1]), subview, addr, code); @@ -525,11 +591,13 @@ static GtkViewPanel **gtk_graph_view_load_nodes(GtkGraphView *view, GOpenidaBina result = (GtkViewPanel **)realloc(result, ++(*count) * sizeof(GtkViewPanel *)); result[*count - 1] = GTK_VIEW_PANEL(gtk_block_view_new()); + gtk_widget_show(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, size_t first, size_t last); + g_buffer_view_restrict(subview, first, last); gtk_buffer_view_attach_buffer(GTK_BUFFER_VIEW(result[*count - 1]), subview, addr, code); @@ -544,11 +612,13 @@ static GtkViewPanel **gtk_graph_view_load_nodes(GtkGraphView *view, GOpenidaBina result = (GtkViewPanel **)realloc(result, ++(*count) * sizeof(GtkViewPanel *)); result[*count - 1] = GTK_VIEW_PANEL(gtk_block_view_new()); + gtk_widget_show(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, size_t first, size_t last); + g_buffer_view_restrict(subview, first, last); gtk_buffer_view_attach_buffer(GTK_BUFFER_VIEW(result[*count - 1]), subview, addr, code); diff --git a/src/gtkext/gtkviewpanel-int.h b/src/gtkext/gtkviewpanel-int.h index 446d182..a4edd06 100644 --- a/src/gtkext/gtkviewpanel-int.h +++ b/src/gtkext/gtkviewpanel-int.h @@ -36,6 +36,9 @@ /* Prend acte de l'association d'un binaire chargé. */ typedef void (* attach_binary_fc) (GtkViewPanel *, GOpenidaBinary *, bool *, bool *); +/* Réagit à la sélection externe d'une adresse. */ +typedef void (* define_address_fc) (GtkViewPanel *, vmpa_t); + /* Indique la position d'affichage d'une adresse donnée. */ typedef bool (* get_addr_coordinates_fc) (const GtkViewPanel *, vmpa_t, gint *, gint *); @@ -57,6 +60,7 @@ struct _GtkViewPanel GOpenidaBinary *binary; /* Binaire à visualiser */ attach_binary_fc attach; /* Association avec un binaire */ + define_address_fc define; /* Centrage sur une partie */ get_addr_coordinates_fc get_coordinates;/* Conversion adresse <-> pos. */ scroll_fc scroll; /* Défilement du contenu */ diff --git a/src/gtkext/gtkviewpanel.c b/src/gtkext/gtkviewpanel.c index 2dac981..326e4d8 100644 --- a/src/gtkext/gtkviewpanel.c +++ b/src/gtkext/gtkviewpanel.c @@ -517,10 +517,8 @@ void gtk_view_panel_scroll_to_address(const GtkViewPanel *panel, vmpa_t addr) gint y; /* Ordonnée à garantir */ GtkAdjustment *adj; /* Défilement à mettre à jour */ - /* TODO - if (panel->define_address != NULL) - panel->define_address(panel, addr); - */ + if (panel->define != NULL) + panel->define(panel, addr); if (panel->get_coordinates(panel, addr, &x, &y)) { |