2
0
mirror of https://github.com/checkpoint-restore/criu synced 2025-09-03 07:45:17 +00:00

util: Add hex_dump helper

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
This commit is contained in:
Cyrill Gorcunov
2011-10-26 10:10:19 +04:00
parent ae41bc9d2a
commit 0d20dd0b41
2 changed files with 16 additions and 0 deletions

View File

@@ -154,6 +154,8 @@ int reopen_fd_as(int new_fd, int old_fd);
int parse_maps(pid_t pid, struct list_head *vma_list);
int close_safe(int *fd);
void hex_dump(void *addr, unsigned long len);
DIR *opendir_proc(char *fmt, ...);
FILE *fopen_proc(char *fmt, char *mode, ...);
int open_fmt(char *fmt, int mode, ...);

14
util.c
View File

@@ -130,6 +130,20 @@ err:
return -2;
}
void hex_dump(void *addr, unsigned long len)
{
unsigned char *p = addr;
unsigned long i;
len = (len + 8) & ~7;
for (i = 0; i < len; i += 8) {
printk("%08lx: %02x %02x %02x %02x %02x %02x %02x %02x\n",
p, p[i+0], p[i+1], p[i+2], p[i+3],
p[i+4], p[i+5], p[i+6], p[i+7]);
}
}
void printk_registers(user_regs_struct_t *regs)
{
printk("ip : %16lx cs : %16lx ds : %16lx\n"