From c81d2f989a14ed083bd99eff91791eca29bf3799 Mon Sep 17 00:00:00 2001
From: Cyrille Bagard <nocbos@gmail.com>
Date: Wed, 28 Nov 2018 00:15:45 +0100
Subject: Logged loaded formats.

---
 plugins/dwarf/format.c  | 54 +++++++++++++++++++++++++++++++++++++++++++++++++
 src/analysis/binary.c   |  9 ++++++++-
 src/format/executable.c | 16 ++++++++++-----
 3 files changed, 73 insertions(+), 6 deletions(-)

diff --git a/plugins/dwarf/format.c b/plugins/dwarf/format.c
index 3883606..96ce831 100644
--- a/plugins/dwarf/format.c
+++ b/plugins/dwarf/format.c
@@ -48,6 +48,12 @@ static void g_dwarf_format_dispose(GDwarfFormat *);
 /* Procède à la libération totale de la mémoire. */
 static void g_dwarf_format_finalize(GDwarfFormat *);
 
+/* Indique la désignation interne du format. */
+static const char *g_dwarf_format_get_name(const GDwarfFormat *);
+
+/* Fournit une description humaine du format. */
+static const char *g_dwarf_format_get_description(const GDwarfFormat *);
+
 /* Assure l'interprétation d'un format en différé. */
 static bool g_dwarf_format_analyze(GDwarfFormat *, wgroup_id_t, GtkStatusStack *);
 
@@ -119,6 +125,8 @@ static void g_dwarf_format_class_init(GDwarfFormatClass *klass)
 
     fmt = G_BIN_FORMAT_CLASS(klass);
 
+    fmt->get_name = (format_get_name_fc)g_dwarf_format_get_name;
+    fmt->get_desc = (format_get_desc_fc)g_dwarf_format_get_description;
     fmt->analyze = (format_analyze_fc)g_dwarf_format_analyze;
 
 }
@@ -223,6 +231,52 @@ GDbgFormat *g_dwarf_format_new(GExeFormat *parent)
 
 /******************************************************************************
 *                                                                             *
+*  Paramètres  : format = description de l'exécutable à consulter.            *
+*                                                                             *
+*  Description : Indique la désignation interne du format.                    *
+*                                                                             *
+*  Retour      : Description du format.                                       *
+*                                                                             *
+*  Remarques   : -                                                            *
+*                                                                             *
+******************************************************************************/
+
+static const char *g_dwarf_format_get_name(const GDwarfFormat *format)
+{
+    const char *result;                     /* Désignation à retourner     */
+
+    result = "dwarf";
+
+    return result;
+
+}
+
+
+/******************************************************************************
+*                                                                             *
+*  Paramètres  : format = description de l'exécutable à consulter.            *
+*                                                                             *
+*  Description : Fournit une description humaine du format.                   *
+*                                                                             *
+*  Retour      : Description du format.                                       *
+*                                                                             *
+*  Remarques   : -                                                            *
+*                                                                             *
+******************************************************************************/
+
+static const char *g_dwarf_format_get_description(const GDwarfFormat *format)
+{
+    const char *result;                     /* Désignation à retourner     */
+
+    result = "DWARF Debugging Information Format";
+
+    return result;
+
+}
+
+
+/******************************************************************************
+*                                                                             *
 *  Paramètres  : format = format chargé dont l'analyse est lancée.            *
 *                gid    = groupe de travail dédié.                            *
 *                status = barre de statut à tenir informée.                   *
diff --git a/src/analysis/binary.c b/src/analysis/binary.c
index 8946311..8fc34f2 100644
--- a/src/analysis/binary.c
+++ b/src/analysis/binary.c
@@ -1430,8 +1430,8 @@ static bool g_loaded_binary_analyze(GLoadedBinary *binary, wgroup_id_t gid, GtkS
 {
     bool result;                            /* Bilan à retourner           */
     GBinFormat *format;                     /* Format lié au binaire       */
-    const char *arch;                       /* Architecture d'exécution    */
     const char *desc;                       /* Description humaine associée*/
+    const char *arch;                       /* Architecture d'exécution    */
     bool has_virt;                          /* Présence de virtuel ?       */
     GProcContext *context;                  /* Contexte de suivi dédié     */
     GWidthTracker *tracker;                 /* Gestionnaire de largeur     */
@@ -1440,6 +1440,13 @@ static bool g_loaded_binary_analyze(GLoadedBinary *binary, wgroup_id_t gid, GtkS
 
     format = G_BIN_FORMAT(binary->format);
 
+    desc = g_binary_format_get_description(format);
+
+    if (desc == NULL)
+        log_simple_message(LMT_WARNING, _("Unnamed format"));
+    else
+        log_variadic_message(LMT_INFO, _("Selected format: %s"), desc);
+
     result = g_binary_format_analyze(format, gid, status);
     if (!result) goto glba_exit;
 
diff --git a/src/format/executable.c b/src/format/executable.c
index fcc0acd..1f21ca3 100644
--- a/src/format/executable.c
+++ b/src/format/executable.c
@@ -30,6 +30,9 @@
 #include <stdlib.h>
 
 
+#include <i18n.h>
+
+
 #include "executable-int.h"
 #include "format.h"
 #include "../core/logs.h"
@@ -161,17 +164,20 @@ static void g_executable_format_finalize(GExeFormat *format)
 
 void g_exe_format_add_debug_info(GExeFormat *format, GDbgFormat *info)
 {
-    /* Ajout dans la liste */
+    const char *desc;                       /* Description humaine associée*/
+
+    desc = g_binary_format_get_description(G_BIN_FORMAT(info));
+
+    if (desc == NULL)
+        log_simple_message(LMT_WARNING, _("Unnamed debug information"));
+    else
+        log_variadic_message(LMT_INFO, _("Found debug information: %s"), desc);
 
     format->debugs = (GDbgFormat **)realloc(format->debugs,
                                             ++format->debugs_count * sizeof(GDbgFormat *));
 
     format->debugs[format->debugs_count - 1] = info;
 
-    /* Intégration des symboles */
-
-    /* TODO */
-
 }
 
 
-- 
cgit v0.11.2-87-g4458