diff options
Diffstat (limited to 'src/gtkext/graph')
-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 |
4 files changed, 147 insertions, 32 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); } |