mirror of
https://github.com/checkpoint-restore/criu
synced 2025-09-03 15:55:53 +00:00
show: Put printing xdigits and symbols in helpers
This is preparation for the next patch. Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
This commit is contained in:
24
cr-show.c
24
cr-show.c
@@ -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)
|
|||||||
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)
|
|||||||
|
|
||||||
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");
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user