Watchpoint.h revision ecd4feb5111432d2878e95461220c720cb2d24c8
1//===-- Watchpoint.h --------------------------------------------*- C++ -*-===//
2//
3//                     The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9
10#ifndef liblldb_Watchpoint_h_
11#define liblldb_Watchpoint_h_
12
13// C Includes
14
15// C++ Includes
16#include <list>
17#include <string>
18
19// Other libraries and framework includes
20
21// Project includes
22#include "lldb/lldb-private.h"
23#include "lldb/Target/Target.h"
24#include "lldb/Core/UserID.h"
25#include "lldb/Breakpoint/StoppointLocation.h"
26
27namespace lldb_private {
28
29class Watchpoint :
30    public StoppointLocation
31{
32public:
33
34    Watchpoint (lldb::addr_t addr, size_t size, bool hardware = true);
35
36    ~Watchpoint ();
37
38    bool
39    IsEnabled () const;
40
41    void
42    SetEnabled (bool enabled);
43
44    virtual bool
45    IsHardware () const;
46
47    virtual bool
48    ShouldStop (StoppointCallbackContext *context);
49
50    bool        WatchpointRead () const;
51    bool        WatchpointWrite () const;
52    uint32_t    GetIgnoreCount () const;
53    void        SetIgnoreCount (uint32_t n);
54    void        SetWatchpointType (uint32_t type);
55    bool        SetCallback (WatchpointHitCallback callback, void *callback_baton);
56    void        SetDeclInfo (std::string &str);
57    void        GetDescription (Stream *s, lldb::DescriptionLevel level);
58    void        Dump (Stream *s) const;
59    void        DumpWithLevel (Stream *s, lldb::DescriptionLevel description_level) const;
60    Target      &GetTarget() { return *m_target; }
61
62private:
63    friend class Target;
64
65    void        SetTarget(Target *target_ptr) { m_target = target_ptr; }
66
67    Target      *m_target;
68    bool        m_enabled;          // Is this watchpoint enabled
69    bool        m_is_hardware;      // Is this a hardware watchpoint
70    uint32_t    m_watch_read:1,     // 1 if we stop when the watched data is read from
71                m_watch_write:1,    // 1 if we stop when the watched data is written to
72                m_watch_was_read:1, // Set to 1 when watchpoint is hit for a read access
73                m_watch_was_written:1;  // Set to 1 when watchpoint is hit for a write access
74    uint32_t    m_ignore_count;     // Number of times to ignore this breakpoint
75    WatchpointHitCallback m_callback;
76    void *      m_callback_baton;   // Callback user data to pass to callback
77    std::string m_decl_str;         // Declaration information, if any.
78
79    static lldb::break_id_t
80    GetNextID();
81
82    DISALLOW_COPY_AND_ASSIGN (Watchpoint);
83};
84
85} // namespace lldb_private
86
87#endif  // liblldb_Watchpoint_h_
88