summaryrefslogtreecommitdiff
path: root/src/analysis/disass/dragon.h
blob: 74bb2e9181190413cbbb0445b5c4dedd6355522f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97

/* Chrysalide - Outil d'analyse de fichiers binaires
 * dragon.h - prototypes pour les capacités apportées par la lecture du livre du dragon
 *
 * Copyright (C) 2016-2017 Cyrille Bagard
 *
 *  This file is part of Chrysalide.
 *
 *  Chrysalide 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.
 *
 *  Chrysalide 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 _ANALYSIS_DISASS_DRAGON_H
#define _ANALYSIS_DISASS_DRAGON_H


#include "block.h"
#include "../../arch/processor.h"
#include "../../common/bits.h"



/* -------------------------- DECOUPAGES DE CODE EN NOEUDS -------------------------- */


/* Description de noeud, en référence à "Compilers: Principles, Techniques, and Tools" */
typedef struct _dragon_node dragon_node;


/* Fournit les instructions bornant un noeud de code. */
void get_dragon_node_bounding_instructions(dragon_node *, GArchInstruction **, GArchInstruction **);

/* Fournit un noeud particulier à partir d'une liste. */
dragon_node *get_dragon_node(dragon_node *, size_t);

/* Fournit l'indice d'un noeud particulier à partir d'une liste. */
size_t get_dragon_node_index(dragon_node *, dragon_node *);

/* Recherche un noeud selon son intruction de départ. */
dragon_node *find_node_for_instruction(dragon_node *, size_t, bool, const GArchInstruction *);

/* Marque tous les noeuds accessibles pour chaque noeud de code. */
void compute_all_paths(dragon_node *, size_t);

/* Fournit la liste des noeuds accessibles depuis un autre. */
const bitfield_t *get_paths_bits(const dragon_node *);

/* Détermine toute la chaîne hiérarchique de domination. */
void compute_all_dominators(dragon_node *, size_t);

/* Fournit la liste des noeuds dominés par un noeud. */
const bitfield_t *get_domination_bits(const dragon_node *);



/* ---------------------------- ENCAPSULATION DES NOEUDS ---------------------------- */


/* Concentration de tous les efforts */
typedef struct _dragon_knight dragon_knight;


/* Attaque la complexité d'un code en créant des noeuds. */
dragon_knight *begin_dragon_knight(GArchProcessor *, const instr_coverage *, const mrange_t *, const vmpa2t *);

/* Supprime de la mémoire les données d'une complexité de code. */
void end_dragon_knight(dragon_knight *);

/* Fournit les éléments utiles à un traitement de blocs de code. */
void get_dragon_knight_content(const dragon_knight *, dragon_node **, size_t *);

/* Fournit un noeud particulier à partir d'une liste. */
dragon_node *get_dragon_knight_node(const dragon_knight *, size_t);

/* Fournit l'indice d'un noeud particulier à partir d'une liste. */
size_t get_dragon_knight_node_index(const dragon_knight *, dragon_node *);

/* Recherche un noeud selon son intruction de départ. */
dragon_node *find_knight_node_for_instruction(const dragon_knight *, bool, const GArchInstruction *);

/* Traduit une complexité de noeuds en liste de blocs basiques. */
GBlockList *translate_dragon_knight(const dragon_knight *);



#endif  /* _ANALYSIS_DISASS_DRAGON_H */