]>
Commit | Line | Data |
---|---|---|
04dae7e9 JR |
1 | --- fpcbuild-2.6.0/fpcsrc/packages/gdbint/Makefile 2011-12-10 21:19:00.000000000 +0100 |
2 | +++ fixes_2_6/fpcsrc/packages/gdbint/Makefile 2012-11-18 19:06:54.295222330 +0100 | |
3 | @@ -2337,10 +2318,12 @@ | |
4 | endif | |
5 | ifeq ($(OS_SOURCE),openbsd) | |
6 | override FPCOPT+=-FD$(NEW_BINUTILS_PATH) | |
7 | +override FPCMAKEOPT+=-FD$(NEW_BINUTILS_PATH) | |
8 | endif | |
9 | ifndef CROSSBOOTSTRAP | |
10 | ifneq ($(BINUTILSPREFIX),) | |
11 | override FPCOPT+=-XP$(BINUTILSPREFIX) | |
12 | +override FPCMAKEOPT+=-XP$(BINUTILSPREFIX) | |
13 | endif | |
14 | ifneq ($(BINUTILSPREFIX),) | |
15 | override FPCOPT+=-Xr$(RLINKPATH) | |
16 | --- fpcbuild-2.6.0/fpcsrc/packages/gdbint/src/gdbint.pp 2012-11-18 19:12:04.578544717 +0100 | |
17 | +++ fixes_2_6/fpcsrc/packages/gdbint/src/gdbint.pp 2012-11-18 19:06:54.121889002 +0100 | |
18 | @@ -50,7 +50,6 @@ | |
19 | {$ifdef GDB_V601} | |
20 | {$info using gdb 6.1.x} | |
21 | {$define GDB_V6} | |
22 | - {$define GDB_HAS_DB_COMMANDS} | |
23 | {$undef GDB_HAS_DEPRECATED_CBPH} | |
24 | {$endif def GDB_V601} | |
25 | ||
26 | @@ -58,14 +57,12 @@ | |
27 | {$ifdef GDB_V602} | |
28 | {$info using gdb 6.2.x} | |
29 | {$define GDB_V6} | |
30 | - {$define GDB_HAS_DB_COMMANDS} | |
31 | {$endif def GDB_V602} | |
32 | ||
33 | { 6.3.x } | |
34 | {$ifdef GDB_V603} | |
35 | {$info using gdb 6.3.x} | |
36 | {$define GDB_V6} | |
37 | - {$define GDB_HAS_DB_COMMANDS} | |
38 | {$endif def GDB_V603} | |
39 | ||
40 | { 6.4.x } | |
41 | @@ -73,7 +70,6 @@ | |
42 | {$info using gdb 6.4.x} | |
43 | {$define GDB_V6} | |
44 | {$define GDB_NEEDS_NO_ERROR_INIT} | |
45 | - {$define GDB_HAS_DB_COMMANDS} | |
46 | {$endif def GDB_V604} | |
47 | ||
48 | { 6.5.x } | |
49 | @@ -87,7 +83,6 @@ | |
50 | {$ifdef GDB_V606} | |
51 | {$info using gdb 6.6.x} | |
52 | {$define GDB_V6} | |
53 | - {$define GDB_HAS_DB_COMMANDS} | |
54 | {$define GDB_USES_BP_LOCATION} | |
55 | {$define GDB_NEEDS_NO_ERROR_INIT} | |
56 | {$define GDB_USES_EXPAT_LIB} | |
57 | @@ -98,7 +93,6 @@ | |
58 | {$ifdef GDB_V607} | |
59 | {$info using gdb 6.7.x} | |
60 | {$define GDB_V6} | |
61 | - {$define GDB_HAS_DB_COMMANDS} | |
62 | {$define GDB_USES_BP_LOCATION} | |
63 | {$define GDB_NEEDS_NO_ERROR_INIT} | |
64 | {$define GDB_USES_EXPAT_LIB} | |
65 | @@ -109,7 +103,6 @@ | |
66 | {$ifdef GDB_V608} | |
67 | {$info using gdb 6.8.x} | |
68 | {$define GDB_V6} | |
69 | - {$define GDB_HAS_DB_COMMANDS} | |
70 | {$define GDB_USES_BP_LOCATION} | |
71 | {$define GDB_BP_LOCATION_HAS_GLOBAL_NEXT} | |
72 | {$define GDB_NEEDS_NO_ERROR_INIT} | |
73 | @@ -120,13 +113,44 @@ | |
74 | {$define GDB_HAS_BP_NONE} | |
75 | {$endif def GDB_V608} | |
76 | ||
77 | +{ 7.4.x } | |
78 | +{$ifdef GDB_V704} | |
79 | + {$info using gdb 7.4.x} | |
80 | + {$define GDB_V7} | |
81 | + {$define GDB_BP_LOCATION_HAS_GDBARCH} | |
82 | + {$define GDB_HAS_PROGRAM_SPACE} | |
83 | + {$define GDB_NO_UIOUT} | |
84 | + {$define GDB_NEEDS_INTERPRETER_SETUP} | |
85 | + {$define GDB_NEEDS_SET_INSTREAM} | |
86 | + {$define GDB_NOTIFY_BREAKPOINT_ARG_IS_BREAKPOINT_PTR} | |
87 | + {$define GDB_USES_BP_OPS} | |
88 | + {$define GDB_BP_TI_HAS_LENGTH} | |
89 | + {$define GDB_BP_LOCATION_HAS_REFCOUNT} | |
90 | + {$define GDB_BP_LOCATION_HAS_OPS} | |
91 | + {$define GDB_UI_FILE_HAS_WRITE_ASYNC} | |
92 | + {$ifdef win32} | |
93 | + {$define GDB_USES_LIBADVAPI32} | |
94 | + {$endif win32} | |
95 | +{$endif def GDB_V704} | |
96 | + | |
97 | { 7.3.x } | |
98 | {$ifdef GDB_V703} | |
99 | {$info using gdb 7.3.x} | |
100 | {$define GDB_V7} | |
101 | {$define GDB_BP_LOCATION_HAS_GDBARCH} | |
102 | {$define GDB_HAS_PROGRAM_SPACE} | |
103 | -{$endif def GDB_V702} | |
104 | + {$define GDB_BP_TI_HAS_LENGTH} | |
105 | + {$define GDB_BP_LOCATION_HAS_REFCOUNT} | |
106 | + {$ifdef GDB_CVS} | |
107 | + {$define GDB_NO_UIOUT} | |
108 | + {$define GDB_NEEDS_INTERPRETER_SETUP} | |
109 | + {$define GDB_NEEDS_SET_INSTREAM} | |
110 | + {$define GDB_NOTIFY_BREAKPOINT_ARG_IS_BREAKPOINT_PTR} | |
111 | + {$define GDB_USES_BP_OPS} | |
112 | + {$define GDB_BP_LOCATION_HAS_OPS} | |
113 | + {$define GDB_UI_FILE_HAS_WRITE_ASYNC} | |
114 | + {$endif GDB_CVS} | |
115 | +{$endif def GDB_V703} | |
116 | ||
117 | { 7.2.x } | |
118 | {$ifdef GDB_V702} | |
119 | @@ -449,8 +472,11 @@ | |
120 | {$LINKLIB libintl.a} | |
121 | {$LINKLIB imagehlp} | |
122 | {$endif not USE_MINGW_GDB} | |
123 | - {$LINKLIB kernel32} | |
124 | + {$ifdef GDB_USES_LIBADVAPI32} | |
125 | + {$LINKLIB advapi32} | |
126 | + {$endif GDB_USES_LIBADVAPI32} | |
127 | {$LINKLIB user32} | |
128 | + {$LINKLIB kernel32} | |
129 | {$endif win32} | |
130 | ||
131 | {$ifdef win64} | |
132 | @@ -589,9 +615,11 @@ | |
133 | type | |
134 | ||
135 | pui_file = ^ui_file; | |
136 | + pstdio_file = ^stdio_file; | |
137 | ||
138 | ui_file_flush_ftype = procedure(stream : pui_file);cdecl; | |
139 | ui_file_write_ftype = procedure(stream : pui_file;buf : pchar;len : longint);cdecl; | |
140 | + ui_file_write_async_save_ftype = procedure(stream : pui_file;buf : pchar;len : longint);cdecl; | |
141 | ui_file_fputs_ftype = procedure(buf : pchar; stream : pui_file);cdecl; | |
142 | ui_file_delete_ftype = procedure(stream : pui_file);cdecl; | |
143 | ui_file_isatty_ftype = function(stream : pui_file) : longbool;cdecl; | |
144 | @@ -606,6 +634,9 @@ | |
145 | magic : plongint; | |
146 | to_flush : ui_file_flush_ftype; | |
147 | to_write : ui_file_write_ftype; | |
148 | + {$ifdef GDB_UI_FILE_HAS_WRITE_ASYNC} | |
149 | + to_write_async_safe : ui_file_write_async_save_ftype; | |
150 | + {$endif} | |
151 | to_fputs : ui_file_fputs_ftype; | |
152 | {$ifdef GDB_V6} | |
153 | to_read : ui_file_read_ftype; | |
154 | @@ -617,6 +648,13 @@ | |
155 | to_data : pointer; | |
156 | end; | |
157 | ||
158 | + stdio_file = record | |
159 | + magic : plongint; | |
160 | + _file : P_C_FILE; | |
161 | + df : longint; | |
162 | + close_p : longint; | |
163 | + end; | |
164 | + | |
165 | { used to delete stdio_ui_file gdb_stdout and gdb_stderr } | |
166 | procedure ui_file_delete(stream : pui_file);cdecl;external; | |
167 | ||
168 | @@ -775,10 +813,16 @@ | |
169 | {$ifdef GDB_V6} | |
170 | type | |
171 | ui_out = pointer; | |
172 | +{$ifndef GDB_NO_UIOUT} | |
173 | var | |
174 | uiout : ui_out;cvar;external; | |
175 | +{$else GDB_NO_UIOUT} | |
176 | +var | |
177 | + cli_uiout : ui_out;cvar;external; | |
178 | + current_uiout : ui_out;cvar;external; | |
179 | +{$endif GDB_NO_UIOUT} | |
180 | function cli_out_new (stream : pui_file):ui_out;cdecl;external; | |
181 | -{$endif} | |
182 | +{$endif GDB_V6} | |
183 | ||
184 | {$ifdef go32v2} | |
185 | { needed to be sure %fs contains the DOS memory selector | |
186 | @@ -816,8 +860,11 @@ | |
187 | jmp_buf = dpmi_jmp_buf; | |
188 | pjmp_buf = pdpmi_jmp_buf; | |
189 | ||
190 | + | |
191 | function setjmp(var rec : jmp_buf) : longint;cdecl;external; | |
192 | ||
193 | + function malloc(size : longint) : pointer;cdecl;external; | |
194 | + | |
195 | procedure longjmp(var rec : jmp_buf;return_value : longint);cdecl;external; | |
196 | ||
197 | procedure reload_fs;assembler; | |
198 | @@ -870,6 +917,13 @@ | |
199 | pCORE_ADDR = ^CORE_ADDR; | |
200 | pblock = ^block; | |
201 | ||
202 | + tframe_id = record | |
203 | + stack_addr, code_addr, special_addr : CORE_ADDR; | |
204 | + addr_p_flags : byte;{ for three 1 bit flags | |
205 | + stack_addr_p, code_addr_p, special_addr_p : cint : 1; } | |
206 | + inline_depth : longint; | |
207 | + end; | |
208 | + | |
209 | tlanguage = (language_unknown,language_auto,language_c, | |
210 | language_cplus,language_java,language_chill, | |
211 | language_fortran,language_m2,language_asm, | |
212 | @@ -898,9 +952,18 @@ | |
213 | ||
214 | target_hw_bp_type = (hw_write, hw_read, hw_access, hw_execute); | |
215 | ||
216 | + { pointer to structures that we don't need } | |
217 | + pbp_ops = pointer; | |
218 | + pbp_location_ops = pointer; | |
219 | + pprogram_space = pointer; | |
220 | + pgdbarch = pointer; | |
221 | + | |
222 | {$PACKRECORDS 4} | |
223 | pbreakpoint = ^breakpoint; | |
224 | breakpoint = record | |
225 | +{$ifdef GDB_USES_BP_OPS} | |
226 | + ops : pbp_ops; | |
227 | +{$endif GDB_USES_BP_OPS} | |
228 | next : pbreakpoint; | |
229 | typ : bptype; | |
230 | enable : tenable; | |
231 | @@ -911,19 +974,36 @@ | |
232 | {$else not GDB_USES_BP_LOCATION} | |
233 | address : CORE_ADDR; | |
234 | {$endif not GDB_USES_BP_LOCATION} | |
235 | +{$ifndef GDB_USES_BP_OPS} | |
236 | line_number : longint; | |
237 | source_file : pchar; | |
238 | +{$endif not GDB_USES_BP_OPS} | |
239 | silent : byte; | |
240 | +{$ifdef GDB_USES_BP_OPS} | |
241 | + display_canonical: byte; | |
242 | +{$endif GDB_USES_BP_OPS} | |
243 | + | |
244 | ignore_count : longint; | |
245 | {$ifndef GDB_USES_BP_LOCATION} | |
246 | shadow_contents : array[0..15] of char; | |
247 | inserted : char; | |
248 | duplicate : char; | |
249 | {$endif not GDB_USES_BP_LOCATION} | |
250 | + | |
251 | commands : pointer; {^command_line} | |
252 | +{$ifdef GDB_USES_BP_OPS} | |
253 | + frame_id : tframe_id; | |
254 | + pspace : pprogram_space; | |
255 | +{$else not GDB_USES_BP_OPS} | |
256 | frame : CORE_ADDR; | |
257 | cond : pointer; {^expression} | |
258 | - addr_string : ^char; | |
259 | +{$endif GDB_USES_BP_OPS} | |
260 | + addr_string : pchar; | |
261 | +{$ifdef GDB_USES_BP_OPS} | |
262 | + filter : pchar; | |
263 | + addr_string_range_end : pchar; | |
264 | + gdbarch : pgdbarch; | |
265 | +{$endif GDB_USES_BP_OPS} | |
266 | language : tlanguage; | |
267 | input_radix : longint; | |
268 | cond_string : ^char; | |
269 | @@ -942,6 +1022,9 @@ | |
270 | bp_target_info = record | |
271 | placed_address_space : pointer;{paddress_space;} | |
272 | placed_address : CORE_ADDR; | |
273 | +{$ifdef GDB_BP_TI_HAS_LENGTH} | |
274 | + length : longint; | |
275 | +{$endif GDB_BP_TI_HAS_LENGTH} | |
276 | shadow_contents : array[0..15] of char; | |
277 | shadow_len : longint; | |
278 | placed_size : longint; | |
279 | @@ -949,9 +1032,17 @@ | |
280 | ||
281 | bp_location = record | |
282 | next : pbp_location; | |
283 | +{$ifdef GDB_BP_LOCATION_HAS_OPS} | |
284 | + ops : pbp_location_ops; | |
285 | +{$endif GDB_BP_LOCATION_HAS_OPS} | |
286 | + | |
287 | +{$ifdef GDB_BP_LOCATION_HAS_REFCOUNT} | |
288 | + refc : longint; | |
289 | +{$else} | |
290 | {$ifdef GDB_BP_LOCATION_HAS_GLOBAL_NEXT} | |
291 | global_next : pbp_location; | |
292 | {$endif GDB_BP_LOCATION_HAS_GLOBAL_NEXT} | |
293 | +{$endif} | |
294 | loc_type : bp_loc_type; | |
295 | owner : pbreakpoint; | |
296 | {$ifdef GDB_BP_LOCATION_HAS_GLOBAL_NEXT} | |
297 | @@ -962,10 +1053,10 @@ | |
298 | inserted : byte; | |
299 | duplicate : byte; | |
300 | {$ifdef GDB_BP_LOCATION_HAS_GDBARCH} | |
301 | - gdbarch : pointer;{pgdbarch;} | |
302 | + gdbarch : pgdbarch; | |
303 | {$endif GDB_BP_LOCATION_HAS_GDBARCH} | |
304 | {$ifdef GDB_HAS_PROGRAM_SPACE} | |
305 | - pspace : pointer;{pprogram_space;} | |
306 | + pspace : pprogram_space; | |
307 | {$endif GDB_HAS_PROGRAM_SPACE} | |
308 | address : CORE_ADDR; | |
309 | {$ifdef GDB_BP_LOCATION_HAS_GLOBAL_NEXT} | |
310 | @@ -980,6 +1071,11 @@ | |
311 | target_info : bp_target_info; | |
312 | overlay_target_info : bp_target_info; | |
313 | events_till_retirement : longint; | |
314 | +{$ifdef GDB_USES_BP_OPS} | |
315 | + { line and source file are in location } | |
316 | + line_number : longint; | |
317 | + source_file : pchar; | |
318 | +{$endif not GDB_USES_BP_OPS} | |
319 | end; | |
320 | ||
321 | tfreecode=(free_nothing,free_contents,free_linetable); | |
322 | @@ -1489,7 +1585,9 @@ | |
323 | {$endif ndef GDB_HAS_OBSERVER_NOTIFY_BREAKPOINT_CREATED} | |
324 | current_target : target_ops;cvar;external; | |
325 | stop_pc : CORE_ADDR;cvar;external; | |
326 | - { Only used from GDB 5.01 but doesn't hurst otherwise } | |
327 | + { Only used from GDB 5.0 but doesn't hurst otherwise } | |
328 | + { This global variable is declared in defs.h as external | |
329 | + and instanciated in main.c since version 5.0. } | |
330 | interpreter_p : pchar;cvar;public; | |
331 | ||
332 | { we need also to declare some vars } | |
333 | @@ -1503,13 +1601,22 @@ | |
334 | ||
335 | { Whether xdb commands will be handled } | |
336 | {$ifdef GDB_HAS_DB_COMMANDS} | |
337 | + { These two global variables are declared in defs.h | |
338 | + since version 4.18 } | |
339 | xdb_commands : longint;cvar;public; | |
340 | ||
341 | { Whether dbx commands will be handled } | |
342 | dbx_commands : longint;cvar;public; | |
343 | {$endif GDB_HAS_DB_COMMANDS} | |
344 | ||
345 | +{$ifdef GDB_NEEDS_SET_INSTREAM} | |
346 | +var | |
347 | + instream : P_C_FILE;cvar;external; | |
348 | + function gdb_fopen (filename : pchar; mode : pchar) : pui_file;cdecl;external; | |
349 | +{$endif GDB_NEEDS_SET_INSTREAM} | |
350 | var | |
351 | + { The four following variables are defined in defs.h | |
352 | + and instanciated in main.c since version 5.0 } | |
353 | gdb_stdout : pui_file;cvar;public; | |
354 | gdb_stderr : pui_file;cvar;public; | |
355 | gdb_stdlog : pui_file;cvar;public; | |
356 | @@ -1517,6 +1624,9 @@ | |
357 | event_loop_p : longint;cvar;public; | |
358 | {$ifdef GDB_V6} | |
359 | (* target IO streams *) | |
360 | + { The three following variables are declared in defs.h | |
361 | + and instanciated in main.c since version 6.0 } | |
362 | + gdb_stdin : pui_file;cvar;public; | |
363 | gdb_stdtargin : pui_file;cvar;public; | |
364 | gdb_stdtargerr : pui_file;cvar;public; | |
365 | {$endif} | |
366 | @@ -1524,7 +1634,10 @@ | |
367 | { used for gdb_stdout and gdb_stderr } | |
368 | function xmalloc(size : longint) : pointer;cdecl;external; | |
369 | { used for QueryHook } | |
370 | -function xstrvprintf(msg : pchar) : pchar; varargs; cdecl; external; | |
371 | +{ xvasprintf is present at least from GDB 5.3 | |
372 | + while xstrvprintf only appears in version 6.2, | |
373 | + so only use xvasprintf function } | |
374 | +function xvasprintf(ret : ppchar; msg : pchar) : pchar; varargs; cdecl; external; | |
375 | procedure xfree(p : pointer); cdecl; external; | |
376 | function find_pc_line(i:CORE_ADDR;l:longint):symtab_and_line;cdecl;external; | |
377 | function find_pc_function(i:CORE_ADDR):psymbol;cdecl;external; | |
378 | @@ -2407,11 +2520,15 @@ | |
379 | QueryHook:=0 | |
380 | else | |
381 | begin | |
382 | - if curr_gdb^.reset_command and (pos('Kill',question)>0) then | |
383 | + if curr_gdb^.reset_command and ((pos('Kill',question)>0) or | |
384 | + (pos('Discard symbol table',question)>0)) then | |
385 | QueryHook:=1 | |
386 | else if pos('%',question)>0 then | |
387 | begin | |
388 | - local:=xstrvprintf(question,arg); | |
389 | + xvasprintf(@local,question,arg); | |
390 | + { xvasprintf can failed, in that case local is set to nil } | |
391 | + if not assigned(local) then | |
392 | + local:=question; | |
393 | QueryHook:=curr_gdb^.Query(local, nil); | |
394 | xfree(local); | |
395 | end | |
396 | @@ -2452,7 +2569,12 @@ | |
397 | last_breakpoint_number:=b.number; | |
398 | { function breakpoints have zero as file and as line !! | |
399 | but they are valid !! } | |
400 | +{$ifndef GDB_USES_BP_OPS} | |
401 | invalid_breakpoint_line:=(b.line_number<>sym.line) and (b.line_number<>0); | |
402 | +{$else GDB_USES_BP_OPS} | |
403 | + invalid_breakpoint_line:=(b.loc=nil) or | |
404 | + ((b.loc^.line_number<>sym.line) and (b.loc^.line_number<>0)); | |
405 | +{$endif GDB_USES_BP_OPS} | |
406 | {$ifdef GDB_USES_BP_LOCATION} | |
407 | if assigned (b.loc) then | |
408 | last_breakpoint_address:=b.loc^.address | |
409 | @@ -2472,7 +2594,11 @@ | |
410 | {$ifdef GDB_HAS_OBSERVER_NOTIFY_BREAKPOINT_CREATED} | |
411 | ||
412 | type | |
413 | +{$ifdef GDB_NOTIFY_BREAKPOINT_ARG_IS_BREAKPOINT_PTR} | |
414 | + breakpoint_created_function_type = procedure (bpp : pbreakpoint); cdecl; | |
415 | +{$else not GDB_NOTIFY_BREAKPOINT_ARG_IS_BREAKPOINT_PTR} | |
416 | breakpoint_created_function_type = procedure (bpnum : longint); cdecl; | |
417 | +{$endif not GDB_NOTIFY_BREAKPOINT_ARG_IS_BREAKPOINT_PTR} | |
418 | pobserver = pointer; | |
419 | var | |
420 | breakpoint_created_observer : pobserver = nil; | |
421 | @@ -2480,8 +2606,14 @@ | |
422 | function observer_attach_breakpoint_created(create_func : breakpoint_created_function_type) : pobserver;cdecl;external; | |
423 | procedure observer_detach_breakpoint_created(pob : pobserver);cdecl;external; | |
424 | ||
425 | -var breakpoint_chain : pbreakpoint ;cvar;external; | |
426 | ||
427 | +{$ifdef GDB_NOTIFY_BREAKPOINT_ARG_IS_BREAKPOINT_PTR} | |
428 | +procedure notify_breakpoint_created(bpp : pbreakpoint); cdecl; | |
429 | +begin | |
430 | + CreateBreakpointHook(bpp^); | |
431 | +end; | |
432 | +{$else not GDB_NOTIFY_BREAKPOINT_ARG_IS_BREAKPOINT_PTR} | |
433 | +var breakpoint_chain : pbreakpoint ;cvar;external; | |
434 | ||
435 | procedure notify_breakpoint_created(bpnum : longint);cdecl; | |
436 | var | |
437 | @@ -2499,8 +2631,16 @@ | |
438 | pb:=pb^.next; | |
439 | end; | |
440 | end; | |
441 | +{$endif not GDB_NOTIFY_BREAKPOINT_ARG_IS_BREAKPOINT_PTR} | |
442 | {$endif def GDB_HAS_OBSERVER_NOTIFY_BREAKPOINT_CREATED} | |
443 | ||
444 | +{ Avoid loading of main.o object by providing a | |
445 | + stripped down version of relocate_gdb_directory function } | |
446 | +function relocate_gdb_directory(path : pchar) : pchar; cdecl; public; | |
447 | +begin | |
448 | + relocate_gdb_directory:=path; | |
449 | +end; | |
450 | + | |
451 | {***************************************************************************** | |
452 | tgdbinterface | |
453 | *****************************************************************************} | |
454 | @@ -2529,7 +2669,7 @@ | |
455 | gdb_command('set print object on'); | |
456 | gdb_command('set print null-stop'); | |
457 | {$ifdef USE_MINGW_GDB} // maybe this also should be done for newer cygwin gdbs. | |
458 | - gdb_command('set confirm off'); | |
459 | + //gdb_command('set confirm off'); | |
460 | {$endif} | |
461 | end; | |
462 | ||
463 | @@ -2610,9 +2750,9 @@ | |
464 | var | |
465 | top_level_val : longint; | |
466 | ||
467 | -function catch_errors(func : pointer; command : pchar; from_tty,mask : longint) : longint;cdecl;external; | |
468 | +function catch_command_errors(func : pointer; command : pchar; from_tty,mask : longint) : longint;cdecl;external; | |
469 | ||
470 | -function gdbint_execute_command(command : pchar; from_tty,mask : longint) : longint;cdecl; | |
471 | +function gdbint_execute_command(command : pchar; from_tty : longint) : longint;cdecl; | |
472 | begin | |
473 | gdbint_execute_command:=1; | |
474 | execute_command(command,from_tty); | |
475 | @@ -2659,6 +2799,8 @@ | |
476 | begin | |
477 | {$ifdef cpui386} | |
478 | MaskAllFPUExceptions := control or MaskAllExceptions; | |
479 | +{$else} | |
480 | + MaskAllFPUExceptions:=0; | |
481 | {$endif} | |
482 | end; | |
483 | ||
484 | @@ -2717,7 +2859,8 @@ | |
485 | begin | |
486 | quit_return:=error_return; | |
487 | mask:=longint($ffffffff); | |
488 | - catch_errors(@gdbint_execute_command,@command,0,mask); | |
489 | + catch_command_errors(@gdbint_execute_command,@command, | |
490 | + 1,mask); | |
491 | {$ifdef go32v2} | |
492 | reload_fs; | |
493 | {$endif go32v2} | |
494 | @@ -2974,11 +3117,43 @@ | |
495 | c_environ : ppchar;external name '_environ'; | |
496 | c_argc : longint;external name '___crt0_argc'; | |
497 | c_argv : ppchar;external name '___crt0_argv'; | |
498 | + | |
499 | + procedure ReallocateEnvironUsingCMalloc; | |
500 | + | |
501 | + var | |
502 | + neededsize , count : longint; | |
503 | + penv : pchar; | |
504 | + newenv : ppchar; | |
505 | + begin | |
506 | + if not assigned(c_environ) then | |
507 | + neededsize:=0 | |
508 | + else | |
509 | + begin | |
510 | + count:=0; | |
511 | + penv:=c_environ^; | |
512 | + while assigned(penv) do | |
513 | + begin | |
514 | + inc(count); | |
515 | + inc(penv,sizeof(pchar)); | |
516 | + end; | |
517 | + neededsize:=count*sizeof(pchar); | |
518 | + end; | |
519 | + newenv:=malloc(neededsize); | |
520 | + system.move(c_environ,newenv,neededsize); | |
521 | + c_environ:=newenv; | |
522 | + end; | |
523 | + | |
524 | {$endif def go32v2} | |
525 | var | |
526 | current_directory : pchar; cvar; external; | |
527 | gdb_dirbuf : array[0..0] of char; cvar; external; | |
528 | CurrentDir : AnsiString; | |
529 | +{$ifdef GDB_NEEDS_INTERPRETER_SETUP} | |
530 | + type | |
531 | + interpreter_struct_p = pointer; { to opaque type } | |
532 | + function interp_lookup (name : pchar) : interpreter_struct_p;cdecl; external; | |
533 | + function interp_set (interp : interpreter_struct_p) : longbool;cdecl; external; | |
534 | +{$endif GDB_NEEDS_INTERPRETER_SETUP} | |
535 | const | |
536 | DIRBUF_SIZE = 1024; | |
537 | ||
538 | @@ -2987,13 +3162,28 @@ | |
539 | var | |
540 | OldSigInt : SignalHandler; | |
541 | {$endif supportexceptions} | |
542 | +{$ifdef GDB_NEEDS_SET_INSTREAM} | |
543 | +var | |
544 | + dummy_file : pui_file; | |
545 | +{$endif GDB_NEEDS_SET_INSTREAM} | |
546 | + | |
547 | {$ifdef GDB_INIT_HAS_ARGV0} | |
548 | var | |
549 | argv0 : pchar; | |
550 | {$endif not GDB_INIT_HAS_ARGV0} | |
551 | +{$ifdef GDB_NEEDS_INTERPRETER_SETUP} | |
552 | +var | |
553 | + interp : interpreter_struct_p; | |
554 | +{$endif GDB_NEEDS_INTERPRETER_SETUP} | |
555 | +var | |
556 | + save_gdb_stdin, | |
557 | + save_gdb_stdout, | |
558 | + save_gdb_stderr : pui_file; | |
559 | begin | |
560 | {$ifdef go32v2} | |
561 | - c_environ:=system.envp; | |
562 | + { c_environ:=system.envp; } | |
563 | + { DJGPP libC presupposes the c_enivron was malloc'ated } | |
564 | + ReallocateEnvironUsingCMalloc; | |
565 | c_argc:=system.argc; | |
566 | c_argv:=system.argv; | |
567 | {$endif def go32v2} | |
568 | @@ -3013,8 +3203,25 @@ | |
569 | ui_file_delete(gdb_stderr); | |
570 | if assigned(gdb_stdout) then | |
571 | ui_file_delete(gdb_stdout); | |
572 | +{$ifdef GDB_NEEDS_SET_INSTREAM} | |
573 | + if assigned(gdb_stdin) then | |
574 | + ui_file_delete(gdb_stdin); | |
575 | + gdb_stdin:=mem_fileopen; | |
576 | + save_gdb_stdin:=gdb_stdin; | |
577 | + dummy_file :=gdb_fopen('dummy.$$$','a'); | |
578 | + {in captured_main code, this is simply | |
579 | + instream:=stdin; but stdin is a highly system dependent macro | |
580 | + so that we try to avoid it here } | |
581 | + if assigned(dummy_file) then | |
582 | + instream:=pstdio_file(dummy_file^.to_data)^._file | |
583 | + else | |
584 | + instream:=nil; | |
585 | +{$endif GDB_NEEDS_SET_INSTREAM} | |
586 | + | |
587 | gdb_stderr:=mem_fileopen; | |
588 | gdb_stdout:=mem_fileopen; | |
589 | + save_gdb_stderr:=gdb_stderr; | |
590 | + save_gdb_stdout:=gdb_stdout; | |
591 | gdb_stdlog:=gdb_stderr; | |
592 | gdb_stdtarg:=gdb_stderr; | |
593 | set_ui_file_write(gdb_stdout,@gdbint_ui_file_write); | |
594 | @@ -3023,7 +3230,9 @@ | |
595 | error_init; | |
596 | {$endif GDB_NEEDS_NO_ERROR_INIT} | |
597 | {$ifdef GDB_V6} | |
598 | -// gdb_stdtargin := gdb_stdin; | |
599 | +{$ifdef GDB_NEEDS_SET_INSTREAM} | |
600 | + gdb_stdtargin := gdb_stdin; | |
601 | +{$endif GDB_NEEDS_SET_INSTREAM} | |
602 | gdb_stdtargerr := gdb_stderr; | |
603 | {$endif} | |
604 | GetDir(0, CurrentDir); | |
605 | @@ -3035,8 +3244,10 @@ | |
606 | next_exit:=exitproc; | |
607 | exitproc:=@DoneLibGDB; | |
608 | {$ifdef GDB_V6} | |
609 | +{$ifndef GDB_NO_UIOUT} | |
610 | uiout := cli_out_new (gdb_stdout); | |
611 | -{$endif} | |
612 | +{$endif not GDB_NO_UIOUT} | |
613 | +{$endif GDB_V6} | |
614 | {$ifdef GDB_INIT_HAS_ARGV0} | |
615 | getmem(argv0,length(paramstr(0))+1); | |
616 | strpcopy(argv0,paramstr(0)); | |
617 | @@ -3045,6 +3256,31 @@ | |
618 | {$else not GDB_INIT_HAS_ARGV0} | |
619 | gdb_init; | |
620 | {$endif not GDB_INIT_HAS_ARGV0} | |
621 | +{$ifdef GDB_NEEDS_INTERPRETER_SETUP} | |
622 | + { interpreter can only be set after all files are | |
623 | + initialized, which is done in gdb_init function. } | |
624 | + interp := interp_lookup ('console'); | |
625 | + interp_set (interp); | |
626 | + | |
627 | + { We need to re-set gdb_stdXX ui_files } | |
628 | + if assigned(gdb_stderr) then | |
629 | + ui_file_delete(gdb_stderr); | |
630 | + if assigned(gdb_stdout) then | |
631 | + ui_file_delete(gdb_stdout); | |
632 | + if assigned(gdb_stdin) then | |
633 | + ui_file_delete(gdb_stdin); | |
634 | + gdb_stdin:=save_gdb_stdin; | |
635 | + gdb_stderr:=save_gdb_stderr; | |
636 | + gdb_stdout:=save_gdb_stdout; | |
637 | + gdb_stdlog:=gdb_stderr; | |
638 | + gdb_stdtarg:=gdb_stderr; | |
639 | + set_ui_file_write(gdb_stdout,@gdbint_ui_file_write); | |
640 | + set_ui_file_write(gdb_stderr,@gdbint_ui_file_write); | |
641 | +{$ifdef GDB_NO_UIOUT} | |
642 | + cli_uiout := cli_out_new (gdb_stdout); | |
643 | + current_uiout:=cli_uiout; | |
644 | +{$endif GDB_NO_UIOUT} | |
645 | +{$endif GDB_NEEDS_INTERPRETER_SETUP} | |
646 | {$ifdef supportexceptions} | |
647 | {$ifdef unix} | |
648 | fpsignal(SIGINT,OldSigInt); | |
649 | @@ -3070,14 +3306,34 @@ | |
650 | end; | |
651 | ||
652 | {$ifdef GDB_HAS_SYSROOT} | |
653 | -var gdb_sysroot : pchar; cvar;public; | |
654 | + { Here we declare as cvar;public; a bunch of global | |
655 | + variables that are defined in main.c source. | |
656 | + We must not load main.o otherwise, we will get | |
657 | + into multiply defined symbols troubles. } | |
658 | +var | |
659 | + gdb_sysrootc : char; | |
660 | + { used locally only to provide a pchar pointing to '\0' } | |
661 | + gdb_sysroot : pchar; cvar;public; | |
662 | + { gdb_sysroot global variable is declared in defs.h and | |
663 | + instanciated in main.c since version 6.0 } | |
664 | gdb_datadir : pchar; cvar;public; | |
665 | + { gdb_datadir global variable is declared in defs.h and | |
666 | + instanciated in main.c since version 7.0 } | |
667 | python_libdir : pchar;cvar;public; | |
668 | - gdb_sysrootc : char; | |
669 | + { python_libdir global variable is declared in defs.h and instanciated | |
670 | + in main.c since version 7.2 } | |
671 | return_child_result : longbool;cvar;public; | |
672 | + { return_chlid_result global variable is declared in main.h and | |
673 | + instanciated in main.c since version 6.4 } | |
674 | return_child_result_value : longint;cvar;public; | |
675 | + { return_child_result_value global variable is declared in main.h and | |
676 | + instanciated in main.c since version 6.4 with a startup value of -1 } | |
677 | batch_silent : longbool;cvar;public; | |
678 | + { batch_silent global variable is declared in main.h since 7.0, but | |
679 | + instanciated in main.c since version 6.4 } | |
680 | batch_flag : longbool;cvar;public; | |
681 | + { batch_flag global variable is declared in main.h and | |
682 | + instanciated in main.c since version 7.2 } | |
683 | {$endif} | |
684 | {$ifdef GDB_HAS_DEBUG_FILE_DIRECTORY} | |
685 | var | |
686 | @@ -3087,6 +3343,7 @@ | |
687 | begin | |
688 | {$ifdef GDB_HAS_SYSROOT} | |
689 | gdb_sysrootc := #0; | |
690 | + return_child_result_value := -1; | |
691 | gdb_sysroot := @gdb_sysrootc; | |
692 | gdb_datadir := @gdb_sysrootc; | |
693 | python_libdir := @gdb_sysrootc; |