⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 gdbint.texinfo

📁 这个是LINUX下的GDB调度工具的源码
💻 TEXINFO
📖 第 1 页 / 共 5 页
字号:
\input texinfo   @c -*- texinfo -*-@setfilename gdbint.info@include gdb-cfg.texi@dircategory Software development@direntry* Gdb-Internals: (gdbint).	The GNU debugger's internals.@end direntry@ifinfoThis file documents the internals of the GNU debugger @value{GDBN}.Copyright 1990,1991,1992,1993,1994,1996,1998,1999,2000,2001,2002,2003,2004   Free Software Foundation, Inc.Contributed by Cygnus Solutions.  Written by John Gilmore.Second Edition by Stan Shebs.Permission is granted to copy, distribute and/or modify this documentunder the terms of the GNU Free Documentation License, Version 1.1 orany later version published by the Free Software Foundation; with noInvariant Sections, with no Front-Cover Texts, and with no Back-CoverTexts.  A copy of the license is included in the section entitled ``GNUFree Documentation License''.@end ifinfo@setchapternewpage off@settitle @value{GDBN} Internals@syncodeindex fn cp@syncodeindex vr cp@titlepage@title @value{GDBN} Internals@subtitle{A guide to the internals of the GNU debugger}@author John Gilmore@author Cygnus Solutions@author Second Edition:@author Stan Shebs@author Cygnus Solutions@page@tex\def\$#1${{#1}}  % Kluge: collect RCS revision info without $...$\xdef\manvers{\$Revision$}  % For use in headers, footers too{\parskip=0pt\hfill Cygnus Solutions\par\hfill \manvers\par\hfill \TeX{}info \texinfoversion\par}@end tex@vskip 0pt plus 1filllCopyright @copyright{} 1990,1991,1992,1993,1994,1996,1998,1999,2000,2001,   2002, 2003, 2004  Free Software Foundation, Inc.Permission is granted to copy, distribute and/or modify this documentunder the terms of the GNU Free Documentation License, Version 1.1 orany later version published by the Free Software Foundation; with noInvariant Sections, with no Front-Cover Texts, and with no Back-CoverTexts.  A copy of the license is included in the section entitled ``GNUFree Documentation License''.@end titlepage@contents@node Top@c Perhaps this should be the title of the document (but only for info,@c not for TeX).  Existing GNU manuals seem inconsistent on this point.@top Scope of this DocumentThis document documents the internals of the GNU debugger, @value{GDBN}.  Itincludes description of @value{GDBN}'s key algorithms and operations, as wellas the mechanisms that adapt @value{GDBN} to specific hosts and targets.@menu* Requirements::* Overall Structure::* Algorithms::* User Interface::* libgdb::* Symbol Handling::* Language Support::* Host Definition::* Target Architecture Definition::* Target Vector Definition::* Native Debugging::* Support Libraries::* Coding::* Porting GDB::* Versions and Branches::* Releasing GDB::* Testsuite::* Hints::* GDB Observers::  @value{GDBN} Currently available observers* GNU Free Documentation License::  The license for this documentation* Index::@end menu@node Requirements@chapter Requirements@cindex requirements for @value{GDBN}Before diving into the internals, you should understand the formalrequirements and other expectations for @value{GDBN}.  Although someof these may seem obvious, there have been proposals for @value{GDBN}that have run counter to these requirements.First of all, @value{GDBN} is a debugger.  It's not designed to be afront panel for embedded systems.  It's not a text editor.  It's not ashell.  It's not a programming environment.@value{GDBN} is an interactive tool.  Although a batch mode isavailable, @value{GDBN}'s primary role is to interact with a humanprogrammer.@value{GDBN} should be responsive to the user.  A programmer hot onthe trail of a nasty bug, and operating under a looming deadline, isgoing to be very impatient of everything, including the response timeto debugger commands.@value{GDBN} should be relatively permissive, such as for expressions.While the compiler should be picky (or have the option to be madepicky), since source code lives for a long time usually, theprogrammer doing debugging shouldn't be spending time figuring out tomollify the debugger.@value{GDBN} will be called upon to deal with really large programs.Executable sizes of 50 to 100 megabytes occur regularly, and we'veheard reports of programs approaching 1 gigabyte in size.@value{GDBN} should be able to run everywhere.  No other debugger isavailable for even half as many configurations as @value{GDBN}supports.@node Overall Structure@chapter Overall Structure@value{GDBN} consists of three major subsystems: user interface,symbol handling (the @dfn{symbol side}), and target system handling (the@dfn{target side}).The user interface consists of several actual interfaces, plussupporting code.The symbol side consists of object file readers, debugging infointerpreters, symbol table management, source language expressionparsing, type and value printing.The target side consists of execution control, stack frame analysis, andphysical target manipulation.The target side/symbol side division is not formal, and there are anumber of exceptions.  For instance, core file support involves symbolicelements (the basic core file reader is in BFD) and target elements (itsupplies the contents of memory and the values of registers).  Instead,this division is useful for understanding how the minor subsystemsshould fit together.@section The Symbol SideThe symbolic side of @value{GDBN} can be thought of as ``everythingyou can do in @value{GDBN} without having a live program running''.For instance, you can look at the types of variables, and evaluatemany kinds of expressions.@section The Target SideThe target side of @value{GDBN} is the ``bits and bytes manipulator''.Although it may make reference to symbolic info here and there, mostof the target side will run with only a stripped executableavailable---or even no executable at all, in remote debugging cases.Operations such as disassembly, stack frame crawls, and registerdisplay, are able to work with no symbolic info at all.  In some cases,such as disassembly, @value{GDBN} will use symbolic info to present addressesrelative to symbols rather than as raw numbers, but it will work eitherway.@section Configurations@cindex host@cindex target@dfn{Host} refers to attributes of the system where @value{GDBN} runs.@dfn{Target} refers to the system where the program being debuggedexecutes.  In most cases they are the same machine, in which case athird type of @dfn{Native} attributes come into play.Defines and include files needed to build on the host are host support.Examples are tty support, system defined types, host byte order, hostfloat format.Defines and information needed to handle the target format are targetdependent.  Examples are the stack frame format, instruction set,breakpoint instruction, registers, and how to set up and tear down the stackto call a function.Information that is only needed when the host and target are the same,is native dependent.  One example is Unix child process support; if thehost and target are not the same, doing a fork to start the targetprocess is a bad idea.  The various macros needed for finding theregisters in the @code{upage}, running @code{ptrace}, and such are allin the native-dependent files.Another example of native-dependent code is support for features thatare really part of the target environment, but which require@code{#include} files that are only available on the host system.  Corefile handling and @code{setjmp} handling are two common cases.When you want to make @value{GDBN} work ``native'' on a particular machine, youhave to include all three kinds of information.@node Algorithms@chapter Algorithms@cindex algorithms@value{GDBN} uses a number of debugging-specific algorithms.  They areoften not very complicated, but get lost in the thicket of specialcases and real-world issues.  This chapter describes the basicalgorithms and mentions some of the specific target definitions thatthey use.@section Frames@cindex frame@cindex call stack frameA frame is a construct that @value{GDBN} uses to keep track of callingand called functions.@findex create_new_frame@vindex FRAME_FP@code{FRAME_FP} in the machine description has no meaning to themachine-independent part of @value{GDBN}, except that it is used whensetting up a new frame from scratch, as follows:@smallexamplecreate_new_frame (read_register (DEPRECATED_FP_REGNUM), read_pc ()));@end smallexample@cindex frame pointer registerOther than that, all the meaning imparted to @code{DEPRECATED_FP_REGNUM}is imparted by the machine-dependent code.  So,@code{DEPRECATED_FP_REGNUM} can have any value that is convenient forthe code that creates new frames.  (@code{create_new_frame} calls@code{DEPRECATED_INIT_EXTRA_FRAME_INFO} if it is defined; that is whereyou should use the @code{DEPRECATED_FP_REGNUM} value, if your frames arenonstandard.)@cindex frame chainGiven a @value{GDBN} frame, define @code{DEPRECATED_FRAME_CHAIN} todetermine the address of the calling function's frame.  This will beused to create a new @value{GDBN} frame struct, and then@code{DEPRECATED_INIT_EXTRA_FRAME_INFO} and@code{DEPRECATED_INIT_FRAME_PC} will be called for the new frame.@section Breakpoint Handling@cindex breakpointsIn general, a breakpoint is a user-designated location in the programwhere the user wants to regain control if program execution ever reachesthat location.There are two main ways to implement breakpoints; either as ``hardware''breakpoints or as ``software'' breakpoints.@cindex hardware breakpoints@cindex program counterHardware breakpoints are sometimes available as a builtin debuggingfeatures with some chips.  Typically these work by having dedicatedregister into which the breakpoint address may be stored.  If the PC(shorthand for @dfn{program counter})ever matches a value in a breakpoint registers, the CPU raises anexception and reports it to @value{GDBN}.Another possibility is when an emulator is in use; many emulatorsinclude circuitry that watches the address lines coming out from theprocessor, and force it to stop if the address matches a breakpoint'saddress.A third possibility is that the target already has the ability to dobreakpoints somehow; for instance, a ROM monitor may do its ownsoftware breakpoints.  So although these are not literally ``hardwarebreakpoints'', from @value{GDBN}'s point of view they work the same;@value{GDBN} need not do anything more than set the breakpoint and waitfor something to happen.Since they depend on hardware resources, hardware breakpoints may belimited in number; when the user asks for more, @value{GDBN} willstart trying to set software breakpoints.  (On some architectures,notably the 32-bit x86 platforms, @value{GDBN} cannot always knowwhether there's enough hardware resources to insert all the hardwarebreakpoints and watchpoints.  On those platforms, @value{GDBN} printsan error message only when the program being debugged is continued.)@cindex software breakpointsSoftware breakpoints require @value{GDBN} to do somewhat more work.The basic theory is that @value{GDBN} will replace a programinstruction with a trap, illegal divide, or some other instructionthat will cause an exception, and then when it's encountered,@value{GDBN} will take the exception and stop the program.  When theuser says to continue, @value{GDBN} will restore the originalinstruction, single-step, re-insert the trap, and continue on.Since it literally overwrites the program being tested, the program areamust be writable, so this technique won't work on programs in ROM.  Itcan also distort the behavior of programs that examine themselves,although such a situation would be highly unusual.Also, the software breakpoint instruction should be the smallest size ofinstruction, so it doesn't overwrite an instruction that might be a jumptarget, and cause disaster when the program jumps into the middle of thebreakpoint instruction.  (Strictly speaking, the breakpoint must be nolarger than the smallest interval between instructions that may be jumptargets; perhaps there is an architecture where only even-numberedinstructions may jumped to.)  Note that it's possible for an instructionset not to have any instructions usable for a software breakpoint,although in practice only the ARC has failed to define such aninstruction.@findex BREAKPOINTThe basic definition of the software breakpoint is the macro@code{BREAKPOINT}.Basic breakpoint object handling is in @file{breakpoint.c}.  However,much of the interesting breakpoint action is in @file{infrun.c}.@section Single Stepping@section Signal Handling@section Thread Handling@section Inferior Function Calls@section Longjmp Support

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -