Debian Codegraph @

CodeLite/clDebuggerBreakpoint.hpp

raw
1 #ifndef CLDEBUGGERBREAKPOINT_HPP
2 #define CLDEBUGGERBREAKPOINT_HPP
3
4 #include "JSON.h"
5 #include "codelite_exports.h"
6 #include "serialized_object.h"
7 #include <vector>
8 #include <wx/string.h>
9
10 // Breakpoint types. If you add more, clEditor::FillBPtoMarkerArray will also need altering
11 enum BreakpointType {
12 /*Convenient return-codes*/
13 BP_type_invalid = -1,
14 BP_type_none = 0,
15 /*Real breakpoint-types*/
16 BP_FIRST_ITEM,
17 BP_type_break = BP_FIRST_ITEM,
18 BP_type_cmdlistbreak,
19 BP_type_condbreak,
20 BP_type_ignoredbreak,
21 BP_type_tempbreak,
22 BP_LAST_MARKED_ITEM = BP_type_tempbreak,
23 BP_type_watchpt,
24 BP_LAST_ITEM = BP_type_watchpt
25 };
26
27 // Watchpoint subtypes: write,read and both
28 enum WatchpointType { WP_watch, WP_rwatch, WP_awatch };
29
30 // The breakpoint origin:
31 // Can be from the Editor (user clicked 'F9')
32 // or from any other source (direct command to gdb, from the start up command etc)
33 enum BreakpointOrigin { BO_Editor, BO_Other };
34
35 class WXDLLIMPEXP_CL clDebuggerBreakpoint : public SerializedObject
36 {
37 public:
38 typedef std::vector<clDebuggerBreakpoint> Vec_t;
39
40 public:
41 // Where the bp is: file/lineno, function name (e.g. main()) or the memory location
42 wxString file;
43 int lineno = -1;
44 wxString watchpt_data;
45 wxString function_name;
46 bool regex = false; // Is the function_name a regex?
47 wxString memory_address;
48 // How to identify the bp. Because the debugger won't always be running, we need an internal id as well as the
49 // debugger's one
50 double internal_id = wxNOT_FOUND;
51 double debugger_id = wxNOT_FOUND; // -1 signifies not set
52 BreakpointType bp_type =
53 BP_type_break; // Is it a plain vanilla breakpoint, or a temporary one, or a watchpoint, or...
54 size_t ignore_number =
55 0; // 0 means 'not ignored'. >0 is the number of times the bp must be hit before it becomes enabled
56 bool is_enabled = true;
57 bool is_temp = false;
58 WatchpointType watchpoint_type = WP_watch; // If this is a watchpoint, holds which sort it is
59 wxString commandlist;
60 wxString conditions;
61 wxString at;
62 wxString what;
63 BreakpointOrigin origin = BO_Other;
64
65 clDebuggerBreakpoint(const clDebuggerBreakpoint& BI);
66 clDebuggerBreakpoint();
67 clDebuggerBreakpoint& operator=(const clDebuggerBreakpoint& BI);
68 ~clDebuggerBreakpoint();
69
70 bool IsConditional()
71 {
72 return !conditions.IsEmpty();
73 }
74 double GetId() const
75 {
76 int best_id = (this->debugger_id == -1 ? this->internal_id : this->debugger_id);
77 return best_id;
78 }
79
80 void Create(const wxString& filename, int line, int int_id, int ext_id = -1)
81 {
82 bp_type = BP_type_break;
83 lineno = line;
84 file = filename;
85 internal_id = int_id;
86 debugger_id = ext_id;
87 }
88
89 bool operator==(const clDebuggerBreakpoint& BI)
90 {
91 return ((origin == BI.origin) && (what == BI.what) && (at == BI.at) && (file == BI.file) &&
92 (lineno == BI.lineno) && (function_name == BI.function_name) && (memory_address == BI.memory_address) &&
93 (bp_type == BI.bp_type) && (watchpt_data == BI.watchpt_data) && (is_enabled == BI.is_enabled) &&
94 (ignore_number == BI.ignore_number) && (conditions == BI.conditions) &&
95 (commandlist == BI.commandlist) && (is_temp == BI.is_temp) &&
96 (bp_type == BP_type_watchpt ? (watchpoint_type == BI.watchpoint_type) : true) &&
97 (!function_name.IsEmpty() ? (regex == BI.regex) : true));
98 }
99
100 bool IsNull() const
101 {
102 return internal_id == wxNOT_FOUND && debugger_id == wxNOT_FOUND;
103 }
104
105 // JSON serialization
106 JSONItem ToJSON() const;
107 void FromJSON(const JSONItem& json);
108
109 protected:
110 // SerializedObject interface
111 virtual void Serialize(Archive& arch);
112 virtual void DeSerialize(Archive& arch);
113 };
114 typedef std::vector<clDebuggerBreakpoint> clDebuggerBreakpointVec_t;
115 #endif // CLDEBUGGERBREAKPOINT_HPP