summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/analysis/binary.c7
-rw-r--r--src/analysis/line-int.h5
-rw-r--r--src/analysis/line.c26
-rw-r--r--src/analysis/line.h4
-rw-r--r--src/editor.c4
-rw-r--r--src/graph/layout.c92
-rw-r--r--src/gtkext/gtkbinview-int.h6
-rw-r--r--src/gtkext/gtkbinview.c22
-rw-r--r--src/gtkext/gtkbinview.h29
-rw-r--r--src/gtkext/gtkgraphview.c2
-rw-r--r--src/panel/symbols.c2
11 files changed, 92 insertions, 107 deletions
diff --git a/src/analysis/binary.c b/src/analysis/binary.c
index c528e96..09b7212 100644
--- a/src/analysis/binary.c
+++ b/src/analysis/binary.c
@@ -698,6 +698,9 @@ void establish_links_in_openida_binary(const openida_binary *binary)
break;
+ case ILT_JUMP_IF_FALSE:
+ break;
+
case ILT_JUMP_IF_TRUE:
target = g_rendering_line_find_by_address(binary->lines, NULL, addr);
@@ -705,11 +708,11 @@ void establish_links_in_openida_binary(const openida_binary *binary)
if (target != NULL)
{
g_rendering_line_link_with(iter, target, type);
- /*
+
target = g_rendering_line_get_next_iter(binary->lines, iter, NULL);
if (target != NULL)
g_rendering_line_link_with(iter, target, ILT_JUMP_IF_FALSE);
- */
+
}
break;
diff --git a/src/analysis/line-int.h b/src/analysis/line-int.h
index cf70695..4d181f9 100644
--- a/src/analysis/line-int.h
+++ b/src/analysis/line-int.h
@@ -54,8 +54,9 @@ struct _GRenderingLine
GRenderingLine **from; /* Origines des références */
size_t from_count; /* Nombre de ces origines */
- GRenderingLine *to; /* Eventuelle ligne visée */
- InstructionLinkType link_type; /* Type de visée */
+ GRenderingLine **to; /* Eventuelles lignes visées */
+ InstructionLinkType *links_type; /* Type des liens de dest. */
+ size_t to_count; /* Nombre de ces destinations */
PangoLayout *layout[MRD_COUNT]; /* Moteur de rendu du code/txt */
diff --git a/src/analysis/line.c b/src/analysis/line.c
index 42b034a..740673a 100644
--- a/src/analysis/line.c
+++ b/src/analysis/line.c
@@ -295,8 +295,14 @@ void g_rendering_line_link_with(GRenderingLine *line, GRenderingLine *dest, Inst
{
g_rendering_line_add_link_reference(dest, line);
- line->to = dest;
- line->link_type = type;
+ line->to_count++;
+
+ line->to = (GRenderingLine **)realloc(line->to, line->to_count * sizeof(GRenderingLine *));
+ line->links_type = (InstructionLinkType *)realloc(line->links_type, line->to_count * sizeof(InstructionLinkType));
+
+ line->to[line->to_count - 1] = dest;
+ line->links_type[line->to_count - 1] = type;
+
}
@@ -332,17 +338,18 @@ bool g_rendering_line_has_sources(const GRenderingLine *line)
* *
******************************************************************************/
-bool g_rendering_line_has_destination(const GRenderingLine *line)
+bool g_rendering_line_has_destinations(const GRenderingLine *line)
{
- return (line->to != NULL && line->link_type != ILT_CALL);
+ return (line->to_count > 1 || (line->to_count == 1 && line->links_type[0] != ILT_CALL));
}
/******************************************************************************
* *
-* Paramètres : line = ligne dont les informations sont à consulter. *
-* type = type de lien présent. [OUT] *
+* Paramètres : line = ligne dont les informations sont à consulter. *
+* lines = liste des lignes de destination. [OUT] *
+* types = liste des types de liens présents. [OUT] *
* *
* Description : Fournit la ligne de code de destination du lien de la ligne. *
* *
@@ -352,11 +359,12 @@ bool g_rendering_line_has_destination(const GRenderingLine *line)
* *
******************************************************************************/
-GRenderingLine *g_rendering_line_get_destination(const GRenderingLine *line, InstructionLinkType *type)
+size_t g_rendering_line_get_destinations(const GRenderingLine *line, GRenderingLine ***lines, InstructionLinkType **types)
{
- *type = line->link_type;
+ *lines = line->to;
+ *types = line->links_type;
- return line->to;
+ return line->to_count;
}
diff --git a/src/analysis/line.h b/src/analysis/line.h
index 4a293cf..5f22db2 100644
--- a/src/analysis/line.h
+++ b/src/analysis/line.h
@@ -97,10 +97,10 @@ void g_rendering_line_link_with(GRenderingLine *, GRenderingLine *, InstructionL
bool g_rendering_line_has_sources(const GRenderingLine *);
/* Indique si la ligne a une suite autre que la ligne suivante. */
-bool g_rendering_line_has_destination(const GRenderingLine *);
+bool g_rendering_line_has_destinations(const GRenderingLine *);
/* Fournit la ligne de code de destination du lien de la ligne. */
-GRenderingLine *g_rendering_line_get_destination(const GRenderingLine *, InstructionLinkType *);
+size_t g_rendering_line_get_destinations(const GRenderingLine *, GRenderingLine ***, InstructionLinkType **);
/* Procède à l'initialisation des bases d'une représentation. */
void g_rendering_line_draw(GRenderingLine *, GdkDrawable *, GdkGC *, gint, gint, gint, gint, MainRendering);
diff --git a/src/editor.c b/src/editor.c
index eed74fb..66187c8 100644
--- a/src/editor.c
+++ b/src/editor.c
@@ -770,7 +770,7 @@ void mcb_view_change_support(GtkRadioMenuItem *menuitem, GObject *ref)
void mcb_view_vaddress(GtkCheckMenuItem *menuitem, gpointer data)
{
- GtkBinview *binview; /* Zone de code principale */
+ GtkBinView *binview; /* Zone de code principale */
gboolean active; /* Etat de sélection du menu */
binview = GTK_BIN_VIEW(g_object_get_data(G_OBJECT(data), "binview"));
@@ -796,7 +796,7 @@ void mcb_view_vaddress(GtkCheckMenuItem *menuitem, gpointer data)
void mcb_view_code(GtkCheckMenuItem *menuitem, gpointer data)
{
- GtkBinview *binview; /* Zone de code principale */
+ GtkBinView *binview; /* Zone de code principale */
gboolean active; /* Etat de sélection du menu */
binview = GTK_BIN_VIEW(g_object_get_data(G_OBJECT(data), "binview"));
diff --git a/src/graph/layout.c b/src/graph/layout.c
index 725d76c..0b4a6c6 100644
--- a/src/graph/layout.c
+++ b/src/graph/layout.c
@@ -127,77 +127,53 @@ static char *complete_graph_links(const GtkGraphView *view, GtkBinView **views,
{
size_t i; /* Boucle de parcours #1 */
GRenderingLine *last; /* Dernière ligne d'un bloc */
- GRenderingLine *dest; /* Ligne visée par une autre */
- InstructionLinkType type; /* Type de lien entre lignes */
- bool link_next; /* Lien auto. avec la suivante */
+ GRenderingLine **dests; /* Ligne 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 */
vmpa_t addr; /* Addresse de destination */
- size_t k; /* Boucle de parcours #2 */
+ size_t k; /* Boucle de parcours #3 */
char buffer[LINKS_DESC_LEN]; /* Tampon pour l'ajout de liens*/
+ GRenderingLine *next; /* Ligne suivante dans le flux */
for (i = 0; i < count; i++)
{
last = gtk_bin_view_get_last_line(views[i]);
- if (g_rendering_line_has_destination(last))
+ if (g_rendering_line_has_destinations(last))
{
- link_next = false;
+ dcount = g_rendering_line_get_destinations(last, &dests, &types);
- /* Premier saut : exigé par l'instruction */
-
- dest = g_rendering_line_get_destination(last, &type);
-
- addr = get_rendering_line_address(dest);
-
- for (k = 0; k < count; k++)
- if (gtk_bin_view_contain_address(views[k], addr))
- break;
-
- if (k < count)
- switch (type)
- {
- case ILT_JUMP:
- snprintf(buffer, LINKS_DESC_LEN, "_%p -> _%p;\n", views[i], views[k]);
- desc = stradd(desc, buffer);
- break;
-
- case ILT_JUMP_IF_TRUE:
- snprintf(buffer, LINKS_DESC_LEN, "_%p -> _%p;\n", views[i], views[k]);
- desc = stradd(desc, buffer);
- link_next = true;
- break;
-
- case ILT_JUMP_IF_FALSE:
- snprintf(buffer, LINKS_DESC_LEN, "_%p -> _%p;\n", views[i], views[k]);
- desc = stradd(desc, buffer);
- link_next = true;
- break;
-
- default:
- break;
-
- }
-
- /* Second saut : automatique selon l'instruction */
-
- if (link_next)
+ for (j = 0; j < dcount; j++)
{
- dest = g_rendering_line_get_next_iter(gtk_bin_view_get_lines(GTK_BIN_VIEW(view)),
- last,
- gtk_bin_view_get_last_line(GTK_BIN_VIEW(view)));
-
- if (dest == NULL) continue;
-
- addr = get_rendering_line_address(dest);
+ addr = get_rendering_line_address(dests[j]);
for (k = 0; k < count; k++)
if (gtk_bin_view_contain_address(views[k], addr))
break;
if (k < count)
- {
- snprintf(buffer, LINKS_DESC_LEN, "_%p -> _%p;\n", views[i], views[k]);
- desc = stradd(desc, buffer);
- }
+ switch (types[j])
+ {
+ case ILT_JUMP:
+ snprintf(buffer, LINKS_DESC_LEN, "_%p -> _%p;\n", views[i], views[k]);
+ desc = stradd(desc, buffer);
+ break;
+
+ case ILT_JUMP_IF_TRUE:
+ snprintf(buffer, LINKS_DESC_LEN, "_%p -> _%p;\n", views[i], views[k]);
+ desc = stradd(desc, buffer);
+ break;
+
+ case ILT_JUMP_IF_FALSE:
+ snprintf(buffer, LINKS_DESC_LEN, "_%p -> _%p;\n", views[i], views[k]);
+ desc = stradd(desc, buffer);
+ break;
+
+ default:
+ break;
+
+ }
}
@@ -206,13 +182,13 @@ static char *complete_graph_links(const GtkGraphView *view, GtkBinView **views,
/* Si la ligne n'est pas la dernière, on suit le flux normal */
else if (last != gtk_bin_view_get_last_line(view))
{
- dest = g_rendering_line_get_next_iter(gtk_bin_view_get_lines(GTK_BIN_VIEW(view)),
+ next = g_rendering_line_get_next_iter(gtk_bin_view_get_lines(GTK_BIN_VIEW(view)),
last,
gtk_bin_view_get_last_line(GTK_BIN_VIEW(view)));
- if (dest == NULL) continue;
+ if (next == NULL) continue;
- addr = get_rendering_line_address(dest);
+ addr = get_rendering_line_address(next);
for (k = 0; k < count; k++)
if (gtk_bin_view_contain_address(views[k], addr))
diff --git a/src/gtkext/gtkbinview-int.h b/src/gtkext/gtkbinview-int.h
index 2410915..cea40a1 100644
--- a/src/gtkext/gtkbinview-int.h
+++ b/src/gtkext/gtkbinview-int.h
@@ -34,7 +34,7 @@
/* Définit les lignes à associer à la représentation. */
-typedef void (* set_rendering_lines_fc) (GtkBinview *, GRenderingLine *, GRenderingLine *);
+typedef void (* set_rendering_lines_fc) (GtkBinView *, GRenderingLine *, GRenderingLine *);
/* Réagit à la sélection externe d'une adresse. */
typedef void (* define_main_address_fc) (GtkBinView *, vmpa_t);
@@ -43,7 +43,7 @@ typedef void (* define_main_address_fc) (GtkBinView *, vmpa_t);
typedef bool (* get_addr_coordinates_fc) (const GtkBinView *, vmpa_t, gint *, gint *);
-struct _GtkBinview
+struct _GtkBinView
{
GtkFixed parent; /* A laisser en premier */
@@ -62,7 +62,7 @@ struct _GtkBinview
};
-struct _GtkBinviewClass
+struct _GtkBinViewClass
{
GtkFixedClass parent; /* A laisser en premier */
diff --git a/src/gtkext/gtkbinview.c b/src/gtkext/gtkbinview.c
index aa231f2..f0470bc 100644
--- a/src/gtkext/gtkbinview.c
+++ b/src/gtkext/gtkbinview.c
@@ -40,7 +40,7 @@ static gboolean gtk_bin_view_expose(GtkBinView *, GdkEventExpose *);
/* Détermine le type du composant d'affichage des morceaux. */
-G_DEFINE_TYPE(GtkBinview, gtk_binview, GTK_TYPE_FIXED)
+G_DEFINE_TYPE(GtkBinView, gtk_binview, GTK_TYPE_FIXED)
@@ -59,7 +59,7 @@ G_DEFINE_TYPE(GtkBinview, gtk_binview, GTK_TYPE_FIXED)
* *
******************************************************************************/
-static void gtk_binview_class_init(GtkBinviewClass *class)
+static void gtk_binview_class_init(GtkBinViewClass *class)
{
GtkWidgetClass *widget_class; /* Classe de haut niveau */
@@ -83,7 +83,7 @@ static void gtk_binview_class_init(GtkBinviewClass *class)
* *
******************************************************************************/
-static void gtk_binview_init(GtkBinview *view)
+static void gtk_binview_init(GtkBinView *view)
{
gtk_fixed_set_has_window(GTK_FIXED(view), TRUE);
@@ -211,7 +211,7 @@ static gboolean gtk_bin_view_expose(GtkBinView *view, GdkEventExpose *event)
* *
******************************************************************************/
-void gtk_bin_view_show_border(GtkBinview *view, bool show)
+void gtk_bin_view_show_border(GtkBinView *view, bool show)
{
view->show_border = show;
@@ -235,7 +235,7 @@ void gtk_bin_view_show_border(GtkBinview *view, bool show)
* *
******************************************************************************/
-void gtk_bin_view_set_rendering_lines(GtkBinview *view, openida_binary *binary, GRenderingLine *lines, GRenderingLine *last)
+void gtk_bin_view_set_rendering_lines(GtkBinView *view, openida_binary *binary, GRenderingLine *lines, GRenderingLine *last)
{
view->binary = binary;
@@ -259,7 +259,7 @@ void gtk_bin_view_set_rendering_lines(GtkBinview *view, openida_binary *binary,
* *
******************************************************************************/
-GRenderingLine *gtk_bin_view_get_lines(const GtkBinview *view)
+GRenderingLine *gtk_bin_view_get_lines(const GtkBinView *view)
{
return view->lines;
@@ -278,7 +278,7 @@ GRenderingLine *gtk_bin_view_get_lines(const GtkBinview *view)
* *
******************************************************************************/
-GRenderingLine *gtk_bin_view_get_last_line(const GtkBinview *view)
+GRenderingLine *gtk_bin_view_get_last_line(const GtkBinView *view)
{
return view->last; /* FIXME last == NULL */
@@ -309,7 +309,7 @@ GRenderingLine *gtk_bin_view_get_last_line(const GtkBinview *view)
* *
******************************************************************************/
-void gtk_binview_show_vaddress(GtkBinview *binview, gboolean show)
+void gtk_binview_show_vaddress(GtkBinView *binview, gboolean show)
{
GList *list; /* Ensemble des enfants */
GList *iter; /* Boucle de parcours */
@@ -345,7 +345,7 @@ void gtk_binview_show_vaddress(GtkBinview *binview, gboolean show)
* *
******************************************************************************/
-void gtk_binview_show_code(GtkBinview *binview, gboolean show)
+void gtk_binview_show_code(GtkBinView *binview, gboolean show)
{
GList *list; /* Ensemble des enfants */
GList *iter; /* Boucle de parcours */
@@ -378,7 +378,7 @@ void gtk_binview_show_code(GtkBinview *binview, gboolean show)
* *
******************************************************************************/
-bool gtk_bin_view_contain_address(const GtkBinview *view, vmpa_t addr)
+bool gtk_bin_view_contain_address(const GtkBinView *view, vmpa_t addr)
{
gint dummy_x; /* Abscisse pour l'appel */
gint dummy_y; /* Ordonnée pour l'appel */
@@ -401,7 +401,7 @@ bool gtk_bin_view_contain_address(const GtkBinview *view, vmpa_t addr)
* *
******************************************************************************/
-void gtk_bin_view_scroll_to_address(GtkBinview *view, vmpa_t addr)
+void gtk_bin_view_scroll_to_address(GtkBinView *view, vmpa_t addr)
{
gint x; /* Abscisse à garantir */
gint y; /* Ordonnée à garantir */
diff --git a/src/gtkext/gtkbinview.h b/src/gtkext/gtkbinview.h
index 241669c..e443161 100644
--- a/src/gtkext/gtkbinview.h
+++ b/src/gtkext/gtkbinview.h
@@ -33,18 +33,15 @@
#define GTK_TYPE_BIN_VIEW (gtk_binview_get_type())
-#define GTK_BIN_VIEW(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), GTK_TYPE_BIN_VIEW, GtkBinview))
-#define GTK_BIN_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), GTK_TYPE_BIN_VIEW, GtkBinviewClass))
+#define GTK_BIN_VIEW(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), GTK_TYPE_BIN_VIEW, GtkBinView))
+#define GTK_BIN_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), GTK_TYPE_BIN_VIEW, GtkBinViewClass))
#define GTK_IS_BIN_VIEW(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), GTK_TYPE_BIN_VIEW))
#define GTK_IS_BIN_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), GTK_TYPE_BIN_VIEW))
-#define GTK_BIN_VIEW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), GTK_TYPE_BIN_VIEW, GtkBinviewClass))
+#define GTK_BIN_VIEW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), GTK_TYPE_BIN_VIEW, GtkBinViewClass))
-typedef struct _GtkBinview GtkBinview;
-typedef struct _GtkBinviewClass GtkBinviewClass;
-
-typedef struct _GtkBinview GtkBinView;
-typedef struct _GtkBinviewClass GtkBinViewClass;
+typedef struct _GtkBinView GtkBinView;
+typedef struct _GtkBinViewClass GtkBinViewClass;
@@ -55,36 +52,36 @@ GType gtk_binview_get_type(void);
GtkWidget* gtk_binview_new(void);
/* Définit si une bordure est à afficher. */
-void gtk_bin_view_show_border(GtkBinview *, bool);
+void gtk_bin_view_show_border(GtkBinView *, bool);
/* Définit les lignes à associer à la représentation. */
-void gtk_bin_view_set_rendering_lines(GtkBinview *, openida_binary *, GRenderingLine *, GRenderingLine *);
+void gtk_bin_view_set_rendering_lines(GtkBinView *, openida_binary *, GRenderingLine *, GRenderingLine *);
/* Fournit la liste des lignes associées à la représentation. */
-GRenderingLine *gtk_bin_view_get_lines(const GtkBinview *);
+GRenderingLine *gtk_bin_view_get_lines(const GtkBinView *);
/* Fournit la dernière ligne associée à la représentation. */
-GRenderingLine *gtk_bin_view_get_last_line(const GtkBinview *);
+GRenderingLine *gtk_bin_view_get_last_line(const GtkBinView *);
/* Choisit d'afficher les adresses virtuelles ou non. */
-void gtk_binview_show_vaddress(GtkBinview *, gboolean);
+void gtk_binview_show_vaddress(GtkBinView *, gboolean);
/* Choisit d'afficher le code brut ou non. */
-void gtk_binview_show_code(GtkBinview *, gboolean);
+void gtk_binview_show_code(GtkBinView *, gboolean);
/* Indique si la vue contient une addrese donnée. */
-bool gtk_bin_view_contain_address(const GtkBinview *, vmpa_t);
+bool gtk_bin_view_contain_address(const GtkBinView *, vmpa_t);
/* S'assure qu'une adresse donnée est visible à l'écran. */
-void gtk_bin_view_scroll_to_address(GtkBinview *, vmpa_t);
+void gtk_bin_view_scroll_to_address(GtkBinView *, vmpa_t);
diff --git a/src/gtkext/gtkgraphview.c b/src/gtkext/gtkgraphview.c
index 0db03f0..0332557 100644
--- a/src/gtkext/gtkgraphview.c
+++ b/src/gtkext/gtkgraphview.c
@@ -433,7 +433,7 @@ static GtkBinView **gtk_graph_view_load_nodes(openida_binary *binary, GRendering
if (begin == NULL) begin = iter;
end = iter;
- if (g_rendering_line_has_destination(iter))
+ if (g_rendering_line_has_destinations(iter))
{
result = (GtkBinView **)realloc(result, ++(*count) * sizeof(GtkBinView *));
diff --git a/src/panel/symbols.c b/src/panel/symbols.c
index 124b345..a31cc4b 100644
--- a/src/panel/symbols.c
+++ b/src/panel/symbols.c
@@ -128,7 +128,7 @@ void change_symbols_selection(GtkTreeSelection *selection, gpointer data)
GtkTreeModel *model;
gchar *string; /* Chaîne sélectionnée */
vmpa_t address; /* Adresse à rejoindre */
- GtkBinview *binview; /* Affichage à faire défiler */
+ GtkBinView *binview; /* Affichage à faire défiler */
if (gtk_tree_selection_get_selected(selection, &model, &iter))
{