1
# -*- coding: utf-8 -*-
2
# vim:set shiftwidth=4 tabstop=4 expandtab textwidth=79:
4
# Copyright (c) 2006 Ali Afshar
6
#Permission is hereby granted, free of charge, to any person obtaining a copy
7
#of this software and associated documentation files (the "Software"), to deal
8
#in the Software without restriction, including without limitation the rights
9
#to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
#copies of the Software, and to permit persons to whom the Software is
11
#furnished to do so, subject to the following conditions:
13
#The above copyright notice and this permission notice shall be included in
14
#all copies or substantial portions of the Software.
16
#THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
#IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
#FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
#AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
#LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
#OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
24
# Main entry point into application so check sanity
26
#sanity.check_sanity()
36
from console import Console
37
from mainwindow import MainWindow
38
#from sourceviewer import SourceViewer
39
from toolbar import Toolbar, StatusBar
40
from threadviewer import ThreadsViewer
41
from breakpointviewer import BreakpointViewer
42
from namespaceviewer import LocalsViewer, GlobalsViewer
43
from stackviewer import StackViewer, StackItem
46
class Application(object):
48
def __init__(self, viewfactory, options):
49
self.options = options
50
self.main_window = viewfactory(self)
51
self.session_manager = debugsession.SessionManager(self)
52
self.console = Console(self)
53
self.main_window.console = self.console
54
self.stack = StackViewer(self)
55
#self.namespace = AllNamespaceViewer(self)
56
self.threads = ThreadsViewer(self)
57
#self.source = SourceViewer(self)
58
self.globals = GlobalsViewer(self)
59
self.locals = LocalsViewer(self)
60
self.status = StatusBar(self)
61
self.breaks = BreakpointViewer(self)
62
self.toolbar = Toolbar(self)
63
debugsession.connect_events(self)
65
def launch(self, filename):
68
if filename is not None:
70
self.session_manager.launch(True, filename)
71
t = threading.Thread(target=_t)
74
#gobject.idle_add(_l, filename)
76
def update_threads(self, event):
77
current_thread = event.m_current_thread
78
threads_list = event.m_thread_list
79
def _u(threads_list, current_thread):
80
self.threads.update_threads(threads_list, current_thread)
81
gobject.idle_add(_u, threads_list, current_thread)
83
def update_thread_broken(self, event):
86
self.threads.broken_thread(tid)
87
gobject.idle_add(_u, tid)
89
def update_no_threads(self, event):
92
def update_state(self, event):
95
self.status.update_running_status(state)
97
self.toolbar.update_state(state)
99
self.master.update_state(state)
100
gobject.idle_add(_u, state)
101
gobject.idle_add(_u2, state)
102
gobject.idle_add(_u3, state)
104
def update_frame(self, event):
105
index = event.m_frame_index
107
self.stack.select_frame(index)
108
gobject.idle_add(_u, index)
109
self.update_source(-index - 1)
111
def update_stack(self, event):
112
stack = event.m_stack
113
self._last_stack = stack
115
self.stack.update_stack(stack)
116
gobject.idle_add(_u, stack)
117
self.update_source(-1)
119
def update_source(self, index):
121
si =StackItem(index, *self._last_stack['stack'][index])
122
self.source_goto(si.filename, si.linenumber)
123
gobject.idle_add(_u, index)
125
def update_namespace(self, event):
127
self.locals.update_namespace()
128
self.globals.update_namespace()
131
def update_bp(self, event):
134
if event.m_bp is not None:
135
filename = event.m_bp.m_filename
136
linenumber = event.m_bp.m_lineno
137
index = event.m_bp.m_id
143
indices = event.m_id_list
144
self.breaks.update_bp(act, index, indices, filename, linenumber)
145
self.master.update_bp(act, index, indices, filename, linenumber)
146
gobject.idle_add(_u, event)
151
options = debugsession.start(*args)
152
app = Application(MainWindow, options)
154
app.main_window.show_all()
157
if os.path.exists(fn):
161
def embed(parent, viewfactory, filename=None):
162
def start_embedded(*args):
163
options = debugsession.start(*args)
164
app = Application(viewfactory, options)
166
app.main_window.show_all()
170
if os.path.exists(fn):
172
return debugsession.main(start_embedded)
176
debugsession.main(start)
179
if __name__ == '__main__':