2
# Copyright (c) 2003-2006 ActiveState Software Inc.
6
# Permission is hereby granted, free of charge, to any person obtaining
7
# a copy of this software and associated documentation files
8
# (the "Software"), to deal in the Software without restriction,
9
# including without limitation the rights to use, copy, modify,
10
# merge, publish, distribute, sublicense, and/or sell copies of the
11
# Software, and to permit persons to whom the Software is furnished
12
# to do so, subject to the following conditions:
14
# The above copyright notice and this permission notice shall be included
15
# in all copies or substantial portions of the Software.
17
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
18
# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
20
# IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
21
# CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
22
# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
23
# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
27
# Shane Caraveo <ShaneC@ActiveState.com>
28
# Trent Mick <TrentM@ActiveState.com>
34
from dbgp import _logging as logging
36
# insert a frame flag for ourselves. This flag is used to drop frames from
37
# the stack that we wouldn't want to normally see. See
38
# dbgpClient.get_stack
42
# hide children gets set when writing stdout. This prevents deeper stack levels
43
# that stdout uses from showing up in the stack frame and causing breaks in weird
47
# if set allows stepping into parts of this file.
48
# 0 - dont allow (default)
49
# 1 - allow, but not the io streams
50
# 2 - allow plus the io streams
56
ERROR_COMMAND_PARSE = 1
57
ERROR_DUPLICATE_ARGS = 2
58
ERROR_INVALID_ARGS = 3
59
ERROR_COMMAND_NOT_SUPPORTED = 4
60
ERROR_COMMAND_NOT_AVAILABLE = 5
61
ERROR_FILE_ACCESS = 100
62
ERROR_STREAM_REDIRECT_FAILED = 101
63
ERROR_BREAKPOINT_INVALID = 200
64
ERROR_BREAKPOINT_TYPE = 201
65
ERROR_BREAKPOINT_INVALID_LINE = 202
66
ERROR_BREAKPOINT_NOT_REACHABLE = 203
67
ERROR_BREAKPOINT_STATE = 204
68
ERROR_BREAKPOINT_DOES_NOT_EXIST = 205
69
ERROR_EVAL_FAILED = 206
70
ERROR_INVALID_EXPRESSION = 207
71
ERROR_PROPERTY_DOES_NOT_EXIST = 300
72
ERROR_STACK_DEPTH = 301
73
ERROR_CONTEXT_INVALID = 302
93
STATUS_INTERACTIVE = 5
95
status_names = ['starting', 'stopping', 'stopped', 'running', 'break', 'interactive']
103
reason_names = ['ok' , 'error', 'aborted', 'exception']
105
RESUME_STOP = 0 # session terminated.
106
RESUME_STEP_IN = 1 # step into things.
107
RESUME_STEP_OVER = 2 # step over current thing
108
RESUME_STEP_OUT = 3 # step out of current thing.
109
RESUME_GO = 4 # go for it.
110
RESUME_INTERACTIVE = 5 # go for it.
112
resume_command_names = ['stop', 'step_into', 'step_over', 'step_out', 'run', 'interact']
114
def getenv(key, default=None):
116
if not hasattr(os, 'getenv'):
117
# on Symbian, getenv doesn't exist! (AttributeError)
119
retval = os.getenv(key)
123
# on Jython, one gets an exception instead of None back
127
class DBGPError(Exception):
130
class DBGPQuit(Exception):
133
an exception thrown to quit debugging
137
def configureLogging(log, level = logging.INFO):
138
global __log_configured
143
class DBGPFormatter(logging.Formatter):
144
"""Logging formatter to prefix log level name to all log output
145
*except* normal INFO level logs.
147
def format(self, record):
148
s = logging.Formatter.format(self, record)
149
#if record.levelno != logging.INFO:
150
s = "%s: %s: %s" % (record.levelname, record.name, s)
153
hdlr = logging.StreamHandler()
154
fmtr = DBGPFormatter()
155
hdlr.setFormatter(fmtr)