2 * Copyright (c) 1996-2009 Barton P. Miller
4 * We provide the Paradyn Parallel Performance Tools (below
5 * described as "Paradyn") on an AS IS basis, and do not warrant its
6 * validity or performance. We reserve the right to update, modify,
7 * or discontinue this software at any time. We shall have no
8 * obligation to supply such updates or modifications or any other
9 * form of support to you.
11 * By your use of Paradyn, you understand and agree that we (or any
12 * other person or entity with proprietary rights in Paradyn) are
13 * under no obligation to provide either maintenance services,
14 * update services, notices of latent defects, or correction of
15 * defects for Paradyn.
17 * This library is free software; you can redistribute it and/or
18 * modify it under the terms of the GNU Lesser General Public
19 * License as published by the Free Software Foundation; either
20 * version 2.1 of the License, or (at your option) any later version.
22 * This library is distributed in the hope that it will be useful,
23 * but WITHOUT ANY WARRANTY; without even the implied warranty of
24 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
25 * Lesser General Public License for more details.
27 * You should have received a copy of the GNU Lesser General Public
28 * License along with this library; if not, write to the Free Software
29 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
31 #if !defined(FREEBSD_H_)
34 #include "proccontrol/h/Generator.h"
35 #include "proccontrol/h/Event.h"
36 #include "proccontrol/h/Decoder.h"
37 #include "proccontrol/h/Handler.h"
38 #include "proccontrol/src/int_process.h"
39 #include "proccontrol/src/int_thread_db.h"
40 #include "common/h/dthread.h"
42 using namespace Dyninst;
43 using namespace ProcControlAPI;
45 class GeneratorFreeBSD : public GeneratorMT
49 virtual ~GeneratorFreeBSD();
51 virtual bool initialize();
52 virtual bool canFastHandle();
53 virtual ArchEvent *getEvent(bool block);
56 class ArchEventFreeBSD : public ArchEvent
65 ArchEventFreeBSD(bool inter_);
66 ArchEventFreeBSD(pid_t p, lwpid_t l, int s);
67 ArchEventFreeBSD(int e);
69 virtual ~ArchEventFreeBSD();
72 class DecoderFreeBSD : public Decoder
76 virtual ~DecoderFreeBSD();
77 virtual unsigned getPriority() const;
78 virtual bool decode(ArchEvent *ae, std::vector<Event::ptr> &events);
79 Dyninst::Address adjustTrapAddr(Dyninst::Address address, Dyninst::Architecture arch);
82 class freebsd_process : public thread_db_process
85 freebsd_process(Dyninst::PID p, std::string e, std::vector<std::string> a);
86 freebsd_process(Dyninst::PID pid_, int_process *p);
87 virtual ~freebsd_process();
89 virtual bool plat_create();
90 virtual bool plat_attach();
91 virtual bool plat_forked();
92 virtual bool post_forked();
93 virtual bool plat_execed();
94 virtual bool plat_detach();
95 virtual bool plat_terminate(bool &needs_sync);
97 virtual bool plat_readMem(int_thread *thr, void *local,
98 Dyninst::Address remote, size_t size);
99 virtual bool plat_writeMem(int_thread *thr, void *local,
100 Dyninst::Address remote, size_t size);
102 virtual bool needIndividualThreadAttach();
103 virtual bool getThreadLWPs(std::vector<Dyninst::LWP> &lwps);
104 virtual Dyninst::Architecture getTargetArch();
105 virtual bool plat_individualRegAccess();
106 virtual bool plat_contProcess();
108 /* thread_db_process methods */
109 virtual string getThreadLibName(const char *symName);
110 virtual bool isSupportedThreadLib(const string &libName);
111 virtual bool plat_readProcMem(void *local,
112 Dyninst::Address remote, size_t size);
113 virtual bool plat_writeProcMem(void *local,
114 Dyninst::Address remote, size_t size);
115 virtual bool plat_getLWPInfo(lwpid_t lwp, void *lwpInfo);
116 virtual bool plat_contThread(lwpid_t lwp);
117 virtual bool plat_stopThread(lwpid_t lwp);
120 string libThreadName;
123 class freebsd_thread : public thread_db_thread
126 freebsd_thread(int_process *p, Dyninst::THR_ID t, Dyninst::LWP l);
129 virtual ~freebsd_thread();
131 virtual bool plat_cont(bool user_cont);
132 virtual bool plat_stop();
133 virtual bool plat_getAllRegisters(int_registerPool ®);
134 virtual bool plat_getRegister(Dyninst::MachRegister reg, Dyninst::MachRegisterVal &val);
135 virtual bool plat_setAllRegisters(int_registerPool ®);
136 virtual bool plat_setRegister(Dyninst::MachRegister reg, Dyninst::MachRegisterVal val);
137 virtual bool attach();
139 /* FreeBSD-specific */
140 virtual bool plat_setStep();
143 class FreeBSDSyncHandler : public Handler
146 FreeBSDSyncHandler();
147 virtual ~FreeBSDSyncHandler();
148 virtual bool handleEvent(Event::ptr ev);
149 virtual int getPriority() const;
150 void getEventTypesHandled(std::vector<EventType> &etypes);