summaryrefslogtreecommitdiffstats
path: root/scilab/modules/ast/includes/ast/breakpoint.hxx
blob: 1628ee4a48060132db6f5a4e71e040a140b8bf5b (plain)
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
139
140
141
142
143
144
145
146
147
148
149
150
151
152
/*
 *  Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
 *  Copyright (C) 2015 - Scilab Enterprises - Antoine ELIAS
 *
 * Copyright (C) 2012 - 2016 - Scilab Enterprises
 *
 * This file is hereby licensed under the terms of the GNU GPL v2.0,
 * pursuant to article 5.3.4 of the CeCILL v.2.1.
 * This file was originally licensed under the terms of the CeCILL v2.1,
 * and continues to be available under such terms.
 * For more information, see the COPYING file which you should have received
 * along with this program.
 *
 */

#ifndef __BREAKPOINT_HXX__
#define __BREAKPOINT_HXX__

#include <string>
#include "macro.hxx"
#include "exp.hxx"

extern "C"
{
#include "parsecommand.h"
}

namespace debugger
{
struct Breakpoint
{
    Breakpoint() :  _pFunctionName(""),
                    _iMacroLine(0),
                    _pFileName(""),
                    _iFileLine(0),
                    _iFirstColumn(0),
                    _condition(""),
                    _conditionExp(NULL),
                    _enable(true) {}
    ~Breakpoint()
    {
        if (_conditionExp)
        {
            delete _conditionExp;
        }
    };

    void setFileName(const std::string& name)
    {
        _pFileName = name;
    }
    const std::string& getFileName() const
    {
        return _pFileName;
    }

    void setFunctionName(const std::string& functionName)
    {
        _pFunctionName = functionName;
    }
    const std::string& getFunctioName() const
    {
        return _pFunctionName;
    }

    void setMacroLine(int line)
    {
        _iMacroLine = line;
    }
    int getMacroLine() const
    {
        return _iMacroLine;
    }

    void setBeginLine(int column)
    {
        _iFirstColumn = column;
    }
    int getBeginLine() const
    {
        return _iFirstColumn;
    }

    void setFileLine(int line)
    {
        _iFileLine = line;
    }
    int getFileLine() const
    {
        return _iFileLine;
    }

    bool hasMacro() const
    {
        return _pFunctionName.empty() == false && _iMacroLine >= 0;
    }

    bool hasFile() const
    {
        return _pFileName.empty() == false && _iFileLine >= 0;
    }

    void setEnable()
    {
        _enable = true;
    }
    void setDisable()
    {
        _enable = false;
    }
    bool isEnable() const
    {
        return _enable;
    }

    char* setCondition(const std::string& condition)
    {
        char* error = parseCommand(condition.data(), (void**)(&_conditionExp));
        if(error)
        {
            return error;
        }
        _condition = condition;
        return nullptr;
    }

    const std::string& getCondition() const
    {
        return _condition;
    }

    ast::Exp* getConditionExp()
    {
        return _conditionExp;
    }

private:
    std::string _pFunctionName;
    int _iMacroLine;
    int _iFirstColumn;
    std::string _pFileName;
    int _iFileLine;
    std::string _condition;
    ast::Exp* _conditionExp;
    bool _enable;
};

typedef std::vector<Breakpoint*> Breakpoints;

}

#endif /* !__BREAKPOINT_HXX__ */