[Pdbg] [PATCH v3 3/3] pdbg: Add progress tick callbacks for get/putmem
Alistair Popple
alistair at popple.id.au
Thu May 17 15:44:28 AEST 2018
People like progress bars. Give the people what they want.
Signed-off-by: Alistair Popple <alistair at popple.id.au>
---
libpdbg/adu.c | 7 +++++++
src/mem.c | 7 +++++++
2 files changed, 14 insertions(+)
diff --git a/libpdbg/adu.c b/libpdbg/adu.c
index 612d70a..2b9c063 100644
--- a/libpdbg/adu.c
+++ b/libpdbg/adu.c
@@ -95,6 +95,8 @@ int adu_getmem(struct pdbg_target *adu_target, uint64_t start_addr, uint8_t *out
if (adu->getmem(adu, addr, &data))
return -1;
+ pdbg_progress_tick(addr - start_addr, size);
+
/* ADU returns data in big-endian form in the register */
data = __builtin_bswap64(data);
@@ -109,6 +111,8 @@ int adu_getmem(struct pdbg_target *adu_target, uint64_t start_addr, uint8_t *out
}
}
+ pdbg_progress_tick(size, size);
+
return rc;
}
@@ -136,8 +140,11 @@ int adu_putmem(struct pdbg_target *adu_target, uint64_t start_addr, uint8_t *inp
}
adu->putmem(adu, addr, data, tsize);
+ pdbg_progress_tick(addr - start_addr, size);
}
+ pdbg_progress_tick(size, size);
+
return rc;
}
diff --git a/src/mem.c b/src/mem.c
index 4f12dcf..e0e9cc3 100644
--- a/src/mem.c
+++ b/src/mem.c
@@ -24,6 +24,7 @@
#include <target.h>
#include "main.h"
+#include "progress.h"
#define PUTMEM_BUF_SIZE 1024
static int getmem(uint64_t addr, uint64_t size)
@@ -37,6 +38,8 @@ static int getmem(uint64_t addr, uint64_t size)
if (pdbg_target_probe(target) != PDBG_TARGET_ENABLED)
continue;
+ pdbg_set_progress_tick(progress_tick);
+ progress_init();
if (!adu_getmem(target, addr, buf, size)) {
if (write(STDOUT_FILENO, buf, size) < 0)
PR_ERROR("Unable to write stdout.\n");
@@ -45,6 +48,7 @@ static int getmem(uint64_t addr, uint64_t size)
} else
PR_ERROR("Unable to read memory.\n");
/* We only ever care about getting memory from a single processor */
+ progress_end();
break;
}
free(buf);
@@ -62,6 +66,8 @@ static int putmem(uint64_t addr)
buf = malloc(PUTMEM_BUF_SIZE);
assert(buf);
+ pdbg_set_progress_tick(progress_tick);
+ progress_init();
do {
read_size = read(STDIN_FILENO, buf, PUTMEM_BUF_SIZE);
if (adu_putmem(adu_target, addr, buf, read_size)) {
@@ -71,6 +77,7 @@ static int putmem(uint64_t addr)
}
rc += read_size;
} while (read_size > 0);
+ progress_end();
printf("Wrote %d bytes starting at 0x%016" PRIx64 "\n", rc, addr);
free(buf);
--
2.11.0
More information about the Pdbg
mailing list