File: grt_python_debugger.h

package info (click to toggle)
mysql-workbench 6.3.8%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 113,932 kB
  • ctags: 87,814
  • sloc: ansic: 955,521; cpp: 427,465; python: 59,728; yacc: 59,129; xml: 54,204; sql: 7,091; objc: 965; makefile: 638; sh: 613; java: 237; perl: 30; ruby: 6; php: 1
file content (107 lines) | stat: -rw-r--r-- 3,067 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
/* 
 * Copyright (c) 2010, 2012, Oracle and/or its affiliates. All rights reserved.
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License as
 * published by the Free Software Foundation; version 2 of the
 * License.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
 * 02110-1301  USA
 */

#ifndef __GRT_PYTHON_DEBUGGER_H_
#define __GRT_PYTHON_DEBUGGER_H_

#include "python_context.h"
#include "grt/grt_manager.h"
#include "base/trackable.h"

#include "mforms/tabview.h"
#include "mforms/treenodeview.h"
#include "mforms/utilities.h"
#include "mforms/panel.h"
#include "mforms/splitter.h"
#include "mforms/textentry.h"
#include "mforms/textbox.h"

class GRTCodeEditor;
class GRTShellWindow;

class PythonDebugger : public base::trackable
{
  GRTShellWindow *_shell;
  mforms::TabView *_lower_tabs;
  
  mforms::TreeNodeView *_stack_list;
  mforms::TreeNodeView *_breakpoint_list;
  mforms::TreeNodeView *_variable_list;

  GRTCodeEditor *_stack_position_editor;
  int _stack_position_line;
  
  std::string _tmpfile_name;
  
  grt::AutoPyObject _pdb;
  std::string _pdb_varname;
  
  bec::GRTManager::Timer *_heartbeat_timeout_timer;
  
  bool _pause_clicked;
  bool _program_stopped;
    
  void show_stack();
  
  bool ensure_code_saved();

  void edit_breakpoint(mforms::TreeNodeRef node, int column, std::string value);
  void line_gutter_clicked(int margin, int line, mforms::ModifierKey mods, GRTCodeEditor *editor);
  void editor_text_changed(int line, int linesAdded, GRTCodeEditor *editor);
  void stack_selected();

  bool heartbeat_timeout();
private:
  bool toggle_breakpoint(const char *file, int line);
  
public:
  static PythonDebugger *from_cobject(PyObject *cobj);
  PyObject *as_cobject();
  
  void debug_print(const std::string &s);
  void ui_clear_breakpoints();
  void ui_add_breakpoint(const char *file, int line, const char *condition);
  const char *ui_program_stopped(const char *file, int line, int reason);
  void ui_clear_stack();
  void ui_add_stack(const char *location, const char *file, int line);

  void ui_clear_variables();
  void ui_add_variable(const char *varname, const char *value);

public:
  PythonDebugger(GRTShellWindow *shell, mforms::TabView *tabview);
  void init_pdb();
  
  bool program_stopped() { return _program_stopped; }
  
  void editor_added(GRTCodeEditor *editor);
  void editor_closed(GRTCodeEditor *editor);
  
  void refresh_file(const std::string &file);

  void run(GRTCodeEditor *editor, bool stepping = false);
  void stop();
  void pause();
  void step_into();
  void step();
  void step_out();
  void continue_();
};

#endif