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
127#include "arch/vtophys.hh"
128#endif
129
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"
134#include "cpu/thread_context.hh"
135#include "cpu/static_inst.hh"
132#include "mem/physical.hh"
136//#include "mem/physical.hh"
137#include "mem/port.hh"
138#include "mem/translating_port.hh"
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
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
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];
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
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);
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 ---