/usr/include/xqilla/debug/InteractiveDebugger.hpp is in libxqilla-dev 2.3.0-3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 | /*
* Copyright (c) 2001, 2008,
* DecisionSoft Limited. All rights reserved.
* Copyright (c) 2004, 2011,
* Oracle and/or its affiliates. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef _INTERACTIVEDEBUGGER_HPP
#define _INTERACTIVEDEBUGGER_HPP
#include <string>
#include <vector>
#include <map>
#include <xqilla/debug/DebugListener.hpp>
#include <xqilla/ast/LocationInfo.hpp>
#include <xqilla/debug/InputParser.hpp>
class XQQuery;
class DynamicContext;
class DebugCommand;
class InteractiveDebugger;
class XQILLA_API BaseInteractiveDebugger
{
public:
struct XQILLA_API Run {};
struct XQILLA_API Continue {};
struct XQILLA_API Quit {};
static void outputLocation(const XMLCh *file, unsigned int line, unsigned int column,
unsigned int context = 0);
static void outputLocationFromString(const XMLCh *query, unsigned int line, unsigned int column,
unsigned int context = 0);
static std::string regexFind(const char *regex, const std::string &str, int groupNo = 1);
virtual ~BaseInteractiveDebugger();
unsigned int setBreakPoint(const std::string &file, unsigned int line, unsigned int column, bool temporary);
bool disableBreakPoint(unsigned int number);
bool enableBreakPoint(unsigned int number);
void listBreakPoints() const;
void setStep();
void setNext();
bool queryStarted() const { return queryStarted_; }
virtual void run() = 0;
virtual bool changeFrame(unsigned int number) = 0;
virtual unsigned int getStackSize() const = 0;
virtual void stackTrace() const = 0;
virtual bool outputCurrentFrame(unsigned int context = 0) const = 0;
virtual void outputCurrentFrameQueryPlan() const = 0;
virtual bool queryCurrentFrame(const char *queryString) const = 0;
virtual bool currentFrameLocation(std::string &file, unsigned int &line, unsigned int &column) const = 0;
virtual void setDoLazyEvaluation(bool lazy) = 0;
virtual void setDoFocusOptimizationsn(bool opt) = 0;
virtual void setDoProjection(bool opt) = 0;
protected:
BaseInteractiveDebugger();
DebugCommand *findCommand(std::string &command) const;
void checkBreak(bool entering);
void breakForError(const char *message);
void interrupted();
void readCommand();
std::vector<DebugCommand*> commands_;
DebugCommand *prevcmd_;
bool queryStarted_;
struct BreakPoint
{
BreakPoint(const std::string &f, unsigned int l, unsigned int c, bool t)
: file(f), line(l), column(c), temporary(t), disabled(false) {}
std::string file;
unsigned int line, column;
bool temporary;
bool disabled;
};
std::vector<BreakPoint> breaks_;
bool step_;
unsigned int next_;
};
class XQILLA_API DebugCommand
{
public:
virtual ~DebugCommand() {};
virtual const char *getCommandName() const { return name_; }
virtual const char *getCommandNameCompat() const { return compatName_; }
virtual const char *getBriefHelp() const { return briefHelp_; }
virtual const char *getMoreHelp() const { return moreHelp_; }
static bool matches(const std::string &command,
const std::string &toMatch);
virtual bool matches(const std::string &command) const;
virtual void execute(InputParser::Args &args, BaseInteractiveDebugger &env) = 0;
protected:
DebugCommand(const char *name, const char *compatName,
const char *briefHelp, const char *moreHelp)
: name_(name), compatName_(compatName), briefHelp_(briefHelp), moreHelp_(moreHelp) {}
const char *name_;
const char *compatName_;
const char *briefHelp_;
const char *moreHelp_;
};
class XQILLA_API InteractiveDebugger : private BaseInteractiveDebugger,
private DebugListener
{
public:
static void debugQuery(const XQQuery *query, DynamicContext *context);
static void outputLocation(const LocationInfo *info, unsigned int context = 0);
private:
InteractiveDebugger(const XQQuery *query, DynamicContext *context);
virtual void enter(const StackFrame *stack, const DynamicContext *context);
virtual void exit(const StackFrame *stack, const DynamicContext *context);
virtual void error(const XQException &error, const StackFrame *stack, const DynamicContext *context);
virtual bool doLazyEvaluation() const { return lazy_; }
virtual bool doFocusOptimizations() const { return focusOptimzations_; }
virtual void run();
virtual bool changeFrame(unsigned int number);
virtual unsigned int getStackSize() const;
virtual void stackTrace() const;
virtual bool outputCurrentFrame(unsigned int context) const;
virtual void outputCurrentFrameQueryPlan() const;
virtual bool queryCurrentFrame(const char *queryString) const;
virtual bool currentFrameLocation(std::string &file, unsigned int &line, unsigned int &column) const;
virtual void setDoLazyEvaluation(bool lazy) { lazy_ = lazy; }
virtual void setDoFocusOptimizationsn(bool opt) { focusOptimzations_ = opt; }
virtual void setDoProjection(bool opt);
unsigned int getCurrentFrameNumber() const;
void output(const StackFrame *frame) const;
void report(const StackFrame *frame) const;
const StackFrame *stack_;
const StackFrame *currentFrame_;
const XQQuery *query_;
DynamicContext *context_;
bool lazy_;
bool focusOptimzations_;
};
#endif
|