Commit 255d9851 authored by Pavel Emelyanov's avatar Pavel Emelyanov

show: Put printing xdigits and symbols in helpers

This is preparation for the next patch.
Signed-off-by: 's avatarPavel Emelyanov <xemul@parallels.com>
parent 360c1c13
...@@ -33,9 +33,6 @@ ...@@ -33,9 +33,6 @@
#define DEF_PAGES_PER_LINE 6 #define DEF_PAGES_PER_LINE 6
#define PR_SYMBOL(sym) \
(isprint(sym) ? sym : '.')
static LIST_HEAD(pstree_list); static LIST_HEAD(pstree_list);
static void pipe_data_handler(int fd, void *obj) static void pipe_data_handler(int fd, void *obj)
...@@ -56,6 +53,19 @@ static int nice_width_for(unsigned long addr) ...@@ -56,6 +53,19 @@ static int nice_width_for(unsigned long addr)
return ret; return ret;
} }
static inline void pr_xdigi(unsigned char *data, size_t len, int pos)
{
pr_msg("%02x ", data[pos]);
}
static inline void pr_xsym(unsigned char *data, size_t len, int pos)
{
char sym;
sym = data[pos];
pr_msg("%c", isprint(sym) ? sym : '.');
}
void print_data(unsigned long addr, unsigned char *data, size_t size) void print_data(unsigned long addr, unsigned char *data, size_t size)
{ {
int i, j, addr_len; int i, j, addr_len;
...@@ -80,17 +90,17 @@ void print_data(unsigned long addr, unsigned char *data, size_t size) ...@@ -80,17 +90,17 @@ void print_data(unsigned long addr, unsigned char *data, size_t size)
pr_msg("%#0*lx: ", addr_len, addr + i); pr_msg("%#0*lx: ", addr_len, addr + i);
for (j = 0; j < 8; j++) for (j = 0; j < 8; j++)
pr_msg("%02x ", data[i + j]); pr_xdigi(data, size, i + j);
pr_msg(" "); pr_msg(" ");
for (j = 8; j < 16; j++) for (j = 8; j < 16; j++)
pr_msg("%02x ", data[i + j]); pr_xdigi(data, size, i + j);
pr_msg(" |"); pr_msg(" |");
for (j = 0; j < 8; j++) for (j = 0; j < 8; j++)
pr_msg("%c", PR_SYMBOL(data[i + j])); pr_xsym(data, size, i + j);
pr_msg(" "); pr_msg(" ");
for (j = 8; j < 16; j++) for (j = 8; j < 16; j++)
pr_msg("%c", PR_SYMBOL(data[i + j])); pr_xsym(data, size, i + j);
pr_msg("|\n"); pr_msg("|\n");
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment