Revision 3475187d gdbstub.c

b/gdbstub.c
1 1
/*
2 2
 * gdb server stub
3 3
 * 
4
 * Copyright (c) 2003 Fabrice Bellard
4
 * Copyright (c) 2003-2005 Fabrice Bellard
5 5
 *
6 6
 * This library is free software; you can redistribute it and/or
7 7
 * modify it under the terms of the GNU Lesser General Public
......
293 293
#elif defined (TARGET_SPARC)
294 294
static int cpu_gdb_read_registers(CPUState *env, uint8_t *mem_buf)
295 295
{
296
    uint32_t *registers = (uint32_t *)mem_buf, tmp;
296
    target_ulong *registers = (target_ulong *)mem_buf;
297 297
    int i;
298 298

  
299 299
    /* fill in g0..g7 */
......
308 308
    for (i = 0; i < 32; i++) {
309 309
        registers[i + 32] = tswapl(*((uint32_t *)&env->fpr[i]));
310 310
    }
311
#ifndef TARGET_SPARC64
311 312
    /* Y, PSR, WIM, TBR, PC, NPC, FPSR, CPSR */
312 313
    registers[64] = tswapl(env->y);
313
    tmp = GET_PSR(env);
314
    registers[65] = tswapl(tmp);
314
    {
315
	target_ulong tmp;
316

  
317
	tmp = GET_PSR(env);
318
	registers[65] = tswapl(tmp);
319
    }
315 320
    registers[66] = tswapl(env->wim);
316 321
    registers[67] = tswapl(env->tbr);
317 322
    registers[68] = tswapl(env->pc);
......
319 324
    registers[70] = tswapl(env->fsr);
320 325
    registers[71] = 0; /* csr */
321 326
    registers[72] = 0;
322

  
323
    return 73 * 4;
327
    return 73 * sizeof(target_ulong);
328
#else
329
    for (i = 0; i < 32; i += 2) {
330
        registers[i/2 + 64] = tswapl(*((uint64_t *)&env->fpr[i]));
331
    }
332
    registers[81] = tswapl(env->pc);
333
    registers[82] = tswapl(env->npc);
334
    registers[83] = tswapl(env->tstate[env->tl]);
335
    registers[84] = tswapl(env->fsr);
336
    registers[85] = tswapl(env->fprs);
337
    registers[86] = tswapl(env->y);
338
    return 87 * sizeof(target_ulong);
339
#endif
324 340
}
325 341

  
326 342
static void cpu_gdb_write_registers(CPUState *env, uint8_t *mem_buf, int size)
327 343
{
328
    uint32_t *registers = (uint32_t *)mem_buf;
344
    target_ulong *registers = (target_ulong *)mem_buf;
329 345
    int i;
330 346

  
331 347
    /* fill in g0..g7 */
......
334 350
    }
335 351
    /* fill in register window */
336 352
    for(i = 0; i < 24; i++) {
337
        env->regwptr[i] = tswapl(registers[i]);
353
        env->regwptr[i] = tswapl(registers[i + 8]);
338 354
    }
339 355
    /* fill in fprs */
340 356
    for (i = 0; i < 32; i++) {
341 357
        *((uint32_t *)&env->fpr[i]) = tswapl(registers[i + 32]);
342 358
    }
359
#ifndef TARGET_SPARC64
343 360
    /* Y, PSR, WIM, TBR, PC, NPC, FPSR, CPSR */
344 361
    env->y = tswapl(registers[64]);
345 362
    PUT_PSR(env, tswapl(registers[65]));
......
348 365
    env->pc = tswapl(registers[68]);
349 366
    env->npc = tswapl(registers[69]);
350 367
    env->fsr = tswapl(registers[70]);
368
#else
369
    for (i = 0; i < 32; i += 2) {
370
	uint64_t tmp;
371
	tmp = tswapl(registers[i/2 + 64]) << 32;
372
	tmp |= tswapl(registers[i/2 + 64 + 1]);
373
        *((uint64_t *)&env->fpr[i]) = tmp;
374
    }
375
    env->pc = tswapl(registers[81]);
376
    env->npc = tswapl(registers[82]);
377
    env->tstate[env->tl] = tswapl(registers[83]);
378
    env->fsr = tswapl(registers[84]);
379
    env->fprs = tswapl(registers[85]);
380
    env->y = tswapl(registers[86]);
381
#endif
351 382
}
352 383
#elif defined (TARGET_ARM)
353 384
static int cpu_gdb_read_registers(CPUState *env, uint8_t *mem_buf)

Also available in: Unified diff