remote_gdb.hh revision 3536
16019Shines@cs.fsu.edu/*
26019Shines@cs.fsu.edu * Copyright (c) 2002-2005 The Regents of The University of Michigan
37178Sgblack@eecs.umich.edu * All rights reserved.
47178Sgblack@eecs.umich.edu *
57178Sgblack@eecs.umich.edu * Redistribution and use in source and binary forms, with or without
67178Sgblack@eecs.umich.edu * modification, are permitted provided that the following conditions are
77178Sgblack@eecs.umich.edu * met: redistributions of source code must retain the above copyright
87178Sgblack@eecs.umich.edu * notice, this list of conditions and the following disclaimer;
97178Sgblack@eecs.umich.edu * redistributions in binary form must reproduce the above copyright
107178Sgblack@eecs.umich.edu * notice, this list of conditions and the following disclaimer in the
117178Sgblack@eecs.umich.edu * documentation and/or other materials provided with the distribution;
127178Sgblack@eecs.umich.edu * neither the name of the copyright holders nor the names of its
137178Sgblack@eecs.umich.edu * contributors may be used to endorse or promote products derived from
147178Sgblack@eecs.umich.edu * this software without specific prior written permission.
156019Shines@cs.fsu.edu *
166019Shines@cs.fsu.edu * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
176019Shines@cs.fsu.edu * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
186019Shines@cs.fsu.edu * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
196019Shines@cs.fsu.edu * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
206019Shines@cs.fsu.edu * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
216019Shines@cs.fsu.edu * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
226019Shines@cs.fsu.edu * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
236019Shines@cs.fsu.edu * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
246019Shines@cs.fsu.edu * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
256019Shines@cs.fsu.edu * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
266019Shines@cs.fsu.edu * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
276019Shines@cs.fsu.edu *
286019Shines@cs.fsu.edu * Authors: Nathan Binkert
296019Shines@cs.fsu.edu */
306019Shines@cs.fsu.edu
316019Shines@cs.fsu.edu#ifndef __ARCH_ALPHA_REMOTE_GDB_HH__
326019Shines@cs.fsu.edu#define __ARCH_ALPHA_REMOTE_GDB_HH__
336019Shines@cs.fsu.edu
346019Shines@cs.fsu.edu#include <map>
356019Shines@cs.fsu.edu
366019Shines@cs.fsu.edu#include "arch/alpha/types.hh"
376019Shines@cs.fsu.edu#include "arch/alpha/kgdb.h"
386019Shines@cs.fsu.edu#include "base/remote_gdb.hh"
396019Shines@cs.fsu.edu#include "cpu/pc_event.hh"
406019Shines@cs.fsu.edu#include "base/pollevent.hh"
416019Shines@cs.fsu.edu#include "base/socket.hh"
426019Shines@cs.fsu.edu
436019Shines@cs.fsu.educlass System;
446019Shines@cs.fsu.educlass ThreadContext;
456019Shines@cs.fsu.educlass PhysicalMemory;
466019Shines@cs.fsu.edu
476019Shines@cs.fsu.edunamespace AlphaISA
486019Shines@cs.fsu.edu{
496019Shines@cs.fsu.edu    class RemoteGDB : public BaseRemoteGDB
506019Shines@cs.fsu.edu    {
516019Shines@cs.fsu.edu      private:
526019Shines@cs.fsu.edu        friend void debugger();
536019Shines@cs.fsu.edu        friend class GDBListener;
546019Shines@cs.fsu.edu
556019Shines@cs.fsu.edu      protected:
566019Shines@cs.fsu.edu        class Event : public PollEvent
576019Shines@cs.fsu.edu        {
586243Sgblack@eecs.umich.edu          protected:
596243Sgblack@eecs.umich.edu            RemoteGDB *gdb;
606243Sgblack@eecs.umich.edu
616243Sgblack@eecs.umich.edu          public:
626243Sgblack@eecs.umich.edu            Event(RemoteGDB *g, int fd, int e);
636019Shines@cs.fsu.edu            void process(int revent);
646019Shines@cs.fsu.edu        };
656019Shines@cs.fsu.edu
666019Shines@cs.fsu.edu        friend class Event;
676019Shines@cs.fsu.edu        Event *event;
686019Shines@cs.fsu.edu
696019Shines@cs.fsu.edu      protected:
706019Shines@cs.fsu.edu        // Machine memory
716019Shines@cs.fsu.edu        bool write(Addr addr, size_t size, const char *data);
726019Shines@cs.fsu.edu
736019Shines@cs.fsu.edu      public:
746019Shines@cs.fsu.edu        RemoteGDB(System *system, ThreadContext *context);
756019Shines@cs.fsu.edu        ~RemoteGDB();
766019Shines@cs.fsu.edu
776019Shines@cs.fsu.edu        bool acc(Addr addr, size_t len);
786019Shines@cs.fsu.edu
796019Shines@cs.fsu.edu      protected:
806019Shines@cs.fsu.edu        void getregs();
816019Shines@cs.fsu.edu        void setregs();
826019Shines@cs.fsu.edu
836019Shines@cs.fsu.edu        void clearSingleStep();
846019Shines@cs.fsu.edu        void setSingleStep();
856019Shines@cs.fsu.edu
866019Shines@cs.fsu.edu        PCEventQueue *getPcEventQueue();
876019Shines@cs.fsu.edu
886019Shines@cs.fsu.edu      protected:
896019Shines@cs.fsu.edu        class HardBreakpoint : public PCEvent
906019Shines@cs.fsu.edu        {
916019Shines@cs.fsu.edu          private:
926019Shines@cs.fsu.edu            RemoteGDB *gdb;
936019Shines@cs.fsu.edu
946252Sgblack@eecs.umich.edu          public:
956243Sgblack@eecs.umich.edu            int refcount;
966243Sgblack@eecs.umich.edu
976243Sgblack@eecs.umich.edu          public:
986019Shines@cs.fsu.edu            HardBreakpoint(RemoteGDB *_gdb, Addr addr);
996019Shines@cs.fsu.edu            std::string name() { return gdb->name() + ".hwbkpt"; }
1006019Shines@cs.fsu.edu
1016019Shines@cs.fsu.edu            virtual void process(ThreadContext *tc);
1026019Shines@cs.fsu.edu        };
1036252Sgblack@eecs.umich.edu        friend class HardBreakpoint;
1046243Sgblack@eecs.umich.edu
1056243Sgblack@eecs.umich.edu        typedef std::map<Addr, HardBreakpoint *> break_map_t;
1066243Sgblack@eecs.umich.edu        typedef break_map_t::iterator break_iter_t;
1076019Shines@cs.fsu.edu        break_map_t hardBreakMap;
1086019Shines@cs.fsu.edu
1096019Shines@cs.fsu.edu        bool insertSoftBreak(Addr addr, size_t len);
1106019Shines@cs.fsu.edu        bool removeSoftBreak(Addr addr, size_t len);
1116019Shines@cs.fsu.edu        bool insertHardBreak(Addr addr, size_t len);
1126019Shines@cs.fsu.edu        bool removeHardBreak(Addr addr, size_t len);
1136019Shines@cs.fsu.edu
1146252Sgblack@eecs.umich.edu      protected:
1156243Sgblack@eecs.umich.edu        struct TempBreakpoint {
1166243Sgblack@eecs.umich.edu            Addr	address;		// set here
1176243Sgblack@eecs.umich.edu            MachInst	bkpt_inst;		// saved instruction at bkpt
1186019Shines@cs.fsu.edu            int		init_count;		// number of times to skip bkpt
1196019Shines@cs.fsu.edu            int		count;			// current count
1206019Shines@cs.fsu.edu        };
1216019Shines@cs.fsu.edu
1226019Shines@cs.fsu.edu        TempBreakpoint notTakenBkpt;
1236019Shines@cs.fsu.edu        TempBreakpoint takenBkpt;
1246019Shines@cs.fsu.edu
1256019Shines@cs.fsu.edu        void clearTempBreakpoint(TempBreakpoint &bkpt);
1266019Shines@cs.fsu.edu        void setTempBreakpoint(TempBreakpoint &bkpt, Addr addr);
1276019Shines@cs.fsu.edu    };
1286019Shines@cs.fsu.edu}
1296019Shines@cs.fsu.edu
1306019Shines@cs.fsu.edu#endif /* __ARCH_ALPHA_REMOTE_GDB_H__ */
1316019Shines@cs.fsu.edu