[v2] libpdbg: Attempt to restore registers that we clobbered on failure

Message ID 20180606071439.32354-1-rashmica.g@gmail.com
State Accepted
Headers show
Series
  • [v2] libpdbg: Attempt to restore registers that we clobbered on failure
Related show

Commit Message

Rashmica Gupta June 6, 2018, 7:14 a.m.
---
v1 -> v2 print out variables properly...

 libpdbg/chip.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

Patch

diff --git a/libpdbg/chip.c b/libpdbg/chip.c
index 6d0b47e..cb92de1 100644
--- a/libpdbg/chip.c
+++ b/libpdbg/chip.c
@@ -266,9 +266,13 @@  static int ram_instructions(struct pdbg_target *thread_target, uint64_t *opcodes
 		}
 
 		if (thread->ram_instruction(thread, opcode, &scratch)) {
-			PR_DEBUG("%s: %d\n", __FUNCTION__, __LINE__);
+			PR_DEBUG("%s: %d, %016" PRIx64 "\n", __FUNCTION__, __LINE__, opcode);
 			exception = 1;
-			break;
+			if (i >= 0 || i < len)
+				/* skip the rest and attempt to restore r0 and r1 */
+				i = len - 1;
+			else
+				break;
 		}
 
 		if (i == -2)