diff options
author | Cyrille Bagard <nocbos@gmail.com> | 2018-07-04 12:39:01 (GMT) |
---|---|---|
committer | Cyrille Bagard <nocbos@gmail.com> | 2018-07-04 12:39:01 (GMT) |
commit | ade3ee4fd3b78e96deb08210838643969f2f6699 (patch) | |
tree | 09003a6f4ac00c09560de9ea9a91c125a7b14f68 /src/gui | |
parent | a0463dfa8fe232d01ea925668f393d7507fa787b (diff) |
Updated the API for building symbol labels.
Diffstat (limited to 'src/gui')
-rw-r--r-- | src/gui/dialogs/gotox.c | 17 | ||||
-rw-r--r-- | src/gui/panels/strings.c | 9 | ||||
-rw-r--r-- | src/gui/panels/symbols.c | 46 |
3 files changed, 49 insertions, 23 deletions
diff --git a/src/gui/dialogs/gotox.c b/src/gui/dialogs/gotox.c index f28654d..72c2f8c 100644 --- a/src/gui/dialogs/gotox.c +++ b/src/gui/dialogs/gotox.c @@ -372,7 +372,7 @@ static void add_new_location_to_list(GtkTreeStore *store, GLoadedBinary *binary, size_t index; /* Indice de ligne à traiter */ GBufferLine *line; /* Ligne présente à l'adresse */ char *virtual; /* Transcription d'adresse */ - const char *label; /* Etiquette de symbole trouvé */ + char *label; /* Etiquette de symbole trouvé */ GBinFormat *format; /* Format associé au binaire */ GBinSymbol *symbol; /* Symbole associé à l'adresse */ phys_t diff; /* Décalage vis à vis du début */ @@ -410,7 +410,17 @@ static void add_new_location_to_list(GtkTreeStore *store, GLoadedBinary *binary, label = g_binary_symbol_get_label(hint); - name = make_symbol_offset(label, 0); + /** + * Cf. commentaire suivant. + */ + if (label == NULL) + name = strdup(_("<no symbol found>")); + + else + { + name = make_symbol_offset(label, 0); + free(label); + } } else @@ -430,7 +440,10 @@ static void add_new_location_to_list(GtkTreeStore *store, GLoadedBinary *binary, name = strdup(_("<no symbol found>")); else + { name = make_symbol_offset(label, diff); + free(label); + } } else diff --git a/src/gui/panels/strings.c b/src/gui/panels/strings.c index 4828038..a50eeae 100644 --- a/src/gui/panels/strings.c +++ b/src/gui/panels/strings.c @@ -26,8 +26,9 @@ #include <assert.h> -#include <string.h> #include <inttypes.h> +#include <malloc.h> +#include <string.h> #include "panel-int.h" @@ -1360,7 +1361,7 @@ static bool is_string_name_matching(const strings_update_data *data, GtkTreeMode #ifndef NDEBUG SymbolType type; /* Type associé au symbole */ #endif - const char *label; /* Etiquette à analyser */ + char *label; /* Etiquette à analyser */ gtk_tree_model_get(model, iter, STC_SYMBOL, &symbol, -1); assert(symbol != NULL); @@ -1377,8 +1378,12 @@ static bool is_string_name_matching(const strings_update_data *data, GtkTreeMode if (label == NULL) result = false; + else + { result = is_content_matching(data->filter, label, match); + free(label); + } g_object_unref(G_OBJECT(symbol)); diff --git a/src/gui/panels/symbols.c b/src/gui/panels/symbols.c index 94605b3..0c88bce 100644 --- a/src/gui/panels/symbols.c +++ b/src/gui/panels/symbols.c @@ -727,7 +727,7 @@ static void reload_symbols_for_new_list_view(const GSymbolsPanel *panel, GtkStat cairo_surface_t *icon; /* Image associée au symbole */ regmatch_t match; /* Récupération des trouvailles*/ bool matched; /* Correspondance de sélection */ - const char *original; /* Etiquette brute d'origine */ + char *original; /* Etiquette brute d'origine */ char *name; /* Etiquette mise en relief */ const vmpa2t *addr; /* Localisation d'un symbole */ VMPA_BUFFER(virt); /* Version humainement lisible */ @@ -775,6 +775,8 @@ static void reload_symbols_for_new_list_view(const GSymbolsPanel *panel, GtkStat else name = NULL; + free(original); + addr = get_mrange_addr(g_binary_symbol_get_range(symbol)); vmpa2_virt_to_string(addr, size, virt, NULL); @@ -939,8 +941,7 @@ static GtkTreeIter ensure_symbol_node_exist(const GSymbolsPanel *panel, GtkTreeI static bool find_parent_for_symbol(const GSymbolsPanel *panel, const GBinSymbol *symbol, GtkTreeIter *parent, const regmatch_t *match, size_t *last) { bool result; /* Bilan à retourner */ - const char *label; /* Etiquette immuable */ - char *string; /* Etiquette modifiable */ + char *label; /* Etiquette modifiable */ char *start; /* Début de boucle de parcours */ char *token; /* Partie de texte isolée */ char *next; /* Prochaine partie à traiter */ @@ -952,24 +953,22 @@ static bool find_parent_for_symbol(const GSymbolsPanel *panel, const GBinSymbol label = g_binary_symbol_get_label(symbol); if (label == NULL) return false; - string = strdup(label); - - for (start = string, token = strtok_w(&start, panel->sep); ; token = next) + for (start = label, token = strtok_w(&start, panel->sep); ; token = next) { next = strtok_w(&start, panel->sep); if (next == NULL) { - *last = (token - string); + *last = (token - label); break; } - *parent = ensure_symbol_node_exist(panel, (token == string ? NULL : parent), token, match, token - string); + *parent = ensure_symbol_node_exist(panel, (token == label ? NULL : parent), token, match, token - label); result = true; } - free(string); + free(label); return result; @@ -1005,7 +1004,7 @@ static void reload_symbols_for_new_tree_view(const GSymbolsPanel *panel, GtkStat bool matched; /* Correspondance de sélection */ GtkTreeIter parent; /* Point d'insertion parent */ size_t last; /* Position du dernier élément */ - const char *original; /* Etiquette brute d'origine */ + char *original; /* Etiquette brute d'origine */ char *name; /* Etiquette mise en relief */ const vmpa2t *addr; /* Localisation d'un symbole */ char virt[VMPA_MAX_LEN]; /* Version humainement lisible */ @@ -1066,6 +1065,8 @@ static void reload_symbols_for_new_tree_view(const GSymbolsPanel *panel, GtkStat else name = NULL; + free(original); + addr = get_mrange_addr(g_binary_symbol_get_range(symbol)); vmpa2_virt_to_string(addr, size, virt, NULL); @@ -1258,8 +1259,7 @@ static GtkTreeIter update_symbol_partial_name_in_tree_view(GtkTreeStore *store, static void update_symbol_name_in_tree_view(const GSymbolsPanel *panel, GtkTreeStore *store, const GBinSymbol *symbol, const regmatch_t *match) { - const char *label; /* Etiquette immuable */ - char *string; /* Etiquette modifiable */ + char *label; /* Etiquette modifiable */ GtkTreeIter parent; /* Point d'analyse courant */ char *start; /* Début de boucle de parcours */ char *token; /* Partie de texte isolée */ @@ -1268,17 +1268,15 @@ static void update_symbol_name_in_tree_view(const GSymbolsPanel *panel, GtkTreeS if (label != NULL) { - string = strdup(label); - - for (start = string, token = strtok_w(&start, panel->sep); + for (start = label, token = strtok_w(&start, panel->sep); token != NULL; token = strtok_w(&start, panel->sep)) { - parent = update_symbol_partial_name_in_tree_view(store, (token == string ? NULL : &parent), - token, match, token - string); + parent = update_symbol_partial_name_in_tree_view(store, (token == label ? NULL : &parent), + token, match, token - label); } - free(string); + free(label); } @@ -1420,6 +1418,7 @@ static bool is_symbol_matching(const symbols_update_data *data, const GBinSymbol #ifndef NDEBUG SymbolType type; /* Type associé au symbole */ #endif + char *label; /* Etiquette à analyser */ #ifndef NDEBUG @@ -1429,7 +1428,16 @@ static bool is_symbol_matching(const symbols_update_data *data, const GBinSymbol #endif - result = is_content_matching(data->filter, g_binary_symbol_get_label(symbol), match); + label = g_binary_symbol_get_label(symbol); + + if (label == NULL) + result = false; + + else + { + result = is_content_matching(data->filter, label, match); + free(label); + } return result; |