>From e53a87e4f17271f2f1984c7002ed988a30c714bb Mon Sep 17 00:00:00 2001 From: HATAYAMA Daisuke <d.hatayama@xxxxxxxxxxxxxx> Date: Tue, 13 Sep 2011 15:47:43 +0900 Subject: [PATCH 12/12] sadump: fill buffer with zero if zero_excluded variable is on --- defs.h | 4 ++++ sadump.c | 19 +++++++++++++++++++ tools.c | 18 ++++++++++++------ 3 files changed, 35 insertions(+), 6 deletions(-) diff --git a/defs.h b/defs.h index 7ad46c9..dcc8fcf 100755 --- a/defs.h +++ b/defs.h @@ -255,6 +255,7 @@ struct number_option { #define SADUMP_LOCAL (0x1) #define SADUMP_DISKSET (0x2) #define SADUMP_MEDIA (0x4) +#define SADUMP_ZERO_EXCLUDED (0x8) #define SADUMP_VALID() (sd->flags & SADUMP_LOCAL) #define CRASHDEBUG(x) (pc->debug >= (x)) @@ -4736,6 +4737,9 @@ void get_sadump_regs(struct bt_info *bt, ulong *ipp, ulong *spp); void sadump_display_regs(int, FILE *); int sadump_phys_base(unsigned long *); void sadump_show_diskset(void); +int sadump_is_zero_excluded(void); +void sadump_set_zero_excluded(void); +void sadump_unset_zero_excluded(void); /* * qemu.c diff --git a/sadump.c b/sadump.c index 9736d9e..14c6eae 100644 --- a/sadump.c +++ b/sadump.c @@ -728,6 +728,8 @@ int read_sadump(int fd, void *bufptr, int cnt, ulong addr, physaddr_t paddr) if ((pfn >= sd->dump_header->max_mapnr) || !page_is_ram(pfn)) return SEEK_ERROR; if (!page_is_dumpable(pfn)) { + if (sd->flags & SADUMP_ZERO_EXCLUDED) + return PAGE_EXCLUDED; memset(bufptr, 0, cnt); return cnt; } @@ -872,6 +874,8 @@ int sadump_memory_dump(FILE *fp) fprintf(fp, "%sSADUMP_DISKSET", others++ ? "|" : ""); if (sd->flags & SADUMP_MEDIA) fprintf(fp, "%sSADUMP_MEDIA", others++ ? "|" : ""); + if (sd->flags & SADUMP_ZERO_EXCLUDED) + fprintf(fp, "%sSADUMP_ZERO_EXCLUDED", others++ ? "|" : ""); fprintf(fp, ") \n"); fprintf(fp, " dfd: %d\n", sd->dfd); fprintf(fp, " machine_type: %d ", sd->machine_type); @@ -1533,3 +1537,18 @@ static ulong pfn_to_block(ulong pfn) return block; } + +int sadump_is_zero_excluded(void) +{ + return (sd->flags & SADUMP_ZERO_EXCLUDED) ? TRUE : FALSE; +} + +void sadump_set_zero_excluded(void) +{ + sd->flags |= SADUMP_ZERO_EXCLUDED; +} + +void sadump_unset_zero_excluded(void) +{ + sd->flags &= ~SADUMP_ZERO_EXCLUDED; +} diff --git a/tools.c b/tools.c index ae38ce8..41e2323 100755 --- a/tools.c +++ b/tools.c @@ -2217,24 +2217,30 @@ cmd_set(void) optind++; if (from_rc_file) already_done(); - else if (STREQ(args[optind], "on")) + else if (STREQ(args[optind], "on")) { *diskdump_flags |= ZERO_EXCLUDED; - else if (STREQ(args[optind], "off")) + sadump_set_zero_excluded(); + } else if (STREQ(args[optind], "off")) { *diskdump_flags &= ~ZERO_EXCLUDED; - else if (IS_A_NUMBER(args[optind])) { + sadump_unset_zero_excluded(); + } else if (IS_A_NUMBER(args[optind])) { value = stol(args[optind], FAULT_ON_ERROR, NULL); - if (value) + if (value) { *diskdump_flags |= ZERO_EXCLUDED; - else + sadump_set_zero_excluded(); + } else { *diskdump_flags &= ~ZERO_EXCLUDED; + sadump_unset_zero_excluded(); + } } else goto invalid_set_command; } if (runtime) fprintf(fp, "zero_excluded: %s\n", - *diskdump_flags & ZERO_EXCLUDED ? + (*diskdump_flags & ZERO_EXCLUDED) || + sadump_is_zero_excluded() ? "on" : "off"); return; -- 1.7.4.4
-- Crash-utility mailing list Crash-utility@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/crash-utility