| 1 |
#include "clDebuggerBreakpoint.hpp" |
| 2 |
|
| 3 |
#ifdef __WXMSW__ |
| 4 |
#define is_windows true |
| 5 |
#else |
| 6 |
#define is_windows false |
| 7 |
#endif |
| 8 |
|
| 9 |
clDebuggerBreakpoint::clDebuggerBreakpoint() |
| 10 |
{ |
| 11 |
} |
| 12 |
|
| 13 |
clDebuggerBreakpoint::~clDebuggerBreakpoint() |
| 14 |
{ |
| 15 |
} |
| 16 |
|
| 17 |
clDebuggerBreakpoint::clDebuggerBreakpoint(const clDebuggerBreakpoint& BI) |
| 18 |
{ |
| 19 |
if(this == &BI) { |
| 20 |
return; |
| 21 |
} |
| 22 |
|
| 23 |
// call operator= |
| 24 |
*this = BI; |
| 25 |
|
| 26 |
if(!is_windows || (is_windows && !file.Contains("/"))) { |
| 27 |
// Normalize the file name |
| 28 |
if(!file.IsEmpty()) { |
| 29 |
wxFileName fn(file); |
| 30 |
fn.Normalize(wxPATH_NORM_ALL & ~wxPATH_NORM_LONG); |
| 31 |
file = fn.GetFullPath(); |
| 32 |
} |
| 33 |
} |
| 34 |
} |
| 35 |
|
| 36 |
clDebuggerBreakpoint& clDebuggerBreakpoint::operator=(const clDebuggerBreakpoint& BI) |
| 37 |
{ |
| 38 |
if(this == &BI) { |
| 39 |
return *this; |
| 40 |
} |
| 41 |
|
| 42 |
file = BI.file; |
| 43 |
lineno = BI.lineno; |
| 44 |
watchpt_data = BI.watchpt_data; |
| 45 |
function_name = BI.function_name; |
| 46 |
regex = BI.regex; |
| 47 |
memory_address = BI.memory_address; |
| 48 |
internal_id = BI.internal_id; |
| 49 |
debugger_id = BI.debugger_id; |
| 50 |
bp_type = BI.bp_type; |
| 51 |
ignore_number = BI.ignore_number; |
| 52 |
is_enabled = BI.is_enabled; |
| 53 |
is_temp = BI.is_temp; |
| 54 |
watchpoint_type = BI.watchpoint_type; |
| 55 |
commandlist = BI.commandlist; |
| 56 |
conditions = BI.conditions; |
| 57 |
at = BI.at; // Provided by the debugger, no need to serialize |
| 58 |
what = BI.what; // Provided by the debugger, no need to serialize |
| 59 |
origin = BI.origin; |
| 60 |
return *this; |
| 61 |
} |
| 62 |
|
| 63 |
void clDebuggerBreakpoint::DeSerialize(Archive& arch) |
| 64 |
{ |
| 65 |
arch.Read(wxT("file"), file); |
| 66 |
arch.Read(wxT("lineno"), lineno); |
| 67 |
arch.Read(wxT("function_name"), function_name); |
| 68 |
arch.Read(wxT("memory_address"), memory_address); |
| 69 |
|
| 70 |
int tmpint; |
| 71 |
arch.Read(wxT("bp_type"), tmpint); |
| 72 |
bp_type = (BreakpointType)tmpint; |
| 73 |
|
| 74 |
arch.Read(wxT("watchpoint_type"), tmpint); |
| 75 |
watchpoint_type = (WatchpointType)tmpint; |
| 76 |
arch.Read(wxT("watchpt_data"), watchpt_data); |
| 77 |
arch.ReadCData(wxT("commandlist"), commandlist); |
| 78 |
commandlist.Trim().Trim(false); // ReadCData tends to add white-space to the commands e.g. a terminal \n |
| 79 |
arch.Read(wxT("regex"), regex); |
| 80 |
arch.Read(wxT("is_temp"), is_temp); |
| 81 |
arch.Read(wxT("is_enabled"), is_enabled); |
| 82 |
|
| 83 |
arch.Read(wxT("ignore_number"), tmpint); |
| 84 |
ignore_number = (unsigned int)tmpint; |
| 85 |
arch.Read(wxT("conditions"), conditions); |
| 86 |
|
| 87 |
arch.Read(wxT("origin"), tmpint); |
| 88 |
origin = (BreakpointOrigin)tmpint; |
| 89 |
} |
| 90 |
|
| 91 |
void clDebuggerBreakpoint::Serialize(Archive& arch) |
| 92 |
{ |
| 93 |
arch.Write(wxT("file"), file); |
| 94 |
arch.Write(wxT("lineno"), lineno); |
| 95 |
arch.Write(wxT("function_name"), function_name); |
| 96 |
arch.Write(wxT("memory_address"), memory_address); |
| 97 |
arch.Write(wxT("bp_type"), bp_type); |
| 98 |
arch.Write(wxT("watchpoint_type"), watchpoint_type); |
| 99 |
arch.Write(wxT("watchpt_data"), watchpt_data); |
| 100 |
// WriteCDate tends to write white-space even for empty commandlists |
| 101 |
arch.WriteCData(wxT("commandlist"), commandlist.Trim().Trim(false)); |
| 102 |
arch.Write(wxT("regex"), regex); |
| 103 |
arch.Write(wxT("is_temp"), is_temp); |
| 104 |
arch.Write(wxT("is_enabled"), is_enabled); |
| 105 |
arch.Write(wxT("ignore_number"), ignore_number); |
| 106 |
arch.Write(wxT("conditions"), conditions); |
| 107 |
arch.Write(wxT("origin"), (int)origin); |
| 108 |
} |
| 109 |
|
| 110 |
JSONItem clDebuggerBreakpoint::ToJSON() const |
| 111 |
{ |
| 112 |
auto json = JSONItem::createObject(); |
| 113 |
json.addProperty("file", file); |
| 114 |
json.addProperty("lineno", lineno); |
| 115 |
json.addProperty("function_name", function_name); |
| 116 |
json.addProperty("bp_type", (int)bp_type); |
| 117 |
json.addProperty("watchpoint_type", (int)watchpoint_type); |
| 118 |
json.addProperty("watchpt_data", watchpt_data); |
| 119 |
wxString command_list(commandlist); |
| 120 |
command_list.Trim(false).Trim(true); |
| 121 |
json.addProperty("commandlist", command_list); |
| 122 |
json.addProperty("ignore_number", ignore_number); |
| 123 |
json.addProperty("conditions", conditions); |
| 124 |
return json; |
| 125 |
} |
| 126 |
|
| 127 |
void clDebuggerBreakpoint::FromJSON(const JSONItem& json) |
| 128 |
{ |
| 129 |
file = json["file"].toString(); |
| 130 |
lineno = json["lineno"].toInt(); |
| 131 |
function_name = json["function_name"].toString(); |
| 132 |
bp_type = (BreakpointType)json["bp_type"].toInt(); |
| 133 |
watchpoint_type = (WatchpointType)json["watchpoint_type"].toInt(); |
| 134 |
watchpt_data = json["watchpt_data"].toString(); |
| 135 |
commandlist = json["commandlist"].toString(); |
| 136 |
ignore_number = json["ignore_number"].toSize_t(); |
| 137 |
conditions = json["conditions"].toString(); |
| 138 |
} |