--- fpcbuild-2.6.4/fpcsrc/packages/gdbint/src/gdbint.pp.orig 2013-08-07 20:58:05.756050489 +0200 +++ fpcbuild-2.6.4/fpcsrc/packages/gdbint/src/gdbint.pp 2013-08-07 21:09:31.746021701 +0200 @@ -14,6 +14,7 @@ unit GdbInt; {$mode objfpc} +{$smartlink off} {$define NotImplemented} @@ -39,83 +40,94 @@ interface -{$smartlink off} { Is create_breakpoint_hook deprecated? } { Seem not so for 6.1 } {$define GDB_HAS_DEPRECATED_CBPH} -{ 6.1.x } -{$ifdef GDB_V601} - {$info using gdb 6.1.x} - {$define GDB_V6} - {$undef GDB_HAS_DEPRECATED_CBPH} -{$endif def GDB_V601} -{ 6.2.x } -{$ifdef GDB_V602} - {$info using gdb 6.2.x} - {$define GDB_V6} -{$endif def GDB_V602} +{ + Excatly one + GDB_VXYZ macro + where XYZ are three numbers + needs to defined + either inside gdblib.inc or gdbver.inc + This corresponds to version + X.YZ.patch_level +} -{ 6.3.x } -{$ifdef GDB_V603} - {$info using gdb 6.3.x} - {$define GDB_V6} -{$endif def GDB_V603} +{$undef GDB_VERSION_RECOGNIZED} -{ 6.4.x } -{$ifdef GDB_V604} - {$info using gdb 6.4.x} - {$define GDB_V6} - {$define GDB_NEEDS_NO_ERROR_INIT} -{$endif def GDB_V604} +{ 7.9.x } +{$ifdef GDB_V709} + {$info using gdb 7.9.x} + {$define GDB_VERSION_RECOGNIZED} + {$define GDB_VER_GE_709} +{$endif} -{ 6.5.x } -{$ifdef GDB_V605} - {$info using gdb 6.5.x} - {$define GDB_V6} - {$define GDB_NEEDS_NO_ERROR_INIT} -{$endif def GDB_V605} +{$ifdef GDB_VER_GE_709} + {$define GDB_VER_GE_708} +{$endif} -{ 6.6.x } -{$ifdef GDB_V606} - {$info using gdb 6.6.x} - {$define GDB_V6} - {$define GDB_USES_BP_LOCATION} - {$define GDB_NEEDS_NO_ERROR_INIT} - {$define GDB_USES_EXPAT_LIB} - {$define GDB_HAS_DEBUG_FILE_DIRECTORY} -{$endif def GDB_V606} +{ 7.8.x } +{$ifdef GDB_V708} + {$info using gdb 7.8.x} + {$define GDB_VERSION_RECOGNIZED} + {$define GDB_VER_GE_708} +{$endif} -{ 6.7.x } -{$ifdef GDB_V607} - {$info using gdb 6.7.x} - {$define GDB_V6} - {$define GDB_USES_BP_LOCATION} - {$define GDB_NEEDS_NO_ERROR_INIT} - {$define GDB_USES_EXPAT_LIB} - {$define GDB_HAS_DEBUG_FILE_DIRECTORY} -{$endif def GDB_V607} +{$ifdef GDB_VER_GE_708} + {$define USE_CATCH_EXCEPTIONS} + {$define USE_LOCAL_SET_GDB_DATA_DIRECTORY} + {$define GDB_VER_GE_707} +{$endif} -{ 6.8.x } -{$ifdef GDB_V608} - {$info using gdb 6.8.x} - {$define GDB_V6} - {$define GDB_USES_BP_LOCATION} - {$define GDB_BP_LOCATION_HAS_GLOBAL_NEXT} - {$define GDB_NEEDS_NO_ERROR_INIT} - {$define GDB_USES_EXPAT_LIB} - {$define GDB_HAS_DEBUG_FILE_DIRECTORY} - {$define GDB_USES_LIBDECNUMBER} - // {$define GDB_HAS_OBSERVER_NOTIFY_BREAKPOINT_CREATED} - {$define GDB_HAS_BP_NONE} -{$endif def GDB_V608} +{ 7.7.x } +{$ifdef GDB_V707} + {$info using gdb 7.7.x} + {$define GDB_VERSION_RECOGNIZED} + {$define GDB_VER_GE_707} +{$endif} + +{$ifdef GDB_VER_GE_707} + {$define GDB_VER_GE_706} +{$endif} + +{ 7.6.x } +{$ifdef GDB_V706} + {$info using gdb 7.6.x} + {$define GDB_VERSION_RECOGNIZED} + {$define GDB_VER_GE_706} +{$endif} + +{$ifdef GDB_VER_GE_706} + {$define GDB_UI_FILE_HAS_FSEEK} + {$define GDB_VER_GE_705} +{$endif} + +{ 7.5.x } +{$ifdef GDB_V705} + {$info using gdb 7.5.x} + {$define GDB_VERSION_RECOGNIZED} + {$define GDB_VER_GE_705} +{$endif} + +{$ifdef GDB_VER_GE_705} + {$define GDB_VER_GE_704} + {$define GDB_BP_LOCATION_HAS_COND_BYTECODE} + {$define GDB_BP_LOCATION_HAS_RELATED_ADDRESS} + {$define GDB_BP_HAS_ENABLE_COUNT} +{$endif} { 7.4.x } {$ifdef GDB_V704} {$info using gdb 7.4.x} + {$define GDB_VERSION_RECOGNIZED} + {$define GDB_VER_GE_704} +{$endif} + +{$ifdef GDB_VER_GE_704} {$define GDB_V7} {$define GDB_BP_LOCATION_HAS_GDBARCH} {$define GDB_HAS_PROGRAM_SPACE} @@ -131,11 +143,12 @@ {$ifdef win32} {$define GDB_USES_LIBADVAPI32} {$endif win32} -{$endif def GDB_V704} +{$endif def GDB_VER_GE_704} { 7.3.x } {$ifdef GDB_V703} {$info using gdb 7.3.x} + {$define GDB_VERSION_RECOGNIZED} {$define GDB_V7} {$define GDB_BP_LOCATION_HAS_GDBARCH} {$define GDB_HAS_PROGRAM_SPACE} @@ -150,11 +163,13 @@ {$define GDB_BP_LOCATION_HAS_OPS} {$define GDB_UI_FILE_HAS_WRITE_ASYNC} {$endif GDB_CVS} + {$define GDB_VERSION_RECOGNIZED} {$endif def GDB_V703} { 7.2.x } {$ifdef GDB_V702} {$info using gdb 7.2.x} + {$define GDB_VERSION_RECOGNIZED} {$define GDB_V7} {$define GDB_BP_LOCATION_HAS_GDBARCH} {$define GDB_HAS_PROGRAM_SPACE} @@ -163,6 +178,7 @@ { 7.1.x } {$ifdef GDB_V701} {$info using gdb 7.1.x} + {$define GDB_VERSION_RECOGNIZED} {$define GDB_V7} {$define GDB_BP_LOCATION_HAS_GDBARCH} {$define GDB_HAS_PROGRAM_SPACE} @@ -173,6 +189,7 @@ { 7.0.x } {$ifdef GDB_V700} {$info using gdb 7.0.x} + {$define GDB_VERSION_RECOGNIZED} {$define GDB_V7} {$ifdef GDB_CVS} {$define GDB_BP_LOCATION_HAS_GDBARCH} @@ -197,9 +214,92 @@ {$define GDB_HAS_OBSERVER_NOTIFY_BREAKPOINT_CREATED} {$define GDB_TARGET_CLOSE_HAS_PTARGET_ARG} {$define GDB_HAS_BP_NONE} + {$define GDB_USE_XSTRVPRINTF} {$endif def GDB_V7} +{ 6.8.x } +{$ifdef GDB_V608} + {$info using gdb 6.8.x} + {$define GDB_VERSION_RECOGNIZED} + {$define GDB_V6} + {$define GDB_USES_BP_LOCATION} + {$define GDB_BP_LOCATION_HAS_GLOBAL_NEXT} + {$define GDB_NEEDS_NO_ERROR_INIT} + {$define GDB_USES_EXPAT_LIB} + {$define GDB_HAS_DEBUG_FILE_DIRECTORY} + {$define GDB_USES_LIBDECNUMBER} + // {$define GDB_HAS_OBSERVER_NOTIFY_BREAKPOINT_CREATED} + {$define GDB_HAS_BP_NONE} +{$endif def GDB_V608} + +{ 6.7.x } +{$ifdef GDB_V607} + {$info using gdb 6.7.x} + {$define GDB_VERSION_RECOGNIZED} + {$define GDB_V6} + {$define GDB_USES_BP_LOCATION} + {$define GDB_NEEDS_NO_ERROR_INIT} + {$define GDB_USES_EXPAT_LIB} + {$define GDB_HAS_DEBUG_FILE_DIRECTORY} +{$endif def GDB_V607} + +{ 6.6.x } +{$ifdef GDB_V606} + {$info using gdb 6.6.x} + {$define GDB_VERSION_RECOGNIZED} + {$define GDB_V6} + {$define GDB_USES_BP_LOCATION} + {$define GDB_NEEDS_NO_ERROR_INIT} + {$define GDB_USES_EXPAT_LIB} + {Official 6.6 release doesn't have GDB_HAS_DEBUG_FILE_DIRECTORY} +{$endif def GDB_V606} + +{ 6.5.x } +{$ifdef GDB_V605} + {$info using gdb 6.5.x} + {$define GDB_VERSION_RECOGNIZED} + {$define GDB_V6} + {$define GDB_NEEDS_NO_ERROR_INIT} +{$endif def GDB_V605} + +{ 6.4.x } +{$ifdef GDB_V604} + {$info using gdb 6.4.x} + {$define GDB_VERSION_RECOGNIZED} + {$define GDB_V6} + {$define GDB_NEEDS_NO_ERROR_INIT} +{$endif def GDB_V604} + +{ 6.3.x } +{$ifdef GDB_V603} + {$info using gdb 6.3.x} + {$define GDB_VERSION_RECOGNIZED} + {$define GDB_V6} +{$endif def GDB_V603} + +{ 6.2.x } +{$ifdef GDB_V602} + {$info using gdb 6.2.x} + {$define GDB_VERSION_RECOGNIZED} + {$define GDB_V6} +{$endif def GDB_V602} + +{ 6.1.x } +{$ifdef GDB_V601} + {$info using gdb 6.1.x} + {$define GDB_VERSION_RECOGNIZED} + {$define GDB_V6} + {$undef GDB_HAS_DEPRECATED_CBPH} +{$endif def GDB_V601} + +{ 6.0.x } +{$ifdef GDB_V600} + {$info using gdb 6.0.x} + {$define GDB_VERSION_RECOGNIZED} + {$define GDB_V6} +{$endif def GDB_V600} + {$ifdef GDB_V6} {$define GDB_HAS_SYSROOT} {$define GDB_HAS_DB_COMMANDS} @@ -207,6 +307,10 @@ {$define GDB_INIT_HAS_ARGV0} {$endif GDB_V6} +{$ifdef GDB_VERSION_RECOGNIZED} + {$warning no recognized GDB_VXYZ conditional found, linking might fail. } +{$endif} + {$ifdef GDB_HAS_OBSERVER_NOTIFY_BREAKPOINT_CREATED} {$define DO_NOT_USE_CBPH} @@ -426,9 +530,9 @@ {$ifdef NotImplemented} {$undef NotImplemented} {$LINKLIB libgdb.a} - {$ifdef GDB_HAS_SIM} - {$LINKLIB libsim.a} - {$endif GDB_HAS_SIM} + {$ifdef GDB_HAS_SIM} + {$LINKLIB libsim.a} + {$endif GDB_HAS_SIM} {$LINKLIB libbfd.a} {$LINKLIB libreadline.a} {$LINKLIB libopcodes.a} @@ -552,6 +656,11 @@ {$LINKLIB gcc} {$endif beos} +{$ifdef aix} + { AIX linker requires more precise external/public separation } + {$define NEED_EXTERNAL_CVAR} + {$undef NotImplemented} +{$endif aix} {$ifdef go32v2} {$define supportexceptions} @@ -631,6 +740,9 @@ {$ifdef GDB_V6} ui_file_read_ftype = function (stream : pui_file; buffer : pchar; len : longint):longint;cdecl; {$endif} + {$ifdef GDB_UI_FILE_HAS_FSEEK} + ui_file_fseek_ftype = function (stream : pui_file; offset : longint{clong}; whence : longint {cint}) : longint{cint};cdecl; + {$endif GDB_UI_FILE_HAS_FSEEK} ui_file = record magic : plongint; @@ -647,6 +759,9 @@ to_isatty : ui_file_isatty_ftype; to_rewind : ui_file_rewind_ftype; to_put : ui_file_put_ftype; + {$ifdef GDB_UI_FILE_HAS_FSEEK} + to_fseek : ui_file_fseek_ftype; + {$endif GDB_UI_FILE_HAS_FSEEK} to_data : pointer; end; @@ -822,6 +937,8 @@ var cli_uiout : ui_out;cvar;external; current_uiout : ui_out;cvar;external; + { out local copy for catch_exceptions call } + our_uiout : ui_out; {$endif GDB_NO_UIOUT} function cli_out_new (stream : pui_file):ui_out;cdecl;external; {$endif GDB_V6} @@ -960,7 +1077,7 @@ pprogram_space = pointer; pgdbarch = pointer; -{$PACKRECORDS 4} +{$PACKRECORDS C} pbreakpoint = ^breakpoint; breakpoint = record {$ifdef GDB_USES_BP_OPS} @@ -984,8 +1101,10 @@ {$ifdef GDB_USES_BP_OPS} display_canonical: byte; {$endif GDB_USES_BP_OPS} - ignore_count : longint; +{$ifdef GDB_BP_HAS_ENABLE_COUNT} + enable_count : longint; +{$endif GDB_BP_HAS_ENABLE_COUNT} {$ifndef GDB_USES_BP_LOCATION} shadow_contents : array[0..15] of char; inserted : char; @@ -1021,6 +1140,9 @@ section : pointer; {^asection} end; + pagent_expr = pointer; + tcondition_status = (condition_unchanged, condition_modified); + bp_target_info = record placed_address_space : pointer;{paddress_space;} placed_address : CORE_ADDR; @@ -1049,6 +1171,12 @@ owner : pbreakpoint; {$ifdef GDB_BP_LOCATION_HAS_GLOBAL_NEXT} cond : pointer;{pexpression;} +{$ifdef GDB_BP_LOCATION_HAS_COND_BYTECODE} + cond_bytecode : pagent_expr; + condition_changed : tcondition_status; + cmd_bytecode : pagent_expr; + needs_update : byte; +{$endif} shlib_disabled : byte; enabled : byte; {$endif GDB_BP_LOCATION_HAS_GLOBAL_NEXT} @@ -1067,6 +1195,10 @@ {$endif GDB_BP_LOCATION_HAS_GLOBAL_NEXT} section : pointer;{pobj_section;} requested_address : CORE_ADDR; +{$ifdef GDB_BP_LOCATION_HAS_RELATED_ADDRESS} + related_address : CORE_ADDR; + probe : pointer; { struct probe *probe; } +{$endif} {$ifdef GDB_BP_LOCATION_HAS_GLOBAL_NEXT} function_name : ^char; {$endif GDB_BP_LOCATION_HAS_GLOBAL_NEXT} @@ -1121,6 +1253,10 @@ avoid stack memory corruption PM } explicit_pc : longint; explicit_line : longint; + { New field added in GDB 7.5 version } + probe : pointer;{struct probe *probe; } + { New field added in GDB 7.8? version } + objfile : pointer; { struct objfile * } end; symtabs_and_lines = record @@ -1566,7 +1702,7 @@ to_magic : longint; end; -{$PACKRECORDS NORMAL} +{$PACKRECORDS C} {***************************************************************************** Define external calls to libgdb.a @@ -1576,7 +1712,8 @@ { external variables } error_return : jmp_buf;cvar;public; quit_return : jmp_buf;cvar;public; - deprecated_query_hook : pointer;cvar;public; + deprecated_query_hook : pointer;cvar; +{$ifdef NEED_EXTERNAL_CVAR}external;{$else}public;{$endif} {$ifndef GDB_HAS_OBSERVER_NOTIFY_BREAKPOINT_CREATED} {$ifdef GDB_HAS_DEPRECATED_CBPH} @@ -1615,9 +1752,17 @@ var instream : P_C_FILE;cvar;external; function gdb_fopen (filename : pchar; mode : pchar) : pui_file;cdecl;external; +{$ifdef LIBGDB_HAS_GET_STDIN} + { this function is generated by the gen-libgdb-inc.sh script + in a object called gdb_get_stdin.o added to the libgdb.a archive } + function gdb_get_stdin : P_C_FILE; cdecl; external; +var + saved_command_line : pchar;cvar;external; { defined in top.c source } + saved_command_line_size : longint;cvar;external; {defined in top.c source } +{$endif} {$endif GDB_NEEDS_SET_INSTREAM} var - { The four following variables are defined in defs.h + { The four following variables are defined in defs.h and instanciated in main.c since version 5.0 } gdb_stdout : pui_file;cvar;public; gdb_stderr : pui_file;cvar;public; @@ -1639,7 +1784,11 @@ { xvasprintf is present at least from GDB 5.3 while xstrvprintf only appears in version 6.2, so only use xvasprintf function } +{$ifdef GDB_USE_XSTRVPRINTF} +function xstrvprintf(msg : pchar) : pchar; varargs; cdecl; external; +{$else} function xvasprintf(ret : ppchar; msg : pchar) : pchar; varargs; cdecl; external; +{$endif} procedure xfree(p : pointer); cdecl; external; function find_pc_line(i:CORE_ADDR;l:longint):symtab_and_line;cdecl;external; function find_pc_function(i:CORE_ADDR):psymbol;cdecl;external; @@ -2021,6 +2170,13 @@ stop_breakpoint_number:=num; end; +procedure annotate_breakpoints_changed;cdecl;public; +begin +{$ifdef Verbose} + Debug('|breakpoints_changed|'); +{$endif} +end; + procedure annotate_watchpoint(num:longint);cdecl;public; begin @@ -2358,6 +2514,14 @@ {$endif} end; +procedure annotate_display_prompt;cdecl;public; +begin +{$ifdef Verbose} + Debug('|display_prompt|'); +{$endif} +end; + + procedure annotate_display_begin;cdecl;public; begin {$ifdef Verbose} @@ -2527,7 +2691,11 @@ QueryHook:=1 else if pos('%',question)>0 then begin +{$ifdef GDB_USE_XSTRVPRINTF} + local:=xstrvprintf(question,arg); +{$else} xvasprintf(@local,question,arg); +{$endif} { xvasprintf can failed, in that case local is set to nil } if not assigned(local) then local:=question; @@ -2752,6 +2920,16 @@ var top_level_val : longint; +{$ifdef USE_CATCH_EXCEPTIONS} +function catch_exceptions(uiout : ui_out; func : pointer; command : pchar; mask : longint) : longint;cdecl;external; + +function gdbint_execute_command(uiout : ui_out; command : pchar) : longint;cdecl; +begin + gdbint_execute_command:=1; + execute_command(command,1); + gdbint_execute_command:=0; +end; +{$else not USE_CATCH_EXCEPTIONS} function catch_command_errors(func : pointer; command : pchar; from_tty,mask : longint) : longint;cdecl;external; function gdbint_execute_command(command : pchar; from_tty : longint) : longint;cdecl; @@ -2760,6 +2938,7 @@ execute_command(command,from_tty); gdbint_execute_command:=0; end; +{$endif not USE_CATCH_EXCEPTIONS} {$ifdef cpui386} type @@ -2861,8 +3040,12 @@ begin quit_return:=error_return; mask:=longint($ffffffff); +{$ifdef USE_CATCH_EXCEPTIONS} + catch_exceptions(our_uiout, @gdbint_execute_command,@command,mask); +{$else i.e. not USE_CATCH_EXCEPTIONS} catch_command_errors(@gdbint_execute_command,@command, 1,mask); +{$endif not def USE_CATCH_EXCEPTIONS} {$ifdef go32v2} reload_fs; {$endif go32v2} @@ -3226,6 +3409,10 @@ ui_file_delete(gdb_stdin); gdb_stdin:=mem_fileopen; save_gdb_stdin:=gdb_stdin; +{$ifdef LIBGDB_HAS_GET_STDIN} + instream:=gdb_get_stdin; + saved_command_line:=xmalloc(saved_command_line_size); +{$else} dummy_file :=gdb_fopen('dummy.$$$','a'); {in captured_main code, this is simply instream:=stdin; but stdin is a highly system dependent macro @@ -3234,6 +3421,7 @@ instream:=pstdio_file(dummy_file^.to_data)^._file else instream:=nil; +{$endif} {$endif GDB_NEEDS_SET_INSTREAM} gdb_stderr:=mem_fileopen; @@ -3297,6 +3485,7 @@ {$ifdef GDB_NO_UIOUT} cli_uiout := cli_out_new (gdb_stdout); current_uiout:=cli_uiout; + our_uiout:=cli_uiout; {$endif GDB_NO_UIOUT} {$endif GDB_NEEDS_INTERPRETER_SETUP} {$ifdef supportexceptions} @@ -3328,10 +3517,10 @@ variables that are defined in main.c source. We must not load main.o otherwise, we will get into multiply defined symbols troubles. } -var +var gdb_sysrootc : char; { used locally only to provide a pchar pointing to '\0' } - gdb_sysroot : pchar; cvar;public; + gdb_sysroot : pchar; cvar;public; { gdb_sysroot global variable is declared in defs.h and instanciated in main.c since version 6.0 } gdb_datadir : pchar; cvar;public; @@ -3358,6 +3547,15 @@ debug_file_directory : pchar; cvar; external; {$endif GDB_HAS_DEBUG_FILE_DIRECTORY} +{$ifdef USE_LOCAL_SET_GDB_DATA_DIRECTORY} +{ Avoid loading of main.o object by providing a + stripped down version of relocate_gdb_directory function } +procedure set_gdb_data_directory(path : pchar); cdecl; public; +begin + gdb_datadir:=path; +end; +{$endif USE_LOCAL_SET_GDB_DATA_DIRECTORY} + begin {$ifdef GDB_HAS_SYSROOT} gdb_sysrootc := #0;