Indirect tail calls can be PC-relative and should be treated as indirect calls during...
[dyninst.git] / proccontrol / h / Event.h
1 /*
2  * See the dyninst/COPYRIGHT file for copyright information.
3  * 
4  * We provide the Paradyn Tools (below described as "Paradyn")
5  * on an AS IS basis, and do not warrant its validity or performance.
6  * We reserve the right to update, modify, or discontinue this
7  * software at any time.  We shall have no obligation to supply such
8  * updates or modifications or any other form of support to you.
9  * 
10  * By your use of Paradyn, you understand and agree that we (or any
11  * other person or entity with proprietary rights in Paradyn) are
12  * under no obligation to provide either maintenance services,
13  * update services, notices of latent defects, or correction of
14  * defects for Paradyn.
15  * 
16  * This library is free software; you can redistribute it and/or
17  * modify it under the terms of the GNU Lesser General Public
18  * License as published by the Free Software Foundation; either
19  * version 2.1 of the License, or (at your option) any later version.
20  * 
21  * This library is distributed in the hope that it will be useful,
22  * but WITHOUT ANY WARRANTY; without even the implied warranty of
23  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
24  * Lesser General Public License for more details.
25  * 
26  * You should have received a copy of the GNU Lesser General Public
27  * License along with this library; if not, write to the Free Software
28  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
29  */
30 #if !defined(EVENT_H_)
31 #define EVENT_H_
32
33 #include <string>
34 #include <set>
35 #include "dyntypes.h"
36 #include "MachSyscall.h"
37 #include "EventType.h"
38 #include "PCProcess.h"
39 #include "util.h"
40
41 class HandlerPool;
42 class HandleCallbacks;
43
44 namespace Dyninst {
45 namespace ProcControlAPI {
46
47 class PC_EXPORT ArchEvent
48 {
49 private:
50    std::string name;
51 public:
52    ArchEvent(std::string name_ = std::string(""));
53    virtual ~ArchEvent();
54    std::string getName(); 
55 };
56
57 class Handler;
58 class EventTerminate;
59 class EventExit;
60 class EventCrash;
61 class EventForceTerminate;
62 class EventExec;
63 class EventBreakpoint;
64 class EventStop;
65 class EventNewThread;
66 class EventNewUserThread;
67 class EventNewLWP;
68 class EventThreadDestroy;
69 class EventUserThreadDestroy;
70 class EventLWPDestroy;
71 class EventFork;
72 class EventSignal;
73 class EventBootstrap;
74 class EventRPC;
75 class EventSingleStep;
76 class EventBreakpointClear;
77 class EventBreakpointRestore;
78 class EventLibrary;
79 class EventRPCLaunch;
80 class EventAsync;
81 class EventChangePCStop;
82 class EventPreBootstrap;
83 class EventDetach;
84 class EventIntBootstrap;
85 class EventNop;
86 class EventThreadDB;
87 class EventWinStopThreadDestroy;
88 class EventControlAuthority;
89 class EventAsyncIO;
90 class EventAsyncRead;
91 class EventAsyncWrite;
92 class EventAsyncReadAllRegs;
93 class EventAsyncSetAllRegs;
94 class EventAsyncFileRead;
95 class EventPostponedSyscall;
96 class EventSyscall;
97 class EventPreSyscall;
98 class EventPostSyscall;
99
100 class PC_EXPORT Event : public boost::enable_shared_from_this<Event>
101 {
102    friend void boost::checked_delete<Event>(Event *);
103    friend void boost::checked_delete<const Event>(const Event *);
104    friend class ::HandlerPool;
105    friend class ::int_process;
106    friend class ::HandleCallbacks;
107  public:
108    typedef boost::shared_ptr<Event> ptr;
109    typedef boost::shared_ptr<const Event> const_ptr;
110    typedef boost::weak_ptr<Event> weak_ptr;
111
112    Event(EventType etype_, Thread::ptr thread_ = Thread::ptr());
113    virtual ~Event();
114
115    typedef enum {
116       unset,
117       async,
118       sync_thread,
119       sync_process
120    } SyncType;
121
122    EventType getEventType() const;
123    Thread::const_ptr getThread() const;
124    Process::const_ptr getProcess() const;
125    SyncType getSyncType() const;
126    std::string name() const;
127
128    void setThread(Thread::const_ptr t);
129    void setProcess(Process::const_ptr p);
130    void setSyncType(SyncType t);
131    void setSuppressCB(bool b);
132
133    virtual bool suppressCB() const;
134    virtual bool triggersCB() const;
135    virtual bool canFastHandle() const;
136    virtual bool userEvent() const;
137    virtual void setUserEvent(bool b);
138    virtual bool procStopper() const;
139
140    Event::weak_ptr subservientTo() const;
141    void addSubservientEvent(Event::ptr ev);
142
143    boost::shared_ptr<EventTerminate> getEventTerminate();
144    boost::shared_ptr<const EventTerminate> getEventTerminate() const;
145
146    boost::shared_ptr<EventExit> getEventExit();
147    boost::shared_ptr<const EventExit> getEventExit() const;
148
149    boost::shared_ptr<EventCrash> getEventCrash();
150    boost::shared_ptr<const EventCrash> getEventCrash() const;
151
152    boost::shared_ptr<EventForceTerminate> getEventForceTerminate();
153    boost::shared_ptr<const EventForceTerminate> getEventForceTerminate() const;
154
155    boost::shared_ptr<EventExec> getEventExec();
156    boost::shared_ptr<const EventExec> getEventExec() const;
157
158    boost::shared_ptr<EventStop> getEventStop();
159    boost::shared_ptr<const EventStop> getEventStop() const;
160
161    boost::shared_ptr<EventBreakpoint> getEventBreakpoint();
162    boost::shared_ptr<const EventBreakpoint> getEventBreakpoint() const;
163
164    boost::shared_ptr<EventNewThread> getEventNewThread();
165    boost::shared_ptr<const EventNewThread> getEventNewThread() const;
166
167    boost::shared_ptr<EventNewUserThread> getEventNewUserThread();
168    boost::shared_ptr<const EventNewUserThread> getEventNewUserThread() const;
169
170    boost::shared_ptr<EventNewLWP> getEventNewLWP();
171    boost::shared_ptr<const EventNewLWP> getEventNewLWP() const;
172
173    boost::shared_ptr<EventThreadDestroy> getEventThreadDestroy();
174    boost::shared_ptr<const EventThreadDestroy> getEventThreadDestroy() const;
175
176    boost::shared_ptr<EventUserThreadDestroy> getEventUserThreadDestroy();
177    boost::shared_ptr<const EventUserThreadDestroy> getEventUserThreadDestroy() const;
178
179    boost::shared_ptr<EventLWPDestroy> getEventLWPDestroy();
180    boost::shared_ptr<const EventLWPDestroy> getEventLWPDestroy() const;
181
182    boost::shared_ptr<EventFork> getEventFork();
183    boost::shared_ptr<const EventFork> getEventFork() const;
184
185    boost::shared_ptr<EventSignal> getEventSignal();
186    boost::shared_ptr<const EventSignal> getEventSignal() const;
187
188    boost::shared_ptr<EventBootstrap> getEventBootstrap();
189    boost::shared_ptr<const EventBootstrap> getEventBootstrap() const;
190
191    boost::shared_ptr<EventPreBootstrap> getEventPreBootstrap();
192    boost::shared_ptr<const EventPreBootstrap> getEventPreBootstrap() const;
193
194    boost::shared_ptr<EventRPC> getEventRPC();
195    boost::shared_ptr<const EventRPC> getEventRPC() const;
196
197    boost::shared_ptr<EventRPCLaunch> getEventRPCLaunch();
198    boost::shared_ptr<const EventRPCLaunch> getEventRPCLaunch() const;
199
200    boost::shared_ptr<EventSingleStep> getEventSingleStep();
201    boost::shared_ptr<const EventSingleStep> getEventSingleStep() const;
202
203    boost::shared_ptr<EventBreakpointClear> getEventBreakpointClear();
204    boost::shared_ptr<const EventBreakpointClear> getEventBreakpointClear() const;
205
206    boost::shared_ptr<EventBreakpointRestore> getEventBreakpointRestore();
207    boost::shared_ptr<const EventBreakpointRestore> getEventBreakpointRestore() const;
208
209    boost::shared_ptr<EventLibrary> getEventLibrary();
210    boost::shared_ptr<const EventLibrary> getEventLibrary() const;
211
212    boost::shared_ptr<EventAsync> getEventAsync();
213    boost::shared_ptr<const EventAsync> getEventAsync() const;
214
215    boost::shared_ptr<EventChangePCStop> getEventChangePCStop();
216    boost::shared_ptr<const EventChangePCStop> getEventChangePCStop() const;
217
218    boost::shared_ptr<EventDetach> getEventDetach();
219    boost::shared_ptr<const EventDetach> getEventDetach() const;
220
221    boost::shared_ptr<EventIntBootstrap> getEventIntBootstrap();
222    boost::shared_ptr<const EventIntBootstrap> getEventIntBootstrap() const;
223
224    boost::shared_ptr<EventNop> getEventNop();
225    boost::shared_ptr<const EventNop> getEventNop() const;
226
227    boost::shared_ptr<EventThreadDB> getEventThreadDB();
228    boost::shared_ptr<const EventThreadDB> getEventThreadDB() const;
229
230    boost::shared_ptr<EventWinStopThreadDestroy> getEventWinStopThreadDestroy();
231    boost::shared_ptr<const EventWinStopThreadDestroy> getEventWinStopThreadDestroy() const;
232
233    boost::shared_ptr<EventControlAuthority> getEventControlAuthority();
234    boost::shared_ptr<const EventControlAuthority> getEventControlAuthority() const;
235
236    boost::shared_ptr<EventAsyncIO> getEventAsyncIO();
237    boost::shared_ptr<const EventAsyncIO> getEventAsyncIO() const;
238
239    boost::shared_ptr<EventAsyncRead> getEventAsyncRead();
240    boost::shared_ptr<const EventAsyncRead> getEventAsyncRead() const;
241
242    boost::shared_ptr<EventAsyncWrite> getEventAsyncWrite();
243    boost::shared_ptr<const EventAsyncWrite> getEventAsyncWrite() const;
244
245    boost::shared_ptr<EventAsyncReadAllRegs> getEventAsyncReadAllRegs();
246    boost::shared_ptr<const EventAsyncReadAllRegs> getEventAsyncReadAllRegs() const;
247
248    boost::shared_ptr<EventAsyncSetAllRegs> getEventAsyncSetAllRegs();
249    boost::shared_ptr<const EventAsyncSetAllRegs> getEventAsyncSetAllRegs() const;
250
251    boost::shared_ptr<EventAsyncFileRead> getEventAsyncFileRead();
252    boost::shared_ptr<const EventAsyncFileRead> getEventAsyncFileRead() const;
253
254    boost::shared_ptr<EventPostponedSyscall> getEventPostponedSyscall();
255    boost::shared_ptr<const EventPostponedSyscall> getEventPostponedSyscall() const;
256
257    boost::shared_ptr<EventSyscall> getEventSyscall();
258    boost::shared_ptr<const EventSyscall> getEventSyscall() const;
259    
260    boost::shared_ptr<EventPreSyscall> getEventPreSyscall();
261    boost::shared_ptr<const EventPreSyscall> getEventPreSyscall() const;
262    
263    boost::shared_ptr<EventPostSyscall> getEventPostSyscall();
264    boost::shared_ptr<const EventPostSyscall> getEventPostSyscall() const;
265
266
267    //Not meant for public consumption
268    void setLastError(err_t ec, const char *es);
269  protected:
270    EventType etype;
271    Thread::const_ptr thread;
272    Process::const_ptr proc;
273    SyncType stype;
274    std::vector<Event::ptr> subservient_events;
275    Event::weak_ptr master_event;
276    std::set<Handler *> handled_by;
277    bool suppress_cb;
278    bool user_event;
279    bool handling_started;
280    bool noted_event;
281 };
282
283 template<typename OS>
284 OS& operator<<(OS& str, Event& e)
285 {
286         str << e.getEventType().name() << " event is ";
287         switch(e.getSyncType())
288         {
289         case Event::async:
290                 str << "asynchronous ";
291                 break;
292         case Event::sync_thread:
293                 str << "thread synchronous ";
294                 break;
295         case Event::sync_process:
296                 str << "process synchronous ";
297                 break;
298         default:
299                 str << "<UNKNOWN SYNC TYPE> ";
300                 break;
301         }
302         str << "on " << (e.getProcess() ? e.getProcess()->getPid() : -1);
303         str << "/" << ((e.getThread()) ?  e.getThread()->getLWP() : (Dyninst::LWP) -1);
304         str << "\n";
305         return str;
306 }
307
308 class PC_EXPORT EventTerminate : public Event
309 {
310    friend void boost::checked_delete<EventTerminate>(EventTerminate *);
311    friend void boost::checked_delete<const EventTerminate>(const EventTerminate *);
312  public:
313    typedef boost::shared_ptr<EventTerminate> ptr;
314    typedef boost::shared_ptr<const EventTerminate> const_ptr;
315    EventTerminate(EventType type_);
316    virtual ~EventTerminate();
317 };
318
319 class PC_EXPORT EventExit : public EventTerminate
320 {
321    friend void boost::checked_delete<EventExit>(EventExit *);
322    friend void boost::checked_delete<const EventExit>(const EventExit *);
323  private:
324    int exitcode;
325  public:
326    typedef boost::shared_ptr<EventExit> ptr;
327    typedef boost::shared_ptr<const EventExit> const_ptr;
328    int getExitCode() const;
329    EventExit(EventType::Time eventtime, int exitcode_);
330    virtual ~EventExit();
331 };
332
333 class PC_EXPORT EventCrash : public EventTerminate
334 {
335    friend void boost::checked_delete<EventCrash>(EventCrash *);
336    friend void boost::checked_delete<const EventCrash>(const EventCrash *);
337  private:
338    int termsig;
339  public:
340    typedef boost::shared_ptr<EventCrash> ptr;
341    typedef boost::shared_ptr<const EventCrash> const_ptr;
342    int getTermSignal() const;
343    EventCrash(int termsig);
344    virtual ~EventCrash();
345 };
346
347 class PC_EXPORT EventForceTerminate : public EventTerminate
348 {
349    friend void boost::checked_delete<EventForceTerminate>(EventForceTerminate *);
350    friend void boost::checked_delete<const EventForceTerminate>(const EventForceTerminate *);
351  private:
352    int termsig;
353  public:
354    typedef boost::shared_ptr<EventForceTerminate> ptr;
355    typedef boost::shared_ptr<const EventForceTerminate> const_ptr;
356    int getTermSignal() const;
357    EventForceTerminate(int termsig);
358    virtual ~EventForceTerminate();
359 };
360
361 class PC_EXPORT EventExec : public Event
362 {
363    friend void boost::checked_delete<EventExec>(EventExec *);
364    friend void boost::checked_delete<const EventExec>(const EventExec *);
365  private:
366    std::string execpath;
367  public:
368    typedef boost::shared_ptr<EventExec> ptr;
369    typedef boost::shared_ptr<const EventExec> const_ptr;
370    EventExec(EventType::Time etime_, std::string path = std::string(""));
371    virtual ~EventExec();
372
373    std::string getExecPath() const;
374    void setExecPath(std::string path_);
375 };
376
377 class PC_EXPORT EventStop : public Event
378 {
379    friend void boost::checked_delete<EventStop>(EventStop *);
380    friend void boost::checked_delete<const EventStop>(const EventStop *);
381  public:
382    typedef boost::shared_ptr<EventStop> ptr;
383    typedef boost::shared_ptr<const EventStop> const_ptr;
384    EventStop();
385    virtual ~EventStop();
386 };
387
388 class PC_EXPORT EventNewThread : public Event
389 {
390    friend void boost::checked_delete<EventNewThread>(EventNewThread *);
391    friend void boost::checked_delete<const EventNewThread>(const EventNewThread *);
392  public:
393    typedef boost::shared_ptr<EventNewThread> ptr;
394    typedef boost::shared_ptr<const EventNewThread> const_ptr;
395    EventNewThread(EventType et);
396    virtual ~EventNewThread();
397
398    virtual Dyninst::LWP getLWP() const = 0;
399    virtual Thread::const_ptr getNewThread() const = 0;
400 };
401
402 class int_eventNewUserThread;
403 class PC_EXPORT EventNewUserThread : public EventNewThread
404 {
405    friend void boost::checked_delete<EventNewUserThread>(EventNewUserThread *);
406    friend void boost::checked_delete<const EventNewUserThread>(const EventNewUserThread *);
407   private:
408    int_eventNewUserThread *iev;
409   public:
410    typedef boost::shared_ptr<EventNewUserThread> ptr;
411    typedef boost::shared_ptr<const EventNewUserThread> const_ptr;   
412
413    EventNewUserThread();
414    virtual ~EventNewUserThread();
415    int_eventNewUserThread *getInternalEvent() const;
416
417    virtual Dyninst::LWP getLWP() const;
418    virtual Thread::const_ptr getNewThread() const;
419 };
420
421 class int_eventNewLWP;
422 class PC_EXPORT EventNewLWP : public EventNewThread
423 {
424    friend void boost::checked_delete<EventNewLWP>(EventNewLWP *);
425    friend void boost::checked_delete<const EventNewLWP>(const EventNewLWP *);
426   private:
427    int_eventNewLWP *iev;
428    Dyninst::LWP lwp;
429   public:
430    int_eventNewLWP *getInternalEvent();
431    typedef boost::shared_ptr<EventNewLWP> ptr;
432    typedef boost::shared_ptr<const EventNewLWP> const_ptr;   
433    EventNewLWP(Dyninst::LWP lwp_, int status = 0);
434    virtual ~EventNewLWP();
435
436    virtual Dyninst::LWP getLWP() const;
437    virtual Thread::const_ptr getNewThread() const;
438 };
439
440 class PC_EXPORT EventThreadDestroy : public Event
441 {
442    friend void boost::checked_delete<EventThreadDestroy>(EventThreadDestroy *);
443    friend void boost::checked_delete<const EventThreadDestroy>(const EventThreadDestroy *);
444  public:
445    typedef boost::shared_ptr<EventThreadDestroy> ptr;
446    typedef boost::shared_ptr<const EventThreadDestroy> const_ptr;
447    EventThreadDestroy(EventType et);
448    virtual ~EventThreadDestroy() = 0;
449 };
450
451 class PC_EXPORT EventUserThreadDestroy : public EventThreadDestroy
452 {
453    friend void boost::checked_delete<EventUserThreadDestroy>(EventUserThreadDestroy *);
454    friend void boost::checked_delete<const EventUserThreadDestroy>(const EventUserThreadDestroy *);
455  public:
456    typedef boost::shared_ptr<EventUserThreadDestroy> ptr;
457    typedef boost::shared_ptr<const EventUserThreadDestroy> const_ptr;
458    EventUserThreadDestroy(EventType::Time time_);
459    virtual ~EventUserThreadDestroy();
460 };
461
462 class PC_EXPORT EventLWPDestroy : public EventThreadDestroy
463 {
464    friend void boost::checked_delete<EventLWPDestroy>(EventLWPDestroy *);
465    friend void boost::checked_delete<const EventLWPDestroy>(const EventLWPDestroy *);
466  public:
467    typedef boost::shared_ptr<EventLWPDestroy> ptr;
468    typedef boost::shared_ptr<const EventLWPDestroy> const_ptr;
469    EventLWPDestroy(EventType::Time time_);
470    virtual ~EventLWPDestroy();
471 };
472
473 class PC_EXPORT EventFork : public Event
474 {
475    friend void boost::checked_delete<EventFork>(EventFork *);
476    friend void boost::checked_delete<const EventFork>(const EventFork *);
477   private:
478    Dyninst::PID pid;
479   public:
480    typedef boost::shared_ptr<EventFork> ptr;
481    typedef boost::shared_ptr<const EventFork> const_ptr;
482    EventFork(EventType::Time time_, Dyninst::PID pid_);
483    virtual ~EventFork();
484    Dyninst::PID getPID() const;
485    Process::const_ptr getChildProcess() const;
486 };
487
488 class PC_EXPORT EventSignal : public Event
489 {
490 public:
491    // causes of signal. unknown refers to all non-access violations.
492    // this is needed for defensve mode.
493    enum Cause { Unknown, ReadViolation, WriteViolation, ExecuteViolation };
494    friend void boost::checked_delete<EventSignal>(EventSignal *);
495    friend void boost::checked_delete<const EventSignal>(const EventSignal *);
496  private:
497    int sig;
498    // address that caused the signal (if any), the cause, and
499    // whether this is a first-cause exception (windows access violations).
500    Address addr;
501    Cause cause;
502    bool first;
503  public:
504    typedef boost::shared_ptr<EventSignal> ptr;
505    typedef boost::shared_ptr<const EventSignal> const_ptr;
506    EventSignal(int sig);
507    EventSignal(int s, Address a, Cause c, bool f) : Event(EventType(EventType::None, EventType::Signal)), 
508        sig(s), addr(a), cause(c), first(f) { }
509    virtual ~EventSignal();
510
511    int getSignal() const;
512    void setThreadSignal(int newSignal) const;
513    void clearThreadSignal() const;
514
515    // used to get information about windows access violations.
516    Address getAddress() const { return addr; }
517    Cause getCause() const { return cause; }
518    bool isFirst() const { return first; }
519 };
520
521 class PC_EXPORT EventBootstrap : public Event
522 {
523    friend void boost::checked_delete<EventBootstrap>(EventBootstrap *);
524    friend void boost::checked_delete<const EventBootstrap>(const EventBootstrap *);
525  public:
526    typedef boost::shared_ptr<EventBootstrap> ptr;
527    typedef boost::shared_ptr<const EventBootstrap> const_ptr;
528    EventBootstrap();
529    virtual ~EventBootstrap();
530 };
531
532 class PC_EXPORT EventPreBootstrap : public Event
533 {
534    friend void boost::checked_delete<EventPreBootstrap>(EventPreBootstrap *);
535    friend void boost::checked_delete<const EventPreBootstrap>(const EventPreBootstrap *);
536  public:
537    typedef boost::shared_ptr<EventPreBootstrap> ptr;
538    typedef boost::shared_ptr<const EventPreBootstrap> const_ptr;
539    EventPreBootstrap();
540    virtual ~EventPreBootstrap();
541 };
542
543
544 class int_eventRPC;
545 class PC_EXPORT EventRPC : public Event
546 {
547    friend void boost::checked_delete<EventRPC>(EventRPC *);
548    friend void boost::checked_delete<const EventRPC>(const EventRPC *);
549  private:
550    int_eventRPC *int_rpc;
551    rpc_wrapper *wrapper;
552  public:
553    virtual bool suppressCB() const;
554    rpc_wrapper *getllRPC();
555    typedef boost::shared_ptr<EventRPC> ptr;
556    typedef boost::shared_ptr<const EventRPC> const_ptr;
557    EventRPC(rpc_wrapper *wrapper_);
558    virtual ~EventRPC();
559
560    IRPC::const_ptr getIRPC() const;
561    int_eventRPC *getInternal() const;
562 };
563
564 class PC_EXPORT EventRPCLaunch : public Event
565 {
566    friend void boost::checked_delete<EventRPCLaunch>(EventRPCLaunch *);
567    friend void boost::checked_delete<const EventRPCLaunch>(const EventRPCLaunch *);
568  public:
569    typedef boost::shared_ptr<EventRPCLaunch> ptr;
570    typedef boost::shared_ptr<const EventRPCLaunch> const_ptr;
571    virtual bool procStopper() const;
572    EventRPCLaunch();
573    virtual ~EventRPCLaunch();
574 };
575
576 class PC_EXPORT EventSingleStep : public Event
577 {
578    friend void boost::checked_delete<EventSingleStep>(EventSingleStep *);
579    friend void boost::checked_delete<const EventSingleStep>(const EventSingleStep *);
580  public:
581    typedef boost::shared_ptr<EventSingleStep> ptr;
582    typedef boost::shared_ptr<const EventSingleStep> const_ptr;
583    EventSingleStep();
584    virtual ~EventSingleStep();
585 };
586
587 class PC_EXPORT EventSyscall : public Event
588 {
589    friend void boost::checked_delete<EventSyscall>(EventSyscall *);
590    friend void boost::checked_delete<const EventSyscall>(const EventSyscall *);
591
592    friend MachSyscall makeFromEvent(const EventSyscall *);
593
594  public:
595    typedef boost::shared_ptr<EventSyscall> ptr;
596    typedef boost::shared_ptr<const EventSyscall> const_ptr;
597    EventSyscall(EventType type_);
598    virtual ~EventSyscall();
599
600    Dyninst::Address getAddress() const;
601    MachSyscall getSyscall() const;
602    
603  private:
604     long getSyscallNumber() const;
605 };
606
607 class PC_EXPORT EventPreSyscall : public EventSyscall
608 {
609    friend void boost::checked_delete<EventPreSyscall>(EventPreSyscall *);
610    friend void boost::checked_delete<const EventPreSyscall>(const EventPreSyscall *);
611
612    friend MachSyscall makeFromEvent(const EventPreSyscall *);
613
614  public:
615    typedef boost::shared_ptr<EventPreSyscall> ptr;
616    typedef boost::shared_ptr<const EventPreSyscall> const_ptr;
617    EventPreSyscall();
618    virtual ~EventPreSyscall();
619 };
620
621 class PC_EXPORT EventPostSyscall : public EventSyscall
622 {
623    friend void boost::checked_delete<EventPostSyscall>(EventPostSyscall *);
624    friend void boost::checked_delete<const EventPostSyscall>(const EventPostSyscall *);
625
626    friend MachSyscall makeFromEvent(const EventPostSyscall *);
627
628  public:
629    typedef boost::shared_ptr<EventPostSyscall> ptr;
630    typedef boost::shared_ptr<const EventPostSyscall> const_ptr;
631    EventPostSyscall();
632    virtual ~EventPostSyscall();
633
634    long getReturnValue() const;
635 };
636
637 class int_eventBreakpoint;
638 class PC_EXPORT EventBreakpoint : public Event
639 {
640    friend void boost::checked_delete<EventBreakpoint>(EventBreakpoint *);
641    friend void boost::checked_delete<const EventBreakpoint>(const EventBreakpoint *);
642  private:
643    int_eventBreakpoint *int_bp;
644  public:
645    typedef boost::shared_ptr<EventBreakpoint> ptr;
646    typedef boost::shared_ptr<const EventBreakpoint> const_ptr;
647    int_eventBreakpoint *getInternal() const;
648
649    EventBreakpoint(int_eventBreakpoint *ibp);
650    virtual ~EventBreakpoint();
651
652    Dyninst::Address getAddress() const;
653    void getBreakpoints(std::vector<Breakpoint::const_ptr> &bps) const;
654    void getBreakpoints(std::vector<Breakpoint::ptr> &bps);
655    virtual bool suppressCB() const;
656    virtual bool procStopper() const;
657 };
658
659
660 class int_eventBreakpointClear;
661 class PC_EXPORT EventBreakpointClear : public Event
662 {
663    friend void boost::checked_delete<EventBreakpointClear>(EventBreakpointClear *);
664    friend void boost::checked_delete<const EventBreakpointClear>(const EventBreakpointClear *);
665   private:
666    int_eventBreakpointClear *int_bpc;
667   public:
668    typedef boost::shared_ptr<EventBreakpointClear> ptr;
669    typedef boost::shared_ptr<const EventBreakpointClear> const_ptr;
670    EventBreakpointClear();
671    virtual ~EventBreakpointClear();
672    
673    int_eventBreakpointClear *getInternal() const;
674    virtual bool procStopper() const;
675 };
676
677 class int_eventBreakpointRestore;
678 class EventBreakpointRestore : public Event
679 {
680    friend void boost::checked_delete<EventBreakpointRestore>(EventBreakpointRestore *);
681    friend void boost::checked_delete<const EventBreakpointRestore>(const EventBreakpointRestore *);
682   private:
683    int_eventBreakpointRestore *int_bpr;
684   public:
685    typedef boost::shared_ptr<EventBreakpointRestore> ptr;
686    typedef boost::shared_ptr<const EventBreakpointRestore> const_ptr;
687
688    EventBreakpointRestore(int_eventBreakpointRestore *iebpr);
689    virtual ~EventBreakpointRestore();
690
691    int_eventBreakpointRestore *getInternal() const;
692 };
693
694 class PC_EXPORT EventLibrary : public Event
695 {
696    friend void boost::checked_delete<EventLibrary>(EventLibrary *);
697    friend void boost::checked_delete<const EventLibrary>(const EventLibrary *);
698  private:
699    std::set<Library::ptr> added_libs;
700    std::set<Library::ptr> rmd_libs;
701  public:
702    typedef boost::shared_ptr<EventLibrary> ptr;
703    typedef boost::shared_ptr<const EventLibrary> const_ptr;
704    EventLibrary();
705    EventLibrary(const std::set<Library::ptr> &added_libs_,
706                 const std::set<Library::ptr> &rmd_libs_);
707    virtual ~EventLibrary();
708
709    void setLibs(const std::set<Library::ptr> &added_libs_,
710                 const std::set<Library::ptr> &rmd_libs_);
711    const std::set<Library::ptr> &libsAdded() const;
712    const std::set<Library::ptr> &libsRemoved() const;
713 };
714
715 class int_eventAsync;
716 class PC_EXPORT EventAsync : public Event
717 {
718    friend void boost::checked_delete<EventAsync>(EventAsync *);
719    friend void boost::checked_delete<const EventAsync>(const EventAsync *);
720    
721   private:
722    int_eventAsync *internal;
723   public:
724    typedef boost::shared_ptr<EventAsync> ptr;
725    typedef boost::shared_ptr<const EventAsync> const_ptr;
726
727    EventAsync(int_eventAsync *ievent);
728    virtual ~EventAsync();
729    int_eventAsync *getInternal() const;
730 };
731
732 class PC_EXPORT EventChangePCStop : public Event
733 {
734    friend void boost::checked_delete<EventChangePCStop>(EventChangePCStop *);
735    friend void boost::checked_delete<const EventChangePCStop>(const EventChangePCStop *);
736  public:
737    typedef boost::shared_ptr<EventChangePCStop> ptr;
738    typedef boost::shared_ptr<const EventChangePCStop> const_ptr;
739    EventChangePCStop();
740    virtual ~EventChangePCStop();
741 };
742
743 class int_eventDetach;
744 class PC_EXPORT EventDetach : public Event
745 {
746    friend void boost::checked_delete<EventDetach>(EventDetach *);
747    friend void boost::checked_delete<const EventDetach>(const EventDetach *);
748    int_eventDetach *int_detach;
749  public:
750    typedef boost::shared_ptr<EventDetach> ptr;
751    typedef boost::shared_ptr<const EventDetach> const_ptr;
752
753    EventDetach();
754    virtual ~EventDetach();
755    int_eventDetach *getInternal() const;
756    virtual bool procStopper() const;
757 };
758
759 class PC_EXPORT EventIntBootstrap : public Event
760 {
761    friend void boost::checked_delete<EventIntBootstrap>(EventIntBootstrap *);
762    friend void boost::checked_delete<const EventIntBootstrap>(const EventIntBootstrap *);
763    
764    void *data;
765  public:
766    typedef boost::shared_ptr<EventIntBootstrap> ptr;
767    typedef boost::shared_ptr<const EventIntBootstrap> const_ptr;
768    EventIntBootstrap(void *d = NULL);
769    virtual ~EventIntBootstrap();
770
771    void *getData() const;
772    void setData(void *v);
773 };
774
775 class PC_EXPORT EventNop : public Event
776 {
777    friend void boost::checked_delete<EventNop>(EventNop *);
778    friend void boost::checked_delete<const EventNop>(const EventNop *);
779  public:
780    typedef boost::shared_ptr<EventNop> ptr;
781    typedef boost::shared_ptr<const EventNop> const_ptr;
782    EventNop();
783    virtual ~EventNop();
784 };
785
786 class int_eventThreadDB;
787 class PC_EXPORT EventThreadDB : public Event
788 {
789    friend void boost::checked_delete<EventThreadDB>(EventThreadDB *);
790    friend void boost::checked_delete<const EventThreadDB>(const EventThreadDB *);
791    int_eventThreadDB *int_etdb;
792   public:
793    typedef boost::shared_ptr<EventThreadDB> ptr;
794    typedef boost::shared_ptr<const EventThreadDB> const_ptr;
795    int_eventThreadDB *getInternal() const;
796
797    EventThreadDB();
798    virtual ~EventThreadDB();
799
800    virtual bool triggersCB() const;
801 };
802
803 class PC_EXPORT EventWinStopThreadDestroy : public EventThreadDestroy
804 {
805    friend void boost::checked_delete<EventWinStopThreadDestroy>(EventWinStopThreadDestroy *);
806    friend void boost::checked_delete<const EventWinStopThreadDestroy>(const EventWinStopThreadDestroy *);
807  public:
808    typedef boost::shared_ptr<EventWinStopThreadDestroy> ptr;
809    typedef boost::shared_ptr<const EventWinStopThreadDestroy> const_ptr;
810    EventWinStopThreadDestroy(EventType::Time time_);
811    virtual ~EventWinStopThreadDestroy();
812 };
813
814 class int_eventControlAuthority;
815 class PC_EXPORT EventControlAuthority : public Event
816 {
817    friend void boost::checked_delete<EventControlAuthority>(EventControlAuthority *);
818    friend void boost::checked_delete<const EventControlAuthority>(const EventControlAuthority *);
819    int_eventControlAuthority *iev;
820   public:
821    typedef boost::shared_ptr<EventControlAuthority> ptr;
822    typedef boost::shared_ptr<const EventControlAuthority> const_ptr;
823    int_eventControlAuthority *getInternalEvent() const;
824
825    EventControlAuthority(EventType::Time t, int_eventControlAuthority *iev_);
826    virtual ~EventControlAuthority();
827    virtual bool procStopper() const;
828
829    std::string otherToolName() const;
830    unsigned int otherToolID() const;
831    int otherToolPriority() const;
832    
833    typedef enum {
834       ControlUnset,
835       ControlLost,
836       ControlGained,
837       ControlNoChange
838    } Trigger;
839    Trigger eventTrigger() const;
840 };
841
842 class int_eventAsyncIO;
843 class PC_EXPORT EventAsyncIO : public Event {
844    friend void boost::checked_delete<EventAsyncIO>(EventAsyncIO *);
845    friend void boost::checked_delete<const EventAsyncIO>(const EventAsyncIO *);
846   protected:
847    int_eventAsyncIO *iev;
848   public:
849    typedef boost::shared_ptr<EventAsyncIO> ptr;
850    typedef boost::shared_ptr<const EventAsyncIO> const_ptr;
851    int_eventAsyncIO *getInternalEvent() const;
852
853    EventAsyncIO(EventType et, int_eventAsyncIO *iev_);
854    ~EventAsyncIO();
855
856    bool hadError() const;
857    void *getOpaqueVal() const;
858 };
859
860 class PC_EXPORT EventAsyncRead : public EventAsyncIO {
861    friend void boost::checked_delete<EventAsyncRead>(EventAsyncRead *);
862    friend void boost::checked_delete<const EventAsyncRead>(const EventAsyncRead *);
863   public:
864    typedef boost::shared_ptr<EventAsyncRead> ptr;
865    typedef boost::shared_ptr<const EventAsyncRead> const_ptr;
866    
867    EventAsyncRead(int_eventAsyncIO *iev_);
868    ~EventAsyncRead();
869
870    void *getMemory() const;
871    size_t getSize() const;
872    Dyninst::Address getAddress() const;
873 };
874
875 class PC_EXPORT EventAsyncWrite : public EventAsyncIO {
876    friend void boost::checked_delete<EventAsyncWrite>(EventAsyncWrite *);
877    friend void boost::checked_delete<const EventAsyncWrite>(const EventAsyncWrite *);
878   public:
879    typedef boost::shared_ptr<EventAsyncWrite> ptr;
880    typedef boost::shared_ptr<const EventAsyncWrite> const_ptr;
881    
882    EventAsyncWrite(int_eventAsyncIO *iev_);
883    ~EventAsyncWrite();
884
885    size_t getSize() const;
886    Dyninst::Address getAddress() const;
887 };
888
889 class PC_EXPORT EventAsyncReadAllRegs : public EventAsyncIO {
890    friend void boost::checked_delete<EventAsyncReadAllRegs>(EventAsyncReadAllRegs *);
891    friend void boost::checked_delete<const EventAsyncReadAllRegs>(const EventAsyncReadAllRegs *);
892   public:
893    typedef boost::shared_ptr<EventAsyncReadAllRegs> ptr;
894    typedef boost::shared_ptr<const EventAsyncReadAllRegs> const_ptr;
895    
896    EventAsyncReadAllRegs(int_eventAsyncIO *iev_);
897    ~EventAsyncReadAllRegs();
898
899    const RegisterPool &getRegisters() const;
900 };
901
902 class PC_EXPORT EventAsyncSetAllRegs : public EventAsyncIO {
903    friend void boost::checked_delete<EventAsyncSetAllRegs>(EventAsyncSetAllRegs *);
904    friend void boost::checked_delete<const EventAsyncSetAllRegs>(const EventAsyncSetAllRegs *);
905   public:
906    typedef boost::shared_ptr<EventAsyncSetAllRegs> ptr;
907    typedef boost::shared_ptr<const EventAsyncSetAllRegs> const_ptr;
908    
909    EventAsyncSetAllRegs(int_eventAsyncIO *iev_);
910    ~EventAsyncSetAllRegs();
911 };
912
913 class int_eventAsyncFileRead;
914 class PC_EXPORT EventAsyncFileRead : public Event {
915    friend void boost::checked_delete<EventAsyncFileRead>(EventAsyncFileRead *);
916    friend void boost::checked_delete<const EventAsyncFileRead>(const EventAsyncFileRead *);
917    int_eventAsyncFileRead *iev;
918   public:
919    typedef boost::shared_ptr<EventAsyncFileRead> ptr;
920    typedef boost::shared_ptr<const EventAsyncFileRead> const_ptr;
921    int_eventAsyncFileRead *getInternal();
922    
923    EventAsyncFileRead(int_eventAsyncFileRead *iev_);
924    ~EventAsyncFileRead();
925    
926    std::string getFilename() const;
927    size_t getReadSize() const;
928    Dyninst::Offset getReadOffset() const;
929
930    void *getBuffer() const;
931    size_t getBufferSize() const;
932
933    bool isEOF() const;
934    int errorCode() const;
935 };
936
937 class EventPostponedSyscall : public Event
938 {
939    friend void boost::checked_delete<EventPostponedSyscall>(EventPostponedSyscall *);
940    friend void boost::checked_delete<const EventPostponedSyscall>(const EventPostponedSyscall *);
941   public:
942    typedef boost::shared_ptr<EventPostponedSyscall> ptr;
943    typedef boost::shared_ptr<const EventPostponedSyscall> const_ptr;
944
945    EventPostponedSyscall();
946    virtual ~EventPostponedSyscall();
947 };
948
949 }
950 }
951
952 #endif