summaryrefslogtreecommitdiff
path: root/src/gtkext
diff options
context:
space:
mode:
authorCyrille Bagard <nocbos@gmail.com>2015-04-06 10:15:41 (GMT)
committerCyrille Bagard <nocbos@gmail.com>2015-04-06 10:15:41 (GMT)
commite108e192582aa1dbe020dfbc09bee5e6ab2cc534 (patch)
treeff037f19f3ab5ee2aabb8f1cd62d6c7f634179ad /src/gtkext
parent40d624af29e752bb4255099ab3f1de64e3c96dd3 (diff)
Said goodbye to Graphviz.
git-svn-id: svn://svn.gna.org/svn/chrysalide/trunk@505 abbe820e-26c8-41b2-8c08-b7b2b41f8b0a
Diffstat (limited to 'src/gtkext')
-rwxr-xr-xsrc/gtkext/graph/Makefile.am3
-rw-r--r--src/gtkext/graph/dot.c290
-rw-r--r--src/gtkext/graph/dot.h51
-rw-r--r--src/gtkext/graph/layout.c398
-rw-r--r--src/gtkext/graph/layout.h17
-rw-r--r--src/gtkext/graph/node-int.h12
-rw-r--r--src/gtkext/graph/node.c327
-rw-r--r--src/gtkext/graph/node.h40
-rw-r--r--src/gtkext/graph/nodes/flow.c31
-rw-r--r--src/gtkext/gtkgraphview.c11
10 files changed, 6 insertions, 1174 deletions
diff --git a/src/gtkext/graph/Makefile.am b/src/gtkext/graph/Makefile.am
index 50ec8d0..f54a97b 100755
--- a/src/gtkext/graph/Makefile.am
+++ b/src/gtkext/graph/Makefile.am
@@ -2,7 +2,6 @@
noinst_LTLIBRARIES = libgtkextgraph.la
libgtkextgraph_la_SOURCES = \
- dot.h dot.c \
edge.h edge.c \
layout.h layout.c \
node.h node.c \
@@ -15,7 +14,7 @@ libgtkextgraph_la_LIBADD = \
libgtkextgraph_la_LDFLAGS =
-AM_CPPFLAGS = $(LIBGTK_CFLAGS) $(LIBXML_CFLAGS) $(LIBGRAPH_CFLAGS)
+AM_CPPFLAGS = $(LIBGTK_CFLAGS) $(LIBXML_CFLAGS)
AM_CFLAGS = $(DEBUG_CFLAGS) $(WARNING_FLAGS) $(COMPLIANCE_FLAGS)
diff --git a/src/gtkext/graph/dot.c b/src/gtkext/graph/dot.c
deleted file mode 100644
index 30aeaee..0000000
--- a/src/gtkext/graph/dot.c
+++ /dev/null
@@ -1,290 +0,0 @@
-
-/* Chrysalide - Outil d'analyse de fichiers binaires
- * dot.c - interactions avec le système dot
- *
- * Copyright (C) 2009-2013 Cyrille Bagard
- *
- * This file is part of Chrysalide.
- *
- * OpenIDA is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * OpenIDA is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with Foobar. If not, see <http://www.gnu.org/licenses/>.
- */
-
-
-#include "dot.h"
-
-
-#include <malloc.h>
-#include <string.h>
-#include <graphviz/gvc.h>
-#include <graphviz/types.h>
-
-
-
-/* Graphique selon Graphviz */
-struct _graph_layout
-{
- GVC_t *context; /* Contexte pour Graphviz */
- graph_t *graph; /* Graphique construit */
-
-};
-
-
-
-/******************************************************************************
-* *
-* Paramètres : cmds = description textuelle du graphique à représenter. *
-* *
-* Description : Charge un graphique à partir de sa description. *
-* *
-* Retour : Bilan de l'opération. *
-* *
-* Remarques : - *
-* *
-******************************************************************************/
-
-graph_layout *create_graph_layout(char *cmds)
-{
- graph_layout *result; /* Composants à retourner */
- int ret; /* Bilan d'un appel */
-
- result = (graph_layout *)calloc(1, sizeof(graph_layout));
-
- agseterr(AGMAX);
-
- result->context = gvContext();
- result->graph = agmemread(cmds);
-
- if (result->graph == NULL) goto cdl_error;
-
-
-
- printf("CMDS =======\n%s\n\n=================\n", cmds);
-
- ret = gvLayout(result->context, result->graph, "dot");
- if (ret != 0) goto cdl_error;
-
-
- //printf("ret = %d\n", ret);
-
- /*
- ret = gvLayoutJobs(result->context, result->graph);
- printf("ret = %d\n", ret);
- ret = gvRenderJobs(result->context, result->graph);
- printf("ret = %d\n", ret);
- */
-
- ret = gvRender(result->context, result->graph, "dot", NULL);
- if (ret != 0) goto cdl_error;
-
-
-
- //ret = gvRender(result->context, result->graph, "plain", NULL);
-
- //printf("ret = %d\n", ret);
-
-
-
-
-
- return result;
-
- cdl_error:
-
- delete_graph_layout(result);
-
- return NULL;
-
-}
-
-
-/******************************************************************************
-* *
-* Paramètres : layout = graphique à supprimer de la mémoire. *
-* *
-* Description : Décharge un graphique. *
-* *
-* Retour : - *
-* *
-* Remarques : - *
-* *
-******************************************************************************/
-
-void delete_graph_layout(graph_layout *layout)
-{
- if (layout->graph != NULL)
- {
- gvFreeLayout(layout->context, layout->graph);
- agclose(layout->graph);
- }
-
- gvFreeContext(layout->context);
-
- free(layout);
-
-}
-
-
-/******************************************************************************
-* *
-* Paramètres : layout = graphique à supprimer de la mémoire. *
-* view = support de destination. *
-* nodes = liste de noeuds à traiter. *
-* count = taille de la liste. *
-* *
-* Description : Place tous les éléments du graphique à l'écran. *
-* *
-* Retour : - *
-* *
-* Remarques : - *
-* *
-******************************************************************************/
-
-void place_nodes_of_graph_layout(const graph_layout *layout, GtkGraphView *view, GGraphNode **nodes, size_t count)
-{
-#if 0
- int height; /* Hauteur du graphique */
- node_t *iter; /* Boucle de parcours */
- GGraphNode *node; /* Intermédiaire concerné */
-
- height = GD_bb(layout->graph).UR.y;
-
- for (iter = agfstnode(layout->graph); iter != NULL; iter = agnxtnode(layout->graph, iter))
- {
- node = find_graph_node_by_name(nodes, count, iter->name);
-
- /* S'il s'agit d'un noeud artificiel créé pour dot uniquement... */
- if (node == NULL) continue;
-
- g_graph_node_place_old(node, view, iter->u.coord.x, height - iter->u.coord.y);
-
- }
-#endif
-}
-
-
-/******************************************************************************
-* *
-* Paramètres : layout = graphique à supprimer de la mémoire. *
-* count = nombre d'éléments mis en place. *
-* nodes = liste de noeuds à consulter. *
-* ncount = taille de la liste des noeuds. *
-* *
-* Description : Charge la définition de tous les liens graphiques. *
-* *
-* Retour : - *
-* *
-* Remarques : - *
-* *
-******************************************************************************/
-
-GtkLinkRenderer **create_links_from_graph_layout(const graph_layout *layout, size_t *count, GGraphNode **nodes, size_t ncount)
-{
-#if 0
- GtkLinkRenderer **result; /* Liste à retourner */
- int height; /* Hauteur du graphique */
- node_t *niter; /* Boucle de parcours #1 */
- edge_t *eiter; /* Boucle de parcours #2 */
- GdkPoint *points; /* Points de ligne relus */
- size_t points_count; /* Nombre de ces points */
- splines *lines; /* Lignes déjà tracées */
- Agsym_t *attrib; /* Couleur d'un lien */
- LinkColor color; /* Couleur d'impression */
- GGraphNode *node; /* Noeud rattaché */
- int i; /* Boucle de parcours #3 */
- int k; /* Boucle de parcours #4 */
- bezier *bez; /* Courbe à reproduire */
-
- result = NULL;
- *count = 0;
-
- height = GD_bb(layout->graph).UR.y;
-
- for (niter = agfstnode(layout->graph); niter != NULL; niter = agnxtnode(layout->graph, niter))
- for (eiter = agfstout(layout->graph, niter); eiter != NULL; eiter = agnxtout(layout->graph, eiter))
- {
- points = NULL;
- points_count = 0;
-
- lines = ED_spl(eiter);
-
- /* Détermination de la couleur */
-
- color = LKC_DEFAULT;
-
- attrib = agfindedgeattr(agraphof(agtail(eiter)), "color");
-
- if (attrib != NULL)
- {
- if (strcmp("green", eiter->attr[attrib->index]) == 0)
- color = LKC_GREEN;
- else if (strcmp("red", eiter->attr[attrib->index]) == 0)
- color = LKC_RED;
- else if (strcmp("blue", eiter->attr[attrib->index]) == 0)
- color = LKC_BLUE;
- else if (strcmp("gray", eiter->attr[attrib->index]) == 0)
- color = LKC_DASHED_GRAY;
- }
-
- /* Raccordement au point de départ */
-
- node = find_graph_node_by_name(nodes, ncount, agtail(eiter)->name);
-
- /* S'il s'agit d'un noeud artificiel créé pour dot uniquement... */
- if (node == NULL) continue;
-
- g_graph_node_connect(node,
- lines->list[0].list[0].x,
- height - lines->list[0].list[0].y,
- &points, &points_count);
-
- /* Tracé du lien... */
-
- for (i = 0; i < lines->size; i++)
- {
- bez = &lines->list[i];
-
- points = (GdkPoint *)realloc(points, (points_count + bez->size) * sizeof(GdkPoint));
-
- for (k = 0; k < bez->size; k++)
- {
- points[points_count + k].x = bez->list[k].x;
- points[points_count + k].y = height - bez->list[k].y;
- }
-
- points_count += bez->size;
-
- }
-
- /* Raccordement au point d'arrivée */
-
- node = find_graph_node_by_name(nodes, ncount, aghead(eiter)->name);
-
- g_graph_node_connect(node,
- bez->list[k - 1].x,
- height - bez->list[k - 1].y,
- &points, &points_count);
-
- result = (GtkLinkRenderer **)realloc(result, ++(*count) * sizeof(GtkLinkRenderer *));
-
- result[*count - 1] = GTK_LINK_RENDERER(gtk_link_renderer_new(color,
- points, points_count));
-
- }
-
- return result;
-#endif
-
- return NULL;
-
-}
diff --git a/src/gtkext/graph/dot.h b/src/gtkext/graph/dot.h
deleted file mode 100644
index ad91881..0000000
--- a/src/gtkext/graph/dot.h
+++ /dev/null
@@ -1,51 +0,0 @@
-
-/* Chrysalide - Outil d'analyse de fichiers binaires
- * dot.h - prototypes pour les interactions avec le système dot
- *
- * Copyright (C) 2009-2012 Cyrille Bagard
- *
- * This file is part of Chrysalide.
- *
- * OpenIDA is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * OpenIDA is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with Foobar. If not, see <http://www.gnu.org/licenses/>.
- */
-
-
-#ifndef _GRAPH_DOT_H
-#define _GRAPH_DOT_H
-
-
-#include "node.h"
-#include "../gtklinkrenderer.h"
-
-
-
-/* Graphique selon Graphviz */
-typedef struct _graph_layout graph_layout;
-
-
-/* Charge un graphique à partir de sa description. */
-graph_layout *create_graph_layout(char *);
-
-/* Décharge un graphique. */
-void delete_graph_layout(graph_layout *);
-
-/* Place tous les éléments du graphique à l'écran. */
-void place_nodes_of_graph_layout(const graph_layout *, GtkGraphView *, GGraphNode **, size_t);
-
-/* Charge la définition de tous les liens graphiques. */
-GtkLinkRenderer **create_links_from_graph_layout(const graph_layout *, size_t *, GGraphNode **, size_t);
-
-
-
-#endif /* _GRAPH_DOT_H */
diff --git a/src/gtkext/graph/layout.c b/src/gtkext/graph/layout.c
index 2e3759a..de83a22 100644
--- a/src/gtkext/graph/layout.c
+++ b/src/gtkext/graph/layout.c
@@ -25,411 +25,15 @@
#include <malloc.h>
-#include <string.h>
-#include <gtk/gtkfixed.h>
-#include "dot.h"
#include "node.h"
-#include "nodes/flow.h"
-#include "../gtkbufferview.h"
-#include "../../analysis/binary.h"
-#include "../../analysis/blocks/flow.h"
-#include "../../common/extstr.h"
-
-
-
-/* Taille maximale des noms de classement */
-#define RANK_DESC_LEN 128
-
-/* Taille maximale des introductions aux clusters */
-#define CLUSTER_DESC_LEN 128
-
-/* Taille maximale des descriptions de liens */
-#define LINKS_DESC_LEN 128
-
-
-/* Paramètres de construction des commandes */
-typedef struct _visitor_dot_params
-{
- GGraphNode **nodes; /* Intermédiaires en place */
- size_t count; /* Quantité de noeuds en place */
-
- char **ranks; /* Profondeurs des blocs */
-
- unsigned int level; /* Profondeur de la visite */
- char *cmds; /* Description à envoyer à dot */
-
-} visitor_dot_params;
-
-
-/* Construit les rangs pour dot en parcourant les noeuds. */
-static bool rank_graph_nodes(GInstrBlock *, BlockVisitOrder, visitor_dot_params *);
-
-/* Etablit le classement de tous les prochains noeuds pour dot. */
-static void build_graph_ranking(visitor_dot_params *);
-
-/* Construit les commandes pour dot en parcourant les noeuds. */
-static bool register_graph_nodes(GInstrBlock *, BlockVisitOrder, visitor_dot_params *);
-
-/* Etablit tous les liens entre les différents morceaux de code. */
-static char *complete_graph_links(const GtkGraphView *, GtkViewPanel **, size_t, char *);
-
-
-
-/******************************************************************************
-* *
-* Paramètres : view = support où placer les différents éléments. *
-* views = morceaux de code à afficher de façon organisée. *
-* count = quantité de ces morceaux de code. *
-* *
-* Description : Dispose une série de morceaux d'affichage en graphique. *
-* *
-* Retour : - *
-* *
-* Remarques : - *
-* *
-******************************************************************************/
-
-bool build_graph_view(GtkGraphView *view, GInstrBlock *blocks, GtkViewPanel **views, size_t count)
-{
- visitor_dot_params params; /* Paramètres de construction */
- size_t i; /* Boucle de parcours */
- graph_layout *layout; /* Graphique construit */
- GtkLinkRenderer **links; /* Liens graphiques construits */
- size_t links_count; /* Quantité de ces liens */
-
- /* Création de la glue */
-
- params.nodes = (GGraphNode **)calloc(count, sizeof(GGraphNode *));
- params.count = count;
-
- for (i = 0; i < count; i++)
- params.nodes[i] = g_graph_node_new(GTK_WIDGET(views[i]));
-
- /* Définition du graphique */
-
- params.level = 1;
- params.cmds = strdup("digraph G {\n overlap=false;\n splines=ortho;\n compound=true;\n");
-
- params.ranks = (char **)calloc(count, sizeof(char *));
-
- g_instr_block_visit(blocks, (instr_block_visitor_cb)rank_graph_nodes, &params);
- build_graph_ranking(&params);
-
- g_instr_block_visit(blocks, (instr_block_visitor_cb)register_graph_nodes, &params);
-
- params.cmds = complete_graph_links(view, views, count, params.cmds);
-
- params.cmds = stradd(params.cmds, "}");
-
- layout = create_graph_layout(params.cmds);
-
- /* Affichage du graphique */
-
- place_nodes_of_graph_layout(layout, view, params.nodes, count);
-
- links = create_links_from_graph_layout(layout, &links_count, params.nodes, count);
- gtk_graph_view_attach_links(view, links, links_count);
-
- gtk_widget_queue_draw(GTK_WIDGET(view));
-
- delete_graph_layout(layout);
-
- for (i = 0; i < count; i++)
- g_object_unref(params.nodes[i]);
-
- return true;
-
-}
-
-
-/******************************************************************************
-* *
-* Paramètres : block = bloc d'instructions concerné par la visite. *
-* order = position dans la visite. *
-* params = informations à mettre à jour pour dot. *
-* *
-* Description : Construit les rangs pour dot en parcourant les noeuds. *
-* *
-* Retour : true si le parcours a été jusqu'à son terme, false sinon. *
-* *
-* Remarques : - *
-* *
-******************************************************************************/
-
-static bool rank_graph_nodes(GInstrBlock *block, BlockVisitOrder order, visitor_dot_params *params)
-{
- 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);
-
- rank = g_flow_block_get_rank(G_FLOW_BLOCK(block));
- /* BUG_ON(count >= params->count) */
-
- params->ranks[rank] = g_graph_node_append_name_to_rank(node, params->ranks[rank]);
-
- }
-
- return true;
-
-}
-
-
-/******************************************************************************
-* *
-* Paramètres : params = informations à mettre à jour pour dot. *
-* *
-* Description : Etablit le classement de tous les prochains noeuds pour dot. *
-* *
-* Retour : - *
-* *
-* Remarques : - *
-* *
-******************************************************************************/
-
-static void build_graph_ranking(visitor_dot_params *params)
-{
- unsigned int id; /* Identifiant unique */
- size_t i; /* Boucle de parcours #1 */
- char buffer[RANK_DESC_LEN]; /* Tampon pour les commandes */
- unsigned int j; /* Boucle de parcours #2 */
-
- id = 0;
-
- for (i = 0; i < params->count; i++)
- {
- if (params->ranks[i] == NULL)
- continue;
-
- snprintf(buffer, CLUSTER_DESC_LEN, DOT_IDENT "{ rank = same; rk%u;", id++);
- params->cmds = stradd(params->cmds, buffer);
-
- params->cmds = stradd(params->cmds, params->ranks[i]);
-
- params->cmds = stradd(params->cmds, " }\n");
-
- }
-
- params->cmds = stradd(params->cmds, DOT_IDENT);
-
- for (j = 0; j < id; j++)
- {
- if (j == 0)
- snprintf(buffer, CLUSTER_DESC_LEN, "rk%u", j);
- else
- snprintf(buffer, CLUSTER_DESC_LEN, " -> rk%u", j);
-
- params->cmds = stradd(params->cmds, buffer);
-
- }
-
- params->cmds = stradd(params->cmds, "\n");
-
-}
-
-
-/******************************************************************************
-* *
-* Paramètres : block = bloc d'instructions concerné par la visite. *
-* order = position dans la visite. *
-* params = informations à mettre à jour pour dot. *
-* *
-* Description : Construit les commandes pour dot en parcourant les noeuds. *
-* *
-* Retour : true si le parcours a été jusqu'à son terme, false sinon. *
-* *
-* Remarques : - *
-* *
-******************************************************************************/
-
-static bool register_graph_nodes(GInstrBlock *block, BlockVisitOrder order, visitor_dot_params *params)
-{
- char *cmds; /* Raccourci d'usage pratique */
- 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 */
-
- cmds = params->cmds;
-
- 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);
-
- cmds = g_graph_node_register_for_dot(node, cmds, params->level);
-
- }
- else
- {
- if (order == BVO_IN)
- {
- for (i = 0; i < params->level; i++)
- cmds = stradd(cmds, DOT_IDENT);
-
- snprintf(buffer, CLUSTER_DESC_LEN, "subgraph cluster_v%p {\n", block);
- cmds = stradd(cmds, buffer);
-
- params->level++;
-
- for (i = 0; i < params->level; i++)
- cmds = stradd(cmds, DOT_IDENT);
-
- cmds = stradd(cmds, "style=invisible;\n");
-
- }
- else if (order == BVO_OUT)
- {
- params->level--;
-
- for (i = 0; i < params->level; i++)
- cmds = stradd(cmds, DOT_IDENT);
-
- cmds = stradd(cmds, "}\n");
-
- }
-
- }
-
- params->cmds = cmds;
-
- return true;
-
-}
-
-
-/******************************************************************************
-* *
-* Paramètres : view = support contenant les différentes lignes. *
-* views = morceaux de code à afficher de façon organisée. *
-* count = quantité de ces morceaux de code. *
-* desc = description du graphique à compléter. [OUT] *
-* *
-* Description : Etablit tous les liens entre les différents morceaux de code.*
-* *
-* Retour : - *
-* *
-* Remarques : - *
-* *
-******************************************************************************/
-
-static char *complete_graph_links(const GtkGraphView *view, GtkViewPanel **views, size_t count, char *desc)
-{
- GLoadedBinary *binary; /* Binaire rattaché aux vues */
- GArchInstruction *instrs; /* Instructions pour assembleur*/
- GBufferView *buffer; /* Tampon d'une partie de code */
- vmpa_t end; /* Adresse finale du tampon */
- size_t i; /* Boucle de parcours #1 */
- GArchInstruction *last; /* Dernière instruc. d'un bloc */
- vmpa_t addr; /* Addresse d'instruction */
- GArchInstruction **dests; /* Instr. visée par une autre */
- InstructionLinkType *types; /* Type de lien entre lignes */
- size_t dcount; /* Nombre de liens de dest. */
- size_t j; /* Boucle de parcours #2 */
- size_t k; /* Boucle de parcours #3 */
- char cmd[LINKS_DESC_LEN]; /* Tampon pour l'ajout de liens*/
-
- if (count == 0)
- return desc;
-
- binary = gtk_view_panel_get_binary(views[0]);
- instrs = g_loaded_binary_get_instructions(binary);
-
- for (i = 0; i < count; i++)
- {
- buffer = gtk_buffer_view_get_buffer(GTK_BUFFER_VIEW(views[i]));
- g_buffer_view_get_restrictions(buffer, NULL, &end);
-
- last = g_arch_instruction_find_by_address(instrs, end, true);
- g_arch_instruction_get_location(last, NULL, NULL, &addr);
-
- if (g_arch_instruction_has_destinations(last))
- {
- dcount = g_arch_instruction_get_destinations(last, &dests, &types, NULL);
-
- for (j = 0; j < dcount; j++)
- {
- g_arch_instruction_get_location(dests[j], NULL, NULL, &addr);
-
- for (k = 0; k < count; k++)
- if (gtk_view_panel_contain_address(views[k], addr))
- break;
-
- if (k < count)
- switch (types[j])
- {
- case ILT_EXEC_FLOW:
- case ILT_JUMP:
- case ILT_CASE_JUMP:
- snprintf(cmd, LINKS_DESC_LEN,
- "_%p:s -> _%p:n [ltail=cluster_%p, lhead=cluster_%p];\n",
- views[i], views[k], views[i], views[k]);
- desc = stradd(desc, cmd);
- break;
-
- case ILT_JUMP_IF_TRUE:
- snprintf(cmd, LINKS_DESC_LEN,
- "_%p:s -> _%p:n [ltail=cluster_%p, lhead=cluster_%p, " \
- "color=green];\n",
- views[i], views[k], views[i], views[k]);
- desc = stradd(desc, cmd);
- break;
-
- case ILT_JUMP_IF_FALSE:
- snprintf(cmd, LINKS_DESC_LEN,
- "_%p:s -> _%p:n [ltail=cluster_%p, lhead=cluster_%p, " \
- "color=red];\n",
- views[i], views[k], views[i], views[k]);
- desc = stradd(desc, cmd);
- break;
-
- case ILT_LOOP:
- snprintf(cmd, LINKS_DESC_LEN,
- "_%p:s -> _%p:n [ltail=cluster_%p, lhead=cluster_%p, " \
- "color=blue];\n",
- views[i], views[k], views[i], views[k]);
- desc = stradd(desc, cmd);
- break;
-
- case ILT_CATCH_EXCEPTION:
- snprintf(cmd, LINKS_DESC_LEN,
- "_%p:s -> _%p:n [ltail=cluster_%p, lhead=cluster_%p, " \
- "color=gray];\n",
- views[i], views[k], views[i], views[k]);
- desc = stradd(desc, cmd);
- break;
-
- default:
- break;
-
- }
-
- }
-
- }
-
- }
-
- return desc;
-
-}
-
-
-
-
-
#include "ranks.h"
+#include "nodes/flow.h"
#include "nodes/virtual.h"
-
/* Mise en disposition de blocs en graphique (instance) */
struct _GGraphLayout
{
diff --git a/src/gtkext/graph/layout.h b/src/gtkext/graph/layout.h
index 13e0bcc..37598e8 100644
--- a/src/gtkext/graph/layout.h
+++ b/src/gtkext/graph/layout.h
@@ -21,31 +21,18 @@
*/
-#ifndef _GRAPH_LAYOUT_H
-#define _GRAPH_LAYOUT_H
+#ifndef _GTKEXT_GRAPH_LAYOUT_H
+#define _GTKEXT_GRAPH_LAYOUT_H
#include <stdbool.h>
-#include "../gtkgraphview.h"
-#include "../gtkviewpanel.h"
-
-
-
-/* Dispose une série de morceaux d'affichage en graphique. */
-bool build_graph_view(GtkGraphView *, GInstrBlock *, GtkViewPanel **, size_t);
-
-
-
-
-
#include "edge.h"
#include "../gtkbufferview.h"
-
#define G_TYPE_GRAPH_LAYOUT g_graph_layout_get_type()
#define G_GRAPH_LAYOUT(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), g_graph_layout_get_type(), GGraphLayout))
#define G_IS_GRAPH_LAYOUT(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), g_graph_layout_get_type()))
diff --git a/src/gtkext/graph/node-int.h b/src/gtkext/graph/node-int.h
index ae42196..18b6b20 100644
--- a/src/gtkext/graph/node-int.h
+++ b/src/gtkext/graph/node-int.h
@@ -64,24 +64,15 @@ struct _GGraphNode
visit_flow_nodes_fc visit; /* Visite des noeuds d'exécut° */
find_container_fc contain; /* Retrouve un conteneur */
- GtkWidget *view; /* Morceau de code représenté */
- char name[NODE_NAME_LEN]; /* Adresse sous forme humaine */
-
GtkAllocation alloc; /* Emplacement du bloc rattaché*/
pending_position pending_pos; /* Indication sur la position */
PendingPositionFlags pending_flag; /* Cible le champ valide */
GGraphNode *pending_rel; /* Eventuelle ref. relative */
-
-
- gint pending_x; /* Décallage à appliquer #1 */ /* TODO : remme */
- gint pending_y; /* Décallage à appliquer #2 */ /* TODO : remme */
-
bool direct_x; /* Position strictement vert. */
gint pending_left_margin; /* Limite à ne pas dépasser #1 */
gint pending_right_margin; /* Limite à ne pas dépasser #2 */
-
};
@@ -90,9 +81,6 @@ struct _GGraphNodeClass
{
GObjectClass parent; /* A laisser en premier */
- double dpi_x; /* Résolution en abscisse */
- double dpi_y; /* Résolution en ordonnée */
-
};
diff --git a/src/gtkext/graph/node.c b/src/gtkext/graph/node.c
index ec09941..439d4e7 100644
--- a/src/gtkext/graph/node.c
+++ b/src/gtkext/graph/node.c
@@ -40,10 +40,6 @@
/* -------------------------- GESTION DES NOEUDS A L'UNITE -------------------------- */
-/* Taille maximale des lignes de description de noeud */
-#define NODE_DESC_LEN 128
-
-
/* Initialise la classe des intermédiaires avec les noeuds dot. */
static void g_graph_node_class_init(GGraphNodeClass *);
@@ -82,52 +78,12 @@ G_DEFINE_TYPE(GGraphNode, g_graph_node, G_TYPE_OBJECT);
static void g_graph_node_class_init(GGraphNodeClass *klass)
{
GObjectClass *object; /* Autre version de la classe */
- GdkScreen *screen; /* Ecran par défaut */
- gint width; /* Largeur d'écran en pixels */
- gint height; /* Hauteur d'écran en pixels */
- gint width_mm; /* Largeur d'écran en mm. */
- gint height_mm; /* Hauteur d'écran en mm. */
object = G_OBJECT_CLASS(klass);
object->dispose = (GObjectFinalizeFunc/* ! */)g_graph_node_dispose;
object->finalize = (GObjectFinalizeFunc)g_graph_node_finalize;
- /* Calcul des résolutions */
-
- screen = gdk_screen_get_default();
-
- width = gdk_screen_get_width(screen);
- height = gdk_screen_get_height(screen);
-
- width_mm = gdk_screen_get_width_mm(screen);
- height_mm = gdk_screen_get_height_mm(screen);
-
- /**
- * Il y a 2.54 centimètres, soit 25.4 millimètres, dans un pouce.
- * On a donc :
- *
- * dpi = N pixels / (M millimètres / (25.4 millimètres / 1 pouce))
- * = N pixels / (M pouces / 25.4)
- * = N * 25.4 pixels / M pouces
- *
- */
-
- if (width_mm > 0 && height_mm > 0)
- {
- klass->dpi_x = (width * 25.4) / (double)width_mm;
- klass->dpi_y = (height * 25.4) / (double)height_mm;
- }
- else
- {
- klass->dpi_x = 96;
- klass->dpi_y = 96;
- }
-
-
- klass->dpi_x = 72;
- klass->dpi_y = 72;
-
}
@@ -165,8 +121,6 @@ static void g_graph_node_init(GGraphNode *node)
static void g_graph_node_dispose(GGraphNode *node)
{
- g_object_unref(G_OBJECT(node->view));
-
G_OBJECT_CLASS(g_graph_node_parent_class)->dispose(G_OBJECT(node));
}
@@ -193,38 +147,6 @@ static void g_graph_node_finalize(GGraphNode *node)
/******************************************************************************
* *
-* Paramètres : view = morceau d'affichage à représenter. *
-* *
-* Description : Constitue un intermédiaire entre un noeud dot et du code. *
-* *
-* Retour : Adresse de la structure mise en place. *
-* *
-* Remarques : - *
-* *
-******************************************************************************/
-
-GGraphNode *g_graph_node_new(GtkWidget *view)
-{
- GGraphNode *result; /* Structure à retourner */
-
- result = g_object_new(G_TYPE_GRAPH_NODE, NULL);
-
- result->view = view;
- g_object_ref(G_OBJECT(view));
-
- snprintf(result->name, NODE_NAME_LEN, "_%p", result->view);
-
- return result;
-
-}
-
-
-
-
-
-
-/******************************************************************************
-* *
* Paramètres : node = noeud graphique à consulter. *
* *
* Description : Fournit le rang du noeud dans le graphique. *
@@ -555,183 +477,6 @@ GGraphNode *g_graph_node_find_container_at_same_level(GGraphNode *nodes, GGraphN
-
-
-
-/******************************************************************************
-* *
-* Paramètres : node = intermédiaire à consulter. *
-* rank = description pour dot à compléter. *
-* *
-* Description : Inscrit le noeud au rang donné. *
-* *
-* Retour : Description dûment complétée. *
-* *
-* Remarques : - *
-* *
-******************************************************************************/
-
-char *g_graph_node_append_name_to_rank(const GGraphNode *node, char *rank)
-{
- char buffer[NODE_DESC_LEN]; /* Tampon pour les commandes */
-
- snprintf(buffer, NODE_DESC_LEN, " %s;", node->name);
-
- if (rank == NULL)
- rank = strdup(buffer);
- else
- rank = stradd(rank, buffer);
-
- return rank;
-
-}
-
-
-/******************************************************************************
-* *
-* Paramètres : node = intermédiaire à consulter. *
-* cmds = description pour dot à compléter. *
-* level = profondeur du noeud pour l'indentation. *
-* *
-* Description : Déclare l'intermédiaire en tant que noeud pour dot. *
-* *
-* Retour : Description dûment complétée. *
-* *
-* Remarques : - *
-* *
-******************************************************************************/
-
-char *g_graph_node_register_for_dot(const GGraphNode *node, char *cmds, unsigned int level)
-{
- GtkRequisition requisition; /* Taille à l'écran requise */
- unsigned int i; /* Boucle de parcours */
- char buffer[NODE_DESC_LEN]; /* Tampon pour les commandes */
-
- gtk_widget_get_preferred_size(node->view, NULL, &requisition);
-
- for (i = 0; i < level; i++)
- cmds = stradd(cmds, DOT_IDENT);
-
- snprintf(buffer, NODE_DESC_LEN, "subgraph cluster%s {\n", node->name);
- cmds = stradd(cmds, buffer);
-
- for (i = 0; i < (level + 1); i++)
- cmds = stradd(cmds, DOT_IDENT);
-
- cmds = stradd(cmds, "style=invisible;\n");
-
- for (i = 0; i < (level + 1); i++)
- cmds = stradd(cmds, DOT_IDENT);
-
- cmds = stradd(cmds, node->name);
- cmds = stradd(cmds, " [shape=box, fixedsize ");
-
- snprintf(buffer, NODE_DESC_LEN, ", width=\"%g\"",
- requisition.width / G_GRAPH_NODE_GET_CLASS(node)->dpi_x);
- cmds = stradd(cmds, buffer);
-
- snprintf(buffer, NODE_DESC_LEN, ", height=\"%g\"",
- requisition.height / G_GRAPH_NODE_GET_CLASS(node)->dpi_y);
- cmds = stradd(cmds, buffer);
-
- cmds = stradd(cmds, "];\n");
-
- for (i = 0; i < level; i++)
- cmds = stradd(cmds, DOT_IDENT);
-
- cmds = stradd(cmds, "}\n");
-
- return cmds;
-
-}
-
-
-/******************************************************************************
-* *
-* Paramètres : node = intermédiaire à consulter. *
-* view = support de destination. *
-* x = abscisse du point d'intégration. *
-* y = ordonnée du point d'intégration. *
-* *
-* Description : Place le morceau de code de l'intermédiaire à l'écran. *
-* *
-* Retour : - *
-* *
-* Remarques : - *
-* *
-******************************************************************************/
-
-void g_graph_node_place_old(GGraphNode *node, GtkGraphView *view, gint x, gint y)
-{
- GtkRequisition requisition; /* Taille à l'écran actuelle */
-
- gtk_widget_get_preferred_size(node->view, NULL, &requisition);
-
- x -= requisition.width / 2;
- y -= requisition.height / 2;
-
- node->alloc.x = x;
- node->alloc.y = y;
- node->alloc.width = requisition.width;
- node->alloc.height = requisition.height;
-
- gtk_graph_view_put(view, node->view, &node->alloc);
-
-}
-
-
-/******************************************************************************
-* *
-* Paramètres : node = intermédiaire à consulter. *
-* x = abscisse du point à relier. *
-* y = ordonnée du point à relier. *
-* points = liste de points à mettre à jour. [OUT] *
-* count = taille de cette même liste. [OUT] *
-* *
-* Description : Etablit une jonction ferme avec un noeud. *
-* *
-* Retour : - *
-* *
-* Remarques : - *
-* *
-******************************************************************************/
-
-void g_graph_node_connect(const GGraphNode *node, gint x, gint y, GdkPoint **points, size_t *count)
-{
- const GtkAllocation *alloc; /* Emplacement du bloc rattaché*/
-
- alloc = &node->alloc;
-
- *points = (GdkPoint *)realloc(*points, ++(*count) * sizeof(GdkPoint));
-
- /* Si le point est sur la gauche... */
- if (x < alloc->x)
- (*points)[*count - 1].x = alloc->x;
-
- /* Ou s'il est sur la droite... */
- else if (x > (alloc->x + alloc->width))
- (*points)[*count - 1].x = alloc->x + alloc->width;
-
- /* Ou s'il se trouve déjà bien placé... */
- else
- (*points)[*count - 1].x = x;
-
- /* Si le point est au dessus... */
- if (y < alloc->y)
- (*points)[*count - 1].y = alloc->y;
-
- /* Ou s'il est en dessous... */
- else if (y > (alloc->y + alloc->height))
- (*points)[*count - 1].y = alloc->y + alloc->height;
-
- /* Ou s'il se trouve déjà bien placé... */
- else
- (*points)[*count - 1].y = y;
-
-}
-
-
-
/* ---------------------------------------------------------------------------------- */
/* MANIPULATION D'ENSEMBLES DE NOEUDS */
/* ---------------------------------------------------------------------------------- */
@@ -879,75 +624,3 @@ GGraphNode *find_node_for_instruction(GGraphNode *nodes, GArchInstruction *instr
return result;
}
-
-
-
-
-
-
-/******************************************************************************
-* *
-* Paramètres : nodes = liste de noeuds à parcourir. *
-* count = taille de la liste. *
-* addrt = adresse de début du noeud recherché. *
-* *
-* Description : Recherche un noeud donné dans une série de noeuds. *
-* *
-* Retour : Noeud trouvé ou NULL si aucun. *
-* *
-* Remarques : - *
-* *
-******************************************************************************/
-
-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 */
- vmpa2t start; /* Adresse de départ du tampon */
-
- result = NULL;
-
- for (i = 0; i < count && result == NULL; i++)
- {
- buffer = gtk_buffer_view_get_buffer(GTK_BUFFER_VIEW(nodes[i]->view));
- g_buffer_view_get_restrictions(buffer, &start, NULL);
-
- if (cmp_vmpa(&start, addr) == 0)
- result = nodes[i];
-
- }
-
- return result;
-
-}
-
-
-/******************************************************************************
-* *
-* Paramètres : nodes = liste de noeuds à parcourir. *
-* count = taille de la liste. *
-* target = nom du noeud recherché. *
-* *
-* Description : Recherche un noeud donné dans une série de noeuds. *
-* *
-* Retour : Noeud trouvé ou NULL si aucun. *
-* *
-* Remarques : - *
-* *
-******************************************************************************/
-
-GGraphNode *find_graph_node_by_name(GGraphNode **nodes, size_t count, const char *target)
-{
- GGraphNode *result; /* Trouvaille à remonter */
- size_t i; /* Boucle de parcours */
-
- result = NULL;
-
- for (i = 0; i < count && result == NULL; i++)
- if (strcmp(nodes[i]->name, target) == 0)
- result = nodes[i];
-
- return result;
-
-}
diff --git a/src/gtkext/graph/node.h b/src/gtkext/graph/node.h
index 4dcb02a..c68719e 100644
--- a/src/gtkext/graph/node.h
+++ b/src/gtkext/graph/node.h
@@ -21,8 +21,8 @@
*/
-#ifndef _GRAPH_NODE_H
-#define _GRAPH_NODE_H
+#ifndef _GTKEXT_GRAPH_NODE_H
+#define _GTKEXT_GRAPH_NODE_H
#include "params.h"
@@ -34,14 +34,6 @@
-/* Indentation pour l'édition des commandes */
-#define DOT_IDENT " "
-
-/* Taille maximale des noms de noeud ("_%p") */
-#define NODE_NAME_LEN (3 + sizeof(GtkWidget *) * 2 + 1)
-
-
-
/* -------------------------- GESTION DES NOEUDS A L'UNITE -------------------------- */
@@ -98,11 +90,6 @@ typedef bool (* graph_node_visitor_cb) (GGraphNode *, GNodeVisitState, void *);
/* Indique le type définit par la GLib pour le noeud. */
GType g_graph_node_get_type(void);
-/* Constitue un intermédiaire entre un noeud dot et du code. */
-GGraphNode *g_graph_node_new(GtkWidget *);
-
-
-
/* Fournit le rang du noeud dans le graphique. */
unsigned int g_graph_node_get_rank(const GGraphNode *);
@@ -148,20 +135,6 @@ GGraphNode *g_graph_node_find_container_at_same_level(GGraphNode *, GGraphNode *
-/* Inscrit le noeud au rang donné. */
-char *g_graph_node_append_name_to_rank(const GGraphNode *, char *);
-
-/* Déclare l'intermédiaire en tant que noeud pour dot. */
-char *g_graph_node_register_for_dot(const GGraphNode *, char *, unsigned int);
-
-/* Place le morceau de code de l'intermédiaire à l'écran. */
-void g_graph_node_place_old(GGraphNode *, GtkGraphView *, gint , gint);
-
-/* Etablit une jonction ferme avec un noeud. */
-void g_graph_node_connect(const GGraphNode *, gint, gint, GdkPoint **, size_t *);
-
-
-
/* ----------------------- MANIPULATION D'ENSEMBLES DE NOEUDS ----------------------- */
@@ -176,13 +149,4 @@ 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, const vmpa2t *);
-
-/* Recherche un noeud donné dans une série de noeuds. */
-GGraphNode *find_graph_node_by_name(GGraphNode **, size_t, const char *);
-
-
-
#endif /* _GRAPH_NODE_H */
diff --git a/src/gtkext/graph/nodes/flow.c b/src/gtkext/graph/nodes/flow.c
index 863d86c..d691da5 100644
--- a/src/gtkext/graph/nodes/flow.c
+++ b/src/gtkext/graph/nodes/flow.c
@@ -474,21 +474,6 @@ bool g_flow_node_start_with(const GFlowNode *node, GArchInstruction *instr)
g_flow_block_get_boundary(node->block, &first, NULL);
- /*
- do
- {
- vmpa_t a1, a2;
-
- g_arch_instruction_get_location(instr, NULL, NULL, &a1);
- g_arch_instruction_get_location(first, NULL, NULL, &a2);
-
- printf(" -- compare %p (0x%08lx) vs %p (0x%08lx)\n",
- instr, a1, first, a2);
-
- }
- while (0);
- */
-
return (first == instr);
}
@@ -617,10 +602,6 @@ void g_flow_node_link(GFlowNode *node, GGraphLayout *layout, GGraphNode *nodes)
void g_flow_node_place(const GFlowNode *node, GtkGraphView *view)
{
- printf("[put] %p (%d ; %d) - (%d ; %d)\n", node,
- G_GRAPH_NODE(node)->alloc.x, G_GRAPH_NODE(node)->alloc.y,
- G_GRAPH_NODE(node)->alloc.width, G_GRAPH_NODE(node)->alloc.height);
-
gtk_graph_view_put(view, GTK_WIDGET(node->view), &G_GRAPH_NODE(node)->alloc);
}
@@ -951,7 +932,6 @@ GdkPoint g_flow_node_get_point_from_slot(const GFlowNode *node, bool entry, cons
}
-
slots_width = (count - 1) * SPACE_BETWEEN_SLOT;
slots_left = base->alloc.x + (base->alloc.width - slots_width) / 2;
@@ -960,17 +940,6 @@ GdkPoint g_flow_node_get_point_from_slot(const GFlowNode *node, bool entry, cons
result.x = slots_left + index * SPACE_BETWEEN_SLOT;
-
-
-#if 0
- slots_width = (count - 1) * SPACE_BETWEEN_SLOT;
- slots_left = base->alloc.x + (base->alloc.width - slots_width) / 2;
-
- index = (slot - slots)/* / sizeof(node_slot_t)*/;
- /* BUG_ON(index >= count); */
-
- result.x = slots_left + index * SPACE_BETWEEN_SLOT;
-#endif
return result;
}
diff --git a/src/gtkext/gtkgraphview.c b/src/gtkext/gtkgraphview.c
index f9621b8..70a803b 100644
--- a/src/gtkext/gtkgraphview.c
+++ b/src/gtkext/gtkgraphview.c
@@ -287,11 +287,6 @@ static void gtk_graph_view_prepare_resize(GtkGraphView *view)
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);
@@ -356,12 +351,6 @@ static void gtk_graph_view_define_main_address(GtkGraphView *view, const vmpa2t
view->allocs = (GtkAllocation *)calloc(view->children_count,
sizeof(GtkAllocation));
-
- /*
- build_graph_view(view, g_binary_routine_get_basic_blocks(view->routine),
- view->children, view->children_count);
- */
-
view->layout = g_graph_layout_new(g_binary_routine_get_basic_blocks(view->routine),
view->children, view->children_count);