remote_gdb.cc (3918:1f9a98d198e8) | remote_gdb.cc (3960:1dca397b2bab) |
---|---|
1/* 2 * Copyright (c) 2002-2005 The Regents of The University of Michigan 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions are 7 * met: redistributions of source code must retain the above copyright 8 * notice, this list of conditions and the following disclaimer; --- 107 unchanged lines hidden (view full) --- 116 * "Stub" to allow remote cpu to debug over a serial line using gdb. 117 */ 118 119#include <sys/signal.h> 120 121#include <string> 122#include <unistd.h> 123 | 1/* 2 * Copyright (c) 2002-2005 The Regents of The University of Michigan 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions are 7 * met: redistributions of source code must retain the above copyright 8 * notice, this list of conditions and the following disclaimer; --- 107 unchanged lines hidden (view full) --- 116 * "Stub" to allow remote cpu to debug over a serial line using gdb. 117 */ 118 119#include <sys/signal.h> 120 121#include <string> 122#include <unistd.h> 123 |
124#include "config/full_system.hh" 125 126#if FULL_SYSTEM |
|
124#include "arch/vtophys.hh" | 127#include "arch/vtophys.hh" |
128#endif 129 |
|
125#include "base/intmath.hh" 126#include "base/remote_gdb.hh" 127#include "base/socket.hh" 128#include "base/trace.hh" | 130#include "base/intmath.hh" 131#include "base/remote_gdb.hh" 132#include "base/socket.hh" 133#include "base/trace.hh" |
129#include "config/full_system.hh" | |
130#include "cpu/thread_context.hh" 131#include "cpu/static_inst.hh" | 134#include "cpu/thread_context.hh" 135#include "cpu/static_inst.hh" |
132#include "mem/physical.hh" | 136//#include "mem/physical.hh" |
133#include "mem/port.hh" | 137#include "mem/port.hh" |
138#include "mem/translating_port.hh" |
|
134#include "sim/system.hh" 135 136using namespace std; 137using namespace TheISA; 138 139#ifndef NDEBUG 140vector<BaseRemoteGDB *> debuggers; 141 --- 301 unchanged lines hidden (view full) --- 443 444 if (vaddr < 10) { 445 DPRINTF(GDBRead, "read: reading memory location zero!\n"); 446 vaddr = lastaddr + lastsize; 447 } 448 449 DPRINTF(GDBRead, "read: addr=%#x, size=%d", vaddr, size); 450 | 139#include "sim/system.hh" 140 141using namespace std; 142using namespace TheISA; 143 144#ifndef NDEBUG 145vector<BaseRemoteGDB *> debuggers; 146 --- 301 unchanged lines hidden (view full) --- 448 449 if (vaddr < 10) { 450 DPRINTF(GDBRead, "read: reading memory location zero!\n"); 451 vaddr = lastaddr + lastsize; 452 } 453 454 DPRINTF(GDBRead, "read: addr=%#x, size=%d", vaddr, size); 455 |
451 VirtualPort *vp = context->getVirtPort(context); 452 vp->readBlob(vaddr, (uint8_t*)data, size); 453 context->delVirtPort(vp); | 456#if FULL_SYSTEM 457 VirtualPort *port = context->getVirtPort(context); 458#else 459 TranslatingPort *port = context->getMemPort(); 460#endif 461 port->readBlob(vaddr, (uint8_t*)data, size); 462#if FULL_SYSTEM 463 context->delVirtPort(port); 464#else 465 delete port; 466#endif |
454 455#if TRACING_ON 456 if (DTRACE(GDBRead)) { 457 if (DTRACE(GDBExtra)) { 458 char buf[1024]; 459 mem2hex(buf, data, size); 460 DPRINTFNR(": %s\n", buf); 461 } else --- 20 unchanged lines hidden (view full) --- 482 DPRINTFN("write: addr=%#x, size=%d", vaddr, size); 483 if (DTRACE(GDBExtra)) { 484 char buf[1024]; 485 mem2hex(buf, data, size); 486 DPRINTFNR(": %s\n", buf); 487 } else 488 DPRINTFNR("\n"); 489 } | 467 468#if TRACING_ON 469 if (DTRACE(GDBRead)) { 470 if (DTRACE(GDBExtra)) { 471 char buf[1024]; 472 mem2hex(buf, data, size); 473 DPRINTFNR(": %s\n", buf); 474 } else --- 20 unchanged lines hidden (view full) --- 495 DPRINTFN("write: addr=%#x, size=%d", vaddr, size); 496 if (DTRACE(GDBExtra)) { 497 char buf[1024]; 498 mem2hex(buf, data, size); 499 DPRINTFNR(": %s\n", buf); 500 } else 501 DPRINTFNR("\n"); 502 } |
490 VirtualPort *vp = context->getVirtPort(context); 491 vp->writeBlob(vaddr, (uint8_t*)data, size); 492 context->delVirtPort(vp); | 503#if FULL_SYSTEM 504 VirtualPort *port = context->getVirtPort(context); 505#else 506 TranslatingPort *port = context->getMemPort(); 507#endif 508 port->writeBlob(vaddr, (uint8_t*)data, size); 509#if FULL_SYSTEM 510 context->delVirtPort(port); 511#else 512 delete port; 513#endif |
493 494 return true; 495} 496 497PCEventQueue *BaseRemoteGDB::getPcEventQueue() 498{ 499 return &system->pcEventQueue; 500} --- 104 unchanged lines hidden (view full) --- 605// makes sense to use POSIX errno values, because that is what the 606// gdb/remote.c functions want to return. 607bool 608BaseRemoteGDB::trap(int type) 609{ 610 uint64_t val; 611 size_t datalen, len; 612 char data[GDBPacketBufLen + 1]; | 514 515 return true; 516} 517 518PCEventQueue *BaseRemoteGDB::getPcEventQueue() 519{ 520 return &system->pcEventQueue; 521} --- 104 unchanged lines hidden (view full) --- 626// makes sense to use POSIX errno values, because that is what the 627// gdb/remote.c functions want to return. 628bool 629BaseRemoteGDB::trap(int type) 630{ 631 uint64_t val; 632 size_t datalen, len; 633 char data[GDBPacketBufLen + 1]; |
613 char *buffer; | 634 char buffer[gdbregs.bytes() * 2 + 256]; |
614 const char *p; 615 char command, subcmd; 616 string var; 617 bool ret; 618 619 if (!attached) 620 return false; 621 | 635 const char *p; 636 char command, subcmd; 637 string var; 638 bool ret; 639 640 if (!attached) 641 return false; 642 |
622 buffer = (char*)malloc(gdbregs.bytes() * 2 + 256); 623 | |
624 DPRINTF(GDBMisc, "trap: PC=%#x NPC=%#x\n", 625 context->readPC(), context->readNextPC()); 626 627 clearSingleStep(); 628 629 /* 630 * The first entry to this function is normally through 631 * a breakpoint trap in kgdb_connect(), in which case we --- 281 unchanged lines hidden (view full) --- 913 send(""); 914 continue; 915 916 917 } 918 } 919 920 out: | 643 DPRINTF(GDBMisc, "trap: PC=%#x NPC=%#x\n", 644 context->readPC(), context->readNextPC()); 645 646 clearSingleStep(); 647 648 /* 649 * The first entry to this function is normally through 650 * a breakpoint trap in kgdb_connect(), in which case we --- 281 unchanged lines hidden (view full) --- 932 send(""); 933 continue; 934 935 936 } 937 } 938 939 out: |
921 free(buffer); | |
922 return true; 923} 924 925// Convert a hex digit into an integer. 926// This returns -1 if the argument passed is no valid hex digit. 927int 928BaseRemoteGDB::digit2i(char c) 929{ --- 73 unchanged lines hidden --- | 940 return true; 941} 942 943// Convert a hex digit into an integer. 944// This returns -1 if the argument passed is no valid hex digit. 945int 946BaseRemoteGDB::digit2i(char c) 947{ --- 73 unchanged lines hidden --- |