Skip to contentSkip to conversation

kgdb: Remove first_entry for kgdb

PATCH In review Peng Fan 2 participants 2 messages Sep 1, 2014 – Sep 17, 2014

lore
Share & tools
lore

Peng Fan

author
#0 lore raw

PATCH 1/1 kgdb: Remove first_entry for kgdb

There are two ways to run into handle_exception, run command 'kgdb' and encounter a breakpoint which triggers exception handling.

The origin source code only saves regs when first run command 'kgdb'. Take the following for example, When run 'kgdb', regs is saved to entry_regs. When run 'bootz', regs is not saved. However, if we set a breakpoint, then continue. When breakpoint is reached, run quit, and Now return to the instruction which follows kgdb, but not bootz.This may cause errors. So, save regs for each handle_exception call to return to the correct place. Example:

Target      |    Host
=>kgdb      |    (gdb)b bootz
            |    (gdb)c
=>bootz     |
            |    (gdb)Here stop because of breakpoint
            |    (gdb)q
---
 common/kgdb.c | 14 ++------------
 1 file changed, 2 insertions(+), 12 deletions(-)
common/kgdb.c +2 -12
index 8a621ad..d357463 100644
@@ -103,7 +103,7 @@ static char remcomOutBuffer[BUFMAX];
 static char remcomRegBuffer[BUFMAX];
 
 static int initialized = 0;
-static int kgdb_active = 0, first_entry = 1;
+static int kgdb_active;
 static struct pt_regs entry_regs;
 static long error_jmp_buf[BUFMAX/2];
 static int longjmp_on_fault = 0;
@@ -348,16 +348,7 @@ handle_exception (struct pt_regs *regs)
 
 	kgdb_enter(regs, &kd);
 
-	if (first_entry) {
-		/*
-		 * the first time we enter kgdb, we save the processor
-		 * state so that we can return to the monitor if the
-		 * remote end quits gdb (or at least, tells us to quit
-		 * with the 'k' packet)
-		 */
-		entry_regs = *regs;
-		first_entry = 0;
-	}
+	entry_regs = *regs;
 
 	ptr = remcomOutBuffer;
 
@@ -459,7 +450,6 @@ handle_exception (struct pt_regs *regs)
 		case 'k':    /* kill the program, actually return to monitor */
 			kd.extype = KGDBEXIT_KILL;
 			*regs = entry_regs;
-			first_entry = 1;
 			goto doexit;
 
 		case 'C':    /* CSS  continue with signal SS */
Signature · 1 line
1.8.4
#1 lore raw
Quoted 10 lines · Peng Fan

There are two ways to run into handle_exception, run command 'kgdb' and encounter a breakpoint which triggers exception handling.

The origin source code only saves regs when first run command 'kgdb'. Take the following for example, When run 'kgdb', regs is saved to entry_regs. When run 'bootz', regs is not saved. However, if we set a breakpoint, then continue. When breakpoint is reached, run quit, and Now return to the instruction which follows kgdb, but not bootz.This may cause errors. So, save regs for each handle_exception call to return to the correct place. Example:

Quoted 8 lines
Target      |    Host
=>kgdb      |    (gdb)b bootz
            |    (gdb)c
=>bootz     |
            |    (gdb)Here stop because of breakpoint
            |    (gdb)q

Applied to u-boot/master, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20140916/0736112b/attachment.pgp>