-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathmcmini-oldsys.patch
More file actions
208 lines (198 loc) · 8.79 KB
/
Copy pathmcmini-oldsys.patch
File metadata and controls
208 lines (198 loc) · 8.79 KB
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
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
*** a/gdbinit_commands.py 2025-04-09 12:37:33.736635000 -0400
--- b/gdbinit_commands.py 2025-04-09 12:33:20.733476000 -0400
***************
*** 96,103 ****
cmd = exec_file + " -v -q " + mcmini_args
print("** Generating trace sequence for:\n " + cmd)
print(" (This may take a while ...)")
! mcmini_output = subprocess.run(cmd, shell=True, capture_output=True,
! timeout=300)
error_output = mcmini_output.stderr.decode('utf-8')
if "Missing target_executable" in error_output:
print([line for line in error_output.split('\n')
--- 96,104 ----
cmd = exec_file + " -v -q " + mcmini_args
print("** Generating trace sequence for:\n " + cmd)
print(" (This may take a while ...)")
! # In Python 3.7 and later, one can do capture_output=True instead of PIPE.
! mcmini_output = subprocess.run(cmd, shell=True, stdout=subprocess.PIPE,
! stderr=subprocess.PIPE, timeout=300)
error_output = mcmini_output.stderr.decode('utf-8')
if "Missing target_executable" in error_output:
print([line for line in error_output.split('\n')
***************
*** 197,204 ****
return is_traceSeq(args[0])[1]
def is_tui_active():
! return "The TUI is not active." not in gdb.execute("info win", to_string=True)
# This version of gdb.execute() checks if the inferior is no longer running.
def mcmini_execute(command, to_string=False):
--- 198,213 ----
return is_traceSeq(args[0])[1]
+ # gdb-8.5: "info win" returns info even after "tui disable".
+ # If we wanted to fix this, we could do "stdout->TMP_FILE && frame 0"
+ # and if TUI enabled, then it would not be written to TMP_FILE.
+ # Or we could create a child process and pipe to receive it.
def is_tui_active():
! if not gdb.execute("info win", to_string=True): # gdb-8.5 API
! return False
! if "The TUI is not active." not in gdb.execute("info win", to_string=True):
! return False
! return True
# This version of gdb.execute() checks if the inferior is no longer running.
def mcmini_execute(command, to_string=False):
***************
*** 217,227 ****
gdb.execute("set confirm off")
gdb.execute("quit")
def total_num_frames():
frame = gdb.newest_frame()
while frame.older(): # Get oldest frame
frame = frame.older()
! return frame.level() + 1
def select_user_frame():
gdb.invalidate_cached_frames() # Is this useful?
--- 226,248 ----
gdb.execute("set confirm off")
gdb.execute("quit")
+ # gdb.selected_frame().level(); gdb-8.5 doesn't define level() method.
def total_num_frames():
frame = gdb.newest_frame()
+ level = 0
while frame.older(): # Get oldest frame
frame = frame.older()
! level += 1
! return level + 1
!
! # Defines gdb.selected_frame().level(); gdb-8.5 doesn't define level() method.
! def selected_frame_level():
! frame = gdb.newest_frame()
! level = 0
! while frame != gdb.selected_frame():
! frame = frame.older()
! level += 1
! return level
def select_user_frame():
gdb.invalidate_cached_frames() # Is this useful?
***************
*** 270,276 ****
# For example, 'mcmini where/print' doesn't need to change it.
# GDB commands: up; down; fix the display, but print to output
# and leave current line at top.
! gdb.execute("frame " + str( gdb.selected_frame().level() ))
## GDB BUG: 'list <LINE>' should help TUI to center display; but this fails.
# if gdb.execute("frame " + str( gdb.selected_frame().level() )):
# gdb.execute("list " + str( gdb.selected_frame().find_sal().line ))
--- 291,297 ----
# For example, 'mcmini where/print' doesn't need to change it.
# GDB commands: up; down; fix the display, but print to output
# and leave current line at top.
! gdb.execute("frame " + str( selected_frame_level() ))
## GDB BUG: 'list <LINE>' should help TUI to center display; but this fails.
# if gdb.execute("frame " + str( gdb.selected_frame().level() )):
# gdb.execute("list " + str( gdb.selected_frame().find_sal().line ))
***************
*** 296,302 ****
select_user_frame()
# gdb.execute would print newline, but not carriage return:
output = gdb.execute("bt " + str(- (total_num_frames() -
! gdb.selected_frame().level())),
to_string=True)
print(output)
def find_call_frame(name):
--- 317,323 ----
select_user_frame()
# gdb.execute would print newline, but not carriage return:
output = gdb.execute("bt " + str(- (total_num_frames() -
! selected_frame_level())),
to_string=True)
print(output)
def find_call_frame(name):
***************
*** 373,384 ****
## FIXME: If thr.switch() is now silent, do we still need stdout->/dev/null ?
## (And do we still need mcprintf_redirect, for TUI pagination?)
cur_pagination = gdb.parameter("pagination")
! gdb.set_parameter("pagination", "off")
# GDB 'inferior XXX' normally tries to print filename, and errors and
# and sends to stderr Stop trying to print filename. This prevents that.
! cur_frame_info = gdb.execute("show print frame-info", to_string=True)
! cur_frame_info = cur_frame_info.split('"')[1]
! gdb.execute("set print frame-info location")
dup_stdout = os.dup(1)
os.close(1)
cur_stdout = os.open('/dev/null', os.O_WRONLY)
--- 394,409 ----
## FIXME: If thr.switch() is now silent, do we still need stdout->/dev/null ?
## (And do we still need mcprintf_redirect, for TUI pagination?)
cur_pagination = gdb.parameter("pagination")
! # gdb.set_parameter(); gdb-8.5 doesn't define set_parameter() method.
! # gdb.set_parameter("pagination", "off")
! gdb.execute("set pagination off")
# GDB 'inferior XXX' normally tries to print filename, and errors and
# and sends to stderr Stop trying to print filename. This prevents that.
! ## gdb-8.5 doesn't support "show/set print frame-info"
! # cur_frame_info = gdb.execute("show print frame-info", to_string=True)
! # cur_frame_info = cur_frame_info.split('"')[1]
! # gdb.execute("set print frame-info location")
! cur_frame_info = "frame-info UNSUPPORTED IN GDB-8"
dup_stdout = os.dup(1)
os.close(1)
cur_stdout = os.open('/dev/null', os.O_WRONLY)
***************
*** 410,416 ****
thr_user = gdb.selected_thread()
output = gdb.parse_and_eval("mcprintf_redirect_output").string()
# Under TUI, this seems to go to curses (or stderr?), not stdout:
! gdb.execute("set print frame-info " + cur_frame_info)
thr_user.switch()
select_user_frame()
if is_tui_active():
--- 435,442 ----
thr_user = gdb.selected_thread()
output = gdb.parse_and_eval("mcprintf_redirect_output").string()
# Under TUI, this seems to go to curses (or stderr?), not stdout:
! ## gdb-8.5 doesn't support "show/set print frame-info"
! # gdb.execute("set print frame-info " + cur_frame_info)
thr_user.switch()
select_user_frame()
if is_tui_active():
***************
*** 422,428 ****
os.close(dup_stdout)
# It's now safe to print
gdb.flush()
! gdb.set_parameter("pagination", "on" if cur_pagination else "off")
# We need this hack because GDB TUI doesn't erase part of first line.
if is_tui_active() and print_hack:
print(" === ")
--- 448,456 ----
os.close(dup_stdout)
# It's now safe to print
gdb.flush()
! # gdb.set_parameter(); gdb-8.5 doesn't define set_parameter() method.
! # gdb.set_parameter("pagination", "on" if cur_pagination else "off")
! gdb.execute("set pagination %s" % "on" if cur_pagination else "off")
# We need this hack because GDB TUI doesn't erase part of first line.
if is_tui_active() and print_hack:
print(" === ")
***************
*** 526,533 ****
file, line = source_line.split(':')
source_line2 = file + ":" + str(int(line)+1)
list_cmd = "list " + source_line + ", " + source_line2
! if "output styling is enabled." in gdb.execute("show style enabled",
! to_string=True):
gdb.execute("set style enabled off")
extract = gdb.execute(list_cmd, to_string=True)
gdb.execute("set style enabled on")
--- 554,562 ----
file, line = source_line.split(':')
source_line2 = file + ":" + str(int(line)+1)
list_cmd = "list " + source_line + ", " + source_line2
! ## FIXME: gdb-8.5 doesn't support show style enabled; So always False.
! if False and "output styling is enabled." in gdb.execute("show style enabled",
! to_string=True):
gdb.execute("set style enabled off")
extract = gdb.execute(list_cmd, to_string=True)
gdb.execute("set style enabled on")