Patchwork sh4: Fix gdb read/write register

login
register
mail settings
Submitter takasi-y@ops.dti.ne.jp
Date Feb. 17, 2010, 3:53 p.m.
Message ID <201002171553.o1HFrTUc010013@smtp09.dti.ne.jp>
Download mbox | patch
Permalink /patch/45641/
State New
Headers show

Comments

takasi-y@ops.dti.ne.jp - Feb. 17, 2010, 3:53 p.m.
cpu_gdb_read_register(): Fix n={8...15} case.
cpu_gdb_write_register(): Fix n={8...15} case and runaway "case:".

Signed-off-by: Takashi YOSHII <takasi-y@ops.dti.ne.jp>
---
 gdbstub.c |   27 ++++++++++++++-------------
 1 files changed, 14 insertions(+), 13 deletions(-)
Aurelien Jarno - Feb. 27, 2010, 3:27 p.m.
On Thu, Feb 18, 2010 at 12:53:29AM +0900, takasi-y@ops.dti.ne.jp wrote:
> cpu_gdb_read_register(): Fix n={8...15} case.
> cpu_gdb_write_register(): Fix n={8...15} case and runaway "case:".
> 
> Signed-off-by: Takashi YOSHII <takasi-y@ops.dti.ne.jp>

Thanks, applied.

> ---
>  gdbstub.c |   27 ++++++++++++++-------------
>  1 files changed, 14 insertions(+), 13 deletions(-)
> 
> diff --git a/gdbstub.c b/gdbstub.c
> index 80477be..3287dfb 100644
> --- a/gdbstub.c
> +++ b/gdbstub.c
> @@ -1148,7 +1148,7 @@ static int cpu_gdb_read_register(CPUState *env, uint8_t *mem_buf, int n)
>              GET_REGL(env->gregs[n]);
>          }
>      } else if (n < 16) {
> -        GET_REGL(env->gregs[n - 8]);
> +        GET_REGL(env->gregs[n]);
>      } else if (n >= 25 && n < 41) {
>  	GET_REGL(env->fregs[(n - 25) + ((env->fpscr & FPSCR_FR) ? 16 : 0)]);
>      } else if (n >= 43 && n < 51) {
> @@ -1187,10 +1187,11 @@ static int cpu_gdb_write_register(CPUState *env, uint8_t *mem_buf, int n)
>          }
>  	return 4;
>      } else if (n < 16) {
> -        env->gregs[n - 8] = tmp;
> +        env->gregs[n] = tmp;
>  	return 4;
>      } else if (n >= 25 && n < 41) {
>  	env->fregs[(n - 25) + ((env->fpscr & FPSCR_FR) ? 16 : 0)] = tmp;
> +	return 4;
>      } else if (n >= 43 && n < 51) {
>  	env->gregs[n - 43] = tmp;
>  	return 4;
> @@ -1199,17 +1200,17 @@ static int cpu_gdb_write_register(CPUState *env, uint8_t *mem_buf, int n)
>  	return 4;
>      }
>      switch (n) {
> -    case 16: env->pc = tmp;
> -    case 17: env->pr = tmp;
> -    case 18: env->gbr = tmp;
> -    case 19: env->vbr = tmp;
> -    case 20: env->mach = tmp;
> -    case 21: env->macl = tmp;
> -    case 22: env->sr = tmp;
> -    case 23: env->fpul = tmp;
> -    case 24: env->fpscr = tmp;
> -    case 41: env->ssr = tmp;
> -    case 42: env->spc = tmp;
> +    case 16: env->pc = tmp; break;
> +    case 17: env->pr = tmp; break;
> +    case 18: env->gbr = tmp; break;
> +    case 19: env->vbr = tmp; break;
> +    case 20: env->mach = tmp; break;
> +    case 21: env->macl = tmp; break;
> +    case 22: env->sr = tmp; break;
> +    case 23: env->fpul = tmp; break;
> +    case 24: env->fpscr = tmp; break;
> +    case 41: env->ssr = tmp; break;
> +    case 42: env->spc = tmp; break;
>      default: return 0;
>      }
>  
> -- 
> 1.6.5
> 
> 
> 
>

Patch

diff --git a/gdbstub.c b/gdbstub.c
index 80477be..3287dfb 100644
--- a/gdbstub.c
+++ b/gdbstub.c
@@ -1148,7 +1148,7 @@  static int cpu_gdb_read_register(CPUState *env, uint8_t *mem_buf, int n)
             GET_REGL(env->gregs[n]);
         }
     } else if (n < 16) {
-        GET_REGL(env->gregs[n - 8]);
+        GET_REGL(env->gregs[n]);
     } else if (n >= 25 && n < 41) {
 	GET_REGL(env->fregs[(n - 25) + ((env->fpscr & FPSCR_FR) ? 16 : 0)]);
     } else if (n >= 43 && n < 51) {
@@ -1187,10 +1187,11 @@  static int cpu_gdb_write_register(CPUState *env, uint8_t *mem_buf, int n)
         }
 	return 4;
     } else if (n < 16) {
-        env->gregs[n - 8] = tmp;
+        env->gregs[n] = tmp;
 	return 4;
     } else if (n >= 25 && n < 41) {
 	env->fregs[(n - 25) + ((env->fpscr & FPSCR_FR) ? 16 : 0)] = tmp;
+	return 4;
     } else if (n >= 43 && n < 51) {
 	env->gregs[n - 43] = tmp;
 	return 4;
@@ -1199,17 +1200,17 @@  static int cpu_gdb_write_register(CPUState *env, uint8_t *mem_buf, int n)
 	return 4;
     }
     switch (n) {
-    case 16: env->pc = tmp;
-    case 17: env->pr = tmp;
-    case 18: env->gbr = tmp;
-    case 19: env->vbr = tmp;
-    case 20: env->mach = tmp;
-    case 21: env->macl = tmp;
-    case 22: env->sr = tmp;
-    case 23: env->fpul = tmp;
-    case 24: env->fpscr = tmp;
-    case 41: env->ssr = tmp;
-    case 42: env->spc = tmp;
+    case 16: env->pc = tmp; break;
+    case 17: env->pr = tmp; break;
+    case 18: env->gbr = tmp; break;
+    case 19: env->vbr = tmp; break;
+    case 20: env->mach = tmp; break;
+    case 21: env->macl = tmp; break;
+    case 22: env->sr = tmp; break;
+    case 23: env->fpul = tmp; break;
+    case 24: env->fpscr = tmp; break;
+    case 41: env->ssr = tmp; break;
+    case 42: env->spc = tmp; break;
     default: return 0;
     }