diff options
Diffstat (limited to 'src/analysis/disass')
| -rw-r--r-- | src/analysis/disass/dragon.c | 20 | ||||
| -rw-r--r-- | src/analysis/disass/links.c | 8 | ||||
| -rw-r--r-- | src/analysis/disass/loop.c | 4 | ||||
| -rw-r--r-- | src/analysis/disass/rank.c | 14 | 
4 files changed, 34 insertions, 12 deletions
diff --git a/src/analysis/disass/dragon.c b/src/analysis/disass/dragon.c index 44d82da..04f5190 100644 --- a/src/analysis/disass/dragon.c +++ b/src/analysis/disass/dragon.c @@ -104,10 +104,10 @@ static dragon_node *create_dragon_nodes(GArchProcessor *proc, const instr_covera      size_t scount;                          /* Nombre de liens de source   */      bool cut;                               /* Un découpage a été réalisé ?*/      size_t i;                               /* Boucle de parcours          */ -    instr_link_t *source;                   /* Instruction de source liée  */ +    const instr_link_t *source;             /* Instruction de source liée  */      dragon_node *new;                       /* Nouvel élément à créer      */      size_t dcount;                          /* Nombre de liens de dest.    */ -    instr_link_t *dest;                     /* Instruction de destination  */ +    const instr_link_t *dest;               /* Instruction de destination  */      result = NULL;      *count = 0; @@ -204,6 +204,8 @@ static dragon_node *create_dragon_nodes(GArchProcessor *proc, const instr_covera                  } +                unref_instr_link(source); +              }              g_arch_instruction_unlock_src(instr); @@ -238,6 +240,8 @@ static dragon_node *create_dragon_nodes(GArchProcessor *proc, const instr_covera              } +            unref_instr_link(dest); +          }          g_arch_instruction_unlock_dest(instr); @@ -448,7 +452,7 @@ void compute_all_paths(dragon_node *nodes, size_t count)      {          size_t dcount;                      /* Nombre de liens de dest.    */          size_t i;                           /* Boucle de parcours          */ -        instr_link_t *dest;                 /* Instructions de destination */ +        const instr_link_t *dest;           /* Instructions de destination */          dragon_node *next;                  /* Noeud suivant dans le code  */          size_t id;                          /* Indice du bit associé       */ @@ -483,6 +487,8 @@ void compute_all_paths(dragon_node *nodes, size_t count)              } +            unref_instr_link(dest); +          }          g_arch_instruction_unlock_dest(node->last); @@ -535,7 +541,7 @@ void compute_all_dominators(dragon_node *nodes, size_t count)      dragon_node *predecessor;               /* Noeud prédécesseur direct   */      size_t scount;                          /* Nombre de liens de source   */      size_t i;                               /* Boucle de parcours #2       */ -    instr_link_t *source;                   /* Instruction d'origine       */ +    const instr_link_t *source;             /* Instruction d'origine       */      inter = create_bit_field(count, false); @@ -575,9 +581,9 @@ void compute_all_dominators(dragon_node *nodes, size_t count)                          */ -                        if (predecessor == NULL) break; +                        if (predecessor != NULL) +                            and_bit_field(inter, predecessor->bits); -                        and_bit_field(inter, predecessor->bits);                          break;                      default: @@ -585,6 +591,8 @@ void compute_all_dominators(dragon_node *nodes, size_t count)                  } +                unref_instr_link(source); +              }              g_arch_instruction_unlock_src(node->first); diff --git a/src/analysis/disass/links.c b/src/analysis/disass/links.c index ffdee36..381aedc 100644 --- a/src/analysis/disass/links.c +++ b/src/analysis/disass/links.c @@ -56,7 +56,7 @@ void establish_natural_link(GArchInstruction *instr, GArchInstruction *prev)  {      size_t count;                           /* Nbre de sources affichées   */      bool has_src;                           /* Présence de sources ?       */ -    instr_link_t *other;                    /* Instruction diverse liée    */ +    const instr_link_t *other;              /* Instruction diverse liée    */      size_t i;                               /* Boucle de parcours          */      bool no_natural;                        /* Aucun lien naturel présent  */      bool no_need;                           /* Pas de besoin pour ce lien  */ @@ -79,6 +79,8 @@ void establish_natural_link(GArchInstruction *instr, GArchInstruction *prev)          if (other->type != ILT_REF)              has_src = true; +        unref_instr_link(other); +      }      g_arch_instruction_unlock_src(instr); @@ -135,6 +137,8 @@ void establish_natural_link(GArchInstruction *instr, GArchInstruction *prev)          } +        unref_instr_link(other); +      }   check_done: @@ -173,6 +177,8 @@ void establish_natural_link(GArchInstruction *instr, GArchInstruction *prev)              } +            unref_instr_link(other); +          }          g_arch_instruction_unlock_src(instr); diff --git a/src/analysis/disass/loop.c b/src/analysis/disass/loop.c index 9312917..40ce441 100644 --- a/src/analysis/disass/loop.c +++ b/src/analysis/disass/loop.c @@ -51,7 +51,7 @@ static void detect_back_edges(dragon_node *nodes, size_t count)      GArchInstruction *last;                 /* Instruction finale de noeud */      size_t dcount;                          /* Nombre de liens de dest.    */      size_t i;                               /* Boucle de parcours #2       */ -    instr_link_t *dest;                     /* Instr. visée par une autre  */ +    const instr_link_t *dest;               /* Instr. visée par une autre  */      dragon_node *target;                    /* Noeud référence à tester    */      size_t id;                              /* Indice du bit associé       */ @@ -104,6 +104,8 @@ static void detect_back_edges(dragon_node *nodes, size_t count)              } +            unref_instr_link(dest); +          }          g_arch_instruction_unlock_dest(last); diff --git a/src/analysis/disass/rank.c b/src/analysis/disass/rank.c index c31fd58..6e737a5 100644 --- a/src/analysis/disass/rank.c +++ b/src/analysis/disass/rank.c @@ -63,7 +63,7 @@ static bool rank_flow_block(GFlowBlock *block, BlockVisitOrder order, const GIns      GArchInstruction *last;                 /* Dernière instruction du bloc*/      size_t dcount;                          /* Nombre de liens de dest.    */      size_t i;                               /* Boucle de parcours          */ -    instr_link_t *dest;                     /* Instr. visée par une autre  */ +    const instr_link_t *dest;               /* Instr. visée par une autre  */      const mrange_t *range;                  /* Emplacement d'une cible     */      GFlowBlock *target;                     /* Bloc ciblé par un lien      */      unsigned int rank;                      /* Rang à constituer           */ @@ -167,6 +167,8 @@ static bool rank_flow_block(GFlowBlock *block, BlockVisitOrder order, const GIns          } +        unref_instr_link(dest); +          if (target != NULL)          {              rank = MAX(next, g_flow_block_get_rank(target)); @@ -308,7 +310,7 @@ void rank_routine_block(const GBlockList *list, GBasicBlock *block)      GArchInstruction *last;                 /* Dernière instruction du bloc*/      size_t dcount;                          /* Nombre de liens de dest.    */      size_t i;                               /* Boucle de parcours          */ -    instr_link_t *dest;                     /* Instr. visée par une autre  */ +    const instr_link_t *dest;               /* Instr. visée par une autre  */      InstructionLinkType type;               /* Raccourci pour confort      */      GBasicBlock *target;                    /* Bloc ciblé par un lien      */      unsigned int rank;                      /* Rang à constituer           */ @@ -327,7 +329,7 @@ void rank_routine_block(const GBlockList *list, GBasicBlock *block)          type = dest->type;          /* La boucle de remontée n'abaisse pas les rangs */ -        if (type == ILT_LOOP) continue; +        if (type == ILT_LOOP) goto next_dest;          /**           * On se doit de suivre le même cheminement que celui emprunté lors @@ -339,7 +341,7 @@ void rank_routine_block(const GBlockList *list, GBasicBlock *block)              && type != ILT_CASE_JUMP              && type != ILT_JUMP_IF_TRUE              && type != ILT_JUMP_IF_FALSE) -            continue; +            goto next_dest;          target = g_block_list_find_by_starting_instr(list, dest->linked); @@ -368,6 +370,10 @@ void rank_routine_block(const GBlockList *list, GBasicBlock *block)          } + next_dest: + +        unref_instr_link(dest); +      }      g_arch_instruction_unlock_dest(last);  | 
