|
1 | 1 | # -*- coding: utf-8 -*- |
2 | | -# Copyright (C) 2008-2009, 2013, 2015, 2017, 2020-2021 Rocky Bernstein |
3 | | -# <rocky@gnu.org> |
| 2 | +# |
| 3 | +# Copyright (C) 2008-2009, 2013, 2015, 2017, 2020-2021, 2023-2024 |
| 4 | +# Rocky Bernstein <rocky@gnu.org> |
4 | 5 | # |
5 | 6 | # This program is free software: you can redistribute it and/or modify |
6 | 7 | # it under the terms of the GNU General Public License as published by |
|
17 | 18 | """ A place for the debugger default settings """ |
18 | 19 |
|
19 | 20 | # External Egg packages |
20 | | -import os, tracer |
21 | | -from columnize import computed_displaywidth |
| 21 | +import os |
22 | 22 |
|
| 23 | +import tracer |
| 24 | +from columnize import computed_displaywidth |
23 | 25 | from term_background import is_dark_background |
24 | 26 |
|
25 | 27 | width = computed_displaywidth() |
| 28 | +is_dark_bg = is_dark_background() |
| 29 | +default_style = "zenburn" if is_dark_bg else "tango" |
26 | 30 |
|
27 | 31 | # Below are the default debugger settings. The debugger object version |
28 | 32 | # of this may change. A setting is something a user may want to |
29 | 33 | # change, in contrast to settings that the debugger decides to set in |
30 | 34 | # the course of operation. For example, the maximum print width |
31 | 35 | # (width) is user settable, whereas whether the debugging program is |
32 | | -# running (execution_status), or traceback frame isn't user settable |
33 | | -# so it doesn't appear below. Some settings like the current frame |
| 36 | +# running (execution_status), or traceback frame isn't user settable. |
| 37 | +# Therefore, it doesn't appear below. Some settings like the current frame |
34 | 38 | # (curframe) or the number of steps to skip before entering a command |
35 | 39 | # processor (step_ignore) are shared between the two. They also don't |
36 | 40 | # generally appear as settings. |
37 | 41 |
|
| 42 | +# fmt: off |
38 | 43 | DEBUGGER_SETTINGS = { |
39 | 44 | # Emacs and old-style gdb annotate level. Used to annotate output |
40 | 45 | # to make parsing inside Emacs easier and to allow Emacs to get |
41 | 46 | # updated information (stack, local variables) without having to |
42 | 47 | # poll for it. |
43 | 48 | "annotate": 0, |
44 | | - # Format style to use in showing disssembly |
| 49 | + |
| 50 | + # Format style to use in showing disassembly |
45 | 51 | "asmfmt": "extended", |
| 52 | + |
46 | 53 | # Eval as Python the unrecognized debugger commands? |
47 | 54 | "autoeval": True, |
| 55 | + |
48 | 56 | # Run 'list' command every time we enter the debugger? |
49 | 57 | "autolist": False, |
| 58 | + |
50 | 59 | # Enter IPython every time we enter the debugger? |
51 | 60 | # Note: only relevant if we have ipython installed. This takes |
52 | | - # precidence over autopython. |
| 61 | + # precedence over autopython. |
53 | 62 | "autoipython": False, |
| 63 | + |
| 64 | + # Run 'info pc' command every time we enter the debugger? |
| 65 | + "autopc": False, |
| 66 | + |
54 | 67 | # Enter Python every time we enter the debugger? |
55 | 68 | "autopython": False, |
| 69 | + |
56 | 70 | # Show basename only on filename output? |
57 | | - # This opiton is useful in integration testing and |
| 71 | + # This option is useful in integration testing and |
58 | 72 | # possibly to prepare example output for publication |
59 | 73 | "basename": False, |
| 74 | + |
60 | 75 | # Set echoing lines read from debugger? |
61 | 76 | "cmdtrace": False, |
| 77 | + |
62 | 78 | # confirm potentially dangerous operations? |
63 | 79 | "confirm": True, |
| 80 | + |
64 | 81 | # Debug macros? |
65 | 82 | "debugmacro": False, |
| 83 | + |
66 | 84 | # Debug the debugger? |
67 | 85 | "dbg_trepan": False, |
| 86 | + |
68 | 87 | # When True, consecutive stops must be on different |
69 | 88 | # file/line positions. |
70 | 89 | "different": True, |
| 90 | + |
71 | 91 | # events is a set of events to process line-, call-, or return-like |
72 | 92 | # tracing. See tracer.ALL_EVENT_NAMES and ALL_EVENTS |
73 | 93 | # Note this is independent of printset which just prints the event. |
74 | 94 | # This set controls entering the debugger command processor. |
75 | 95 | "events": tracer.ALL_EVENTS, |
| 96 | + |
76 | 97 | # Use terminal highlight? Acceptable values are |
77 | 98 | # 'plain' : no highlighting |
78 | 99 | # 'dark' : terminal highlighting for a dark background |
79 | 100 | # 'light' : terminal highlighting for a light background |
80 | | - "highlight": is_dark_background(), |
| 101 | + "highlight": "dark" if is_dark_bg else "light", |
| 102 | + |
| 103 | + # Where do we save the history? |
| 104 | + "histfile": None, |
| 105 | + |
81 | 106 | # Save debugger history? |
82 | 107 | "hist_save": True, |
| 108 | + |
83 | 109 | # Show function calls/returns? |
84 | 110 | "fntrace": False, |
| 111 | + |
85 | 112 | # Number of lines to show by default in a 'list' command. |
86 | 113 | "listsize": 10, |
| 114 | + |
87 | 115 | # max length to show of parameter string |
88 | 116 | "maxargstrsize": 100, |
| 117 | + |
89 | 118 | # max length to in other strings |
90 | 119 | "maxstring": 150, |
| 120 | + |
91 | 121 | # printset is a set of events to print line-, call-, or return-like |
92 | 122 | # tracing. See tracer.ALL_EVENT_NAMES and ALL_EVENTS. This only |
93 | 123 | # has an effect if trace is set True. |
94 | 124 | "printset": tracer.ALL_EVENTS, |
95 | | - # If this is set True, debugger startup file, e.g. .trepanrc will |
| 125 | + |
| 126 | + # If this is set True, debugger startup file, e.g. ".trepanrc" will |
96 | 127 | # not be read/run. |
| 128 | + |
97 | 129 | "nostartup": False, |
98 | 130 | # Reread source file if we determine it has changed? |
| 131 | + |
99 | 132 | "reload": False, |
100 | | - # Stop at 'def' and 'class' statements? |
| 133 | + # Skip instructions that make classes, functions, and closures? |
| 134 | + # (In the Python they are "class" and "def" statements) |
101 | 135 | "skip": True, |
| 136 | + |
| 137 | + "step_ignore": 0, |
| 138 | + |
| 139 | + # Pygments style. Style is ignored if "highlight" setting |
| 140 | + # is "plain" |
| 141 | + "style": default_style, |
| 142 | + |
102 | 143 | # Location to put temporary decompiled python files. |
103 | 144 | # If value is None, use Python's defaults |
104 | 145 | "tempdir": None, |
| 146 | + |
105 | 147 | # print trace output? |
106 | 148 | "trace": False, |
| 149 | + |
107 | 150 | # The target maximum print length. Used for example in listing |
108 | 151 | # arrays which are columnized. |
109 | 152 | "width": width, |
|
116 | 159 |
|
117 | 160 |
|
118 | 161 | SERVER_SOCKET_OPTS = { |
119 | | - "HOST": None, # Symbolic name meaning all available interfaces |
120 | | - "PORT": 1027, # Arbitrary non-privileged port |
121 | | - "reuse": "posix" == os.name, # Allow port to be resued on close? |
122 | | - "skew": +0, # additional increment on socket tries |
| 162 | + "HOST": None, # Symbolic name meaning all available interfaces |
| 163 | + "PORT": 1027, # Arbitrary non-privileged port |
| 164 | + "reuse": "posix" == os.name, # Allow port to be reused on close? |
| 165 | + "skew": +0, # additional increment on socket tries |
123 | 166 | "search_limit": 100, # max number of ports to try |
124 | 167 | } |
| 168 | +# fmt: on |
125 | 169 |
|
126 | 170 | # Default settings on the Debugger#start() method call |
127 | 171 | START_OPTS = { |
|
140 | 184 | import pprint |
141 | 185 |
|
142 | 186 | for val in ["DEBUGGER_SETTINGS", "START_OPTS", "STOP_OPTS"]: |
143 | | - print("%s:\n" % val), pprint.pformat(eval(val)) |
144 | | - print |
| 187 | + print("%s:" % val) |
| 188 | + print(pprint.pformat(eval(val))) |
| 189 | + print("-" * 10) |
145 | 190 | pass |
146 | 191 | pass |
0 commit comments