📄 gdbint.texinfo
字号:
later. When your code does something (like @code{malloc} some memory, or opena file) that needs to be undone later (e.g. free the memory or closethe file), it can make a cleanup. The cleanup will be done at somefuture point: when the command is finished, when an error occurs, orwhen your code decides it's time to do cleanups.You can also discard cleanups, that is, throw them away without doingwhat they say. This is only done if you ask that it be done.Syntax:@table @code@item @var{old_chain} = make_cleanup (@var{function}, @var{arg});Make a cleanup which will cause @var{function} to be called with @var{arg}(a @code{char *}) later. The result, @var{old_chain}, is a handle that can bepassed to @code{do_cleanups} or @code{discard_cleanups} later. Unless you aregoing to call @code{do_cleanups} or @code{discard_cleanups} yourself,you can ignore the result from @code{make_cleanup}.@item do_cleanups (@var{old_chain});Perform all cleanups done since @code{make_cleanup} returned @var{old_chain}.E.g.: @examplemake_cleanup (a, 0); old = make_cleanup (b, 0); do_cleanups (old);@end example@noindentwill call @code{b()} but will not call @code{a()}. The cleanup that calls @code{a()} will remainin the cleanup chain, and will be done later unless otherwise discarded.@refill@item discard_cleanups (@var{old_chain});Same as @code{do_cleanups} except that it just removes the cleanups from thechain and does not call the specified functions.@end tableSome functions, e.g. @code{fputs_filtered()} or @code{error()}, specify that they``should not be called when cleanups are not in place''. This meansthat any actions you need to reverse in the case of an error orinterruption must be on the cleanup chain before you call these functions,since they might never return to your code (they @samp{longjmp} instead).@node Wrapping@chapter Wrapping Output LinesOutput that goes through @code{printf_filtered} or @code{fputs_filtered} or@code{fputs_demangled} needs only to have calls to @code{wrap_here} added in places that would be good breaking points. The utility routineswill take care of actually wrapping if the line width is exceeded.The argument to @code{wrap_here} is an indentation string which is printed@emph{only} if the line breaks there. This argument is saved away and usedlater. It must remain valid until the next call to @code{wrap_here} oruntil a newline has been printed through the @code{*_filtered} functions.Don't pass in a local variable and then return!It is usually best to call @code{wrap_here()} after printing a comma or space.If you call it before printing a space, make sure that your indentationproperly accounts for the leading space that will print if the line wrapsthere.Any function or set of functions that produce filtered output must finishby printing a newline, to flush the wrap buffer, before switching tounfiltered (``@code{printf}'') output. Symbol reading routines that printwarnings are a good example.@node Frames@chapter FramesA frame is a construct that GDB uses to keep track of calling and calledfunctions.@table @code@item FRAME_FPin the machine description has no meaning to the machine-independentpart of GDB, except that it is used when setting up a new frame fromscratch, as follows:@example create_new_frame (read_register (FP_REGNUM), read_pc ()));@end exampleOther than that, all the meaning imparted to @code{FP_REGNUM} is imparted bythe machine-dependent code. So, @code{FP_REGNUM} can have any value thatis convenient for the code that creates new frames. (@code{create_new_frame}calls @code{INIT_EXTRA_FRAME_INFO} if it is defined; that is where you shoulduse the @code{FP_REGNUM} value, if your frames are nonstandard.)@item FRAME_CHAINGiven a GDB frame, determine the address of the calling function'sframe. This will be used to create a new GDB frame struct, and then@code{INIT_EXTRA_FRAME_INFO} and @code{INIT_FRAME_PC} will be called forthe new frame.@end table@node Coding Style@chapter Coding StyleGDB is generally written using the GNU coding standards, as described in@file{standards.texi}, which you can get from the Free SoftwareFoundation. There are some additional considerations for GDB maintainersthat reflect the unique environment and style of GDB maintenance.If you follow these guidelines, GDB will be more consistent and easierto maintain.GDB's policy on the use of prototypes is that prototypes are usedto @emph{declare} functions but never to @emph{define} them. Simplemacros are used in the declarations, so that a non-ANSI compiler cancompile GDB without trouble. The simple macro calls are used likethis:@example @codeextern intmemory_remove_breakpoint PARAMS ((CORE_ADDR, char *));@end exampleNote the double parentheses around the parameter types. This allowsan arbitrary number of parameters to be described, without freakingout the C preprocessor. When the function has no parameters, itshould be described like:@example @codevoidnoprocess PARAMS ((void));@end exampleThe @code{PARAMS} macro expands to its argument in ANSI C, or to a simple@code{()} in traditional C.All external functions should have a @code{PARAMS} declaration in aheader file that callers include. All static functions should have sucha declaration near the top of their source file.We don't have a gcc option that will properly check that these ruleshave been followed, but it's GDB policy, and we periodically check itusing the tools available (plus manual labor), and clean up any remnants.@node Host Conditionals@chapter Host ConditionalsWhen GDB is configured and compiled, various macros are defined or leftundefined, to control compilation based on the attributes of the hostsystem. These macros and their meanings are:@emph{NOTE: For now, both host and target conditionals are here.Eliminate target conditionals from this list as they are identified.}@table @code@item ALIGN_SIZEalloca.c@item BLOCK_ADDRESS_FUNCTION_RELATIVEdbxread.c@item GDBINIT_FILENAMEmain.c@item KERNELDEBUGtm-hppa.h@item MEM_FNS_DECLAREDdefs.h@item NO_SYS_FILEdbxread.c@item PYRAMID_CONTROL_FRAME_DEBUGGINGpyr-xdep.c@item SIGWINCH_HANDLER_BODYutils.c@item 1buildsym.c@item 1dbxread.c@item 1dbxread.c@item 1buildsym.c@item 1dwarfread.c@item 1valops.c@item 1valops.c@item 1pyr-xdep.c@item ADDITIONAL_OPTIONSmain.c@item ADDITIONAL_OPTION_CASESmain.c@item ADDITIONAL_OPTION_HANDLERmain.c@item ADDITIONAL_OPTION_HELPmain.c@item ADDR_BITS_REMOVEdefs.h@item AIX_BUGGY_PTRACE_CONTINUEinfptrace.c@item ALIGN_STACK_ON_STARTUPmain.c@item ALTOSaltos-xdep.c@item ALTOS_ASxm-altos.h@item ASCII_COFFremote-adapt.c@item BADMAGcoffread.c@item BCStm-delta88.h@item BEFORE_MAIN_LOOP_HOOKmain.c@item BELIEVE_PCC_PROMOTIONcoffread.c@item BELIEVE_PCC_PROMOTION_TYPEstabsread.c@item BIG_ENDIANdefs.h@item BITS_BIG_ENDIANdefs.h@item BKPT_AT_MAINsolib.c@item BLOCK_ADDRESS_ABSOLUTEdbxread.c@item BPT_VECTORtm-68k.h@item BREAKPOINTtm-68k.h@item BREAKPOINT_DEBUGbreakpoint.c@item BROKEN_LARGE_ALLOCAAvoid large @code{alloca}'s. For example, on sun's, Large alloca's failbecause the attempt to increase the stack limit in main() fails becauseshared libraries are allocated just below the initial stack limit. TheSunOS kernel will not allow the stack to grow into the area occupied bythe shared libraries.@item BSTRINGregex.c@item CALL_DUMMYvalops.c@item CALL_DUMMY_LOCATIONinferior.h@item CALL_DUMMY_STACK_ADJUSTvalops.c@item CANNOT_FETCH_REGISTERhppabsd-xdep.c@item CANNOT_STORE_REGISTERfindvar.c@item CFRONT_PRODUCERdwarfread.c@item CHILD_PREPARE_TO_STOREinftarg.c@item CLEAR_DEFERRED_STORESinflow.c@item CLEAR_SOLIBobjfiles.c@item COFF_ENCAPSULATEhppabsd-tdep.c@item COFF_FORMATsymm-tdep.c@item COFF_NO_LONG_FILE_NAMEScoffread.c@item CORE_NEEDS_RELOCATIONstack.c@item CPLUS_MARKERcplus-dem.c@item CREATE_INFERIOR_HOOKinfrun.c@item C_ALLOCAregex.c@item C_GLBLREGcoffread.c@item DAMONxcoffexec.c@item DBXREAD_ONLYpartial-stab.h@item DBX_PARM_SYMBOL_CLASSstabsread.c@item DEBUGremote-adapt.c@item DEBUG_INFOpartial-stab.h@item DEBUG_PTRACEhppabsd-xdep.c@item DECR_PC_AFTER_BREAKbreakpoint.c@item DEFAULT_PROMPTmain.c@item DELTA88m88k-xdep.c@item DEV_TTYsymmisc.c@item DGUXm88k-xdep.c@item DISABLE_UNSETTABLE_BREAKbreakpoint.c@item DONT_USE_REMOTEremote.c@item DO_DEFERRED_STORESinfrun.c@item DO_REGISTERS_INFOinfcmd.c@item END_OF_TEXT_DEFAULTdbxread.c@item EXTERNbuildsym.h@item EXTRACT_RETURN_VALUEtm-68k.h@item EXTRACT_STRUCT_VALUE_ADDRESSvalues.c@item EXTRA_FRAME_INFOframe.h@item EXTRA_SYMTAB_INFOsymtab.h@item FILES_INFO_HOOKtarget.c@item FIXMEcoffread.c@item FLOAT_INFOinfcmd.c@item FOPEN_RBdefs.h@item FP0_REGNUMa68v-xdep.c@item FPC_REGNUMmach386-xdep.c@item FP_REGNUMparse.c@item FRAMELESS_FUNCTION_INVOCATIONblockframe.c@item FRAME_ARGS_ADDRESS_CORRECTstack.c@item FRAME_CHAIN_COMBINEblockframe.c@item FRAME_CHAIN_VALIDframe.h@item FRAME_CHAIN_VALID_ALTERNATEframe.h@item FRAME_FIND_SAVED_REGSstack.c@item FRAME_GET_BASEREG_VALUEframe.h@item FRAME_NUM_ARGStm-68k.h@item FRAME_SPECIFICATION_DYADICstack.c@item FUNCTION_EPILOGUE_SIZEcoffread.c@item F_OKxm-ultra3.h@item GCC2_COMPILED_FLAG_SYMBOLdbxread.c@item GCC_COMPILED_FLAG_SYMBOLdbxread.c@item GCC_MANGLE_BUGsymtab.c@item GCC_PRODUCERdwarfread.c@item GET_SAVED_REGISTERfindvar.c@item GPLUS_PRODUCERdwarfread.c@item GR64_REGNUMremote-adapt.c@item GR64_REGNUMremote-mm.c@item HANDLE_RBRACpartial-stab.h@item HAVE_68881m68k-tdep.c@item HAVE_MMAPIn some cases, use the system call @code{mmap} for reading symboltables. For some machines this allows for sharing and quick updates.@item HAVE_REGISTER_WINDOWSfindvar.c@item HAVE_SIGSETMASKmain.c@item HAVE_TERMIOinflow.c@item HEADER_SEEK_FDarm-tdep.c@item HOSTING_ONLYxm-rtbsd.h@item HOST_BYTE_ORDERieee-float.c@item HPUX_ASMxm-hp300hpux.h@item HPUX_VERSION_5hp300ux-xdep.c@item HP_OS_BUGinfrun.c@item I80960remote-vx.c@item IBM6000_HOSTbreakpoint.c@item IBM6000_TARGETbuildsym.c@item IEEE_DEBUGieee-float.c@item IEEE_FLOATvalprint.c@item IGNORE_SYMBOLdbxread.c@item INIT_EXTRA_FRAME_INFOblockframe.c@item INIT_EXTRA_SYMTAB_INFOsymfile.c@item INIT_FRAME_PCblockframe.c@item INNER_THANvalops.c@item INT_MAXdefs.h@item INT_MINdefs.h@item IN_GDBi960-pinsn.c@item IN_SIGTRAMPinfrun.c@item IN_SOLIB_TRAMPOLINEinfrun.c@item ISATTYmain.c@item IS_TRAPPED_INTERNALVARvalues.c@item KERNELDEBUGdbxread.c@item KERNEL_DEBUGGINGtm-ultra3.h@item KERNEL_U_ADDRDefine this to the address of the @code{u} structure (the ``user struct'',also known as the ``u-page'') in kernel virtual memory. GDB needs to knowthis so that it can subtract this address from absolute addresses inthe upage, that are obtained via ptrace or from core files. On systemsthat don't need this value, set it to zero.@item KERNEL_U_ADDR_BSDDefine this to cause GDB to determine the address of @code{u} at runtime,by using Berkeley-style @code{nlist} on the kernel's image in the rootdirectory.@item KERNEL_U_ADDR_HPUXDefine this to cause GDB to determine the address of @code{u} at runtime,by using HP-style @code{nlist} on the kernel's image in the rootdirectory.@item LCC_PRODUCERdwarfread.c@item LITTLE_ENDIANdefs.h@item LOG_FILEremote-adapt.c@item LONGERNAMEScplus-dem.c@item LONGESTdefs.h@item LONG_LONGdefs.h@item LONG_MAXdefs.h@item LSEEK_NOT_LINEARsource.c@item L_LNNO32coffread.c
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -