From 5c88982fafe33c1183479e555992c759266b708e Mon Sep 17 00:00:00 2001 From: Cyrille Bagard Date: Mon, 5 Jan 2015 21:32:22 +0000 Subject: Changed the way addresses are printed. git-svn-id: svn://svn.gna.org/svn/chrysalide/trunk@449 abbe820e-26c8-41b2-8c08-b7b2b41f8b0a --- ChangeLog | 7 +++++++ src/arch/vmpa.c | 43 +++++++++++++++++++++++---------------- src/arch/vmpa.h | 3 +++ src/glibext/gbufferline.c | 52 +++++++++++++++++++++++++++-------------------- 4 files changed, 65 insertions(+), 40 deletions(-) diff --git a/ChangeLog b/ChangeLog index e933803..4876b28 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,12 @@ 15-01-05 Cyrille Bagard + * src/arch/vmpa.c: + * src/arch/vmpa.h: + * src/glibext/gbufferline.c: + Change the way addresses are printed. + +15-01-05 Cyrille Bagard + * src/analysis/binary.c: * src/analysis/db/cdb.c: Ensure the right macro is used (XSTR vs STR). diff --git a/src/arch/vmpa.c b/src/arch/vmpa.c index fcc1e2f..b306f00 100644 --- a/src/arch/vmpa.c +++ b/src/arch/vmpa.c @@ -30,6 +30,9 @@ #include +#include + + #include "../common/io.h" @@ -404,29 +407,33 @@ char *vmpa2_virt_to_string(const vmpa2t *addr, MemoryDataSize msize, char buffer { size_t ret; /* Retour de l'impression */ - switch (msize) - { - case MDS_8_BITS: - ret = snprintf(buffer, VMPA_MAX_LEN,"0x%02" PRIx64, addr->virtual); - break; + if (addr->virtual == VMPA_NO_VIRTUAL) + ret = snprintf(buffer, VMPA_MAX_LEN, _("(none)")); - case MDS_16_BITS: - ret = snprintf(buffer, VMPA_MAX_LEN, "0x%04" PRIx64, addr->virtual); - break; + else + switch (msize) + { + case MDS_8_BITS: + ret = snprintf(buffer, VMPA_MAX_LEN,"0x%02" PRIx64, addr->virtual); + break; - case MDS_32_BITS: - ret = snprintf(buffer, VMPA_MAX_LEN, "0x%08" PRIx64, addr->virtual); - break; + case MDS_16_BITS: + ret = snprintf(buffer, VMPA_MAX_LEN, "0x%04" PRIx64, addr->virtual); + break; - case MDS_64_BITS: - ret = snprintf(buffer, VMPA_MAX_LEN, "0x%016" PRIx64, addr->virtual); - break; + case MDS_32_BITS: + ret = snprintf(buffer, VMPA_MAX_LEN, "0x%08" PRIx64, addr->virtual); + break; - default: - ret = snprintf(buffer, VMPA_MAX_LEN, "0x%" PRIx64, addr->virtual); - break; + case MDS_64_BITS: + ret = snprintf(buffer, VMPA_MAX_LEN, "0x%016" PRIx64, addr->virtual); + break; - } + default: + ret = snprintf(buffer, VMPA_MAX_LEN, "0x%" PRIx64, addr->virtual); + break; + + } if (length != NULL) *length = ret; diff --git a/src/arch/vmpa.h b/src/arch/vmpa.h index 54dbda9..6f8e809 100644 --- a/src/arch/vmpa.h +++ b/src/arch/vmpa.h @@ -91,6 +91,9 @@ int cmp_vmpa(const vmpa2t *, const vmpa2t *); #define get_phy_addr(a) (a)->physical #define get_virt_addr(a) (a)->virtual +#define has_phys_addr(a) ((a)->physical != VMPA_NO_PHYSICAL) +#define has_virt_addr(a) ((a)->virtual != VMPA_NO_VIRTUAL) + #define dup_vmpa(src) \ make_vmpa(get_phy_addr(src), get_virt_addr(src)) diff --git a/src/glibext/gbufferline.c b/src/glibext/gbufferline.c index cd85cf4..6b5ab18 100644 --- a/src/glibext/gbufferline.c +++ b/src/glibext/gbufferline.c @@ -488,37 +488,45 @@ void g_buffer_line_fill_mrange(GBufferLine *line, MemoryDataSize psize, MemoryDa /* Position physique */ - mrange_phys_to_string(&line->range, psize, true, address, &len); + if (has_phys_addr(get_mrange_addr(&line->range))) + { + mrange_phys_to_string(&line->range, psize, true, address, &len); - for (i = 2; i < len; i++) - if (address[i] != '0') break; + for (i = 2; i < len; i++) + if (address[i] != '0') break; - if (i == len) - g_buffer_line_insert_text(line, BLC_PHYSICAL, address, len, RTT_PHYS_ADDR_PAD); + if (i == len) + g_buffer_line_insert_text(line, BLC_PHYSICAL, address, len, RTT_PHYS_ADDR_PAD); - else - { - g_buffer_line_insert_text(line, BLC_PHYSICAL, address, 2, RTT_PHYS_ADDR); - g_buffer_line_insert_text(line, BLC_PHYSICAL, &address[2], i - 2, RTT_PHYS_ADDR_PAD); - g_buffer_line_insert_text(line, BLC_PHYSICAL, &address[i], len - i, RTT_PHYS_ADDR); - } + else + { + g_buffer_line_insert_text(line, BLC_PHYSICAL, address, 2, RTT_PHYS_ADDR); + g_buffer_line_insert_text(line, BLC_PHYSICAL, &address[2], i - 2, RTT_PHYS_ADDR_PAD); + g_buffer_line_insert_text(line, BLC_PHYSICAL, &address[i], len - i, RTT_PHYS_ADDR); + } + + } /* Adresse virtuelle */ - mrange_virt_to_string(&line->range, vsize, true, address, &len); + if (has_virt_addr(get_mrange_addr(&line->range))) + { + mrange_virt_to_string(&line->range, vsize, true, address, &len); - for (i = 2; i < len; i++) - if (address[i] != '0') break; + for (i = 2; i < len; i++) + if (address[i] != '0') break; - if (i == len) - g_buffer_line_insert_text(line, BLC_VIRTUAL, address, len, RTT_VIRT_ADDR_PAD); + if (i == len) + g_buffer_line_insert_text(line, BLC_VIRTUAL, address, len, RTT_VIRT_ADDR_PAD); - else - { - g_buffer_line_insert_text(line, BLC_VIRTUAL, address, 2, RTT_VIRT_ADDR); - g_buffer_line_insert_text(line, BLC_VIRTUAL, &address[2], i - 2, RTT_VIRT_ADDR_PAD); - g_buffer_line_insert_text(line, BLC_VIRTUAL, &address[i], len - i, RTT_VIRT_ADDR); - } + else + { + g_buffer_line_insert_text(line, BLC_VIRTUAL, address, 2, RTT_VIRT_ADDR); + g_buffer_line_insert_text(line, BLC_VIRTUAL, &address[2], i - 2, RTT_VIRT_ADDR_PAD); + g_buffer_line_insert_text(line, BLC_VIRTUAL, &address[i], len - i, RTT_VIRT_ADDR); + } + + } } -- cgit v0.11.2-87-g4458