From 8df6567b5213fe842e329ad1102c5531d7c509bb Mon Sep 17 00:00:00 2001
From: Cyrille Bagard <nocbos@gmail.com>
Date: Sun, 25 Sep 2016 20:43:06 +0200
Subject: Removed debug code.

---
 ChangeLog                  |   7 ++
 src/analysis/disass/area.c | 172 ---------------------------------------------
 src/arch/link.c            |  18 -----
 src/format/dex/pool.c      |  10 ---
 4 files changed, 7 insertions(+), 200 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 2515f0e..373d7bf 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+16-09-25  Cyrille Bagard <nocbos@gmail.com>
+
+	* src/analysis/disass/area.c:
+	* src/arch/link.c:
+	* src/format/dex/pool.c:
+	Remove debug code.
+
 16-09-24  Cyrille Bagard <nocbos@gmail.com>
 
 	* src/analysis/content-int.h:
diff --git a/src/analysis/disass/area.c b/src/analysis/disass/area.c
index c9612af..96de6f3 100644
--- a/src/analysis/disass/area.c
+++ b/src/analysis/disass/area.c
@@ -399,8 +399,6 @@ void load_code_from_mem_area_v2(mem_area_v2 *area, mem_area_v2 *list, size_t cou
 
     /* Traitement de la zone */
 
-    printf("=== processing @ 0x%08x\n", (unsigned int)start->virtual);
-
     forced_once = false;
 
     for (i = init_diff; i < alen; i += diff)
@@ -411,9 +409,6 @@ void load_code_from_mem_area_v2(mem_area_v2 *area, mem_area_v2 *list, size_t cou
          * inutile.
          */
 
-        printf(" (%u) blank ? %d\n", (unsigned int)i, is_range_blank_in_mem_area_v2(area, i, 1));
-        printf("   +1 blank ? %d\n", is_range_blank_in_mem_area_v2(area, i + 1, 1));
-
         if (!is_range_blank_in_mem_area_v2(area, i, 1))
             break;
 
@@ -840,32 +835,6 @@ mem_area_v2 *compute_memory_areas_v2(const GLoadedBinary *binary, phys_t bin_len
 
     }
 
-
-
-
-
-
-
-
-    for (i = 0; i < *count; i++)
-    {
-        printf(" (init) AREA %zu :: 0x%x / 0x%x + 0x%x\n",
-               i,
-               (unsigned int)get_phy_addr(get_mrange_addr(&result[i].range)),
-               (unsigned int)get_virt_addr(get_mrange_addr(&result[i].range)),
-               (unsigned int)get_mrange_length(&result[i].range));
-
-    }
-
-    printf("--------------------\n");
-
-
-
-
-
-
-
-
     /* Seconde étape : on s'assure du découpage autour des portions pour respecter l'alignement */
 
     layer = g_exe_format_get_main_layer(format);
@@ -876,12 +845,6 @@ mem_area_v2 *compute_memory_areas_v2(const GLoadedBinary *binary, phys_t bin_len
     {
         portion_start = get_mrange_addr(g_binary_portion_get_range(portions[i]));
 
-        printf(" [portion % 3zu] addr = 0x%x / 0x%x\n",
-               i,
-               (unsigned int)get_phy_addr(portion_start),
-               (unsigned int)get_virt_addr(portion_start));
-
-
         /**
          * Si plusieurs portions débutent au même endroit, il ne sert
          * à rien de découper plusieurs fois.
@@ -947,30 +910,6 @@ mem_area_v2 *compute_memory_areas_v2(const GLoadedBinary *binary, phys_t bin_len
 
     g_object_unref(G_OBJECT(layer));
 
-
-
-
-
-
-    for (i = 0; i < *count; i++)
-    {
-        printf(" (fini) AREA %zu :: 0x%x / 0x%x + 0x%x\n",
-               i,
-               (unsigned int)get_phy_addr(get_mrange_addr(&result[i].range)),
-               (unsigned int)get_virt_addr(get_mrange_addr(&result[i].range)),
-               (unsigned int)get_mrange_length(&result[i].range));
-
-    }
-
-    printf("--------------------\n");
-
-
-
-
-
-
-
-
     /* Troisième étape : on insère les symboles existants */
 
     for (i = 0; i < sym_count; i++)
@@ -1359,14 +1298,6 @@ static void init_mem_area_from_bigger_area(mem_area *area, const vmpa2t *addr, p
     size_t ref_index;                       /* Cellule de tableau visée #2 */
     unsigned int ref_remaining;             /* Nombre de bits restants #2  */
 
-
-    printf(" INIT_FROM (0x%08x / 0x%08x | 0x%x) : area (0x%08x / 0x%08x) len = 0x%x\n",
-           (unsigned int)ref->range.addr.physical, (unsigned int)ref->range.addr.virtual,
-           (unsigned int)ref->range.length,
-           (unsigned int)addr->physical, (unsigned int)addr->virtual,
-           (unsigned int)len);
-
-
     init_mem_area_from_addr(area, addr, len);
 
     assert(mrange_contains_mrange(&ref->range, &area->range));
@@ -1677,14 +1608,6 @@ bool load_code_from_mem_area(mem_area **list, size_t *count, size_t *index, cons
     copy_vmpa(&pos, get_mrange_addr(&area->range));
     advance_vmpa(&pos, diff);
 
-    //printf(" [%p] CODE start @ %u (len=%u)\n", area, (unsigned int)diff, (unsigned int)alen);
-
-
-
-    printf(" START @ 0x%08x\n", (unsigned int)get_virt_addr(&pos));
-
-
-
     for (i = diff; i < alen; i += diff)
     {
         /* S'il y a eu un point d'entrée en milieu de zone, on s'arrête ! */
@@ -1698,8 +1621,6 @@ bool load_code_from_mem_area(mem_area **list, size_t *count, size_t *index, cons
 
         /* TODO : valider que la taille de l'instruction obtenue ne dépasse pas la zone */
 
-        //printf(" @ 0x%08x -> %p\n", (uint32_t)get_virt_addr(&prev), instr);
-
         if (instr == NULL) break;
 
         /* Enregistrement des positions et adresses */
@@ -1770,22 +1691,12 @@ bool load_code_from_mem_area(mem_area **list, size_t *count, size_t *index, cons
 
         assert(!is_range_blank_in_mem_areas(*list, *count, &range));
 
-
-        if (g_arch_instruction_get_flags(instr) & AIF_RETURN_POINT)
-            printf("BREAK @ 0x%08x\n", (unsigned int)get_virt_addr(&prev));
-
-        //continue;
-
         /* Rupture du flot d'exécution ? */
         if (g_arch_instruction_get_flags(instr) & AIF_RETURN_POINT)
             break;
 
     }
 
-
-    printf("\n");
-
-
     g_object_unref(G_OBJECT(content));
 
     g_object_unref(G_OBJECT(proc));
@@ -1830,7 +1741,6 @@ static void load_data_from_mem_area(mem_area *area, mem_area *list, size_t count
     /* On cherche à obtenir l'assurance que le traitement n'a jamais été fait */
 
     init_mrange(&range, start, 1);
-    if (!is_range_blank_in_mem_areas(list, count, &range)) printf("DATA OK ! @ 0x%08x\n", (unsigned int)get_phy_addr(get_mrange_addr(&area->range)));
     if (!is_range_blank_in_mem_areas(list, count, &range)) return;
 
     /* Récupération des informations de base */
@@ -1854,12 +1764,6 @@ static void load_data_from_mem_area(mem_area *area, mem_area *list, size_t count
     copy_vmpa(&pos, get_mrange_addr(&area->range));
     advance_vmpa(&pos, diff);
 
-    /*
-    printf(" [%p] DATA start @ 0x%08x -> %u (len=%u) => 0x%08x <-> 0x%08x\n",
-           area, (unsigned int)get_phy_addr(&pos), (unsigned int)diff, (unsigned int)alen,
-           (unsigned int)get_virt_addr(&pos), (unsigned int)(get_virt_addr(&pos) + alen));
-    */
-
     for (i = diff; i < alen; i += diff)
     {
         /* Décodage d'une nouvelle instruction, sur mesure */
@@ -2170,25 +2074,6 @@ mem_area *compute_memory_areas(GExeFormat *format, phys_t bin_length, size_t *co
 
     symbols = g_binary_format_get_symbols(G_BIN_FORMAT(format), &sym_count);
 
-
-
-
-
-
-    for (i = 0; i < exe_count; i++)
-    {
-        printf(" (init) AREA %zu :: 0x%08x + %u\n",
-               i,
-               (unsigned int)get_phy_addr(get_mrange_addr(&exe_ranges[i])),
-               (unsigned int)get_mrange_length(&exe_ranges[i]));
-
-    }
-
-
-    printf("----------------\n");
-
-
-
     /* Première étape : on comble les trous ! */
 
     last = make_vmpa(0, VMPA_NO_VIRTUAL);
@@ -2252,19 +2137,6 @@ mem_area *compute_memory_areas(GExeFormat *format, phys_t bin_length, size_t *co
 
     /* Seconde étape : on s'assure du découpage autour des portions pour respecter l'alignement */
 
-
-
-    for (i = 0; i < *count; i++)
-    {
-        printf(" (fini) AREA %zu :: 0x%08x + %u\n",
-               i,
-               (unsigned int)get_phy_addr(get_mrange_addr(&result[i].range)),
-               (unsigned int)get_mrange_length(&result[i].range));
-
-    }
-
-    printf("--------------------\n");
-
     portions = NULL;//g_exe_format_get_portions_at_level(format, -1, &portions_count);
     portions_count = 0;
 
@@ -2316,23 +2188,6 @@ mem_area *compute_memory_areas(GExeFormat *format, phys_t bin_length, size_t *co
 
     }
 
-
-
-
-
-
-    for (i = 0; i < *count; i++)
-    {
-        printf(" (sect) AREA %zu :: 0x%08x + %u\n",
-               i,
-               (unsigned int)get_phy_addr(get_mrange_addr(&result[i].range)),
-               (unsigned int)get_mrange_length(&result[i].range));
-
-    }
-
-
-
-
     /* Troisième étape : on insère les symboles existants */
 
     j = 0;
@@ -2509,33 +2364,6 @@ static bool insert_extra_symbol_into_mem_areas(mem_area **list, size_t *count, G
 
     area = &(*list)[index];
 
-
-
-    do
-    {
-        size_t i;
-
-        printf("--- INDEX = %zu   OLD_INDEX = %zu\n", index, working);
-
-        printf("--- comment '%s'...\n",
-               g_db_comment_get_text(g_binary_symbol_get_comment(symbol)));
-
-        printf("--- insert @ 0x%04x + %u\n",
-               get_phy_addr(get_mrange_addr(sym_range)), get_mrange_length(sym_range));
-
-        for (i = 0; i < 3; i++)
-            printf("area [ %zu ]  <=>  0x%04x + %u (sym ? %d)\n",
-                   index - 1 + i,
-                   get_phy_addr(get_mrange_addr(&(&(*list)[index - 1 + i])->range)),
-                   get_mrange_length(&(&(*list)[index - 1 + i])->range),
-                   (&(*list)[index - 1 + i])->has_sym);
-
-    }
-    while (0);
-
-
-
-
     if (area->has_sym) return false;
 
     assert(!area->has_sym);
diff --git a/src/arch/link.c b/src/arch/link.c
index 3b74e5c..48bc3a3 100644
--- a/src/arch/link.c
+++ b/src/arch/link.c
@@ -121,9 +121,6 @@ void handle_branch_as_link(GArchInstruction *instr, GArchProcessor *proc, GProcC
 
         target = g_arch_processor_find_instr_by_address(proc, &addr);
 
-        printf(" @ 0x%08x BRANCH true to 0x%08x -->> %p\n",
-               (unsigned int)instr->range.addr.virtual, (unsigned int)virt, target);
-
         if (target != NULL)
         {
             g_arch_instruction_link_with(instr, target, ILT_JUMP_IF_TRUE);
@@ -132,14 +129,6 @@ void handle_branch_as_link(GArchInstruction *instr, GArchProcessor *proc, GProcC
 
             target = g_arch_instruction_get_next_iter(list, instr, ~0);
 
-
-            if (target != NULL)
-                printf(" @ 0x%08x BRANCH false to 0x%08x -->> %p\n",
-                       (unsigned int)instr->range.addr.virtual,
-                       (unsigned int)g_arch_instruction_get_range(target)->addr.virtual,
-                       target);
-
-
             if (target != NULL)
                 g_arch_instruction_link_with(instr, target, ILT_JUMP_IF_FALSE);
 
@@ -147,13 +136,6 @@ void handle_branch_as_link(GArchInstruction *instr, GArchProcessor *proc, GProcC
 
     }
 
-
-    else printf(" @ 0x%08x FAILED TO BRANCH\n",
-                (unsigned int)instr->range.addr.virtual);
-
-
-
-
 }
 
 
diff --git a/src/format/dex/pool.c b/src/format/dex/pool.c
index f624ff3..7574638 100644
--- a/src/format/dex/pool.c
+++ b/src/format/dex/pool.c
@@ -424,13 +424,9 @@ GBinRoutine *get_prototype_from_dex_pool(GDexFormat *format, uint32_t index)
             type = get_type_from_dex_pool(format, args.list[i].type_idx);
             if (type == NULL) continue;
 
-            printf(" ++ PROTO POOL ++ type '%s'\n", g_data_type_to_string(type));
-
             arg = g_binary_variable_new(type);
             g_binary_routine_add_arg(result, arg);///////////////////////
 
-            printf(" ++ PROTO POOL ++ arg '%s'\n", g_binary_variable_to_string(arg, true));
-
         }
 
     /* Mise en place finale */
@@ -439,12 +435,6 @@ GBinRoutine *get_prototype_from_dex_pool(GDexFormat *format, uint32_t index)
 
     g_binary_routine_set_name(result, strdup("..."));
 
-    printf(" PROTO POOL //    from   %s   to   %s\n",
-           name,
-           result == NULL ? NULL :
-           g_binary_routine_to_string(result));
-
-
 #if 1
     if (result != NULL)///////////////////////
         g_binary_routine_set_return_type(result, type);
-- 
cgit v0.11.2-87-g4458