diff options
author | Cyrille Bagard <nocbos@gmail.com> | 2015-04-03 13:10:42 (GMT) |
---|---|---|
committer | Cyrille Bagard <nocbos@gmail.com> | 2015-04-03 13:10:42 (GMT) |
commit | 6cfa350c21c1e54cf9c597d92a9ea3d1aab01d78 (patch) | |
tree | f961a21eb14ccdc56d24129ff87012c4647579da /src/gtkext | |
parent | 3293a5b3b13271ea1499718d310c1bd0284762a3 (diff) |
Tried to show basic blocks in the graphic view again.
git-svn-id: svn://svn.gna.org/svn/chrysalide/trunk@499 abbe820e-26c8-41b2-8c08-b7b2b41f8b0a
Diffstat (limited to 'src/gtkext')
-rw-r--r-- | src/gtkext/graph/layout.c | 15 | ||||
-rw-r--r-- | src/gtkext/graph/node.c | 16 | ||||
-rw-r--r-- | src/gtkext/graph/node.h | 4 | ||||
-rw-r--r-- | src/gtkext/graph/nodes/flow.c | 144 | ||||
-rw-r--r-- | src/gtkext/gtkbufferview.c | 35 | ||||
-rw-r--r-- | src/gtkext/gtkgraphview.c | 188 | ||||
-rw-r--r-- | src/gtkext/gtkviewpanel-int.h | 5 | ||||
-rw-r--r-- | src/gtkext/gtkviewpanel.c | 14 |
8 files changed, 309 insertions, 112 deletions
diff --git a/src/gtkext/graph/layout.c b/src/gtkext/graph/layout.c index 94f59e6..ee91aff 100644 --- a/src/gtkext/graph/layout.c +++ b/src/gtkext/graph/layout.c @@ -160,14 +160,14 @@ bool build_graph_view(GtkGraphView *view, GInstrBlock *blocks, GtkViewPanel **vi static bool rank_graph_nodes(GInstrBlock *block, BlockVisitOrder order, visitor_dot_params *params) { - vmpa_t start; /* Adresse de départ d'un bloc */ + vmpa2t start; /* Adresse de départ d'un bloc */ GGraphNode *node; /* Noeud rattaché */ unsigned int rank; /* Classement du bloc lié */ if (G_IS_FLOW_BLOCK(block)) { g_flow_block_get_boundary_addresses(G_FLOW_BLOCK(block), &start, NULL); - node = find_graph_node_by_start_address(params->nodes, params->count, start); + node = find_graph_node_by_start_address(params->nodes, params->count, &start); rank = g_flow_block_get_rank(G_FLOW_BLOCK(block)); /* BUG_ON(count >= params->count) */ @@ -251,7 +251,7 @@ static void build_graph_ranking(visitor_dot_params *params) static bool register_graph_nodes(GInstrBlock *block, BlockVisitOrder order, visitor_dot_params *params) { char *cmds; /* Raccourci d'usage pratique */ - vmpa_t start; /* Adresse de départ d'un bloc */ + vmpa2t start; /* Adresse de départ d'un bloc */ GGraphNode *node; /* Noeud rattaché */ unsigned int i; /* Boucle de parcours */ char buffer[CLUSTER_DESC_LEN]; /* Tampon pour les commandes */ @@ -261,7 +261,7 @@ static bool register_graph_nodes(GInstrBlock *block, BlockVisitOrder order, visi if (G_IS_FLOW_BLOCK(block)) { g_flow_block_get_boundary_addresses(G_FLOW_BLOCK(block), &start, NULL); - node = find_graph_node_by_start_address(params->nodes, params->count, start); + node = find_graph_node_by_start_address(params->nodes, params->count, &start); cmds = g_graph_node_register_for_dot(node, cmds, params->level); @@ -784,6 +784,13 @@ void g_graph_layout_size_request(const GGraphLayout *layout, GtkRequisition *req requisition->height = g_graph_ranks_get_height(layout->ranks); + + requisition->width = 3000; + requisition->height = 3000; + + + printf("SIZE REQ\n"); + } diff --git a/src/gtkext/graph/node.c b/src/gtkext/graph/node.c index f286457..3801d1a 100644 --- a/src/gtkext/graph/node.c +++ b/src/gtkext/graph/node.c @@ -742,12 +742,12 @@ void g_graph_node_connect(const GGraphNode *node, gint x, gint y, GdkPoint **poi * * ******************************************************************************/ -GtkBufferView *find_graph_view_by_start_address(GtkBufferView **views, size_t count, vmpa_t addr) +GtkBufferView *find_graph_view_by_start_address(GtkBufferView **views, size_t count, const vmpa2t *addr) { GtkBufferView *result; /* Trouvaille à remonter */ size_t i; /* Boucle de parcours */ GBufferView *buffer; /* Tampon d'une partie de code */ - vmpa_t start; /* Adresse de départ du tampon */ + vmpa2t start; /* Adresse de départ du tampon */ result = NULL; @@ -756,7 +756,7 @@ GtkBufferView *find_graph_view_by_start_address(GtkBufferView **views, size_t co buffer = gtk_buffer_view_get_buffer(GTK_BUFFER_VIEW(views[i])); g_buffer_view_get_restrictions(buffer, &start, NULL); - if (start == addr) + if (cmp_vmpa(&start, addr) == 0) result = views[i]; } @@ -783,7 +783,7 @@ GtkBufferView *find_graph_view_by_start_address(GtkBufferView **views, size_t co GGraphNode *convert_blocks_into_nodes(GInstrBlock *block, GtkBufferView **views, size_t count) { GGraphNode *result; /* Instance nouvelle à renvoyer*/ - vmpa_t start; /* Adresse de départ */ + vmpa2t start; /* Adresse de départ */ GtkBufferView *view; /* Vue existante à retrouver */ size_t max; /* Nombre de blocs à gérer */ size_t i; /* Boucle de parcours */ @@ -795,7 +795,7 @@ GGraphNode *convert_blocks_into_nodes(GInstrBlock *block, GtkBufferView **views, if (G_IS_FLOW_BLOCK(block)) { g_flow_block_get_boundary_addresses(G_FLOW_BLOCK(block), &start, NULL); - view = find_graph_view_by_start_address(views, count, start); + view = find_graph_view_by_start_address(views, count, &start); result = g_flow_node_new(G_FLOW_BLOCK(block), view); @@ -890,12 +890,12 @@ GGraphNode *find_node_for_instruction(GGraphNode *nodes, GArchInstruction *instr * * ******************************************************************************/ -GGraphNode *find_graph_node_by_start_address(GGraphNode **nodes, size_t count, vmpa_t addr) +GGraphNode *find_graph_node_by_start_address(GGraphNode **nodes, size_t count, const vmpa2t *addr) { GGraphNode *result; /* Trouvaille à remonter */ size_t i; /* Boucle de parcours */ GBufferView *buffer; /* Tampon d'une partie de code */ - vmpa_t start; /* Adresse de départ du tampon */ + vmpa2t start; /* Adresse de départ du tampon */ result = NULL; @@ -904,7 +904,7 @@ GGraphNode *find_graph_node_by_start_address(GGraphNode **nodes, size_t count, v buffer = gtk_buffer_view_get_buffer(GTK_BUFFER_VIEW(nodes[i]->view)); g_buffer_view_get_restrictions(buffer, &start, NULL); - if (start == addr) + if (cmp_vmpa(&start, addr) == 0) result = nodes[i]; } diff --git a/src/gtkext/graph/node.h b/src/gtkext/graph/node.h index 712d9a3..4dcb02a 100644 --- a/src/gtkext/graph/node.h +++ b/src/gtkext/graph/node.h @@ -166,7 +166,7 @@ void g_graph_node_connect(const GGraphNode *, gint, gint, GdkPoint **, size_t *) /* Recherche une vue donnée dans une série de vues. */ -GtkBufferView *find_graph_view_by_start_address(GtkBufferView **, size_t, vmpa_t); +GtkBufferView *find_graph_view_by_start_address(GtkBufferView **, size_t, const vmpa2t *); /* Réalise une conversion de blocs en noeuds. */ GGraphNode *convert_blocks_into_nodes(GInstrBlock *, GtkBufferView **, size_t); @@ -178,7 +178,7 @@ GGraphNode *find_node_for_instruction(GGraphNode *, GArchInstruction *); /* Recherche un noeud donné dans une série de noeuds. */ -GGraphNode *find_graph_node_by_start_address(GGraphNode **, size_t, vmpa_t); +GGraphNode *find_graph_node_by_start_address(GGraphNode **, size_t, const vmpa2t *); /* Recherche un noeud donné dans une série de noeuds. */ GGraphNode *find_graph_node_by_name(GGraphNode **, size_t, const char *); diff --git a/src/gtkext/graph/nodes/flow.c b/src/gtkext/graph/nodes/flow.c index 7ebaf78..5173810 100644 --- a/src/gtkext/graph/nodes/flow.c +++ b/src/gtkext/graph/nodes/flow.c @@ -24,6 +24,9 @@ #include "flow.h" +#include <assert.h> + + #include "../layout.h" #include "../node-int.h" @@ -242,8 +245,13 @@ GGraphNode *g_flow_node_new(GFlowBlock *block, GtkBufferView *view) result->block = block; result->view = view; + gtk_widget_show(GTK_WIDGET(result->view)); + gtk_widget_size_allocate(GTK_WIDGET(result->view), (GtkAllocation []) { { 0, 0, 100, 100 } }); + gtk_widget_get_preferred_size(GTK_WIDGET(result->view), NULL, &requisition); + printf("PREFERED :: (%d ; %d)\n", requisition.width, requisition.height); + G_GRAPH_NODE(result)->alloc.width = requisition.width; G_GRAPH_NODE(result)->alloc.height = requisition.height; @@ -614,26 +622,76 @@ static void g_flow_node_setup_entry_slots(GFlowNode *node) GArchInstruction **instrs; /* Instr. visée par une autre */ InstructionLinkType *types; /* Type de lien entre lignes */ size_t icount; /* Nombre de liens de dest. */ + size_t usable; /* Nombre de liens utiles ici */ size_t i; /* Boucle de parcours */ + size_t used; /* Nombre de liens utilisés */ g_flow_block_get_boundary(node->block, &first, NULL); icount = g_arch_instruction_get_sources(first, &instrs, &types); - node->entries = (node_slot_t *)calloc(icount, sizeof(node_slot_t)); - node->entries_count = icount; + usable = 0; for (i = 0; i < icount; i++) - { - g_object_ref(instrs[i]); - node->entries[i].instr = instrs[i]; + switch (types[i]) + { + case ILT_EXEC_FLOW: + case ILT_JUMP: + case ILT_CASE_JUMP: + case ILT_JUMP_IF_TRUE: + case ILT_JUMP_IF_FALSE: + case ILT_LOOP: + case ILT_CATCH_EXCEPTION: + usable++; + break; - node->entries[i].type = types[i]; - node->entries[i].group_index = g_arch_instruction_compute_group_index(&instrs[i], - instrs, icount); - node->entries[i].slot_index = i; + default: + break; + } + + if (usable == 0) + { + node->entries = NULL; + node->entries_count = 0; + } + else + { + node->entries = (node_slot_t *)calloc(usable, sizeof(node_slot_t)); + node->entries_count = usable; } + used = 0; + + for (i = 0; i < icount; i++) + switch (types[i]) + { + case ILT_EXEC_FLOW: + case ILT_JUMP: + case ILT_CASE_JUMP: + case ILT_JUMP_IF_TRUE: + case ILT_JUMP_IF_FALSE: + case ILT_LOOP: + case ILT_CATCH_EXCEPTION: + + g_object_ref(instrs[i]); + node->entries[used].instr = instrs[i]; + + node->entries[used].type = types[i]; + node->entries[used].group_index = g_arch_instruction_compute_group_index(&instrs[i], + instrs, icount); + node->entries[used].slot_index = i; + + used++; + + break; + + default: + break; + + } + + assert(used == usable); + } @@ -655,25 +713,75 @@ static void g_flow_node_setup_exit_slots(GFlowNode *node) GArchInstruction **instrs; /* Instr. visée par une autre */ InstructionLinkType *types; /* Type de lien entre lignes */ size_t icount; /* Nombre de liens de dest. */ + size_t usable; /* Nombre de liens utiles ici */ size_t i; /* Boucle de parcours */ + size_t used; /* Nombre de liens utilisés */ g_flow_block_get_boundary(node->block, NULL, &last); icount = g_arch_instruction_get_destinations(last, &instrs, &types, NULL); - node->exits = (node_slot_t *)calloc(icount, sizeof(node_slot_t)); - node->exits_count = icount; + usable = 0; for (i = 0; i < icount; i++) - { - g_object_ref(instrs[i]); - node->exits[i].instr = instrs[i]; + switch (types[i]) + { + case ILT_EXEC_FLOW: + case ILT_JUMP: + case ILT_CASE_JUMP: + case ILT_JUMP_IF_TRUE: + case ILT_JUMP_IF_FALSE: + case ILT_LOOP: + case ILT_CATCH_EXCEPTION: + usable++; + break; - node->exits[i].type = types[i]; - node->exits[i].group_index = g_arch_instruction_compute_group_index(&instrs[i], - instrs, icount); - node->exits[i].slot_index = i; + default: + break; + } + + if (usable == 0) + { + node->exits = NULL; + node->exits_count = 0; } + else + { + node->exits = (node_slot_t *)calloc(usable, sizeof(node_slot_t)); + node->exits_count = usable; + } + + used = 0; + + for (i = 0; i < icount; i++) + switch (types[i]) + { + case ILT_EXEC_FLOW: + case ILT_JUMP: + case ILT_CASE_JUMP: + case ILT_JUMP_IF_TRUE: + case ILT_JUMP_IF_FALSE: + case ILT_LOOP: + case ILT_CATCH_EXCEPTION: + + g_object_ref(instrs[i]); + node->exits[used].instr = instrs[i]; + + node->exits[used].type = types[i]; + node->exits[used].group_index = g_arch_instruction_compute_group_index(&instrs[i], + instrs, icount); + node->exits[used].slot_index = i; + + used++; + + break; + + default: + break; + + } + + assert(used == usable); } diff --git a/src/gtkext/gtkbufferview.c b/src/gtkext/gtkbufferview.c index c7c0267..be75d2f 100644 --- a/src/gtkext/gtkbufferview.c +++ b/src/gtkext/gtkbufferview.c @@ -92,6 +92,28 @@ static gboolean gtk_buffer_view_refresh_caret(GtkBufferView *); G_DEFINE_TYPE(GtkBufferView, gtk_buffer_view, GTK_TYPE_VIEW_PANEL) +/* + void (* get_preferred_height) (GtkWidget *widget, + gint *minimum_height, + gint *natural_height); + + void (* get_preferred_width_for_height) (GtkWidget *widget, + gint height, + gint *minimum_width, + gint *natural_width); + void (* get_preferred_width) (GtkWidget *widget, + gint *minimum_width, + gint *natural_width); +*/ + + +void get_preferred(GtkWidget *widget, gint *minimum, gint *natural) +{ + if (minimum != NULL) *minimum = 500; + if (natural != NULL) *natural = 500; +} + + /****************************************************************************** * * * Paramètres : class = classe GTK à initialiser. * @@ -117,6 +139,11 @@ static void gtk_buffer_view_class_init(GtkBufferViewClass *class) widget_class->draw = gtk_buffer_view_draw; widget_class->key_press_event = gtk_buffer_view_key_press; + + widget_class->get_preferred_height = get_preferred; + widget_class->get_preferred_width = get_preferred; + + panel_class->compute_size = (compute_requested_size)gtk_buffer_view_compute_requested_size; panel_class->compute_inc = (compute_scroll_inc)gtk_buffer_view_compute_scroll_inc; panel_class->get_coordinates = (get_addr_coordinates_fc)gtk_buffer_view_get_address_coordinates; @@ -361,7 +388,7 @@ static gboolean gtk_buffer_view_draw(GtkWidget *widget, cairo_t *cr) gtk_style_context_add_class(context, GTK_STYLE_CLASS_TROUGH); - gtk_render_background (context, cr, 0, area.y, view->left_margin, area.height); + gtk_render_background(context, cr, 0, area.y, view->left_margin, area.height); gtk_render_frame(context, cr, 0, area.y - 10, view->left_margin, area.height + 20); gtk_style_context_restore(context); @@ -549,12 +576,6 @@ static void gtk_buffer_view_compute_scroll_inc(GtkBufferView *view, gint size, G } - - - - - - /****************************************************************************** * * * Paramètres : view = composant GTK à consulter. * diff --git a/src/gtkext/gtkgraphview.c b/src/gtkext/gtkgraphview.c index 0265518..1f8d51c 100644 --- a/src/gtkext/gtkgraphview.c +++ b/src/gtkext/gtkgraphview.c @@ -79,15 +79,15 @@ static gboolean gtk_graph_view_draw(GtkWidget *, cairo_t *, GtkGraphView *); /* Indique les dimensions de travail du composant d'affichage. */ static void gtk_graph_view_compute_requested_size(GtkGraphView *, gint *, gint *); - -/* Réagit à la sélection externe d'une adresse. */ -static void gtk_graph_view_define_main_address(GtkGraphView *, vmpa_t); - /* Actualise les besoins internes avant un redimensionnement. */ static void gtk_graph_view_prepare_resize(GtkGraphView *); + +/* Réagit à la sélection externe d'une adresse. */ +static void gtk_graph_view_define_main_address(GtkGraphView *, const vmpa2t *); + /* Indique la position d'affichage d'une adresse donnée. */ -static bool gtk_graph_view_get_address_coordinates(const GtkGraphView *, vmpa_t, gint *, gint *); +static bool gtk_graph_view_get_address_coordinates(const GtkGraphView *, const vmpa2t *addr, gint *x, gint *y, ScrollPositionTweak tweak); /* Place en cache un rendu destiné à l'aperçu graphique rapide. */ static void gtk_graph_view_cache_glance(GtkGraphView *, cairo_t *, const GtkAllocation *, double); @@ -129,6 +129,8 @@ static void gtk_graph_view_class_init(GtkGraphViewClass *class) widget_class->size_allocate = gtk_graph_view_size_allocate; panel_class->compute_size = (compute_requested_size)gtk_graph_view_compute_requested_size; + panel_class->define = (define_address_fc)gtk_graph_view_define_main_address; + panel_class->get_coordinates = (get_addr_coordinates_fc)gtk_graph_view_get_address_coordinates; } @@ -144,7 +146,7 @@ static void gtk_graph_view_class_init(GtkGraphViewClass *class) * Remarques : - * * * ******************************************************************************/ - +#include "easygtk.h"//////////// static void gtk_graph_view_init(GtkGraphView *view) { GtkViewPanel *viewpanel; /* Instance parente #1 */ @@ -153,7 +155,6 @@ 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->resize = (prepare_resize_fc)gtk_graph_view_prepare_resize; ////////viewpanel->get_coordinates = (get_addr_coordinates_fc)gtk_graph_view_get_address_coordinates; viewpanel->cache_glance = (cache_glance_fc)gtk_graph_view_cache_glance; @@ -166,6 +167,7 @@ static void gtk_graph_view_init(GtkGraphView *view) view->support = GTK_FIXED(gtk_fixed_new()); gtk_widget_set_has_window(GTK_WIDGET(view->support), TRUE); + gtk_widget_set_can_focus(GTK_WIDGET(view->support), TRUE); g_signal_connect(G_OBJECT(view->support), "draw", G_CALLBACK(gtk_graph_view_draw), view); @@ -179,6 +181,26 @@ static void gtk_graph_view_init(GtkGraphView *view) gtk_fixed_put(GTK_FIXED(view), GTK_WIDGET(view->support), 0, 0); + //gtk_widget_size_allocate(view->support, (GtkAllocation []){ { 200, 200, 500, 500 } }); + +#if 0 + do + { + GtkWidget *btn; + + btn = qck_create_button(NULL, NULL, "caption 0", NULL, NULL); + gtk_fixed_put(GTK_FIXED(view), btn, 10, 10); + + + btn = qck_create_button(NULL, NULL, "caption 1", NULL, NULL); + gtk_fixed_put(GTK_FIXED(view->support), btn, 100, 100); + + + + } + while (0); +#endif + //view->mutex = g_mutex_new(); //view->cond = g_cond_new(); @@ -215,19 +237,32 @@ static void gtk_graph_view_size_allocate(GtkWidget *widget, GtkAllocation *alloc GdkWindow *window; /* Fenêtre associée au support */ gboolean changed; /* Changement de valeur ? */ - return; + + printf("GRAPH SIZE ALLOC :: (%d ; %d) - (%d ; %d)\n", + allocation->x, allocation->y, + allocation->width, allocation->height); + + + GTK_WIDGET_CLASS(gtk_graph_view_parent_class)->size_allocate(widget, allocation); + /* Mise à jour GTK */ + /* fixed_class = g_type_class_peek_parent(GTK_GRAPH_VIEW_GET_CLASS(widget)); fixed_class = g_type_class_peek_parent(fixed_class); GTK_WIDGET_CLASS(fixed_class)->size_allocate(widget, allocation); + */ + + panel = GTK_VIEW_PANEL(widget); + /* if (panel->hadjustment == NULL || panel->vadjustment == NULL) return; + */ // !!!! moved !!! gtk_view_panel_compute_allocation(panel, &valloc); @@ -238,8 +273,24 @@ static void gtk_graph_view_size_allocate(GtkWidget *widget, GtkAllocation *alloc view = GTK_GRAPH_VIEW(widget); window = gtk_widget_get_window(GTK_WIDGET(view->support)); + + + gtk_widget_size_allocate(view->support, (GtkAllocation []){ { 0, 0, 1500, 1500 } }); + + //gdk_window_resize(window, 500, 500); + + /* + printf(" --> cmp :: (%d ; %d) vs (%d ; %d)\n", + gdk_window_get_width(window), gdk_window_get_height(window), + req.width, req.height); + */ + /* if (gdk_window_get_width(window) != req.width || gdk_window_get_height(window) != req.height) gdk_window_resize(window, req.width, req.height); + */ + + return; + /* Défilement horizontal */ @@ -299,7 +350,7 @@ static void gtk_graph_view_compute_requested_size(GtkGraphView *view, gint *widt if (width != NULL && view->layout != NULL) { g_graph_layout_size_request(view->layout, &requisition); - *width = requisition.height; + *width = requisition.width; } if (height != NULL && view->layout != NULL) @@ -340,6 +391,42 @@ static gboolean gtk_graph_view_draw(GtkWidget *widget, cairo_t *cr, GtkGraphView /****************************************************************************** * * * Paramètres : view = composant GTK à mettre à jour. * +* * +* Description : Actualise les besoins internes avant un redimensionnement. * +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ + +static void gtk_graph_view_prepare_resize(GtkGraphView *view) +{ + size_t i; /* Boucle de parcours */ + + if (view->children_count > 0) + { + for (i = 0; i < view->children_count; i++) + gtk_widget_queue_resize(GTK_WIDGET(view->children[i])); + + /* + build_graph_view(view, g_binary_routine_get_basic_blocks(view->routine), + view->children, view->children_count); + */ + + g_graph_layout_refresh(view->layout); + g_graph_layout_place(view->layout, view); + + change_editor_items_current_view_content(GTK_VIEW_PANEL(view)); + + } + +} + + +/****************************************************************************** +* * +* 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. * @@ -350,16 +437,24 @@ static gboolean gtk_graph_view_draw(GtkWidget *widget, cairo_t *cr, GtkGraphView * * ******************************************************************************/ -static void gtk_graph_view_define_main_address(GtkGraphView *view, vmpa_t addr) +static void gtk_graph_view_define_main_address(GtkGraphView *view, const vmpa2t *addr) { + bool need_update; /* Mise à jour du contenu ? */ + const mrange_t *range; /* Couverture courante */ 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)) + if (view->routine == NULL) + need_update = true; + else + { + range = g_binary_routine_get_range(view->routine); + need_update = !mrange_contains_addr(range, addr); + } + + if (need_update) { gtk_graph_view_reset(view); @@ -368,17 +463,13 @@ static void gtk_graph_view_define_main_address(GtkGraphView *view, vmpa_t addr) for (i = 0; i < routines_count; i++) { - start = g_binary_routine_get_address(routines[i]); - end = start + g_binary_routine_get_size(routines[i]); + range = g_binary_routine_get_range(routines[i]); - if (start <= addr && addr < end) + if (mrange_contains_addr(range, addr)) { view->routine = routines[i]; g_object_ref(G_OBJECT(view->routine)); - view->start = start; - view->end = end; - view->children = gtk_graph_view_load_nodes(view, GTK_VIEW_PANEL(view)->binary, routines[i]); @@ -411,46 +502,11 @@ static void gtk_graph_view_define_main_address(GtkGraphView *view, vmpa_t addr) /****************************************************************************** * * -* Paramètres : view = composant GTK à mettre à jour. * -* * -* Description : Actualise les besoins internes avant un redimensionnement. * -* * -* Retour : - * -* * -* Remarques : - * -* * -******************************************************************************/ - -static void gtk_graph_view_prepare_resize(GtkGraphView *view) -{ - size_t i; /* Boucle de parcours */ - - if (view->children_count > 0) - { - for (i = 0; i < view->children_count; i++) - gtk_widget_queue_resize(GTK_WIDGET(view->children[i])); - - /* - build_graph_view(view, g_binary_routine_get_basic_blocks(view->routine), - view->children, view->children_count); - */ - - g_graph_layout_refresh(view->layout); - g_graph_layout_place(view->layout, view); - - change_editor_items_current_view_content(GTK_VIEW_PANEL(view)); - - } - -} - - -/****************************************************************************** -* * -* Paramètres : view = composant GTK à consulter. * -* addr = adresse à présenter à l'écran. * -* x = position horizontale au sein du composant. [OUT] * -* y = position verticale au sein du composant. [OUT] * +* Paramètres : view = composant GTK à consulter. * +* addr = adresse à présenter à l'écran. * +* x = position horizontale au sein du composant. [OUT] * +* y = position verticale au sein du composant. [OUT] * +* tweak = adaptation finale à effectuer. * * * * Description : Indique la position d'affichage d'une adresse donnée. * * * @@ -460,10 +516,9 @@ static void gtk_graph_view_prepare_resize(GtkGraphView *view) * * ******************************************************************************/ -static bool gtk_graph_view_get_address_coordinates(const GtkGraphView *view, vmpa_t addr, gint *x, gint *y) +static bool gtk_graph_view_get_address_coordinates(const GtkGraphView *view, const vmpa2t *addr, gint *x, gint *y, ScrollPositionTweak tweak) { - - + /* TODO */ return false; @@ -564,7 +619,8 @@ void gtk_graph_view_put(GtkGraphView *view, GtkWidget *widget, const GtkAllocati gtk_container_remove(GTK_CONTAINER(parent), widget); } - gtk_fixed_put(view->support, widget, alloc->x, alloc->y); + //gtk_fixed_put(view->support, widget, alloc->x, alloc->y); + gtk_fixed_put(view->support, widget, i * 200, i * 150); if (parent != NULL) g_object_unref(G_OBJECT(widget)); @@ -665,8 +721,8 @@ static GtkViewPanel **gtk_graph_view_load_nodes(GtkGraphView *view, GLoadedBinar 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 */ - vmpa_t last; /* Fin d'un groupe de lignes */ + vmpa2t first; /* Début d'un groupe de lignes */ + vmpa2t last; /* Fin d'un groupe de lignes */ GBufferView *subview; /* Partie affichée du tampon */ buffer = g_loaded_binary_get_disassembled_buffer(binary); @@ -692,7 +748,7 @@ static GtkViewPanel **gtk_graph_view_load_nodes(GtkGraphView *view, GLoadedBinar 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); + g_buffer_view_restrict(subview, &first, &last); gtk_buffer_view_attach_buffer(GTK_BUFFER_VIEW(result[i]), subview); } diff --git a/src/gtkext/gtkviewpanel-int.h b/src/gtkext/gtkviewpanel-int.h index 220b253..d51c637 100644 --- a/src/gtkext/gtkviewpanel-int.h +++ b/src/gtkext/gtkviewpanel-int.h @@ -43,7 +43,7 @@ typedef void (* compute_scroll_inc) (GtkViewPanel *, gint, GtkOrientation, gdoub typedef void (* attach_binary_fc) (GtkViewPanel *, GLoadedBinary *); /* Réagit à la sélection externe d'une adresse. */ -typedef void (* define_address_fc) (GtkViewPanel *, vmpa_t); +typedef void (* define_address_fc) (GtkViewPanel *, const vmpa2t *); /* Actualise les besoins internes avant un redimensionnement. */ typedef void (* prepare_resize_fc) (GtkViewPanel *); @@ -76,7 +76,7 @@ struct _GtkViewPanel GLoadedBinary *binary; /* Binaire à visualiser */ attach_binary_fc attach; /* Association avec un binaire */ - define_address_fc define; /* Centrage sur une partie */ + //define_address_fc define; /* Centrage sur une partie */ prepare_resize_fc resize; /* Prépare une nouvelle taille */ cache_glance_fc cache_glance; /* Cache de la mignature */ @@ -89,6 +89,7 @@ struct _GtkViewPanelClass compute_requested_size compute_size; /* Calcul de la taille requise */ compute_scroll_inc compute_inc; /* Calcul des bonds */ + define_address_fc define; /* Centrage sur une partie */ get_addr_coordinates_fc get_coordinates;/* Conversion adresse <-> pos. */ get_view_position_fc get_position; /* Indications sur la position */ diff --git a/src/gtkext/gtkviewpanel.c b/src/gtkext/gtkviewpanel.c index d434f1e..3c8febd 100644 --- a/src/gtkext/gtkviewpanel.c +++ b/src/gtkext/gtkviewpanel.c @@ -320,6 +320,11 @@ static void gtk_view_panel_size_allocate(GtkWidget *widget, GtkAllocation *alloc GTK_WIDGET_CLASS(gtk_view_panel_parent_class)->size_allocate(widget, allocation); + + printf("[%s / %p] __SIZE :: (%d ; %d)\n", G_OBJECT_TYPE_NAME(widget), widget, + allocation->width, allocation->height); + + panel = GTK_VIEW_PANEL(widget); gtk_view_panel_update_adjustment(panel, GTK_ORIENTATION_HORIZONTAL); @@ -347,6 +352,8 @@ static gboolean gtk_view_panel_draw(GtkWidget *widget, cairo_t *cr) GtkRequisition req; /* Taille allouée à l'élément */ GtkStyleContext *context; /* Contexte du thème actuel */ + GTK_WIDGET_CLASS(gtk_view_panel_parent_class)->draw(widget, cr); + panel = GTK_VIEW_PANEL(widget); if (panel->show_border) @@ -776,11 +783,8 @@ void gtk_view_panel_scroll_to_address(GtkViewPanel *panel, const vmpa2t *addr, S gdouble page_size; /* Taille de l'affichage */ double value; /* Valeur courante */ - /* - if (panel->define != NULL) - panel->define(panel, addr); - */ - + if (GTK_VIEW_PANEL_GET_CLASS(panel)->define != NULL) + GTK_VIEW_PANEL_GET_CLASS(panel)->define(panel, addr); if (GTK_VIEW_PANEL_GET_CLASS(panel)->get_coordinates(panel, addr, &x, &y, tweak)) { |