File: clDebuggerBreakpoint.cpp

package info (click to toggle)
codelite 17.0.0%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 136,204 kB
  • sloc: cpp: 491,547; ansic: 280,393; php: 10,259; sh: 8,930; lisp: 7,664; vhdl: 6,518; python: 6,020; lex: 4,920; yacc: 3,123; perl: 2,385; javascript: 1,715; cs: 1,193; xml: 1,110; makefile: 804; cobol: 741; sql: 709; ruby: 620; f90: 566; ada: 534; asm: 464; fortran: 350; objc: 289; tcl: 258; java: 157; erlang: 61; pascal: 51; ml: 49; awk: 44; haskell: 36
file content (138 lines) | stat: -rw-r--r-- 4,388 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
#include "clDebuggerBreakpoint.hpp"

#ifdef __WXMSW__
#define is_windows true
#else
#define is_windows false
#endif

clDebuggerBreakpoint::clDebuggerBreakpoint()
{
}

clDebuggerBreakpoint::~clDebuggerBreakpoint()
{
}

clDebuggerBreakpoint::clDebuggerBreakpoint(const clDebuggerBreakpoint& BI)
{
    if(this == &BI) {
        return;
    }

    // call operator=
    *this = BI;

    if(!is_windows || (is_windows && !file.Contains("/"))) {
        // Normalize the file name
        if(!file.IsEmpty()) {
            wxFileName fn(file);
            fn.Normalize(wxPATH_NORM_ALL & ~wxPATH_NORM_LONG);
            file = fn.GetFullPath();
        }
    }
}

clDebuggerBreakpoint& clDebuggerBreakpoint::operator=(const clDebuggerBreakpoint& BI)
{
    if(this == &BI) {
        return *this;
    }

    file = BI.file;
    lineno = BI.lineno;
    watchpt_data = BI.watchpt_data;
    function_name = BI.function_name;
    regex = BI.regex;
    memory_address = BI.memory_address;
    internal_id = BI.internal_id;
    debugger_id = BI.debugger_id;
    bp_type = BI.bp_type;
    ignore_number = BI.ignore_number;
    is_enabled = BI.is_enabled;
    is_temp = BI.is_temp;
    watchpoint_type = BI.watchpoint_type;
    commandlist = BI.commandlist;
    conditions = BI.conditions;
    at = BI.at;     // Provided by the debugger, no need to serialize
    what = BI.what; // Provided by the debugger, no need to serialize
    origin = BI.origin;
    return *this;
}

void clDebuggerBreakpoint::DeSerialize(Archive& arch)
{
    arch.Read(wxT("file"), file);
    arch.Read(wxT("lineno"), lineno);
    arch.Read(wxT("function_name"), function_name);
    arch.Read(wxT("memory_address"), memory_address);

    int tmpint;
    arch.Read(wxT("bp_type"), tmpint);
    bp_type = (BreakpointType)tmpint;

    arch.Read(wxT("watchpoint_type"), tmpint);
    watchpoint_type = (WatchpointType)tmpint;
    arch.Read(wxT("watchpt_data"), watchpt_data);
    arch.ReadCData(wxT("commandlist"), commandlist);
    commandlist.Trim().Trim(false); // ReadCData tends to add white-space to the commands e.g. a terminal \n
    arch.Read(wxT("regex"), regex);
    arch.Read(wxT("is_temp"), is_temp);
    arch.Read(wxT("is_enabled"), is_enabled);

    arch.Read(wxT("ignore_number"), tmpint);
    ignore_number = (unsigned int)tmpint;
    arch.Read(wxT("conditions"), conditions);

    arch.Read(wxT("origin"), tmpint);
    origin = (BreakpointOrigin)tmpint;
}

void clDebuggerBreakpoint::Serialize(Archive& arch)
{
    arch.Write(wxT("file"), file);
    arch.Write(wxT("lineno"), lineno);
    arch.Write(wxT("function_name"), function_name);
    arch.Write(wxT("memory_address"), memory_address);
    arch.Write(wxT("bp_type"), bp_type);
    arch.Write(wxT("watchpoint_type"), watchpoint_type);
    arch.Write(wxT("watchpt_data"), watchpt_data);
    // WriteCDate tends to write white-space even for empty commandlists
    arch.WriteCData(wxT("commandlist"), commandlist.Trim().Trim(false));
    arch.Write(wxT("regex"), regex);
    arch.Write(wxT("is_temp"), is_temp);
    arch.Write(wxT("is_enabled"), is_enabled);
    arch.Write(wxT("ignore_number"), ignore_number);
    arch.Write(wxT("conditions"), conditions);
    arch.Write(wxT("origin"), (int)origin);
}

JSONItem clDebuggerBreakpoint::ToJSON() const
{
    auto json = JSONItem::createObject();
    json.addProperty("file", file);
    json.addProperty("lineno", lineno);
    json.addProperty("function_name", function_name);
    json.addProperty("bp_type", (int)bp_type);
    json.addProperty("watchpoint_type", (int)watchpoint_type);
    json.addProperty("watchpt_data", watchpt_data);
    wxString command_list(commandlist);
    command_list.Trim(false).Trim(true);
    json.addProperty("commandlist", command_list);
    json.addProperty("ignore_number", ignore_number);
    json.addProperty("conditions", conditions);
    return json;
}

void clDebuggerBreakpoint::FromJSON(const JSONItem& json)
{
    file = json["file"].toString();
    lineno = json["lineno"].toInt();
    function_name = json["function_name"].toString();
    bp_type = (BreakpointType)json["bp_type"].toInt();
    watchpoint_type = (WatchpointType)json["watchpoint_type"].toInt();
    watchpt_data = json["watchpt_data"].toString();
    commandlist = json["commandlist"].toString();
    ignore_number = json["ignore_number"].toSize_t();
    conditions = json["conditions"].toString();
}