summaryrefslogtreecommitdiff
path: root/src/arch/target.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/arch/target.c')
-rw-r--r--src/arch/target.c81
1 files changed, 81 insertions, 0 deletions
diff --git a/src/arch/target.c b/src/arch/target.c
index 3632b76..bce00a7 100644
--- a/src/arch/target.c
+++ b/src/arch/target.c
@@ -75,6 +75,9 @@ static void g_target_operand_finalize(GTargetOperand *);
/* Traduit un opérande en version humainement lisible. */
static void g_target_operand_print(const GTargetOperand *, GBufferLine *, AsmSyntax);
+/* Construit un petit résumé concis de l'opérande. */
+static char *g_target_operand_build_tooltip(const GTargetOperand *, const GLoadedBinary *);
+
/* Indique le type défini pour un opérande de valeur numérique. */
@@ -106,6 +109,7 @@ static void g_target_operand_class_init(GTargetOperandClass *klass)
object->finalize = (GObjectFinalizeFunc)g_target_operand_finalize;
operand->print = (operand_print_fc)g_target_operand_print;
+ operand->build_tooltip = (operand_build_tooltip_fc)g_target_operand_build_tooltip;
}
@@ -252,6 +256,83 @@ static void g_target_operand_print(const GTargetOperand *operand, GBufferLine *l
/******************************************************************************
* *
+* Paramètres : operand = opérande à consulter. *
+* binary = informations relatives au binaire chargé. *
+* *
+* Description : Construit un petit résumé concis de l'opérande. *
+* *
+* Retour : Chaîne de caractères à libérer après usage ou NULL. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static char *g_target_operand_build_tooltip(const GTargetOperand *operand, const GLoadedBinary *binary)
+{
+ char *result; /* Description à retourner */
+ SymbolType stype; /* Type de symbole identifié */
+ GBinRoutine *routine; /* Routine à manipuler */
+ const mrange_t *srange; /* Emplacement du symbole */
+ GBufferCache *cache; /* Tampon de désassemblage */
+ size_t index; /* Indice de ligne à traiter */
+ GBufferLine *line; /* Ligne présente à l'adresse */
+
+ result = NULL;
+
+ if (operand->symbol != NULL && operand->diff == 0)
+ {
+ stype = g_binary_symbol_get_target_type(operand->symbol);
+
+ switch (stype)
+ {
+ case STP_ROUTINE:
+ case STP_ENTRY_POINT:
+
+ routine = g_binary_symbol_get_routine(operand->symbol);
+
+ result = g_binary_routine_build_tooltip(routine, binary);
+
+ //g_object_unref(G_OBJECT(routine)); // TODO
+
+ break;
+
+ case STP_STRING:
+ case STP_RO_STRING:
+
+ srange = g_binary_symbol_get_range(operand->symbol);
+
+ cache = g_loaded_binary_get_disassembled_cache(binary);
+
+ index = g_buffer_cache_find_index_by_addr(cache, get_mrange_addr(srange), true);
+
+ index = g_buffer_cache_look_for_flag(cache, index, BLF_HAS_CODE);
+
+ line = g_buffer_cache_find_line_by_index(cache, index);
+
+ if (line != NULL)
+ {
+ result = g_buffer_line_get_text(line, BLC_ASSEMBLY, BLC_COUNT, true);
+ g_object_unref(G_OBJECT(line));
+ }
+
+ g_object_unref(G_OBJECT(cache));
+
+ break;
+
+ default:
+ break;
+
+ }
+
+ }
+
+ return result;
+
+}
+
+
+/******************************************************************************
+* *
* Paramètres : operand = structure dont le contenu est à consulter. *
* *
* Description : Renseigne la taille de la valeur indiquée à la construction. *