1{ 2 Copyright (c) 1998 by Peter Vreman 3 4 Lowlevel GDB interface which communicates directly with libgdb 5 6 See the file COPYING.FPC, included in this distribution, 7 for details about the copyright. 8 9 This program is distributed in the hope that it will be useful, 10 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 13 **********************************************************************} 14unit GdbInt; 15 16{$mode objfpc} 17{$smartlink off} 18 19{$define NotImplemented} 20 21{$define COMPILING_GDBINT_UNIT} 22{$ifdef USE_GDBLIBINC} 23 {$i gdblib.inc} 24{$else not USE_GDBLIBINC} 25 {$i gdbver.inc} 26{$endif not USE_GDBLIBINC} 27 28{ Possible optional conditionals: 29 GDB_DISABLE_INTL To explicitly not use libintl 30 31 GDB_DISABLE_PYTHON To explicitly not use libpython, 32 if gdb was configured using --without-python 33 34 GDB_CORE_ADDR_FORCE_64BITS To force 64 bits for CORE_ADDR 35 36 Verbose To test gdbint 37 38 DebugCommand To debug Command method 39} 40 41interface 42 43 44 45{ Is create_breakpoint_hook deprecated? } 46{ Seem not so for 6.1 } 47{$define GDB_HAS_DEPRECATED_CBPH} 48 49 50{ 51 Excatly one 52 GDB_VXYZ macro 53 where XYZ are three numbers 54 needs to defined 55 either inside gdblib.inc or gdbver.inc 56 This corresponds to version 57 X.YZ.patch_level 58} 59 60{$undef GDB_VERSION_RECOGNIZED} 61 62{ GDB 7.12 is the last version 63 that use a plain C compiler 64 Later version will not work 65 for gdbint unit unless we get a 66 working g++ mangler into Free Pascal compiler } 67 68{ 7.12.x } 69{$ifdef GDB_V712} 70 {$info using gdb 7.12.x} 71 {$define GDB_VERSION_RECOGNIZED} 72 {$define GDB_VER_GE_712} 73 {$define GDB_NO_INSTREAM_VAR} 74 {$define GDB_CURRENT_UIOUT_MACRO} 75 {$define GDB_NEW_UI} 76{$endif} 77 78{$ifdef GDB_VER_GE_712} 79 {$define GDB_VER_GE_711} 80{$endif} 81 82{ 7.11.x } 83{$ifdef GDB_V711} 84 {$info using gdb 7.11.x} 85 {$define GDB_VERSION_RECOGNIZED} 86 {$define GDB_VER_GE_711} 87 {$define GDB_HAS_SAVED_COMMAND_LINE_SIZE} 88{$endif} 89 90{$ifdef GDB_VER_GE_711} 91 {$define GDB_VER_GE_710} 92{$endif} 93 94{ 7.10.x } 95{$ifdef GDB_V710} 96 {$info using gdb 7.10.x} 97 {$define GDB_VERSION_RECOGNIZED} 98 {$define GDB_VER_GE_710} 99{$endif} 100 101{$ifdef GDB_VER_GE_710} 102 {$define GDB_VER_GE_709} 103{$endif} 104 105{ 7.9.x } 106{$ifdef GDB_V709} 107 {$info using gdb 7.9.x} 108 {$define GDB_VERSION_RECOGNIZED} 109 {$define GDB_VER_GE_709} 110{$endif} 111 112{$ifdef GDB_VER_GE_709} 113 {$define GDB_VER_GE_708} 114 {$define SYMTAB_HAS_COMPUNIT_SYMTAB} 115{$endif} 116 117{ 7.8.x } 118{$ifdef GDB_V708} 119 {$info using gdb 7.8.x} 120 {$define GDB_VERSION_RECOGNIZED} 121 {$define GDB_VER_GE_708} 122{$endif} 123 124{$ifdef GDB_VER_GE_708} 125 {$define USE_CATCH_EXCEPTIONS} 126 {$define USE_LOCAL_SET_GDB_DATA_DIRECTORY} 127 {$define GDB_VER_GE_707} 128{$endif} 129 130{ 7.7.x } 131{$ifdef GDB_V707} 132 {$info using gdb 7.7.x} 133 {$define GDB_VERSION_RECOGNIZED} 134 {$define GDB_VER_GE_707} 135{$endif} 136 137{$ifdef GDB_VER_GE_707} 138 {$define GDB_VER_GE_706} 139{$endif} 140 141{ 7.6.x } 142{$ifdef GDB_V706} 143 {$info using gdb 7.6.x} 144 {$define GDB_VERSION_RECOGNIZED} 145 {$define GDB_VER_GE_706} 146{$endif} 147 148{$ifdef GDB_VER_GE_706} 149 {$define GDB_UI_FILE_HAS_FSEEK} 150 {$define GDB_VER_GE_705} 151{$endif} 152 153{ 7.5.x } 154{$ifdef GDB_V705} 155 {$info using gdb 7.5.x} 156 {$define GDB_VERSION_RECOGNIZED} 157 {$define GDB_VER_GE_705} 158{$endif} 159 160{$ifdef GDB_VER_GE_705} 161 {$define GDB_VER_GE_704} 162 {$define GDB_BP_LOCATION_HAS_COND_BYTECODE} 163 {$define GDB_BP_LOCATION_HAS_RELATED_ADDRESS} 164 {$define GDB_BP_HAS_ENABLE_COUNT} 165{$endif} 166 167{ 7.4.x } 168{$ifdef GDB_V704} 169 {$info using gdb 7.4.x} 170 {$define GDB_VERSION_RECOGNIZED} 171 {$define GDB_VER_GE_704} 172{$endif} 173 174{$ifdef GDB_VER_GE_704} 175 {$define GDB_V7} 176 {$define GDB_BP_LOCATION_HAS_GDBARCH} 177 {$define GDB_HAS_PROGRAM_SPACE} 178 {$define GDB_NO_UIOUT} 179 {$define GDB_NEEDS_INTERPRETER_SETUP} 180 {$define GDB_NEEDS_SET_INSTREAM} 181 {$define GDB_NOTIFY_BREAKPOINT_ARG_IS_BREAKPOINT_PTR} 182 {$define GDB_USES_BP_OPS} 183 {$define GDB_BP_TI_HAS_LENGTH} 184 {$define GDB_BP_LOCATION_HAS_REFCOUNT} 185 {$define GDB_BP_LOCATION_HAS_OPS} 186 {$define GDB_UI_FILE_HAS_WRITE_ASYNC} 187 {$ifdef win32} 188 {$define GDB_USES_LIBADVAPI32} 189 {$endif win32} 190{$endif def GDB_VER_GE_704} 191 192{ 7.3.x } 193{$ifdef GDB_V703} 194 {$info using gdb 7.3.x} 195 {$define GDB_VERSION_RECOGNIZED} 196 {$define GDB_V7} 197 {$define GDB_BP_LOCATION_HAS_GDBARCH} 198 {$define GDB_HAS_PROGRAM_SPACE} 199 {$define GDB_BP_TI_HAS_LENGTH} 200 {$define GDB_BP_LOCATION_HAS_REFCOUNT} 201 {$ifdef GDB_CVS} 202 {$define GDB_NO_UIOUT} 203 {$define GDB_NEEDS_INTERPRETER_SETUP} 204 {$define GDB_NEEDS_SET_INSTREAM} 205 {$define GDB_NOTIFY_BREAKPOINT_ARG_IS_BREAKPOINT_PTR} 206 {$define GDB_USES_BP_OPS} 207 {$define GDB_BP_LOCATION_HAS_OPS} 208 {$define GDB_UI_FILE_HAS_WRITE_ASYNC} 209 {$endif GDB_CVS} 210 {$define GDB_VERSION_RECOGNIZED} 211{$endif def GDB_V703} 212 213{ 7.2.x } 214{$ifdef GDB_V702} 215 {$info using gdb 7.2.x} 216 {$define GDB_VERSION_RECOGNIZED} 217 {$define GDB_V7} 218 {$define GDB_BP_LOCATION_HAS_GDBARCH} 219 {$define GDB_HAS_PROGRAM_SPACE} 220{$endif def GDB_V702} 221 222{ 7.1.x } 223{$ifdef GDB_V701} 224 {$info using gdb 7.1.x} 225 {$define GDB_VERSION_RECOGNIZED} 226 {$define GDB_V7} 227 {$define GDB_BP_LOCATION_HAS_GDBARCH} 228 {$define GDB_HAS_PROGRAM_SPACE} 229{$endif def GDB_V701} 230 231 232 233{ 7.0.x } 234{$ifdef GDB_V700} 235 {$info using gdb 7.0.x} 236 {$define GDB_VERSION_RECOGNIZED} 237 {$define GDB_V7} 238 {$ifdef GDB_CVS} 239 {$define GDB_BP_LOCATION_HAS_GDBARCH} 240 {$define GDB_HAS_PROGRAM_SPACE} 241 {$endif GDB_CVS} 242{$endif def GDB_V700} 243 244{$ifdef GDB_V7} 245 {$define GDB_V6} 246 {$define GDB_HAS_DB_COMMANDS} 247 {$define GDB_USES_BP_LOCATION} 248 {$define GDB_BP_LOCATION_HAS_GLOBAL_NEXT} 249 {$define GDB_BP_LOCATION_HAS_GDBARCH} 250 {$define GDB_NEEDS_NO_ERROR_INIT} 251 {$define GDB_USES_EXPAT_LIB} 252 {$define GDB_USES_LIBDECNUMBER} 253 {$define GDB_USES_LIBINTL} 254 {$ifndef GDB_DISABLE_PYTHON} 255 {$define GDB_USES_LIBPYTHON} 256 {$endif} 257 {$define GDB_HAS_DEBUG_FILE_DIRECTORY} 258 {$define GDB_HAS_OBSERVER_NOTIFY_BREAKPOINT_CREATED} 259 {$define GDB_TARGET_CLOSE_HAS_PTARGET_ARG} 260 {$define GDB_HAS_BP_NONE} 261 {$define GDB_USE_XSTRVPRINTF} 262 {$define GDB_ANNOTATE_FRAME_BEGIN_HAS_GDBARCH_FIELD} 263{$endif def GDB_V7} 264 265 266{ 6.8.x } 267{$ifdef GDB_V608} 268 {$info using gdb 6.8.x} 269 {$define GDB_VERSION_RECOGNIZED} 270 {$define GDB_V6} 271 {$define GDB_USES_BP_LOCATION} 272 {$define GDB_BP_LOCATION_HAS_GLOBAL_NEXT} 273 {$define GDB_NEEDS_NO_ERROR_INIT} 274 {$define GDB_USES_EXPAT_LIB} 275 {$define GDB_HAS_DEBUG_FILE_DIRECTORY} 276 {$define GDB_USES_LIBDECNUMBER} 277 // {$define GDB_HAS_OBSERVER_NOTIFY_BREAKPOINT_CREATED} 278 {$define GDB_HAS_BP_NONE} 279{$endif def GDB_V608} 280 281{ 6.7.x } 282{$ifdef GDB_V607} 283 {$info using gdb 6.7.x} 284 {$define GDB_VERSION_RECOGNIZED} 285 {$define GDB_V6} 286 {$define GDB_USES_BP_LOCATION} 287 {$define GDB_NEEDS_NO_ERROR_INIT} 288 {$define GDB_USES_EXPAT_LIB} 289 {$define GDB_HAS_DEBUG_FILE_DIRECTORY} 290{$endif def GDB_V607} 291 292{ 6.6.x } 293{$ifdef GDB_V606} 294 {$info using gdb 6.6.x} 295 {$define GDB_VERSION_RECOGNIZED} 296 {$define GDB_V6} 297 {$define GDB_USES_BP_LOCATION} 298 {$define GDB_NEEDS_NO_ERROR_INIT} 299 {$define GDB_USES_EXPAT_LIB} 300 {Official 6.6 release doesn't have GDB_HAS_DEBUG_FILE_DIRECTORY} 301{$endif def GDB_V606} 302 303{ 6.5.x } 304{$ifdef GDB_V605} 305 {$info using gdb 6.5.x} 306 {$define GDB_VERSION_RECOGNIZED} 307 {$define GDB_V6} 308 {$define GDB_NEEDS_NO_ERROR_INIT} 309{$endif def GDB_V605} 310 311{ 6.4.x } 312{$ifdef GDB_V604} 313 {$info using gdb 6.4.x} 314 {$define GDB_VERSION_RECOGNIZED} 315 {$define GDB_V6} 316 {$define GDB_NEEDS_NO_ERROR_INIT} 317{$endif def GDB_V604} 318 319{ 6.3.x } 320{$ifdef GDB_V603} 321 {$info using gdb 6.3.x} 322 {$define GDB_VERSION_RECOGNIZED} 323 {$define GDB_V6} 324{$endif def GDB_V603} 325 326{ 6.2.x } 327{$ifdef GDB_V602} 328 {$info using gdb 6.2.x} 329 {$define GDB_VERSION_RECOGNIZED} 330 {$define GDB_V6} 331{$endif def GDB_V602} 332 333{ 6.1.x } 334{$ifdef GDB_V601} 335 {$info using gdb 6.1.x} 336 {$define GDB_VERSION_RECOGNIZED} 337 {$define GDB_V6} 338 {$undef GDB_HAS_DEPRECATED_CBPH} 339{$endif def GDB_V601} 340 341{ 6.0.x } 342{$ifdef GDB_V600} 343 {$info using gdb 6.0.x} 344 {$define GDB_VERSION_RECOGNIZED} 345 {$define GDB_V6} 346{$endif def GDB_V600} 347 348{$ifdef GDB_V6} 349 {$define GDB_HAS_SYSROOT} 350 {$define GDB_HAS_DB_COMMANDS} 351 {$define GDB_SYMTAB_HAS_MACROS} 352 {$define GDB_INIT_HAS_ARGV0} 353{$endif GDB_V6} 354 355{$ifndef GDB_VERSION_RECOGNIZED} 356 {$warning no recognized GDB_VXYZ conditional found, linking might fail. } 357{$endif} 358 359 360{$ifdef GDB_HAS_OBSERVER_NOTIFY_BREAKPOINT_CREATED} 361 {$define DO_NOT_USE_CBPH} 362{$endif} 363 364{ GDB has a simulator for powerpc CPU 365 it is integrated into GDB by default } 366{$ifdef cpupowerpc} 367 {$define GDB_HAS_SIM} 368{$endif cpupowerpc} 369 370{$ifdef Solaris} 371 {$ifdef Sparc} 372 { Sparc/i386 solaris gdb also supports 64bit mode, thus 373 CORE_ADDR is 8-byte long } 374 {$define GDB_CORE_ADDR_FORCE_64BITS} 375 {$endif Sparc} 376 {$ifdef i386} 377 {$define GDB_CORE_ADDR_FORCE_64BITS} 378 {$endif i386} 379{$endif Solaris} 380 381{$ifdef go32v2} 382{$ifdef NotImplemented} 383 {$undef NotImplemented} 384 {$LINKLIB gdb} 385 {$ifdef GDB_HAS_SIM} 386 {$LINKLIB sim} 387 {$endif GDB_HAS_SIM} 388 {$LINKLIB bfd} 389 {$LINKLIB readline} 390 {$LINKLIB opcodes} 391 {$LINKLIB history} 392 {$LINKLIB iberty} 393 {$ifdef GDB_USES_LIBDECNUMBER} 394 {$LINKLIB decnumber} 395 {$endif GDB_USES_LIBDECNUMBER} 396 {$ifdef GDB_USES_EXPAT_LIB} 397 {$LINKLIB expat} 398 {$endif GDB_USES_EXPAT_LIB} 399 {$ifdef GDB_USES_LIBPYTHON} 400 {$LINKLIB python} 401 {$endif GDB_USES_LIBPYTHON} 402 {$ifndef GDB_DISABLE_INTL} 403 {$LINKLIB intl} 404 {$endif ndef GDB_DISABLE_INTL} 405{$endif NotImplemented} 406 {$LINKLIB dbg} 407 {$LINKLIB c} 408{$endif go32v2} 409 410{$ifdef linux} 411{$ifdef NotImplemented} 412 {$undef NotImplemented} 413 {$LINKLIB libgdb.a} 414 {$ifdef GDB_HAS_SIM} 415 {$LINKLIB libsim.a} 416 {$endif GDB_HAS_SIM} 417 {$LINKLIB libbfd.a} 418 {$LINKLIB libreadline.a} 419 {$LINKLIB libopcodes.a} 420 {$LINKLIB libhistory.a} 421 {$LINKLIB libiberty.a} 422 {$ifdef GDB_USES_LIBDECNUMBER} 423 {$LINKLIB decnumber} 424 {$endif GDB_USES_LIBDECNUMBER} 425 {$ifdef GDB_USES_EXPAT_LIB} 426 {$LINKLIB expat} 427 {$endif GDB_USES_EXPAT_LIB} 428 {$ifdef GDB_USES_LIBPYTHON} 429 {$LINKLIB python} 430 {$endif GDB_USES_LIBPYTHON} 431 {$LINKLIB ncurses} 432{$endif NotImplemented} 433 {$LINKLIB m} 434 {$LINKLIB dl} 435 {$LINKLIB c} 436 {$LINKLIB gcc} 437{$endif linux} 438 439{$ifdef dragonfly} 440{$ifdef NotImplemented} 441 {$linklib kvm} 442 {$undef NotImplemented} 443 {$LINKLIB libgdb.a} 444 {$ifdef GDB_HAS_SIM} 445 {$LINKLIB libsim.a} 446 {$endif GDB_HAS_SIM} 447 {$LINKLIB libbfd.a} 448 {$LINKLIB libreadline.a} 449 {$LINKLIB libopcodes.a} 450 {$LINKLIB libhistory.a} 451 {$LINKLIB libiberty.a} 452 {$LINKLIB libgnu.a} 453 {$LINKLIB ncurses} 454 {$LINKLIB z} 455 {$LINKLIB m} 456 {$LINKLIB iberty} 457 {$ifndef GDB_DISABLE_INTL} 458 {$LINKLIB intl} 459 {$endif ndef GDB_DISABLE_INTL} 460 {$ifdef GDB_USES_LIBDECNUMBER} 461 {$LINKLIB decnumber} 462 {$endif GDB_USES_LIBDECNUMBER} 463 {$ifdef GDB_USES_EXPAT_LIB} 464 {$LINKLIB expat} 465 {$endif GDB_USES_EXPAT_LIB} 466 {$ifdef GDB_USES_LIBPYTHON} 467 {$LINKLIB python} 468 {$endif GDB_USES_LIBPYTHON} 469{$endif NotImplemented} 470 {$LINKLIB c} 471 {$LINKLIB gcc} 472{$endif freebsd} 473 474{$ifdef freebsd} 475{$ifdef NotImplemented} 476 {$ifdef FreeBSD5} //5.4+ ? 477 {$linklib kvm} 478 {$endif} 479 {$undef NotImplemented} 480 {$LINKLIB libgdb.a} 481 {$ifdef GDB_HAS_SIM} 482 {$LINKLIB libsim.a} 483 {$endif GDB_HAS_SIM} 484 {$LINKLIB libbfd.a} 485 {$LINKLIB libreadline.a} 486 {$LINKLIB libopcodes.a} 487 {$LINKLIB libhistory.a} 488 {$LINKLIB libiberty.a} 489 {$LINKLIB libgnu.a} // at least 7.4 generates this. 490 {$LINKLIB ncurses} 491 {$LINKLIB z} // linked implictely by something on Linux 492 {$LINKLIB m} 493 {$LINKLIB iberty} 494 {$ifndef GDB_DISABLE_INTL} 495 {$LINKLIB intl} 496 {$endif ndef GDB_DISABLE_INTL} 497 {$ifdef GDB_USES_LIBDECNUMBER} 498 {$LINKLIB decnumber} 499 {$endif GDB_USES_LIBDECNUMBER} 500 { does not seem to exist on netbsd LINKLIB dl, 501 but I use GDB CVS snapshots for the *BSDs} 502 {$ifdef GDB_USES_EXPAT_LIB} 503 {$LINKLIB expat} 504 {$endif GDB_USES_EXPAT_LIB} 505 {$ifdef GDB_USES_LIBPYTHON} 506 {$LINKLIB python} 507 {$endif GDB_USES_LIBPYTHON} 508{$endif NotImplemented} 509 {$LINKLIB c} 510 {$LINKLIB gcc} 511{$endif freebsd} 512 513{$ifdef netbsd} 514{$ifdef NotImplemented} 515 {$undef NotImplemented} 516 {$LINKLIB gdb} 517 {$ifdef GDB_HAS_SIM} 518 {$LINKLIB sim} 519 {$endif GDB_HAS_SIM} 520 {$LINKLIB bfd} 521 {$LINKLIB readline} 522 {$LINKLIB opcodes} 523 {$LINKLIB history} 524 {$LINKLIB iberty} 525 {$LINKLIB ncurses} 526 {$LINKLIB m} 527 {$LINKLIB iberty} 528 {$LINKLIB intl} 529 {$ifdef GDB_USES_LIBDECNUMBER} 530 {$LINKLIB decnumber} 531 {$endif GDB_USES_LIBDECNUMBER} 532 {$ifdef GDB_USES_EXPAT_LIB} 533 {$LINKLIB expat} 534 {$endif GDB_USES_EXPAT_LIB} 535 {$ifdef GDB_USES_LIBPYTHON} 536 {$LINKLIB python} 537 {$endif GDB_USES_LIBPYTHON} 538 { does not seem to exist on netbsd LINKLIB dl} 539{$endif NotImplemented} 540 {$LINKLIB c} 541 {$LINKLIB gcc} 542{$endif netbsd} 543 544{$ifdef solaris} 545{$ifdef NotImplemented} 546 {$undef NotImplemented} 547 {$LINKLIB gdb} 548 {$ifdef GDB_HAS_SIM} 549 {$LINKLIB sim} 550 {$endif GDB_HAS_SIM} 551 {$LINKLIB bfd} 552 {$LINKLIB readline} 553 {$LINKLIB opcodes} 554 {$LINKLIB history} 555 {$LINKLIB iberty} 556 {$LINKLIB curses} 557 {$LINKLIB m} 558 {$LINKLIB iberty} 559 {$LINKLIB intl} 560 {$ifdef GDB_USES_LIBDECNUMBER} 561 {$LINKLIB decnumber} 562 {$endif GDB_USES_LIBDECNUMBER} 563 {$ifdef GDB_USES_EXPAT_LIB} 564 {$LINKLIB expat} 565 {$endif GDB_USES_EXPAT_LIB} 566 {$ifdef GDB_USES_LIBPYTHON} 567 {$LINKLIB python} 568 {$endif GDB_USES_LIBPYTHON} 569{$endif NotImplemented} 570 {$LINKLIB dl} 571 {$LINKLIB socket} 572 {$LINKLIB nsl} 573 {$LINKLIB c} 574{$endif solaris} 575 576{$ifdef openbsd} 577{$ifdef NotImplemented} 578 {$undef NotImplemented} 579 {$LINKLIB gdb} 580 {$ifdef GDB_HAS_SIM} 581 {$LINKLIB sim} 582 {$endif GDB_HAS_SIM} 583 {$LINKLIB bfd} 584 {$LINKLIB readline} 585 {$LINKLIB opcodes} 586 {$LINKLIB history} 587 {$LINKLIB iberty} 588 {$LINKLIB ncurses} 589 {$LINKLIB m} 590 {$LINKLIB iberty} 591 {$ifndef GDB_DISABLE_INTL} 592 {$LINKLIB intl} 593 {$endif ndef GDB_DISABLE_INTL} 594 {$ifdef GDB_USES_LIBDECNUMBER} 595 {$LINKLIB decnumber} 596 {$endif GDB_USES_LIBDECNUMBER} 597 {$ifdef GDB_USES_EXPAT_LIB} 598 {$LINKLIB expat} 599 {$endif GDB_USES_EXPAT_LIB} 600 {$ifdef GDB_USES_LIBPYTHON} 601 {$LINKLIB python} 602 {$endif GDB_USES_LIBPYTHON} 603 { does not seem to exist on netbsd LINKLIB dl} 604{$endif NotImplemented} 605 {$LINKLIB c} 606 {$LINKLIB gcc} 607{$endif netbsd} 608 609{$ifdef win32} 610{$ifdef NotImplemented} 611 {$undef NotImplemented} 612 {$LINKLIB libgdb.a} 613 {$ifdef GDB_HAS_SIM} 614 {$LINKLIB libsim.a} 615 {$endif GDB_HAS_SIM} 616 {$LINKLIB libbfd.a} 617 {$LINKLIB libreadline.a} 618 {$LINKLIB libopcodes.a} 619 {$LINKLIB libhistory.a} 620 {$LINKLIB libiberty.a} 621 622 {$ifdef USE_MINGW_GDB} 623 {$LINKLIB libdecnumber.a} 624 {$ifdef GDB_USES_LIBDECNUMBER} 625 {$LINKLIB decnumber} 626 {$endif GDB_USES_LIBDECNUMBER} 627 {$ifdef GDB_USES_EXPAT_LIB} 628 {$LINKLIB expat} 629 {$endif GDB_USES_EXPAT_LIB} 630 {$ifdef GDB_USES_LIBPYTHON} 631 {$LINKLIB python} 632 {$endif GDB_USES_LIBPYTHON} 633 {$else not USE_MINGW_GDB} 634 {$LINKLIB libiconv.a} 635 {$LINKLIB libncurses.a} 636 {$ifdef GDB_USES_LIBDECNUMBER} 637 {$LINKLIB decnumber} 638 {$endif GDB_USES_LIBDECNUMBER} 639 {$ifdef GDB_USES_EXPAT_LIB} 640 {$LINKLIB expat} 641 {$endif GDB_USES_EXPAT_LIB} 642 {$ifdef GDB_USES_LIBPYTHON} 643 {$LINKLIB python} 644 {$endif GDB_USES_LIBPYTHON} 645 {$endif not USE_MINGW_GDB} 646{$endif NotImplemented} 647 {$ifdef USE_MINGW_GDB} 648 {$LINKLIB libm.a} 649 {$LINKLIB libmoldname.a} 650 {$LINKLIB libgcc.a} 651 {$LINKLIB libws2_32.a} 652 {$LINKLIB libmingwex.a} 653 {$LINKLIB libmingw32.a} 654 {$LINKLIB libmsvcrt.a} 655 {$else not USE_MINGW_GDB} 656 {$LINKLIB gcc} 657 {$LINKLIB cygwin} { alias of libm.a and libc.a } 658 {$LINKLIB libintl.a} 659 {$LINKLIB imagehlp} 660 {$endif not USE_MINGW_GDB} 661 {$ifdef GDB_USES_LIBADVAPI32} 662 {$LINKLIB advapi32} 663 {$endif GDB_USES_LIBADVAPI32} 664 {$LINKLIB user32} 665 {$LINKLIB kernel32} 666{$endif win32} 667 668{$ifdef win64} 669{$ifdef NotImplemented} 670 {$undef NotImplemented} 671 {$LINKLIB libgdb.a} 672 {$ifdef GDB_HAS_SIM} 673 {$LINKLIB libsim.a} 674 {$endif GDB_HAS_SIM} 675 {$LINKLIB libbfd.a} 676 {$LINKLIB libreadline.a} 677 {$LINKLIB libopcodes.a} 678 {$LINKLIB libhistory.a} 679 {$LINKLIB libiberty.a} 680 {$LINKLIB libintl.a} 681 682 {$LINKLIB libdecnumber.a} 683 {$ifdef GDB_USES_LIBDECNUMBER} 684 {$LINKLIB decnumber} 685 {$endif GDB_USES_LIBDECNUMBER} 686 {$ifdef GDB_USES_EXPAT_LIB} 687 {$LINKLIB expat} 688 {$endif GDB_USES_EXPAT_LIB} 689 {$ifdef GDB_USES_LIBPYTHON} 690 {$LINKLIB python} 691 {$endif GDB_USES_LIBPYTHON} 692{$endif NotImplemented} 693 {$LINKLIB libm.a} 694 {$LINKLIB libmoldname.a} 695 {$LINKLIB libws2_32.a} 696 {$LINKLIB libmingwex.a} 697 {$LINKLIB libmingw32.a} 698 {$LINKLIB libmsvcrt.a} 699 {$LINKLIB libgcc.a} 700 {$LINKLIB libws2_32.a} 701 {$LINKLIB kernel32} 702 {$LINKLIB user32} 703{$endif win64} 704 705{$ifdef beos} 706{$ifdef NotImplemented} 707 { still need some work... stollen from netbsd} 708 {$undef NotImplemented} 709 {$LINKLIB gdb} 710 {$ifdef GDB_HAS_SIM} 711 {$LINKLIB sim} 712 {$endif GDB_HAS_SIM} 713 {$LINKLIB bfd} 714 {$LINKLIB readline} 715 {$LINKLIB opcodes} 716 { $ LINKLIB history} 717 {$LINKLIB iberty} 718 {$LINKLIB ncurses} 719 { $ LINKLIB m} // include in libroot under BeOS 720 {$ifndef GDB_DISABLE_INTL} 721 {$LINKLIB intl} 722 {$endif ndef GDB_DISABLE_INTL} 723 {$ifdef GDB_USES_LIBDECNUMBER} 724 {$LINKLIB decnumber} 725 {$endif GDB_USES_LIBDECNUMBER} 726 {$ifdef GDB_USES_EXPAT_LIB} 727 {$LINKLIB expat} 728 {$endif GDB_USES_EXPAT_LIB} 729 {$ifdef GDB_USES_LIBPYTHON} 730 {$LINKLIB python} 731 {$endif GDB_USES_LIBPYTHON} 732{$endif NotImplemented} 733 { does not seem to exist on netbsd LINKLIB dl} 734 { $ LINKLIB c} // This is libroot under BeOS, and always linked 735 {$LINKLIB debug} 736 {$LINKLIB gcc} 737{$endif beos} 738 739{$ifdef aix} 740 { AIX linker requires more precise external/public separation } 741 {$define NEED_EXTERNAL_CVAR} 742 {$undef NotImplemented} 743{$endif aix} 744 745{$ifdef go32v2} 746 {$define supportexceptions} 747{$endif go32v2} 748{$ifdef unix} 749 {$define supportexceptions} 750{$endif unix} 751 752{$ifdef CROSSGDB} 753 { do we need something special if cross GDB? } 754{$endif CROSSGDB} 755 756{$ifdef NotImplemented} 757 {$fatal This OS is not yet supported !!!} 758{$endif NotImplemented} 759 760{$packrecords C} 761 762type 763{$if defined(CPUSPARC) and defined(LINUX)} 764 {$define GDB_CORE_ADDR_FORCE_64BITS} 765{$endif} 766{$ifdef GDB_CORE_ADDR_FORCE_64BITS} 767 CORE_ADDR = qword; 768{$else} 769 CORE_ADDR = ptruint; { might be target dependent PM } 770{$endif} 771 772 psyminfo=^tsyminfo; 773 tsyminfo=record 774 address : ptrint; 775 fname : pchar; 776 line : longint; 777 funcname : pchar; 778 offset : ptrint; 779 end; 780 781 tframeentry = object 782 file_name : pchar; 783 function_name : pchar; 784 args : pchar; 785 line_number : longint; 786 address : CORE_ADDR; 787 level : longint; 788 constructor init; 789 destructor done; 790 procedure reset; 791 procedure clear; 792 end; 793 pframeentry=^tframeentry; 794 ppframeentry=^pframeentry; 795 796{ needed for handles } 797{not anymore I textrec.inc} 798 799const 800 k=1; 801 802type 803 streamtype = (afile,astring); 804 C_FILE = ptrint; { at least under DJGPP } 805 P_C_FILE = ^C_FILE; 806 807type 808 809 pui_file = ^ui_file; 810 pstdio_file = ^stdio_file; 811 812 ui_file_flush_ftype = procedure(stream : pui_file);cdecl; 813 ui_file_write_ftype = procedure(stream : pui_file;buf : pchar;len : longint);cdecl; 814 ui_file_write_async_save_ftype = procedure(stream : pui_file;buf : pchar;len : longint);cdecl; 815 ui_file_fputs_ftype = procedure(buf : pchar; stream : pui_file);cdecl; 816 ui_file_delete_ftype = procedure(stream : pui_file);cdecl; 817 ui_file_isatty_ftype = function(stream : pui_file) : longbool;cdecl; 818 ui_file_rewind_ftype = procedure(stream : pui_file);cdecl; 819 ui_file_put_method_ftype = procedure(var _object; buffer : pchar;length_buffer : longint);cdecl; 820 ui_file_put_ftype = procedure(stream : pui_file;method : ui_file_put_method_ftype;var context);cdecl; 821 {$ifdef GDB_V6} 822 ui_file_read_ftype = function (stream : pui_file; buffer : pchar; len : longint):longint;cdecl; 823 {$endif} 824 {$ifdef GDB_UI_FILE_HAS_FSEEK} 825 ui_file_fseek_ftype = function (stream : pui_file; offset : longint{clong}; whence : longint {cint}) : longint{cint};cdecl; 826 {$endif GDB_UI_FILE_HAS_FSEEK} 827 828 ui_file = record 829 magic : plongint; 830 to_flush : ui_file_flush_ftype; 831 to_write : ui_file_write_ftype; 832 {$ifdef GDB_UI_FILE_HAS_WRITE_ASYNC} 833 to_write_async_safe : ui_file_write_async_save_ftype; 834 {$endif} 835 to_fputs : ui_file_fputs_ftype; 836 {$ifdef GDB_V6} 837 to_read : ui_file_read_ftype; 838 {$endif} 839 to_delete : ui_file_delete_ftype; 840 to_isatty : ui_file_isatty_ftype; 841 to_rewind : ui_file_rewind_ftype; 842 to_put : ui_file_put_ftype; 843 {$ifdef GDB_UI_FILE_HAS_FSEEK} 844 to_fseek : ui_file_fseek_ftype; 845 {$endif GDB_UI_FILE_HAS_FSEEK} 846 to_data : pointer; 847 end; 848 849 stdio_file = record 850 magic : plongint; 851 _file : P_C_FILE; 852 df : longint; 853 close_p : longint; 854 end; 855 856 { used to delete stdio_ui_file gdb_stdout and gdb_stderr } 857 procedure ui_file_delete(stream : pui_file);cdecl;external; 858 859 { used to recreate gdb_stdout and gdb_stderr as memory streams } 860 function mem_fileopen : pui_file;cdecl;external; 861 862 { used to change the write procvar to ours } 863 864 procedure set_ui_file_write(stream : pui_file;write : ui_file_write_ftype);cdecl;external; 865 866 867 type 868 869 (* struct ptid 870 { 871 /* Process id */ 872 int pid; 873 874 /* Lightweight process id */ 875 long lwp; 876 877 /* Thread id */ 878 long tid; 879 }; *) 880 pinferior_ptid = ^tinferior_ptid; 881 tinferior_ptid = record 882 pid : longint{C int}; 883 lwp : ptrint{ C long}; 884 tid : ptrint{ C long}; 885 end; 886 887{$ifdef win32} 888 889type 890 { from sys/reent.h 891 real structure is bigger but only std.. are wanted here PM } 892 REENT = record 893 err : longint; 894 stdin,stdout,stderr : P_C_FILE; 895 end; 896 PREENT = ^REENT; 897 898var _impure_ptr : PREENT;cvar;external; 899 900{$endif win32} 901 902 903type 904 tgdbbuffer=object 905 buf : pchar; 906 size, 907 idx : longint; 908 gdb_file : pui_file; 909 constructor Init; 910 destructor Done; 911 procedure Reset; 912 procedure Resize(nsize : longint); 913 procedure Append(p:pchar); 914 procedure lappend(p:pchar;len : longint); 915 end; 916 917 pgdbinterface=^tgdbinterface; 918 tgdbinterface=object 919 private 920 stop_breakpoint_number : longint; 921 public 922 gdberrorbuf, 923 gdboutputbuf : tgdbbuffer; 924 got_error, 925 reset_command, 926 call_reset, 927 signaled, 928 Debuggee_started : boolean; 929 { frames and frame info while recording a frame } 930 frames : ppframeentry; 931 frame_size, 932 frame_count : longint; 933 record_frames, 934 frame_begin_seen : boolean; 935 frame_level, 936 command_level, 937 current_line_number, 938 signal_start, 939 signal_end, 940 signal_name_start, 941 signal_name_end, 942 error_start, 943 error_end, 944 function_start, 945 function_end, 946 args_start, 947 args_end, 948 file_start, 949 file_end, 950 line_start, 951 line_end : longint; 952 signal_name, 953 signal_string : pchar; 954 current_address, 955 current_pc : CORE_ADDR; 956 { breakpoint } 957 last_breakpoint_number, 958 last_breakpoint_line : longint; 959 last_breakpoint_address : CORE_ADDR; 960 last_breakpoint_file : pchar; 961 invalid_breakpoint_line : boolean; 962 user_screen_shown, 963 switch_to_user : boolean; 964 965 { init } 966 constructor init; 967 destructor done; 968 { Lowlevel } 969 function error:boolean; 970 function error_num:longint; 971 procedure gdb_command(const s:string); 972 procedure gdb__init; 973 procedure gdb_done; 974 procedure resize_frames; 975 function add_frameentry:pframeentry; 976 function get_frameentry(level : longint):pframeentry; 977 function get_current_frame : ptrint; 978 function set_current_frame(level : longint) : boolean; 979 procedure clear_frames; 980 { Highlevel } 981 procedure GetAddrSyminfo(addr:ptrint;var si:tsyminfo); 982 function SelectSourceline(fn:pchar;line,BreakIndex:longint): Boolean; 983 procedure StartSession; 984 procedure BreakSession; 985 procedure EndSession(code:longint); 986 procedure DebuggerScreen; 987 procedure UserScreen; 988 procedure FlushAll; virtual; 989 function Query(question : pchar; args : pchar) : longint; virtual; 990 { Hooks } 991 function DoSelectSourceline(const fn:string;line,BreakIndex:longint): Boolean;virtual; 992 procedure DoStartSession;virtual; 993 procedure DoBreakSession;virtual; 994 procedure DoEndSession(code:longint);virtual; 995 procedure DoUserSignal;virtual; 996 procedure DoDebuggerScreen;virtual; 997 procedure DoUserScreen;virtual; 998 function AllowQuit : boolean;virtual; 999 end; 1000 1001 1002const 1003 use_gdb_file : boolean = false; 1004 1005var 1006 curr_gdb : pgdbinterface; 1007 gdb_file : text; 1008 inferior_ptid : tinferior_ptid;cvar;external; 1009 1010function GDBVersion : string; 1011function inferior_pid : longint; 1012 1013{$ifdef GDB_V6} 1014type 1015 ui_out = pointer; 1016{$ifdef GDB_CURRENT_UIOUT_MACRO} 1017type 1018 pui_out = ^ui_out; 1019function current_ui_current_uiout_ptr : ui_out;cdecl;external; 1020var 1021 cli_uiout : ui_out; 1022 current_uiout : ui_out; 1023 { out local copy for catch_exceptions call } 1024 our_uiout : ui_out; 1025 1026type 1027 pui = ^ui; 1028 ui = record 1029 { ui record } 1030 next : pui; 1031 num : longint; 1032 end; 1033 1034{$ifdef GDB_NEW_UI} 1035var 1036 local_ui : pui; 1037 1038function new_ui (instream, outstream,errstream: pui_file) : pui; cdecl;external; 1039{$endif GDB_NEW_UI} 1040 1041{$else not GDB_CURRENT_UIOUT_MACRO} 1042{$ifndef GDB_NO_UIOUT} 1043var 1044 uiout : ui_out;cvar;external; 1045{$else GDB_NO_UIOUT} 1046var 1047 cli_uiout : ui_out;cvar;external; 1048 current_uiout : ui_out;cvar;external; 1049 { out local copy for catch_exceptions call } 1050 our_uiout : ui_out; 1051{$endif GDB_NO_UIOUT} 1052{$endif not GDB_CURRENT_UIOUT_MACRO} 1053function cli_out_new (stream : pui_file):ui_out;cdecl;external; 1054{$endif GDB_V6} 1055 1056{$ifdef go32v2} 1057 { needed to be sure %fs contains the DOS memory selector 1058 used in Mem[] code PM } 1059 procedure reload_fs; 1060{$endif go32v2} 1061 1062 1063 1064implementation 1065 1066uses 1067{$ifdef win32} 1068 {$ifdef USE_MINGW_GDB} 1069 {$else not USE_MINGW_GDB} 1070 initc, 1071 {$endif not USE_MINGW_GDB} 1072{$endif win32} 1073{$ifdef unix} 1074 baseunix, 1075{$endif} 1076{$ifdef go32v2} 1077 go32, 1078 dpmiexcp, 1079 initc, 1080{$endif} 1081 strings; 1082 1083{***************************************************************************** 1084 Types used by libgdb.a 1085*****************************************************************************} 1086 1087{$ifdef go32v2} 1088type 1089 jmp_buf = dpmi_jmp_buf; 1090 pjmp_buf = pdpmi_jmp_buf; 1091 1092 1093 function setjmp(var rec : jmp_buf) : longint;cdecl;external; 1094 1095 function malloc(size : longint) : pointer;cdecl;external; 1096 1097 procedure longjmp(var rec : jmp_buf;return_value : longint);cdecl;external; 1098 1099 procedure reload_fs;assembler; 1100 asm 1101 movw dosmemselector,%ax 1102 movw %ax,%fs 1103 end['EAX']; 1104 1105{$endif} 1106{$ifdef win32} 1107type 1108 jmp_buf = record 1109 case byte of 1110 0 : 1111 { greatest value found in cygwin machine/setjmp.h for i386 } 1112 { mingw uses int[16] C type for i386 } 1113 (unknown_field : array [1..15] of longint;); 1114 1 : 1115 (eax,ebx,ecx,edx : longint; 1116 esi,edi,ebp,esp,eip : longint;); 1117 end; 1118 1119 pjmp_buf = ^jmp_buf; 1120{$ifdef USE_MINGW_GDB} 1121 { for obscure reasons, longjmp and _setjmp are defined in mingw32 libmsvcrt.a } 1122 function _setjmp(var rec : jmp_buf) : longint; cdecl; external; 1123 procedure longjmp(var rec : jmp_buf;return_value : longint); cdecl; external; 1124 function setjmp(var rec : jmp_buf) : longint; 1125 begin 1126 setjmp:=_setjmp(rec); 1127 end; 1128{$else not USE_MINGW_GDB} 1129 function setjmp(var rec : jmp_buf) : longint;cdecl;external; 1130 1131 procedure longjmp(var rec : jmp_buf;return_value : longint);cdecl;external; 1132{$endif not USE_MINGW_GDB} 1133 1134{$ifndef supportexceptions} 1135type 1136 { I don't think FPC would accept that 1137 the funcvar return type is the funcvar type itself ! PM } 1138 SignalHandler = Procedure(Sig : LongInt);cdecl; 1139 function signal(sig : longint;new_signal : SignalHandler) : SignalHandler;cdecl;external; 1140 1141{define supportexceptions not yet working } 1142{$endif now exceptions are supported for win32} 1143{$endif win32} 1144 1145 type 1146 pCORE_ADDR = ^CORE_ADDR; 1147 pblock = ^block; 1148 1149 tframe_id = record 1150 stack_addr, code_addr, special_addr : CORE_ADDR; 1151 addr_p_flags : byte;{ for three 1 bit flags 1152 stack_addr_p, code_addr_p, special_addr_p : cint : 1; } 1153 inline_depth : longint; 1154 end; 1155 1156 tlanguage = (language_unknown,language_auto,language_c, 1157 language_cplus,language_java,language_chill, 1158 language_fortran,language_m2,language_asm, 1159 language_scm,language_pascal,language_objc); 1160 1161 bptype = ( 1162{$ifdef GDB_HAS_BP_NONE} 1163 bp_none, 1164{$endif GDB_HAS_BP_NONE} 1165 bp_breakpoint,bp_hardware_breakpoint, 1166 bp_until,bp_finish,bp_watchpoint,bp_hardware_watchpoint, 1167 bp_read_watchpoint,bp_access_watchpoint, 1168 bp_longjmp,bp_longjmp_resume,bp_step_resume, 1169 bp_through_sigtramp,bp_watchpoint_scope, 1170 bp_call_dummy,bp_shlib_event); 1171 1172 tenable = (disabled,enabled,shlib_disabled); 1173 1174 bpdisp = (del,del_at_next_stop,disable,donttouch); 1175 1176 pbp_location = ^bp_location; 1177 1178 bp_loc_type = (bp_loc_software_breakpoint, bp_loc_hardware_breakpoint, 1179 bp_loc_hardware_watchpoint, bp_loc_other); 1180 1181 1182 target_hw_bp_type = (hw_write, hw_read, hw_access, hw_execute); 1183 1184 { pointer to structures that we don't need } 1185 pbp_ops = pointer; 1186 pbp_location_ops = pointer; 1187 pprogram_space = pointer; 1188 pgdbarch = pointer; 1189 1190{$PACKRECORDS C} 1191 pbreakpoint = ^breakpoint; 1192 breakpoint = record 1193{$ifdef GDB_USES_BP_OPS} 1194 ops : pbp_ops; 1195{$endif GDB_USES_BP_OPS} 1196 next : pbreakpoint; 1197 typ : bptype; 1198 enable : tenable; 1199 disposition : bpdisp; 1200 number : longint; 1201{$ifdef GDB_USES_BP_LOCATION} 1202 loc : pbp_location; 1203{$else not GDB_USES_BP_LOCATION} 1204 address : CORE_ADDR; 1205{$endif not GDB_USES_BP_LOCATION} 1206{$ifndef GDB_USES_BP_OPS} 1207 line_number : longint; 1208 source_file : pchar; 1209{$endif not GDB_USES_BP_OPS} 1210 silent : byte; 1211{$ifdef GDB_USES_BP_OPS} 1212 display_canonical: byte; 1213{$endif GDB_USES_BP_OPS} 1214 ignore_count : longint; 1215{$ifdef GDB_BP_HAS_ENABLE_COUNT} 1216 enable_count : longint; 1217{$endif GDB_BP_HAS_ENABLE_COUNT} 1218{$ifndef GDB_USES_BP_LOCATION} 1219 shadow_contents : array[0..15] of char; 1220 inserted : char; 1221 duplicate : char; 1222{$endif not GDB_USES_BP_LOCATION} 1223 1224 commands : pointer; {^command_line} 1225{$ifdef GDB_USES_BP_OPS} 1226 frame_id : tframe_id; 1227 pspace : pprogram_space; 1228{$else not GDB_USES_BP_OPS} 1229 frame : CORE_ADDR; 1230 cond : pointer; {^expression} 1231{$endif GDB_USES_BP_OPS} 1232 addr_string : pchar; 1233{$ifdef GDB_USES_BP_OPS} 1234 filter : pchar; 1235 addr_string_range_end : pchar; 1236 gdbarch : pgdbarch; 1237{$endif GDB_USES_BP_OPS} 1238 language : tlanguage; 1239 input_radix : longint; 1240 cond_string : ^char; 1241 exp_string : ^char; 1242 exp : pointer; {^expression} 1243 exp_valid_block : pblock; {^block;} 1244 val : pointer; {value_ptr;} 1245 val_chain : pointer; {value_ptr;} 1246 related_breakpoint : pbreakpoint; 1247 watchpoint_frame : CORE_ADDR; 1248 thread : longint; 1249 hit_count : longint; 1250 section : pointer; {^asection} 1251 end; 1252 1253 pagent_expr = pointer; 1254 tcondition_status = (condition_unchanged, condition_modified); 1255 1256 bp_target_info = record 1257 placed_address_space : pointer;{paddress_space;} 1258 placed_address : CORE_ADDR; 1259{$ifdef GDB_BP_TI_HAS_LENGTH} 1260 length : longint; 1261{$endif GDB_BP_TI_HAS_LENGTH} 1262 shadow_contents : array[0..15] of char; 1263 shadow_len : longint; 1264 placed_size : longint; 1265 end; 1266 1267 bp_location = record 1268 next : pbp_location; 1269{$ifdef GDB_BP_LOCATION_HAS_OPS} 1270 ops : pbp_location_ops; 1271{$endif GDB_BP_LOCATION_HAS_OPS} 1272 1273{$ifdef GDB_BP_LOCATION_HAS_REFCOUNT} 1274 refc : longint; 1275{$else} 1276{$ifdef GDB_BP_LOCATION_HAS_GLOBAL_NEXT} 1277 global_next : pbp_location; 1278{$endif GDB_BP_LOCATION_HAS_GLOBAL_NEXT} 1279{$endif} 1280 loc_type : bp_loc_type; 1281 owner : pbreakpoint; 1282{$ifdef GDB_BP_LOCATION_HAS_GLOBAL_NEXT} 1283 cond : pointer;{pexpression;} 1284{$ifdef GDB_BP_LOCATION_HAS_COND_BYTECODE} 1285 cond_bytecode : pagent_expr; 1286 condition_changed : tcondition_status; 1287 cmd_bytecode : pagent_expr; 1288 needs_update : byte; 1289{$endif} 1290 shlib_disabled : byte; 1291 enabled : byte; 1292{$endif GDB_BP_LOCATION_HAS_GLOBAL_NEXT} 1293 inserted : byte; 1294 duplicate : byte; 1295{$ifdef GDB_BP_LOCATION_HAS_GDBARCH} 1296 gdbarch : pgdbarch; 1297{$endif GDB_BP_LOCATION_HAS_GDBARCH} 1298{$ifdef GDB_HAS_PROGRAM_SPACE} 1299 pspace : pprogram_space; 1300{$endif GDB_HAS_PROGRAM_SPACE} 1301 address : CORE_ADDR; 1302{$ifdef GDB_BP_LOCATION_HAS_GLOBAL_NEXT} 1303 length : longint; 1304 watchpoint_type : target_hw_bp_type; 1305{$endif GDB_BP_LOCATION_HAS_GLOBAL_NEXT} 1306 section : pointer;{pobj_section;} 1307 requested_address : CORE_ADDR; 1308{$ifdef GDB_BP_LOCATION_HAS_RELATED_ADDRESS} 1309 related_address : CORE_ADDR; 1310 probe : pointer; { struct probe *probe; } 1311{$endif} 1312{$ifdef GDB_BP_LOCATION_HAS_GLOBAL_NEXT} 1313 function_name : ^char; 1314{$endif GDB_BP_LOCATION_HAS_GLOBAL_NEXT} 1315 target_info : bp_target_info; 1316 overlay_target_info : bp_target_info; 1317 events_till_retirement : longint; 1318{$ifdef GDB_USES_BP_OPS} 1319 { line and source file are in location } 1320 line_number : longint; 1321 source_file : pchar; 1322{$endif not GDB_USES_BP_OPS} 1323 end; 1324 1325 tfreecode=(free_nothing,free_contents,free_linetable); 1326 1327 psymtab = ^symtab; 1328 symtab = record 1329 next : psymtab; 1330{$ifdef SYMTAB_HAS_COMPUNIT_SYMTAB} 1331 comp_unit : pointer; {^compunit_symtab } 1332 linetable : pointer; {^linetable;} 1333 filename : pchar; 1334 nlines : longint; 1335 line_charpos : ^longint; 1336 language : tlanguage; 1337 fullname : pchar; 1338{$else not SYMTAB_HAS_COMPUNIT_SYMTAB} 1339 blockvector : pointer; {^blockvector;} 1340 linetable : pointer; {^linetable;} 1341 block_line_section : longint; 1342 primary : longint; 1343 {$ifdef GDB_SYMTAB_HAS_MACROS} 1344 { new field added in the middle :( } 1345 macro_table : pointer; 1346 {$endif GDB_SYMTAB_HAS_MACROS} 1347 filename : pchar; 1348 dirname : pchar; 1349 free_code : tfreecode; 1350 free_ptr : pchar; 1351 nlines : longint; 1352 line_charpos : ^longint; 1353 language : tlanguage; 1354 Debugformat : pchar; 1355 version : pchar; 1356 fullname : pchar; 1357 objfile : pointer; {^objfile;} 1358{$endif not SYMTAB_HAS_COMPUNIT_SYMTAB} 1359 end; 1360 1361 psymtab_and_line = ^symtab_and_line; 1362 symtab_and_line = record 1363 {$ifdef GDB_HAS_PROGRAM_SPACE} 1364 pspace : pointer; 1365 {$endif GDB_HAS_PROGRAM_SPACE} 1366 symtab : psymtab; 1367 section : pointer; {^asection;} 1368 line : longint; 1369 pc : CORE_ADDR; 1370 _end : CORE_ADDR; 1371 { Added fields, not used in gdbint, 1372 but necessary to allocated enough space to 1373 avoid stack memory corruption PM } 1374 explicit_pc : longint; 1375 explicit_line : longint; 1376 { New field added in GDB 7.5 version } 1377 probe : pointer;{struct probe *probe; } 1378 { New field added in GDB 7.8? version } 1379 objfile : pointer; { struct objfile * } 1380 end; 1381 1382 symtabs_and_lines = record 1383 sals : ^symtab_and_line; 1384 nelts : longint; 1385 end; 1386 1387 psymbol = ^symbol; 1388 pminimal_symbol = ^minimal_symbol; 1389 1390 general_symbol_info = record 1391 (* Name of the symbol. This is a required field. Storage for the name is 1392 allocated on the psymbol_obstack or symbol_obstack for the associated 1393 objfile. *) 1394 1395 _name : pchar; 1396 1397 (* Value of the symbol. Which member of this union to use, and what 1398 it means, depends on what kind of symbol this is and its 1399 SYMBOL_CLASS. See comments there for more details. All of these 1400 are in host byte order (though what they point to might be in 1401 target byte order, e.g. LOC_CONST_BYTES). *) 1402 value : record 1403 case integer of 1404 (* The fact that this is a long not a LONGEST mainly limits the 1405 range of a LOC_CONST. Since LOC_CONST_BYTES exists, I'm not 1406 sure that is a big deal. *) 1407 0 : (ivalue : longint;); 1408 1409 1 : (block : pblock;); 1410 1411 2 : (bytes : pchar;); 1412 1413 3 : (address : CORE_ADDR;); 1414 1415 (* for opaque typedef struct chain *) 1416 1417 4 : (chain : psymbol;); 1418 end; 1419 1420 (* Since one and only one language can apply, wrap the language specific 1421 information inside a union. *) 1422 1423 (* union 1424 { 1425 struct cplus_specific /* For C++ */ 1426 /* and Java */ 1427 { 1428 char *demangled_name; 1429 } cplus_specific; 1430 struct chill_specific /* For Chill */ 1431 { 1432 char *demangled_name; 1433 } chill_specific; 1434 } language_specific; *) 1435 demangled_name : pchar; 1436 1437 (* Record the source code language that applies to this symbol. 1438 This is used to select one of the fields from the language specific 1439 union above. *) 1440 1441 language : tlanguage; 1442 1443 (* Which section is this symbol in? This is an index into 1444 section_offsets for this objfile. Negative means that the symbol 1445 does not get relocated relative to a section. 1446 Disclaimer: currently this is just used for xcoff, so don't 1447 expect all symbol-reading code to set it correctly (the ELF code 1448 also tries to set it correctly). *) 1449 1450 section : word; 1451 1452 (* The bfd section associated with this symbol. *) 1453 1454 bfd_section : pointer {^asection}; 1455 end; { of general_symbol_info record declaration } 1456 1457 tminimal_symbol_type = 1458 ( 1459 mst_unknown := 0, (* Unknown type, the default *) 1460 mst_text, (* Generally executable instructions *) 1461 mst_data, (* Generally initialized data *) 1462 mst_bss, (* Generally uninitialized data *) 1463 mst_abs, (* Generally absolute (nonrelocatable) *) 1464 (* GDB uses mst_solib_trampoline for the start address of a shared 1465 library trampoline entry. Breakpoints for shared library functions 1466 are put there if the shared library is not yet loaded. 1467 After the shared library is loaded, lookup_minimal_symbol will 1468 prefer the minimal symbol from the shared library (usually 1469 a mst_text symbol) over the mst_solib_trampoline symbol, and the 1470 breakpoints will be moved to their true address in the shared 1471 library via breakpoint_re_set. *) 1472 mst_solib_trampoline, (* Shared library trampoline code *) 1473 (* For the mst_file* types, the names are only guaranteed to be unique 1474 within a given .o file. *) 1475 mst_file_text, (* Static version of mst_text *) 1476 mst_file_data, (* Static version of mst_data *) 1477 mst_file_bss (* Static version of mst_bss *) 1478 ); 1479 1480 namespace_enum = ( 1481 (* UNDEF_NAMESPACE is used when a namespace has not been discovered or 1482 none of the following apply. This usually indicates an error either 1483 in the symbol information or in gdb's handling of symbols. *) 1484 UNDEF_NAMESPACE, 1485 1486 (* VAR_NAMESPACE is the usual namespace. In C, this contains variables, 1487 function names, typedef names and enum type values. *) 1488 VAR_NAMESPACE, 1489 1490 (* STRUCT_NAMESPACE is used in C to hold struct, union and enum type names. 1491 Thus, if `struct foo' is used in a C program, it produces a symbol named 1492 `foo' in the STRUCT_NAMESPACE. *) 1493 STRUCT_NAMESPACE, 1494 1495 (* LABEL_NAMESPACE may be used for names of labels (for gotos); 1496 currently it is not used and labels are not recorded at all. *) 1497 LABEL_NAMESPACE, 1498 1499 (* Searching namespaces. These overlap with VAR_NAMESPACE, providing 1500 some granularity with the search_symbols function. *) 1501 (* Everything in VAR_NAMESPACE minus FUNCTIONS_-, TYPES_-, and 1502 METHODS_NAMESPACE *) 1503 VARIABLES_NAMESPACE, 1504 1505 (* All functions -- for some reason not methods, though. *) 1506 FUNCTIONS_NAMESPACE, 1507 1508 (* All defined types *) 1509 TYPES_NAMESPACE, 1510 1511 (* All class methods -- why is this separated out? *) 1512 METHODS_NAMESPACE 1513 1514 ); 1515 address_class = ( 1516 (* Not used; catches errors *) 1517 LOC_UNDEF, 1518 1519 (* Value is constant int SYMBOL_VALUE, host byteorder *) 1520 LOC_CONST, 1521 1522 (* Value is at fixed address SYMBOL_VALUE_ADDRESS *) 1523 LOC_STATIC, 1524 1525 (* Value is in register. SYMBOL_VALUE is the register number. *) 1526 LOC_REGISTER, 1527 1528 (* It's an argument; the value is at SYMBOL_VALUE offset in arglist. *) 1529 LOC_ARG, 1530 1531 (* Value address is at SYMBOL_VALUE offset in arglist. *) 1532 LOC_REF_ARG, 1533 1534 (* Value is in register number SYMBOL_VALUE. Just like LOC_REGISTER 1535 except this is an argument. Probably the cleaner way to handle 1536 this would be to separate address_class (which would include 1537 separate ARG and LOCAL to deal with FRAME_ARGS_ADDRESS versus 1538 FRAME_LOCALS_ADDRESS), and an is_argument flag. 1539 1540 For some symbol formats (stabs, for some compilers at least), 1541 the compiler generates two symbols, an argument and a register. 1542 In some cases we combine them to a single LOC_REGPARM in symbol 1543 reading, but currently not for all cases (e.g. it's passed on the 1544 stack and then loaded into a register). *) 1545 LOC_REGPARM, 1546 1547 (* Value is in specified register. Just like LOC_REGPARM except the 1548 register holds the address of the argument instead of the argument 1549 itself. This is currently used for the passing of structs and unions 1550 on sparc and hppa. It is also used for call by reference where the 1551 address is in a register, at least by mipsread.c. *) 1552 LOC_REGPARM_ADDR, 1553 1554 (* Value is a local variable at SYMBOL_VALUE offset in stack frame. *) 1555 LOC_LOCAL, 1556 1557 (* Value not used; definition in SYMBOL_TYPE. Symbols in the namespace 1558 STRUCT_NAMESPACE all have this class. *) 1559 LOC_TYPEDEF, 1560 1561 (* Value is address SYMBOL_VALUE_ADDRESS in the code *) 1562 LOC_LABEL, 1563 1564 (* In a symbol table, value is SYMBOL_BLOCK_VALUE of a `struct block'. 1565 In a partial symbol table, SYMBOL_VALUE_ADDRESS is the start address 1566 of the block. Function names have this class. *) 1567 LOC_BLOCK, 1568 1569 (* Value is a constant byte-sequence pointed to by SYMBOL_VALUE_BYTES, in 1570 target byte order. *) 1571 LOC_CONST_BYTES, 1572 1573 (* Value is arg at SYMBOL_VALUE offset in stack frame. Differs from 1574 LOC_LOCAL in that symbol is an argument; differs from LOC_ARG in 1575 that we find it in the frame (FRAME_LOCALS_ADDRESS), not in the 1576 arglist (FRAME_ARGS_ADDRESS). Added for i960, which passes args 1577 in regs then copies to frame. *) 1578 LOC_LOCAL_ARG, 1579 1580 (* Value is at SYMBOL_VALUE offset from the current value of 1581 register number SYMBOL_BASEREG. This exists mainly for the same 1582 things that LOC_LOCAL and LOC_ARG do; but we need to do this 1583 instead because on 88k DWARF gives us the offset from the 1584 frame/stack pointer, rather than the offset from the "canonical 1585 frame address" used by COFF, stabs, etc., and we don't know how 1586 to convert between these until we start examining prologues. 1587 1588 Note that LOC_BASEREG is much less general than a DWARF expression. 1589 We don't need the generality (at least not yet), and storing a general 1590 DWARF expression would presumably take up more space than the existing 1591 scheme. *) 1592 LOC_BASEREG, 1593 1594 (* Same as LOC_BASEREG but it is an argument. *) 1595 LOC_BASEREG_ARG, 1596 1597 (* Value is at fixed address, but the address of the variable has 1598 to be determined from the minimal symbol table whenever the 1599 variable is referenced. 1600 This happens if debugging information for a global symbol is 1601 emitted and the corresponding minimal symbol is defined 1602 in another object file or runtime common storage. 1603 The linker might even remove the minimal symbol if the global 1604 symbol is never referenced, in which case the symbol remains 1605 unresolved. *) 1606 LOC_UNRESOLVED, 1607 1608 (* Value is at a thread-specific location calculated by a 1609 target-specific method. *) 1610 LOC_THREAD_LOCAL_STATIC, 1611 1612 (* The variable does not actually exist in the program. 1613 The value is ignored. *) 1614 LOC_OPTIMIZED_OUT, 1615 1616 (* The variable is static, but actually lives at * (address). 1617 * I.e. do an extra indirection to get to it. 1618 * This is used on HP-UX to get at globals that are allocated 1619 * in shared libraries, where references from images other 1620 * than the one where the global was allocated are done 1621 * with a level of indirection. 1622 *) 1623 LOC_INDIRECT 1624 ); 1625 1626 minimal_symbol = record 1627 (* The general symbol info required for all types of symbols. 1628 The SYMBOL_VALUE_ADDRESS contains the address that this symbol 1629 corresponds to. *) 1630 ginfo : general_symbol_info; 1631 1632 (* The info field is available for caching machine-specific information 1633 so it doesn't have to rederive the info constantly (over a serial line). 1634 It is initialized to zero and stays that way until target-dependent code 1635 sets it. Storage for any data pointed to by this field should be allo- 1636 cated on the symbol_obstack for the associated objfile. 1637 The type would be "void *" except for reasons of compatibility with older 1638 compilers. This field is optional. 1639 1640 Currently, the AMD 29000 tdep.c uses it to remember things it has decoded 1641 from the instructions in the function header, and the MIPS-16 code uses 1642 it to identify 16-bit procedures. *) 1643 1644 info : pchar; 1645 1646{$ifdef SOFUN_ADDRESS_MAYBE_MISSING} 1647 (* Which source file is this symbol in? Only relevant for mst_file_*. *) 1648 filename : pchar; 1649{$endif} 1650 1651 (* Classification types for this symbol. These should be taken as "advisory 1652 only", since if gdb can't easily figure out a classification it simply 1653 selects mst_unknown. It may also have to guess when it can't figure out 1654 which is a better match between two types (mst_data versus mst_bss) for 1655 example. Since the minimal symbol info is sometimes derived from the 1656 BFD library's view of a file, we need to live with what information bfd 1657 supplies. *) 1658 1659 minimal_symbol_type : tminimal_symbol_type; 1660 end{ of minimal_symbol}; 1661 1662 block = record 1663 (* Addresses in the executable code that are in this block. *) 1664 startaddr, 1665 endaddr : CORE_ADDR ; 1666 1667 (* The symbol that names this block, if the block is the body of a 1668 function; otherwise, zero. *) 1669 _function : psymbol; 1670 1671 (* The `struct block' for the containing block, or 0 if none. 1672 The superblock of a top-level local block (i.e. a function in the 1673 case of C) is the STATIC_BLOCK. The superblock of the 1674 STATIC_BLOCK is the GLOBAL_BLOCK. *) 1675 1676 superblock : pblock; 1677 1678 (* Version of GCC used to compile the function corresponding 1679 to this block, or 0 if not compiled with GCC. When possible, 1680 GCC should be compatible with the native compiler, or if that 1681 is not feasible, the differences should be fixed during symbol 1682 reading. As of 16 Apr 93, this flag is never used to distinguish 1683 between gcc2 and the native compiler. 1684 1685 If there is no function corresponding to this block, this meaning 1686 of this flag is undefined. *) 1687 1688 gcc_compile_flag : byte; 1689 1690 (* Number of local symbols. *) 1691 nsyms : longint; 1692 1693 (* The symbols. If some of them are arguments, then they must be 1694 in the order in which we would like to print them. *) 1695 sym : array [0..0] of psymbol; 1696 end { of block definition }; 1697 1698 symbol = record 1699 (* The general symbol info required for all types of symbols. *) 1700 ginfo : general_symbol_info; 1701 1702 (* Data type of value *) 1703 _type : pointer{ptype}; 1704 1705 (* Name space code. *) 1706 namespace : namespace_enum; 1707 1708 (* Address class *) 1709 1710 aclass : address_class; 1711 1712 (* Line number of definition. FIXME: Should we really make the assumption 1713 that nobody will try to debug files longer than 64K lines? What about 1714 machine generated programs? *) 1715 1716 line : word; 1717 1718 (* Some symbols require an additional value to be recorded on a per- 1719 symbol basis. Stash those values here. *) 1720 1721 (*union 1722 { 1723 /* Used by LOC_BASEREG and LOC_BASEREG_ARG. */ 1724 short basereg; 1725 } *) 1726 aux_value_base_reg : word; 1727 1728 (* Link to a list of aliases for this symbol. 1729 Only a "primary/main symbol may have aliases. *) 1730 aliases : pointer{palias_list}; 1731 1732 (* List of ranges where this symbol is active. This is only 1733 used by alias symbols at the current time. *) 1734 ranges : pointer{prange_list}; 1735 end; 1736 1737 target_signal = (TARGET_SIGNAL_FIRST := 0, 1738 TARGET_SIGNAL_HUP := 1,TARGET_SIGNAL_INT := 2, 1739 TARGET_SIGNAL_QUIT := 3,TARGET_SIGNAL_ILL := 4, 1740 TARGET_SIGNAL_TRAP := 5,TARGET_SIGNAL_ABRT := 6, 1741 TARGET_SIGNAL_EMT := 7,TARGET_SIGNAL_FPE := 8, 1742 TARGET_SIGNAL_KILL := 9,TARGET_SIGNAL_BUS := 10, 1743 TARGET_SIGNAL_SEGV := 11,TARGET_SIGNAL_SYS := 12, 1744 TARGET_SIGNAL_PIPE := 13,TARGET_SIGNAL_ALRM := 14, 1745 TARGET_SIGNAL_TERM := 15,TARGET_SIGNAL_URG := 16, 1746 TARGET_SIGNAL_STOP := 17,TARGET_SIGNAL_TSTP := 18, 1747 TARGET_SIGNAL_CONT := 19,TARGET_SIGNAL_CHLD := 20, 1748 TARGET_SIGNAL_TTIN := 21,TARGET_SIGNAL_TTOU := 22, 1749 TARGET_SIGNAL_IO := 23,TARGET_SIGNAL_XCPU := 24, 1750 TARGET_SIGNAL_XFSZ := 25,TARGET_SIGNAL_VTALRM := 26, 1751 TARGET_SIGNAL_PROF := 27,TARGET_SIGNAL_WINCH := 28, 1752 TARGET_SIGNAL_LOST := 29,TARGET_SIGNAL_USR1 := 30, 1753 TARGET_SIGNAL_USR2 := 31,TARGET_SIGNAL_PWR := 32, 1754 TARGET_SIGNAL_POLL := 33,TARGET_SIGNAL_WIND := 34, 1755 TARGET_SIGNAL_PHONE := 35,TARGET_SIGNAL_WAITING := 36, 1756 TARGET_SIGNAL_LWP := 37,TARGET_SIGNAL_DANGER := 38, 1757 TARGET_SIGNAL_GRANT := 39,TARGET_SIGNAL_RETRACT := 40, 1758 TARGET_SIGNAL_MSG := 41,TARGET_SIGNAL_SOUND := 42, 1759 TARGET_SIGNAL_SAK := 43,TARGET_SIGNAL_PRIO := 44, 1760 TARGET_SIGNAL_REALTIME_33 := 45,TARGET_SIGNAL_REALTIME_34 := 46, 1761 TARGET_SIGNAL_REALTIME_35 := 47,TARGET_SIGNAL_REALTIME_36 := 48, 1762 TARGET_SIGNAL_REALTIME_37 := 49,TARGET_SIGNAL_REALTIME_38 := 50, 1763 TARGET_SIGNAL_REALTIME_39 := 51,TARGET_SIGNAL_REALTIME_40 := 52, 1764 TARGET_SIGNAL_REALTIME_41 := 53,TARGET_SIGNAL_REALTIME_42 := 54, 1765 TARGET_SIGNAL_REALTIME_43 := 55,TARGET_SIGNAL_REALTIME_44 := 56, 1766 TARGET_SIGNAL_REALTIME_45 := 57,TARGET_SIGNAL_REALTIME_46 := 58, 1767 TARGET_SIGNAL_REALTIME_47 := 59,TARGET_SIGNAL_REALTIME_48 := 60, 1768 TARGET_SIGNAL_REALTIME_49 := 61,TARGET_SIGNAL_REALTIME_50 := 62, 1769 TARGET_SIGNAL_REALTIME_51 := 63,TARGET_SIGNAL_REALTIME_52 := 64, 1770 TARGET_SIGNAL_REALTIME_53 := 65,TARGET_SIGNAL_REALTIME_54 := 66, 1771 TARGET_SIGNAL_REALTIME_55 := 67,TARGET_SIGNAL_REALTIME_56 := 68, 1772 TARGET_SIGNAL_REALTIME_57 := 69,TARGET_SIGNAL_REALTIME_58 := 70, 1773 TARGET_SIGNAL_REALTIME_59 := 71,TARGET_SIGNAL_REALTIME_60 := 72, 1774 TARGET_SIGNAL_REALTIME_61 := 73,TARGET_SIGNAL_REALTIME_62 := 74, 1775 TARGET_SIGNAL_REALTIME_63 := 75,TARGET_SIGNAL_UNKNOWN, 1776 TARGET_SIGNAL_DEFAULT,TARGET_SIGNAL_LAST 1777 ); 1778 1779 strata = (dummy_stratum,file_stratum,core_stratum,download_stratum,process_stratum); 1780 1781 ptarget_ops = ^target_ops; 1782 target_ops = record 1783 to_shortname : pchar; 1784 to_longname : pchar; 1785 to_doc : pchar; 1786 to_open : procedure (_para1:pchar; _para2:longint); 1787 to_close : procedure (_para1:longint); 1788 to_attach : procedure (_para1:pchar; _para2:longint); 1789 to_detach : procedure (_para1:pchar; _para2:longint); 1790 to_resume : procedure (_para1:longint; _para2:longint; _para3:target_signal); 1791 to_wait : pointer; {function (_para1:longint; _para2:ptarget_waitstatus):longint;} 1792 to_fetch_registers : procedure (_para1:longint); 1793 to_store_registers : procedure (_para1:longint); 1794 to_prepare_to_store : procedure ; 1795 to_xfer_memory : function (memaddr:CORE_ADDR; myaddr:pchar; len:longint; write:longint; target:ptarget_ops):longint; 1796 to_files_info : procedure (_para1:ptarget_ops); 1797 to_insert_breakpoint : function (_para1:CORE_ADDR; _para2:pchar):longint; 1798 to_remove_breakpoint : function (_para1:CORE_ADDR; _para2:pchar):longint; 1799 to_terminal_init : procedure ; 1800 to_terminal_inferior : procedure ; 1801 to_terminal_ours_for_output : procedure ; 1802 to_terminal_ours : procedure ; 1803 to_terminal_info : procedure (_para1:pchar; _para2:longint); 1804 to_kill : procedure ; 1805 to_load : procedure (_para1:pchar; _para2:longint); 1806 to_lookup_symbol : function (_para1:pchar; _para2:pCORE_ADDR):longint; 1807 to_create_inferior : procedure (_para1:pchar; _para2:pchar; _para3:ppchar); 1808 to_mourn_inferior : procedure ; 1809 to_can_run : function :longint; 1810 to_notice_signals : procedure (pid:longint); 1811 to_thread_alive : function (pid:longint):longint; 1812 to_stop : procedure ; 1813 to_stratum : strata; 1814 DONT_USE : pointer; 1815 to_has_all_memory : longint; 1816 to_has_memory : longint; 1817 to_has_stack : longint; 1818 to_has_registers : longint; 1819 to_has_execution : longint; 1820 to_sections : pointer; {^section_table} 1821 to_sections_end : pointer; {^section_table} 1822 to_magic : longint; 1823 end; 1824 1825{$PACKRECORDS C} 1826 1827{***************************************************************************** 1828 Define external calls to libgdb.a 1829*****************************************************************************} 1830 1831var 1832{ external variables } 1833 error_return : jmp_buf;cvar;public; 1834 quit_return : jmp_buf;cvar;public; 1835 deprecated_query_hook : pointer;cvar; 1836{$ifdef NEED_EXTERNAL_CVAR}external;{$else}public;{$endif} 1837 1838 {$ifndef GDB_HAS_OBSERVER_NOTIFY_BREAKPOINT_CREATED} 1839 {$ifdef GDB_HAS_DEPRECATED_CBPH} 1840 deprecated_create_breakpoint_hook : pointer;cvar;external; 1841 {$else} 1842 create_breakpoint_hook : pointer;cvar;external; 1843 {$endif} 1844 {$endif ndef GDB_HAS_OBSERVER_NOTIFY_BREAKPOINT_CREATED} 1845 current_target : target_ops;cvar;external; 1846 stop_pc : CORE_ADDR;cvar;external; 1847 { Only used from GDB 5.0 but doesn't hurst otherwise } 1848 { This global variable is declared in defs.h as external 1849 and instanciated in main.c since version 5.0. } 1850 interpreter_p : pchar;cvar;public; 1851 1852{ we need also to declare some vars } 1853 watchdog : longint;cvar;external; 1854 gdb_error : longint;cvar;public; 1855 display_time : longbool;cvar;public; 1856 display_space : longbool;cvar;public; 1857 1858{ Whether this is the command line version or not } 1859 tui_version : longint;cvar;public; 1860 1861{ Whether xdb commands will be handled } 1862{$ifdef GDB_HAS_DB_COMMANDS} 1863 { These two global variables are declared in defs.h 1864 since version 4.18 } 1865 xdb_commands : longint;cvar;public; 1866 1867{ Whether dbx commands will be handled } 1868 dbx_commands : longint;cvar;public; 1869{$endif GDB_HAS_DB_COMMANDS} 1870 1871{$ifdef GDB_NEEDS_SET_INSTREAM} 1872{$ifndef GDB_NO_INSTREAM_VAR} 1873var 1874 instream : P_C_FILE;cvar;external; 1875{$endif not GDB_NO_INSTREAM_VAR} 1876 1877 function gdb_fopen (filename : pchar; mode : pchar) : pui_file;cdecl;external; 1878{$ifdef LIBGDB_HAS_GET_STDIN} 1879 { this function is generated by the gen-libgdb-inc.sh script 1880 in a object called gdb_get_stdin.o added to the libgdb.a archive } 1881 function gdb_get_stdin : P_C_FILE; cdecl; external; 1882{$ifdef GDB_HAS_SAVED_COMMAND_LINE_SIZE} 1883 { In some GDB versions, saved_command_line needs to 1884 be explicitly allocated at startup } 1885var 1886 saved_command_line : pchar;cvar;external; { defined in top.c source } 1887 saved_command_line_size : longint;cvar;external; {defined in top.c source } 1888{$endif def GDB_HAS_SAVED_COMMAND_LINE_SIZE} 1889{$endif} 1890{$endif GDB_NEEDS_SET_INSTREAM} 1891var 1892 { The four following variables are defined in defs.h 1893 and instanciated in main.c since version 5.0 } 1894 gdb_stdout : pui_file;cvar;public; 1895 gdb_stderr : pui_file;cvar;public; 1896 gdb_stdlog : pui_file;cvar;public; 1897 gdb_stdtarg : pui_file;cvar;public; 1898 event_loop_p : longint;cvar;public; 1899{$ifdef GDB_V6} 1900(* target IO streams *) 1901 { The three following variables are declared in defs.h 1902 and instanciated in main.c since version 6.0 } 1903 gdb_stdin : pui_file;cvar;public; 1904 gdb_stdtargin : pui_file;cvar;public; 1905 gdb_stdtargerr : pui_file;cvar;public; 1906{$endif} 1907 1908{ used for gdb_stdout and gdb_stderr } 1909function xmalloc(size : longint) : pointer;cdecl;external; 1910{ used for QueryHook } 1911{ xvasprintf is present at least from GDB 5.3 1912 while xstrvprintf only appears in version 6.2, 1913 so only use xvasprintf function } 1914{$ifdef GDB_USE_XSTRVPRINTF} 1915function xstrvprintf(msg : pchar) : pchar; varargs; cdecl; external; 1916{$else} 1917function xvasprintf(ret : ppchar; msg : pchar) : pchar; varargs; cdecl; external; 1918{$endif} 1919procedure xfree(p : pointer); cdecl; external; 1920function find_pc_line(i:CORE_ADDR;l:longint):symtab_and_line;cdecl;external; 1921function find_pc_function(i:CORE_ADDR):psymbol;cdecl;external; 1922function lookup_minimal_symbol_by_pc(i : CORE_ADDR):pminimal_symbol;cdecl;external; 1923{$ifdef GDB_INIT_HAS_ARGV0} 1924procedure gdb_init(argv0 : pchar);cdecl;external; 1925{$else not GDB_INIT_HAS_ARGV0} 1926procedure gdb_init;cdecl;external; 1927{$endif not GDB_INIT_HAS_ARGV0} 1928procedure execute_command(p:pchar;i:longint);cdecl;external; 1929{$ifdef GDB_TARGET_CLOSE_HAS_PTARGET_ARG} 1930procedure target_kill;cdecl;external; 1931procedure target_close(pt : ptarget_ops; i:longint);cdecl;external; 1932{$else not GDB_TARGET_CLOSE_HAS_PTARGET_ARG} 1933procedure target_close(i:longint);cdecl;external; 1934{$endif ndef GDB_TARGET_CLOSE_HAS_PTARGET_ARG} 1935 1936 1937{***************************************************************************** 1938 Helpers 1939*****************************************************************************} 1940 1941procedure Debug(const s:string); 1942begin 1943 if use_gdb_file then 1944 Writeln(gdb_file,s) 1945 else 1946 Writeln(s); 1947end; 1948 1949 1950{***************************************************************************** 1951 TFrameEntry 1952*****************************************************************************} 1953 1954constructor tframeentry.init; 1955begin 1956 Reset; 1957end; 1958 1959destructor tframeentry.done; 1960begin 1961 Clear; 1962end; 1963 1964procedure tframeentry.reset; 1965begin 1966 file_name:=nil; 1967 function_name:=nil; 1968 args:=nil; 1969 line_number:=0; 1970 address:=0; 1971 level:=0; 1972end; 1973 1974procedure tframeentry.clear; 1975begin 1976 if assigned(file_name) then 1977 strdispose(file_name); 1978 if assigned(function_name) then 1979 strdispose(function_name); 1980 if assigned(args) then 1981 strdispose(args); 1982 reset; 1983end; 1984 1985 1986{***************************************************************************** 1987 tgdbbuffer 1988*****************************************************************************} 1989 1990const 1991 blocksize=2048; 1992 1993constructor tgdbbuffer.init; 1994begin 1995 Buf:=nil; 1996 gdb_file:=nil; 1997 Size:=0; 1998 Resize(blocksize); 1999 Reset; 2000end; 2001 2002 2003destructor tgdbbuffer.done; 2004begin 2005 if assigned(buf) then 2006 freemem(buf,size); 2007end; 2008 2009 2010 2011procedure tgdbbuffer.reset; 2012begin 2013 idx:=0; 2014 Buf[0]:=#0; 2015end; 2016 2017 2018procedure tgdbbuffer.append(p:pchar); 2019var 2020 len : longint; 2021begin 2022 if not assigned(p) then 2023 exit; 2024 len:=Strlen(p); 2025 if len+1+idx>size then 2026 Resize(len+1+idx); 2027 Move(p^,buf[idx],len); 2028 inc(idx,len); 2029 buf[idx]:=#0; 2030end; 2031 2032 2033procedure tgdbbuffer.lappend(p:pchar;len : longint); 2034begin 2035 if not assigned(p) then 2036 exit; 2037 if len+idx+1>size then 2038 Resize(len+idx+1); 2039 Move(p^,buf[idx],len); 2040 inc(idx,len); 2041 buf[idx]:=#0; 2042end; 2043 2044 2045procedure tgdbbuffer.resize(nsize : longint); 2046var 2047 np : pchar; 2048begin 2049 nsize:=((nsize+blocksize-1) div blocksize)*blocksize; 2050 getmem(np,nsize); 2051 if assigned(buf) then 2052 begin 2053 move(buf^,np^,size); 2054 freemem(buf,size); 2055 end; 2056 buf:=np; 2057 size:=nsize; 2058end; 2059 2060 2061{***************************************************************************** 2062 Hook calls from libgdb.a 2063*****************************************************************************} 2064 2065{$ifdef go32v2} 2066procedure gdbpas_prev_exception_handler;cdecl;public; 2067begin 2068end; 2069{$endif go32v2} 2070 2071procedure init_proc;cdecl;public; 2072begin 2073end; 2074 2075 2076procedure annotate_signalled;cdecl;public; 2077begin 2078{$ifdef Verbose} 2079 Debug('|signalled|'); 2080{$endif} 2081end; 2082 2083 2084procedure annotate_signal_name;cdecl;public; 2085begin 2086{$ifdef Verbose} 2087 Debug('|signal_name|'); 2088{$endif} 2089 with curr_gdb^ do 2090 signal_name_start:=gdboutputbuf.idx; 2091end; 2092 2093 2094procedure annotate_signal_name_end;cdecl;public; 2095begin 2096{$ifdef Verbose} 2097 Debug('|signal_name_end|'); 2098{$endif} 2099 with curr_gdb^ do 2100 signal_name_end:=gdboutputbuf.idx; 2101end; 2102 2103 2104procedure annotate_signal_string;cdecl;public; 2105begin 2106{$ifdef Verbose} 2107 Debug('|signal_string|'); 2108{$endif} 2109 with curr_gdb^ do 2110 signal_start:=gdboutputbuf.idx; 2111end; 2112 2113 2114procedure annotate_signal_string_end;cdecl;public; 2115var 2116 c : char; 2117begin 2118{$ifdef Verbose} 2119 Debug('|signal_string_end|'); 2120{$endif} 2121 with curr_gdb^ do 2122 begin 2123 signal_end:=gdboutputbuf.idx; 2124 c:=gdboutputbuf.buf[signal_end]; 2125 gdboutputbuf.buf[signal_end]:=#0; 2126 if assigned(signal_string) then 2127 strdispose(signal_string); 2128 signal_string:=strnew(gdboutputbuf.buf+signal_start); 2129 gdboutputbuf.buf[signal_end]:=c; 2130 c:=gdboutputbuf.buf[signal_name_end]; 2131 gdboutputbuf.buf[signal_name_end]:=#0; 2132 if assigned(signal_name) then 2133 strdispose(signal_name); 2134 signal_name:=strnew(gdboutputbuf.buf+signal_name_start); 2135 gdboutputbuf.buf[signal_name_end]:=c; 2136 if (user_screen_shown) then 2137 begin 2138 DebuggerScreen; 2139 DoUserSignal; 2140 UserScreen; 2141 end 2142 else 2143 DoUserSignal; 2144 call_reset:=true; 2145 signaled:=false; 2146 end; 2147end; 2148 2149 2150procedure annotate_signal;cdecl;public; 2151begin 2152{$ifdef Verbose} 2153 Debug('|signal|'); 2154{$endif} 2155 with curr_gdb^ do 2156 signaled:=true; 2157end; 2158 2159 2160procedure annotate_exited(exitstatus:longint);cdecl;public; 2161begin 2162{$ifdef Verbose} 2163 Debug('|exited|'); 2164{$endif} 2165{#ifdef __DJGPP__ 2166 /* this is very important. The exit code of a djgpp program 2167 disables interrupts and after this there is no other interrupt 2168 called, which enables interrupts with the iret. */ 2169 __dpmi_get_and_enable_virtual_interrupt_state(); 2170#endif } 2171{$ifdef go32v2} 2172 {$asmmode att} 2173 asm 2174 movw $0x901,%ax 2175 int $0x31 2176 end; 2177 {$asmmode default} 2178 reload_fs; 2179{$endif def go32v2} 2180 2181 curr_gdb^.DebuggerScreen; 2182{ DeleteBreakPoints; } 2183 curr_gdb^.EndSession(exitstatus); 2184end; 2185 2186 2187procedure annotate_error;cdecl;public; 2188begin 2189{$ifdef Verbose} 2190 Debug('|error|'); 2191{$endif} 2192end; 2193 2194 2195procedure annotate_error_begin;cdecl;public; 2196begin 2197{$ifdef Verbose} 2198 Debug('|error begin|'); 2199{$endif} 2200 with curr_gdb^ do 2201 begin 2202 error_start:=gdboutputbuf.idx+strlen(gdboutputbuf.buf); 2203 got_error:=true; 2204 end; 2205{$ifdef Verbose} 2206 Debug('|end of error begin|'); 2207{$endif} 2208end; 2209 2210 2211procedure annotate_starting;cdecl;public; 2212begin 2213{$ifdef Verbose} 2214 Debug('|starting|'); 2215{$endif} 2216{$ifdef go32v2} 2217 reload_fs; 2218{$endif go32v2} 2219 curr_gdb^.UserScreen; 2220end; 2221 2222 2223procedure annotate_stopped;cdecl;public; 2224var 2225 sym : symtab_and_line; 2226 fname : pchar; 2227begin 2228{$ifdef Verbose} 2229 Debug('|stopped|'); 2230{$endif} 2231 with curr_gdb^ do 2232 begin 2233{$ifdef go32v2} 2234 reload_fs; 2235{$endif go32v2} 2236 DebuggerScreen; 2237 current_pc:=stop_pc; 2238 Debuggee_started:=inferior_pid<>0; 2239 if not Debuggee_started then exit; 2240 if reset_command then exit; 2241 sym:=find_pc_line(stop_pc,0); 2242 if assigned(sym.symtab) then 2243 fname:=sym.symtab^.filename 2244 else 2245 fname:=nil; 2246 if not SelectSourceLine(fname,sym.line,stop_breakpoint_number) then 2247 gdb_command('continue'); 2248 end; 2249end; 2250 2251 2252function inferior_pid : longint; 2253begin 2254 inferior_pid:=inferior_ptid.pid; 2255end; 2256 2257 2258procedure proc_remove_foreign(pid:longint);cdecl;public; 2259begin 2260end; 2261 2262 2263procedure breakpoints_changed;cdecl;public; 2264begin 2265{$ifdef Verbose} 2266 Debug('|breakpoints_changed|'); 2267{$endif} 2268end; 2269 2270 2271procedure annotate_ignore_count_change;cdecl;public; 2272begin 2273{$ifdef Verbose} 2274 Debug('|annotate_ignore_count_change()|'); 2275{$endif} 2276end; 2277 2278procedure annotate_new_thread;cdecl;public; 2279begin 2280{$ifdef Verbose} 2281 Debug('|annotate_new_thread()|'); 2282{$endif} 2283end; 2284 2285procedure annotate_thread_changed;cdecl;public; 2286begin 2287{$ifdef Verbose} 2288 Debug('|annotate_thread_changed()|'); 2289{$endif} 2290end; 2291 2292 2293procedure annotate_breakpoint(num:longint);cdecl;public; 2294begin 2295{$ifdef Verbose} 2296 Debug('|breakpoint(%d)|'); 2297{$endif} 2298 With Curr_gdb^ do 2299 stop_breakpoint_number:=num; 2300end; 2301 2302procedure annotate_breakpoints_changed;cdecl;public; 2303begin 2304{$ifdef Verbose} 2305 Debug('|breakpoints_changed|'); 2306{$endif} 2307end; 2308 2309 2310procedure annotate_watchpoint(num:longint);cdecl;public; 2311begin 2312{$ifdef Verbose} 2313 Debug('|watchpoint(%d)|'); 2314{$endif} 2315 With Curr_gdb^ do 2316 stop_breakpoint_number:=num; 2317end; 2318 2319procedure annotate_catchpoint(num:longint);cdecl;public; 2320begin 2321{$ifdef Verbose} 2322 Debug('|catchpoint(%d)|'); 2323{$endif} 2324 With Curr_gdb^ do 2325 stop_breakpoint_number:=num; 2326end; 2327 2328 2329procedure annotate_breakpoints_headers;cdecl;public; 2330begin 2331{$ifdef Verbose} 2332 Debug('|breakpoints_headers|'); 2333{$endif} 2334end; 2335 2336 2337procedure annotate_breakpoints_table;cdecl;public; 2338begin 2339{$ifdef Verbose} 2340 Debug('|breakpoints_table|'); 2341{$endif} 2342end; 2343 2344 2345procedure annotate_record;cdecl;public; 2346begin 2347{$ifdef Verbose} 2348 Debug('|record|'); 2349{$endif} 2350end; 2351 2352 2353procedure annotate_breakpoints_table_end;cdecl;public; 2354begin 2355{$ifdef Verbose} 2356 Debug('|breakpoints_table_end|'); 2357{$endif} 2358end; 2359 2360 2361procedure annotate_frames_invalid;cdecl;public; 2362begin 2363{$ifdef Verbose} 2364 Debug('|frames_invalid|'); 2365{$endif} 2366end; 2367 2368 2369procedure annotate_frame_begin(level:longint; 2370{$ifdef GDB_ANNOTATE_FRAME_BEGIN_HAS_GDBARCH_FIELD} 2371 gdbarch : pgdbarch; 2372{$endif GDB_ANNOTATE_FRAME_BEGIN_HAS_GDBARCH_FIELD} 2373pc:CORE_ADDR);cdecl;public; 2374begin 2375{$ifdef Verbose} 2376 Debug('|frame_begin(%d,%ld)|'); 2377{$endif} 2378 with curr_gdb^ do 2379 begin 2380 frame_begin_seen:=true; 2381 frame_level:=level; 2382 current_address:=pc; 2383 current_line_number:=-1; 2384 function_start:=-1; 2385 function_end:=-1; 2386 args_start:=-1; 2387 args_end:=-1; 2388 file_start:=-1; 2389 file_end:=-1; 2390 line_start:=-1; 2391 line_end:=-1; 2392 end; 2393end; 2394 2395 2396procedure annotate_frame_address;cdecl;public; 2397begin 2398{$ifdef Verbose} 2399 Debug('|frame_address|'); 2400{$endif} 2401end; 2402 2403 2404procedure annotate_frame_address_end;cdecl;public; 2405begin 2406{$ifdef Verbose} 2407 Debug('|frame_address_end|'); 2408{$endif} 2409end; 2410 2411procedure annotate_frame_function_name;cdecl;public; 2412begin 2413{$ifdef Verbose} 2414 Debug('|frame_function_name|'); 2415{$endif} 2416 with curr_gdb^ do 2417 function_start:=gdboutputbuf.idx; 2418end; 2419 2420 2421procedure annotate_frame_args;cdecl;public; 2422begin 2423{$ifdef Verbose} 2424 Debug('|frame_args|'); 2425{$endif} 2426 with curr_gdb^ do 2427 begin 2428 function_end:=gdboutputbuf.idx; 2429 args_start:=gdboutputbuf.idx; 2430 end; 2431end; 2432 2433procedure annotate_frame_source_begin;cdecl;public; 2434begin 2435{$ifdef Verbose} 2436 Debug('|frame_source_begin|'); 2437{$endif} 2438 with curr_gdb^ do 2439 args_end:=gdboutputbuf.idx; 2440end; 2441 2442 2443procedure annotate_frame_source_file;cdecl;public; 2444begin 2445{$ifdef Verbose} 2446 Debug('|frame_source_file|'); 2447{$endif} 2448 with curr_gdb^ do 2449 file_start:=gdboutputbuf.idx; 2450end; 2451 2452procedure annotate_frame_source_file_end;cdecl;public; 2453begin 2454{$ifdef Verbose} 2455 Debug('|frame_source_file_end|'); 2456{$endif} 2457 with curr_gdb^ do 2458 file_end:=gdboutputbuf.idx; 2459end; 2460 2461 2462procedure annotate_frame_source_line;cdecl;public; 2463begin 2464{$ifdef Verbose} 2465 Debug('|frame_source_line|'); 2466{$endif} 2467 with curr_gdb^ do 2468 line_start:=gdboutputbuf.idx; 2469end; 2470 2471 2472procedure annotate_frame_source_end;cdecl;public; 2473begin 2474{$ifdef Verbose} 2475 Debug('|frame_source_end|'); 2476{$endif} 2477 with curr_gdb^ do 2478 line_end:=gdboutputbuf.idx; 2479end; 2480 2481 2482procedure annotate_frame_where;cdecl;public; 2483begin 2484{$ifdef Verbose} 2485 Debug('|frame_where|'); 2486{$endif} 2487end; 2488 2489 2490procedure annotate_frame_end;cdecl;public; 2491var 2492 fe : pframeentry; 2493 c : char; 2494 err : integer; 2495begin 2496{$ifdef Verbose} 2497 Debug('|frame_end|'); 2498{$endif} 2499 with curr_gdb^ do 2500 begin 2501 if (not record_frames) or (not frame_begin_seen) then 2502 exit; 2503 { This can happen, when the function has no Debugging information } 2504 if (args_start >= 0) and (args_end < 0) then 2505 args_end:=gdboutputbuf.idx; 2506 frame_begin_seen:=false; 2507 fe:=get_frameentry(frame_level); 2508 fe^.address:=current_address; 2509 fe^.level:=frame_level; 2510 if (function_start>=0) then 2511 begin 2512 c:=gdboutputbuf.buf[function_end]; 2513 gdboutputbuf.buf[function_end]:=#0; 2514 fe^.function_name:=strnew(gdboutputbuf.buf+function_start); 2515 gdboutputbuf.buf[function_end]:=c; 2516 end; 2517 if (file_start>=0) then 2518 begin 2519 c:=gdboutputbuf.buf[file_end]; 2520 gdboutputbuf.buf[file_end]:=#0; 2521 fe^.file_name:=strnew(gdboutputbuf.buf+file_start); 2522 gdboutputbuf.buf[file_end]:=c; 2523 end; 2524 if (args_start>=0) then 2525 begin 2526 {$warning FIXME} {sometimes the ide crashes here because ars_end is 0, AD} 2527 if args_end > 0 then 2528 begin 2529 if (gdboutputbuf.buf[args_end-1]=#10) then 2530 dec(args_end); 2531 { Flushing is not always correct for args, 2532 try to move on to next closing brace } 2533 while (args_end<file_start) and (gdboutputbuf.buf[args_end-1]<>')') do 2534 inc(args_end); 2535 c:=gdboutputbuf.buf[args_end]; 2536 gdboutputbuf.buf[args_end]:=#0; 2537 fe^.args:=strnew(gdboutputbuf.buf+args_start); 2538 gdboutputbuf.buf[args_end]:=c; 2539 end; 2540 end; 2541 if (line_start>=0) then 2542 begin 2543 c:=gdboutputbuf.buf[line_end]; 2544 gdboutputbuf.buf[line_end]:=#0; 2545{ sscanf(gdb_output_buffer+line_start,'%d',&fe^.line_number); } 2546 val(strpas(pchar(@gdboutputbuf.buf[line_start])),fe^.line_number,err); 2547 gdboutputbuf.buf[line_end]:=c; 2548 end; 2549 end; 2550end; 2551 2552 2553procedure annotate_quit;cdecl;public; 2554begin 2555{$ifdef Verbose} 2556 Debug('|quit|'); 2557{$endif} 2558end; 2559 2560 2561procedure annotate_arg_begin;cdecl;public; 2562begin 2563{$ifdef Verbose} 2564 Debug('|arg_begin|'); 2565{$endif} 2566end; 2567 2568 2569procedure annotate_arg_name_end;cdecl;public; 2570begin 2571{$ifdef Verbose} 2572 Debug('|arg_name_end|'); 2573{$endif} 2574end; 2575 2576 2577procedure annotate_arg_value(typ:pointer);cdecl;public; 2578begin 2579{$ifdef Verbose} 2580 Debug('|arg_value|'); 2581{$endif} 2582end; 2583 2584 2585procedure annotate_arg_end;cdecl;public; 2586begin 2587{$ifdef Verbose} 2588 Debug('|arg_end|'); 2589{$endif} 2590end; 2591 2592procedure annotate_source(filename:pchar;line,character,mid:longint; 2593{$ifdef GDB_ANNOTATE_FRAME_BEGIN_HAS_GDBARCH_FIELD} 2594 gdbarch : pgdbarch; 2595{$endif GDB_ANNOTATE_FRAME_BEGIN_HAS_GDBARCH_FIELD} 2596pc:CORE_ADDR);cdecl;public; 2597begin 2598{$ifdef Verbose} 2599 Debug('|source|'); 2600{$endif} 2601end; 2602 2603 2604procedure annotate_function_call;cdecl;public; 2605begin 2606{$ifdef Verbose} 2607 Debug('|function_call|'); 2608{$endif} 2609end; 2610 2611 2612procedure annotate_signal_handler_caller;cdecl;public; 2613begin 2614{$ifdef Verbose} 2615 Debug('|signal_handler_caller|'); 2616{$endif} 2617end; 2618 2619 2620procedure annotate_array_section_begin(index:longint;elttype:pointer);cdecl;public; 2621begin 2622{$ifdef Verbose} 2623 Debug('|array_section_begin()|'); 2624{$endif} 2625end; 2626 2627 2628procedure annotate_elt_rep(repcount:longint);cdecl;public; 2629begin 2630{$ifdef Verbose} 2631 Debug('|elt_rep()|'); 2632{$endif} 2633end; 2634 2635procedure annotate_elt_rep_end;cdecl;public; 2636begin 2637{$ifdef Verbose} 2638 Debug('|elt_rep_end|'); 2639{$endif} 2640end; 2641 2642 2643procedure annotate_elt;cdecl;public; 2644begin 2645{$ifdef Verbose} 2646 Debug('|elt|'); 2647{$endif} 2648end; 2649 2650 2651procedure annotate_array_section_end;cdecl;public; 2652begin 2653{$ifdef Verbose} 2654 Debug('|array_section_end|'); 2655{$endif} 2656end; 2657 2658procedure annotate_display_prompt;cdecl;public; 2659begin 2660{$ifdef Verbose} 2661 Debug('|display_prompt|'); 2662{$endif} 2663end; 2664 2665 2666procedure annotate_display_begin;cdecl;public; 2667begin 2668{$ifdef Verbose} 2669 Debug('|display_begin|'); 2670{$endif} 2671end; 2672 2673 2674procedure annotate_display_number_end;cdecl;public; 2675begin 2676{$ifdef Verbose} 2677 Debug('|display_number_end|'); 2678{$endif} 2679end; 2680 2681 2682procedure annotate_display_format;cdecl;public; 2683begin 2684{$ifdef Verbose} 2685 Debug('|display_format|'); 2686{$endif} 2687end; 2688 2689procedure annotate_display_expression;cdecl;public; 2690begin 2691{$ifdef Verbose} 2692 Debug('|display_expression|'); 2693{$endif} 2694end; 2695 2696 2697procedure annotate_display_expression_end;cdecl;public; 2698begin 2699{$ifdef Verbose} 2700 Debug('|display_expression_end|'); 2701{$endif} 2702end; 2703 2704 2705procedure annotate_display_value;cdecl;public; 2706begin 2707{$ifdef Verbose} 2708 Debug('|display_value|'); 2709{$endif} 2710end; 2711 2712 2713procedure annotate_display_end;cdecl;public; 2714begin 2715{$ifdef Verbose} 2716 Debug('|display_end|'); 2717{$endif} 2718end; 2719 2720 2721procedure annotate_field (num:longint);cdecl;public; 2722begin 2723{$ifdef Verbose} 2724 Debug('a_field(%d)'); 2725{$endif} 2726end; 2727 2728 2729procedure annotate_field_begin(typ:pointer);cdecl;public; 2730begin 2731{$ifdef Verbose} 2732 Debug('a_field_begin\n'); 2733{$endif} 2734end; 2735 2736 2737procedure annotate_field_name_end;cdecl;public; 2738begin 2739{$ifdef Verbose} 2740 Debug('a_field_name_end\n'); 2741{$endif} 2742end; 2743 2744 2745procedure annotate_field_value;cdecl;public; 2746begin 2747{$ifdef Verbose} 2748 Debug('a_field_value\n'); 2749{$endif} 2750end; 2751 2752 2753procedure annotate_field_end;cdecl;public; 2754begin 2755{$ifdef Verbose} 2756 Debug('a_field_end\n'); 2757{$endif} 2758end; 2759 2760 2761procedure annotate_value_history_begin (histindex:longint;typ:pointer);cdecl;public; 2762begin 2763{$ifdef Verbose} 2764 Debug('a_value_history_begin(%d)\n'); 2765{$endif} 2766end; 2767 2768 2769procedure annotate_value_begin (typ:pointer);cdecl;public; 2770begin 2771{$ifdef Verbose} 2772 Debug('a_value_begin\n'); 2773{$endif} 2774end; 2775 2776 2777procedure annotate_value_history_value;cdecl;public; 2778begin 2779{$ifdef Verbose} 2780 Debug('a_value_history_value\n'); 2781{$endif} 2782end; 2783 2784 2785procedure annotate_value_history_end;cdecl;public; 2786begin 2787{$ifdef Verbose} 2788 Debug('a_value_history_end\n'); 2789{$endif} 2790end; 2791 2792 2793procedure annotate_value_end;cdecl;public; 2794begin 2795{$ifdef Verbose} 2796 Debug('a_value_end\n'); 2797{$endif} 2798end; 2799 2800 2801procedure _initialize_annotate;cdecl;public; 2802begin 2803end; 2804 2805 2806procedure gdbint_ui_file_write(stream : pui_file; p : pchar; len : longint);cdecl; 2807begin 2808 if assigned(curr_gdb) then 2809 with curr_gdb^ do 2810 if stream = gdb_stderr then 2811 gdberrorbuf.lappend(p,len) 2812 else if stream = gdb_stdout then 2813 gdboutputbuf.lappend(p,len) 2814 else 2815 begin 2816 gdberrorbuf.append('Unknown gdb ui_file'); 2817 gdberrorbuf.lappend(p,len); 2818 end; 2819end; 2820 2821 2822function QueryHook(question : pchar; arg : ppchar) : longint; cdecl; 2823var local : pchar; 2824 2825begin 2826 if not assigned(curr_gdb) then 2827 QueryHook:=0 2828 else 2829 begin 2830 if curr_gdb^.reset_command and ((pos('Kill',question)>0) or 2831 (pos('Discard symbol table',question)>0)) then 2832 QueryHook:=1 2833 else if pos('%',question)>0 then 2834 begin 2835{$ifdef GDB_USE_XSTRVPRINTF} 2836 local:=xstrvprintf(question,arg); 2837{$else} 2838 xvasprintf(@local,question,arg); 2839{$endif} 2840 { xvasprintf can failed, in that case local is set to nil } 2841 if not assigned(local) then 2842 local:=question; 2843 QueryHook:=curr_gdb^.Query(local, nil); 2844 xfree(local); 2845 end 2846 else 2847 QueryHook:=curr_gdb^.Query(question, nil); 2848 end; 2849end; 2850 2851procedure CreateBreakPointHook(var b:breakpoint);cdecl; 2852var 2853 sym : symtab_and_line; 2854 2855{ this procedure is only here to avoid the problems 2856 with different version of gcc having different stack 2857 handling: 2858 on older versions find_pc_line uses just "ret" 2859 while on newer gcc version "ret $4" is used 2860 if this call is within the CreateBreakPointHook function 2861 it changes %esp and thus the registers are 2862 not restored correctly PM } 2863 procedure get_pc_line; 2864 begin 2865 2866{$ifdef GDB_USES_BP_LOCATION} 2867 if assigned (b.loc) then 2868 sym:=find_pc_line(b.loc^.address,0) 2869{$else not GDB_USES_BP_LOCATION} 2870 if (b.address <> 0) then 2871 sym:=find_pc_line(b.address,0) 2872{$endif not GDB_USES_BP_LOCATION} 2873 else 2874 fillchar (sym, sizeof(sym), #0); 2875 end; 2876begin 2877 get_pc_line; 2878 with curr_gdb^ do 2879 begin 2880 last_breakpoint_number:=b.number; 2881 { function breakpoints have zero as file and as line !! 2882 but they are valid !! } 2883{$ifndef GDB_USES_BP_OPS} 2884 invalid_breakpoint_line:=(b.line_number<>sym.line) and (b.line_number<>0); 2885{$else GDB_USES_BP_OPS} 2886 invalid_breakpoint_line:=(b.loc=nil) or 2887 ((b.loc^.line_number<>sym.line) and (b.loc^.line_number<>0)); 2888{$endif GDB_USES_BP_OPS} 2889{$ifdef GDB_USES_BP_LOCATION} 2890 if assigned (b.loc) then 2891 last_breakpoint_address:=b.loc^.address 2892 else 2893 last_breakpoint_address:=0; 2894{$else not GDB_USES_BP_LOCATION} 2895 last_breakpoint_address:=b.address; 2896{$endif not GDB_USES_BP_LOCATION} 2897 last_breakpoint_line:=sym.line; 2898 if assigned(sym.symtab) then 2899 last_breakpoint_file:=sym.symtab^.filename 2900 else 2901 last_breakpoint_file:=nil; 2902 end; 2903end; 2904 2905{$ifdef GDB_HAS_OBSERVER_NOTIFY_BREAKPOINT_CREATED} 2906 2907type 2908{$ifdef GDB_NOTIFY_BREAKPOINT_ARG_IS_BREAKPOINT_PTR} 2909 breakpoint_created_function_type = procedure (bpp : pbreakpoint); cdecl; 2910{$else not GDB_NOTIFY_BREAKPOINT_ARG_IS_BREAKPOINT_PTR} 2911 breakpoint_created_function_type = procedure (bpnum : longint); cdecl; 2912{$endif not GDB_NOTIFY_BREAKPOINT_ARG_IS_BREAKPOINT_PTR} 2913 pobserver = pointer; 2914var 2915 breakpoint_created_observer : pobserver = nil; 2916 2917function observer_attach_breakpoint_created(create_func : breakpoint_created_function_type) : pobserver;cdecl;external; 2918procedure observer_detach_breakpoint_created(pob : pobserver);cdecl;external; 2919 2920 2921{$ifdef GDB_NOTIFY_BREAKPOINT_ARG_IS_BREAKPOINT_PTR} 2922procedure notify_breakpoint_created(bpp : pbreakpoint); cdecl; 2923begin 2924 CreateBreakpointHook(bpp^); 2925end; 2926{$else not GDB_NOTIFY_BREAKPOINT_ARG_IS_BREAKPOINT_PTR} 2927var breakpoint_chain : pbreakpoint ;cvar;external; 2928 2929procedure notify_breakpoint_created(bpnum : longint);cdecl; 2930var 2931 pb : pbreakpoint; 2932begin 2933 pb:=breakpoint_chain; 2934 while assigned(pb) do 2935 begin 2936 if pb^.number=bpnum then 2937 begin 2938 CreateBreakPointHook(pb^); 2939 exit; 2940 end 2941 else 2942 pb:=pb^.next; 2943 end; 2944end; 2945{$endif not GDB_NOTIFY_BREAKPOINT_ARG_IS_BREAKPOINT_PTR} 2946{$endif def GDB_HAS_OBSERVER_NOTIFY_BREAKPOINT_CREATED} 2947 2948{ Avoid loading of main.o object by providing a 2949 stripped down version of relocate_gdb_directory function } 2950function relocate_gdb_directory(path : pchar) : pchar; cdecl; public; 2951begin 2952 relocate_gdb_directory:=path; 2953end; 2954 2955{***************************************************************************** 2956 tgdbinterface 2957*****************************************************************************} 2958 2959constructor tgdbinterface.init; 2960begin 2961 gdboutputbuf.init; 2962 gdberrorbuf.init; 2963 record_frames:=true; 2964 2965 { This must be placed before gdb__init is called 2966 as gdb_init might issue output PM } 2967 curr_gdb:=@self; 2968 gdb__init; 2969 command_level:=0; 2970{ set output mode for GDB } 2971{ only these values disable filtering 2972 DONT CHANGE THEM !!! PM } 2973 gdb_command('set width 0xffffffff'); 2974 gdb_command('set height 0xffffffff'); 2975{ other standard commands used for fpc debugging } 2976 gdb_command('set print demangle off'); 2977 gdb_command('set gnutarget auto'); 2978 gdb_command('set language auto'); 2979 gdb_command('set print vtbl on'); 2980 gdb_command('set print object on'); 2981 gdb_command('set print null-stop'); 2982 {$ifdef USE_MINGW_GDB} // maybe this also should be done for newer cygwin gdbs. 2983 //gdb_command('set confirm off'); 2984 {$endif} 2985end; 2986 2987 2988destructor tgdbinterface.done; 2989begin 2990 clear_frames; 2991 gdb_done; 2992 gdboutputbuf.done; 2993 gdberrorbuf.done; 2994end; 2995 2996 2997procedure tgdbinterface.gdb__init; 2998begin 2999 gdboutputbuf.reset; 3000 gdberrorbuf.reset; 3001 {$ifdef GDB_HAS_OBSERVER_NOTIFY_BREAKPOINT_CREATED} 3002 breakpoint_created_observer:=observer_attach_breakpoint_created(@notify_breakpoint_created); 3003 {$else not GDB_HAS_OBSERVER_NOTIFY_BREAKPOINT_CREATED} 3004 {$ifdef GDB_HAS_DEPRECATED_CBPH} 3005 deprecated_create_breakpoint_hook:=@CreateBreakPointHook; 3006 {$else} 3007 create_breakpoint_hook:=@CreateBreakPointHook; 3008 {$endif} 3009 {$endif} 3010 deprecated_query_hook :=@QueryHook; 3011 3012 signal_string:=nil; 3013 signal_name:=nil; 3014end; 3015 3016 3017 3018procedure tgdbinterface.gdb_done; 3019begin 3020 if debuggee_started then 3021 begin 3022{$ifdef GDB_TARGET_CLOSE_HAS_PTARGET_ARG} 3023 target_kill; 3024 target_close(@current_target,1); 3025{$else not GDB_TARGET_CLOSE_HAS_PTARGET_ARG} 3026 current_target.to_kill; 3027 target_close(1); 3028{$endif ndef GDB_TARGET_CLOSE_HAS_PTARGET_ARG} 3029 end; 3030 {$ifdef GDB_HAS_OBSERVER_NOTIFY_BREAKPOINT_CREATED} 3031 observer_detach_breakpoint_created(breakpoint_created_observer); 3032 breakpoint_created_observer:=nil; 3033 {$else not GDB_HAS_OBSERVER_NOTIFY_BREAKPOINT_CREATED} 3034 {$ifdef GDB_HAS_DEPRECATED_CBPH} 3035 deprecated_create_breakpoint_hook:=nil; 3036 {$else} 3037 create_breakpoint_hook:=nil; 3038 {$endif} 3039 {$endif} 3040end; 3041 3042procedure tgdbinterface.FlushAll; 3043begin 3044end; 3045 3046function tgdbinterface.Query(question : pchar; args : pchar) : longint; 3047begin 3048 Query:=0; 3049end; 3050 3051function tgdbinterface.error:boolean; 3052begin 3053 error:=got_error; 3054end; 3055 3056function tgdbinterface.error_num:longint; 3057begin 3058 error_num:=gdb_error; 3059end; 3060 3061var 3062 top_level_val : longint; 3063 3064{$ifdef USE_CATCH_EXCEPTIONS} 3065function catch_exceptions(uiout : ui_out; func : pointer; command : pchar; mask : longint) : longint;cdecl;external; 3066 3067function gdbint_execute_command(uiout : ui_out; command : pchar) : longint;cdecl; 3068begin 3069 gdbint_execute_command:=1; 3070 execute_command(command,1); 3071 gdbint_execute_command:=0; 3072end; 3073{$else not USE_CATCH_EXCEPTIONS} 3074function catch_command_errors(func : pointer; command : pchar; from_tty,mask : longint) : longint;cdecl;external; 3075 3076function gdbint_execute_command(command : pchar; from_tty : longint) : longint;cdecl; 3077begin 3078 gdbint_execute_command:=1; 3079 execute_command(command,from_tty); 3080 gdbint_execute_command:=0; 3081end; 3082{$endif not USE_CATCH_EXCEPTIONS} 3083 3084{$ifdef cpui386} 3085type 3086 tfpustate = word; 3087 3088const 3089 MaskAllExceptions = $ff; 3090{$else} 3091type 3092 tfpustate = longint; 3093const 3094 MaskAllExceptions = 0; 3095{$endif} 3096 3097procedure SaveFPUState(var control :TFPUState); 3098begin 3099{$ifdef cpui386} 3100 asm 3101 movl control, %edi 3102 fstcw (%edi) 3103 end; 3104{$else} 3105 control:=0; 3106{$endif} 3107end; 3108 3109procedure SetFPUState(control : TFPUState); 3110begin 3111{$ifdef cpui386} 3112 asm 3113 fnclex 3114 fldcw control 3115 end; 3116{$else} 3117{$endif} 3118end; 3119 3120function MaskAllFPUExceptions(control : TFPUState) : TFPUState; 3121begin 3122{$ifdef cpui386} 3123 MaskAllFPUExceptions := control or MaskAllExceptions; 3124{$else} 3125 MaskAllFPUExceptions:=0; 3126{$endif} 3127end; 3128 3129procedure tgdbinterface.gdb_command(const s:string); 3130var 3131 command : array[0..256] of char; 3132 prev_stop_breakpoint_number, 3133 mask : longint; 3134 s2 : string; 3135 old_quit_return, 3136 old_error_return : jmp_buf; 3137 control : TFPUState; 3138begin 3139 inc(command_level); 3140 SaveFPUState(control); 3141 SetFPUState(MaskAllFPUExceptions(control)); 3142 move(s[1],command,length(s)); 3143 command[length(s)]:=#0; 3144 old_quit_return:=quit_return; 3145 old_error_return:=error_return; 3146 gdb_error:=0; 3147 got_error:=false; 3148 if command_level=1 then 3149 prev_stop_breakpoint_number:=0 3150 else 3151 prev_stop_breakpoint_number:=stop_breakpoint_number; 3152 3153 stop_breakpoint_number:=0; 3154 { Trap quit commands } 3155 s2:=s; 3156 while (length(s2)>0) and ((s2[1]=' ') or (s2[1]=#9)) do 3157 s2:=copy(s2,2,255); 3158 if (length(s2)>0) and 3159 (UpCase(s2[1])='Q') and 3160 ((length(s2)=1) or 3161 (s2[2]=' ') or 3162 ((UpCase(s2[2])='U') and 3163 ((length(s2)=2) or 3164 (s2[3]=' ') or 3165 ((UpCase(s2[3])='I') and 3166 ((length(s2)=3) or 3167 (s2[4]=' ') or 3168 ((UpCase(s2[4])='T') and 3169 ((length(s2)=4) or 3170 (s2[5]=' ') 3171 ))))))) then 3172 begin 3173 if not AllowQuit then 3174 exit; 3175 end; 3176{$ifdef DebugCommand} 3177 Debug('start of handle_gdb_command ('+s+')'); 3178{$endif} 3179 top_level_val:=setjmp(error_return); 3180 if top_level_val=0 then 3181 begin 3182 quit_return:=error_return; 3183 mask:=longint($ffffffff); 3184{$ifdef USE_CATCH_EXCEPTIONS} 3185 catch_exceptions(our_uiout, @gdbint_execute_command,@command,mask); 3186{$else i.e. not USE_CATCH_EXCEPTIONS} 3187 catch_command_errors(@gdbint_execute_command,@command, 3188 1,mask); 3189{$endif not def USE_CATCH_EXCEPTIONS} 3190{$ifdef go32v2} 3191 reload_fs; 3192{$endif go32v2} 3193 end 3194 else 3195{$ifdef Verbose} 3196 Debug('error longjmp in handle_gdb_command ('+s+')'); 3197{$endif} 3198 ; 3199{$ifdef DebugCommand} 3200 Debug('end of handle_gdb_command ('+s+')'); 3201{$endif} 3202 quit_return:=old_quit_return; 3203 error_return:=old_error_return; 3204 dec(command_level); 3205 stop_breakpoint_number:=prev_stop_breakpoint_number; 3206 SetFPUState(control); 3207end; 3208 3209 3210procedure tgdbinterface.resize_frames; 3211var 3212 i : longint; 3213 new_frames : ppframeentry; 3214begin 3215 if (frame_count>=frame_size) then 3216 begin 3217 getmem(new_frames,sizeof(pointer)*(frame_count+1)); 3218 for i:=0 to frame_size-1 do 3219 new_frames[i]:=frames[i]; 3220 if assigned(frames) then 3221 freemem(frames,sizeof(pointer)*frame_size); 3222 frames:=new_frames; 3223 frame_size:=frame_count+1; 3224 for i:=frame_count to frame_size-1 do 3225 frames[i]:=new(pframeentry,init); 3226 end; 3227end; 3228 3229 3230function tgdbinterface.add_frameentry:pframeentry; 3231begin 3232 resize_frames; 3233 add_frameentry:=frames[frame_count]; 3234 inc(frame_count); 3235end; 3236 3237function tgdbinterface.get_frameentry(level : longint) : pframeentry; 3238begin 3239 { only climb values one by one PM } 3240 if level>=frame_count then 3241 resize_frames; 3242 get_frameentry:=frames[level]; 3243 frames[level]^.clear; 3244 if level>=frame_count then 3245 inc(frame_count); 3246end; 3247 3248 3249procedure tgdbinterface.clear_frames; 3250var 3251 i : longint; 3252begin 3253 for i:=0 to frame_size-1 do 3254 dispose(frames[i],done); 3255 if assigned(frames) then 3256 begin 3257 freemem(frames,sizeof(pointer)*Frame_size); 3258 frames:=nil; 3259 end; 3260 frame_count:=0; 3261 frame_size:=0; 3262end; 3263 3264function tgdbinterface.get_current_frame : ptrint; 3265begin 3266 record_frames:=false; 3267 gdb_command('f'); 3268 get_current_frame:=frame_level; 3269 record_frames:=true; 3270end; 3271 3272function tgdbinterface.set_current_frame(level : longint) : boolean; 3273var 3274 s : string; 3275begin 3276 record_frames:=false; 3277 str(level,s); 3278 gdb_command('f '+s); 3279 if level=frame_level then 3280 set_current_frame:=true 3281 else 3282 set_current_frame:=false; 3283 record_frames:=true; 3284end; 3285 3286 3287{***************************************************************************** 3288 Highlevel tgdbinterface 3289*****************************************************************************} 3290 3291procedure tgdbinterface.GetAddrSyminfo(addr:ptrint;var si:tsyminfo); 3292var 3293 sym : symtab_and_line; 3294 symbol : psymbol; 3295begin 3296 sym:=find_pc_line(addr,1); 3297 fillchar(si,sizeof(tsyminfo),0); 3298 si.address:=addr; 3299 si.offset:=addr-sym.pc; 3300 if assigned(sym.symtab) then 3301 si.fname:=sym.symtab^.filename 3302 else 3303 si.fname:=nil; 3304 si.line:=sym.line; 3305 symbol:=find_pc_function(addr); 3306 if assigned(symbol) then 3307 si.funcname:=symbol^.ginfo._name 3308 else 3309 si.funcname:=nil; 3310end; 3311 3312 3313function tgdbinterface.SelectSourceLine(fn:pchar;line,BreakIndex:longint): Boolean; 3314begin 3315 if assigned(fn) then 3316 SelectSourceLine:=DoSelectSourceLine(StrPas(fn),line,BreakIndex) 3317 else 3318 SelectSourceLine:=DoSelectSourceLine('',line,BreakIndex); 3319end; 3320 3321 3322procedure tgdbinterface.StartSession; 3323begin 3324 DoStartSession; 3325end; 3326 3327 3328procedure tgdbinterface.BreakSession; 3329begin 3330 DoBreakSession; 3331end; 3332 3333 3334procedure tgdbinterface.EndSession(code:longint); 3335begin 3336 Debuggee_started:=false; 3337 { inferior_ptid.pid:=0; 3338 This leads to an assertion failure 3339 from generic_mount_inferior } 3340 DoEndSession(code); 3341 if assigned(signal_name) then 3342 strdispose(signal_name); 3343 signal_name:=nil; 3344 if assigned(signal_string) then 3345 strdispose(signal_string); 3346 signal_string:=nil; 3347end; 3348 3349 3350procedure tgdbinterface.DebuggerScreen; 3351begin 3352{$ifdef Verbose} 3353 Debug('|DebuggerScreen|'); 3354{$endif} 3355 if user_screen_shown then 3356 DoDebuggerScreen; 3357 user_screen_shown:=false; 3358end; 3359 3360 3361procedure tgdbinterface.UserScreen; 3362begin 3363{$ifdef Verbose} 3364 Debug('|UserScreen|'); 3365{$endif} 3366 if switch_to_user then 3367 begin 3368 if (not user_screen_shown) then 3369 DoUserScreen; 3370 user_screen_shown:=true; 3371 end; 3372end; 3373 3374 3375 3376{--------------------------------------- 3377 Default Hooks 3378---------------------------------------} 3379 3380function tgdbinterface.DoSelectSourceLine(const fn:string;line,BreakIndex:longint): Boolean; 3381{$ifdef Verbose} 3382var 3383 s,bs : string; 3384{$endif} 3385begin 3386{$ifdef Verbose} 3387 Str(line,S); 3388 Str(BreakIndex,BS); 3389 Debug('|SelectSource '+fn+':'+s+','+bs+'|'); 3390{$endif} 3391end; 3392 3393procedure tgdbinterface.DoStartSession; 3394begin 3395end; 3396 3397procedure tgdbinterface.DoBreakSession; 3398begin 3399end; 3400 3401procedure tgdbinterface.DoEndSession(code:longint); 3402begin 3403end; 3404 3405procedure tgdbinterface.DoUserSignal; 3406begin 3407end; 3408 3409procedure tgdbinterface.DoDebuggerScreen; 3410begin 3411end; 3412 3413procedure tgdbinterface.DoUserScreen; 3414begin 3415end; 3416 3417function tgdbinterface.AllowQuit : boolean; 3418begin 3419 AllowQuit:=true; 3420end; 3421 3422var 3423 version : array[0..0] of char;cvar;external; 3424 3425{$ifndef GDB_NEEDS_NO_ERROR_INIT} 3426{ doesn't seem to exist anymore. Seems to work fine without } 3427procedure error_init;cdecl;external; 3428{$endif GDB_NEEDS_NO_ERROR_INIT} 3429 3430function GDBVersion : string; 3431begin 3432 GDBVersion:='GDB '+StrPas(version); 3433end; 3434 3435 3436const next_exit : pointer = nil; 3437procedure DoneLibGDB; 3438begin 3439 exitproc:=next_exit; 3440end; 3441 3442{$ifdef go32v2} 3443var 3444 c_environ : ppchar;external name '__environ'; 3445 c_argc : longint;external name '___crt0_argc'; 3446 c_argv : ppchar;external name '___crt0_argv'; 3447 3448 procedure ReallocateEnvironUsingCMalloc; 3449 3450 var 3451 neededsize , i, count : longint; 3452 penv : pchar; 3453 newenv : ppchar; 3454 begin 3455 if not assigned(c_environ) then 3456 neededsize:=sizeof(pchar) 3457 else 3458 begin 3459 count:=0; 3460 penv:=c_environ[count]; 3461 while assigned(penv) do 3462 begin 3463 inc(count); 3464 penv:=c_environ[count]; 3465 end; 3466 inc(count); 3467 neededsize:=count*sizeof(pchar); 3468 end; 3469 newenv:=malloc(neededsize); 3470 system.move(c_environ^,newenv^,neededsize); 3471 if assigned(c_environ) then 3472 begin 3473 for i:=0 to count-1 do 3474 begin 3475 penv:=c_environ[i]; 3476 if assigned(penv) then 3477 begin 3478 neededsize:=strlen(penv)+1; 3479 newenv[i]:=malloc(neededsize); 3480 system.move(penv^,newenv[i]^,neededsize); 3481 end 3482 else 3483 newenv[i]:=nil; 3484 end; 3485 end; 3486 c_environ:=newenv; 3487 end; 3488 3489{$endif def go32v2} 3490var 3491 current_directory : pchar; cvar; external; 3492 gdb_dirbuf : array[0..0] of char; cvar; external; 3493 CurrentDir : AnsiString; 3494{$ifdef GDB_NEEDS_INTERPRETER_SETUP} 3495 type 3496 interpreter_struct_p = pointer; { to opaque type } 3497 function interp_lookup (name : pchar) : interpreter_struct_p;cdecl; external; 3498 function interp_set (interp : interpreter_struct_p) : longbool;cdecl; external; 3499{$endif GDB_NEEDS_INTERPRETER_SETUP} 3500const 3501 DIRBUF_SIZE = 1024; 3502 3503procedure InitLibGDB; 3504{$ifdef supportexceptions} 3505var 3506 OldSigInt : SignalHandler; 3507{$endif supportexceptions} 3508{$ifdef GDB_NEEDS_SET_INSTREAM} 3509var 3510 dummy_file : pui_file; 3511{$endif GDB_NEEDS_SET_INSTREAM} 3512 3513{$ifdef GDB_INIT_HAS_ARGV0} 3514var 3515 argv0 : pchar; 3516{$endif not GDB_INIT_HAS_ARGV0} 3517{$ifdef GDB_NEEDS_INTERPRETER_SETUP} 3518var 3519 interp : interpreter_struct_p; 3520{$endif GDB_NEEDS_INTERPRETER_SETUP} 3521var 3522 save_gdb_stdin, 3523 save_gdb_stdout, 3524 save_gdb_stderr : pui_file; 3525begin 3526{$ifdef go32v2} 3527 { c_environ:=system.envp; } 3528 { DJGPP libC presupposes the c_enivron was malloc'ated } 3529 ReallocateEnvironUsingCMalloc; 3530 c_argc:=system.argc; 3531 c_argv:=system.argv; 3532{$endif def go32v2} 3533{$ifdef supportexceptions} 3534{$ifdef go32v2} 3535 OldSigInt:=Signal(SIGINT,SignalHandler(@SIG_DFL)); 3536{$else} 3537 {$ifdef Unix} 3538 OldSigInt:=fpSignal(SIGINT,SignalHandler(SIG_DFL)); 3539 {$else} 3540 OldSigInt:=Signal(SIGINT,SignalHandler(SIG_DFL)); 3541 {$endif} 3542{$endif} 3543{$endif supportexceptions} 3544 3545 if assigned(gdb_stderr) then 3546 ui_file_delete(gdb_stderr); 3547 if assigned(gdb_stdout) then 3548 ui_file_delete(gdb_stdout); 3549{$ifdef GDB_NEEDS_SET_INSTREAM} 3550 if assigned(gdb_stdin) then 3551 ui_file_delete(gdb_stdin); 3552 gdb_stdin:=mem_fileopen; 3553 save_gdb_stdin:=gdb_stdin; 3554{$ifdef LIBGDB_HAS_GET_STDIN} 3555{$ifndef GDB_NO_INSTREAM_VAR} 3556 instream:=gdb_get_stdin; 3557{$endif ndef GDB_NO_INSTREAM_VAR} 3558{$ifdef GDB_HAS_SAVED_COMMAND_LINE_SIZE} 3559 saved_command_line:=xmalloc(saved_command_line_size); 3560{$endif def GDB_HAS_SAVED_COMMAND_LINE_SIZE} 3561{$else} 3562 dummy_file :=gdb_fopen('dummy.$$$','a'); 3563 {in captured_main code, this is simply 3564 instream:=stdin; but stdin is a highly system dependent macro 3565 so that we try to avoid it here } 3566 if assigned(dummy_file) then 3567 instream:=pstdio_file(dummy_file^.to_data)^._file 3568 else 3569 instream:=nil; 3570{$endif} 3571{$endif GDB_NEEDS_SET_INSTREAM} 3572 3573 gdb_stderr:=mem_fileopen; 3574 gdb_stdout:=mem_fileopen; 3575 save_gdb_stderr:=gdb_stderr; 3576 save_gdb_stdout:=gdb_stdout; 3577 gdb_stdlog:=gdb_stderr; 3578 gdb_stdtarg:=gdb_stderr; 3579 set_ui_file_write(gdb_stdout,@gdbint_ui_file_write); 3580 set_ui_file_write(gdb_stderr,@gdbint_ui_file_write); 3581{$ifndef GDB_NEEDS_NO_ERROR_INIT} 3582 error_init; 3583{$endif GDB_NEEDS_NO_ERROR_INIT} 3584{$ifdef GDB_V6} 3585{$ifdef GDB_NEEDS_SET_INSTREAM} 3586 gdb_stdtargin := gdb_stdin; 3587{$endif GDB_NEEDS_SET_INSTREAM} 3588 gdb_stdtargerr := gdb_stderr; 3589{$endif} 3590 GetDir(0, CurrentDir); 3591 if length(CurrentDir)<DIRBUF_SIZE then 3592 strpcopy(@gdb_dirbuf,CurrentDir) 3593 else 3594 gdb_dirbuf[0]:=#0; 3595 current_directory:=@gdb_dirbuf[0]; 3596 next_exit:=exitproc; 3597 exitproc:=@DoneLibGDB; 3598{$ifdef GDB_V6} 3599{$ifndef GDB_NO_UIOUT} 3600 uiout := cli_out_new (gdb_stdout); 3601{$endif not GDB_NO_UIOUT} 3602{$endif GDB_V6} 3603{$ifdef GDB_NEW_UI} 3604 local_ui := new_ui (gdb_stdin,gdb_stdout,gdb_stderr); 3605{$endif not GDB_NEW_UI} 3606{$ifdef GDB_INIT_HAS_ARGV0} 3607 getmem(argv0,length(paramstr(0))+1); 3608 strpcopy(argv0,paramstr(0)); 3609 gdb_init(argv0); 3610 freemem(argv0,length(paramstr(0))+1); 3611{$else not GDB_INIT_HAS_ARGV0} 3612 gdb_init; 3613{$endif not GDB_INIT_HAS_ARGV0} 3614{$ifdef GDB_NEEDS_INTERPRETER_SETUP} 3615 { interpreter can only be set after all files are 3616 initialized, which is done in gdb_init function. } 3617 interp := interp_lookup ('console'); 3618 interp_set (interp); 3619 3620 { We need to re-set gdb_stdXX ui_files } 3621 if assigned(gdb_stderr) then 3622 ui_file_delete(gdb_stderr); 3623 if assigned(gdb_stdout) then 3624 ui_file_delete(gdb_stdout); 3625 if assigned(gdb_stdin) then 3626 ui_file_delete(gdb_stdin); 3627 gdb_stdin:=save_gdb_stdin; 3628 gdb_stderr:=save_gdb_stderr; 3629 gdb_stdout:=save_gdb_stdout; 3630 gdb_stdlog:=gdb_stderr; 3631 gdb_stdtarg:=gdb_stderr; 3632 set_ui_file_write(gdb_stdout,@gdbint_ui_file_write); 3633 set_ui_file_write(gdb_stderr,@gdbint_ui_file_write); 3634{$ifdef GDB_NO_UIOUT} 3635 cli_uiout := cli_out_new (gdb_stdout); 3636 current_uiout:=cli_uiout; 3637 our_uiout:=cli_uiout; 3638{$endif GDB_NO_UIOUT} 3639{$ifdef GDB_NEW_UI} 3640 local_ui := new_ui (gdb_stdin,gdb_stdout,gdb_stderr); 3641{$endif not GDB_NEW_UI} 3642{$endif GDB_NEEDS_INTERPRETER_SETUP} 3643{$ifdef supportexceptions} 3644 {$ifdef unix} 3645 fpsignal(SIGINT,OldSigInt); 3646 {$else} 3647 Signal(SIGINT,OldSigInt); 3648 {$endif} 3649{$endif supportexceptions} 3650 if setjmp(error_return)=0 then 3651 begin 3652 quit_return:=error_return; 3653 exit; 3654 end 3655 else 3656 begin 3657{$ifdef Verbose} 3658 Debug('|LongJump to Init|'); 3659{$endif} 3660{$ifdef go32v2} 3661 RunError(99); 3662{$endif def go32v2} 3663 end; 3664 WatchDog:=0; 3665end; 3666 3667{$ifdef GDB_HAS_SYSROOT} 3668 { Here we declare as cvar;public; a bunch of global 3669 variables that are defined in main.c source. 3670 We must not load main.o otherwise, we will get 3671 into multiply defined symbols troubles. } 3672var 3673 gdb_sysrootc : char; 3674 { used locally only to provide a pchar pointing to '\0' } 3675 gdb_sysroot : pchar; cvar;public; 3676 { gdb_sysroot global variable is declared in defs.h and 3677 instanciated in main.c since version 6.0 } 3678 gdb_datadir : pchar; cvar;public; 3679 { gdb_datadir global variable is declared in defs.h and 3680 instanciated in main.c since version 7.0 } 3681 python_libdir : pchar;cvar;public; 3682 { python_libdir global variable is declared in defs.h and instanciated 3683 in main.c since version 7.2 } 3684 return_child_result : longbool;cvar;public; 3685 { return_chlid_result global variable is declared in main.h and 3686 instanciated in main.c since version 6.4 } 3687 return_child_result_value : longint;cvar;public; 3688 { return_child_result_value global variable is declared in main.h and 3689 instanciated in main.c since version 6.4 with a startup value of -1 } 3690 batch_silent : longbool;cvar;public; 3691 { batch_silent global variable is declared in main.h since 7.0, but 3692 instanciated in main.c since version 6.4 } 3693 batch_flag : longbool;cvar;public; 3694 { batch_flag global variable is declared in main.h and 3695 instanciated in main.c since version 7.2 } 3696{$endif} 3697{$ifdef GDB_HAS_DEBUG_FILE_DIRECTORY} 3698var 3699 debug_file_directory : pchar; cvar; external; 3700{$endif GDB_HAS_DEBUG_FILE_DIRECTORY} 3701 3702{$ifdef USE_LOCAL_SET_GDB_DATA_DIRECTORY} 3703{ Avoid loading of main.o object by providing a 3704 stripped down version of relocate_gdb_directory function } 3705procedure set_gdb_data_directory(path : pchar); cdecl; public; 3706begin 3707 gdb_datadir:=path; 3708end; 3709{$endif USE_LOCAL_SET_GDB_DATA_DIRECTORY} 3710 3711begin 3712{$ifdef GDB_HAS_SYSROOT} 3713 gdb_sysrootc := #0; 3714 return_child_result_value := -1; 3715 gdb_sysroot := @gdb_sysrootc; 3716 gdb_datadir := @gdb_sysrootc; 3717 python_libdir := @gdb_sysrootc; 3718{$endif} 3719{$ifdef GDB_HAS_DEBUG_FILE_DIRECTORY} 3720 debug_file_directory := '/usr/local/lib'; 3721{$endif GDB_HAS_DEBUG_FILE_DIRECTORY} 3722 gdb_stderr:=nil; 3723 gdb_stdout:=nil; 3724 InitLibGDB; 3725end. 3726