gdb.pdf

(2078 KB) Pobierz
669379945 UNPDF
Debuggingwithgdb ThegnuSource-LevelDebugger
NinthEdition,forgdbversion6.8
RichardStallman,RolandPesch,StanShebs,etal.
 
(Sendbugsandcommentsongdbtobug-gdb@gnu.org.)
Debuggingwithgdb
T E Xinfo2004-02-19.09
Copyright c 1988,1989,1990,1991,1992,1993,1994,1995,1996,1998,1999,2000,2001,
2002,2003,2004,2006FreeSoftwareFoundation,Inc.
PublishedbytheFreeSoftwareFoundation
51FranklinStreet,FifthFloor,Boston,MA02110-1301,USA
ISBN1-882114-77-9
Permissionisgrantedtocopy,distributeand/ormodifythisdocumentundertheterms
oftheGNUFreeDocumentationLicense,Version1.1oranylaterversionpublishedby
theFreeSoftwareFoundation;withtheInvariantSectionsbeing“FreeSoftware”and“Free
SoftwareNeedsFreeDocumentation”,withtheFront-CoverTextsbeing“AGNUManual,”
andwiththeBack-CoverTextsasin(a)below.
(a)TheFSF’sBack-CoverTextis:“YouarefreetocopyandmodifythisGNUMan-
ual.BuyingcopiesfromGNUPresssupportstheFSFindevelopingGNUandpromoting
softwarefreedom.”
ThiseditionoftheGDBmanualisdedicatedtothememoryofFredFish.Fredwasa
long-standingcontributortoGDBandtoFreesoftwareingeneral.Wewillmisshim.
i
TableofContents
Summaryofgdb.............................. 1
FreeSoftware.................................................... 1
FreeSoftwareNeedsFreeDocumentation.......................... 1
Contributorstogdb.............................................. 3
1ASamplegdbSession...................... 7
2GettingInandOutofgdb................ 11
2.1Invokinggdb.............................................. 11
2.1.1ChoosingFiles......................................... 12
2.1.2ChoosingModes....................................... 13
2.1.3WhatgdbDoesDuringStartup........................ 15
2.2Quittinggdb.............................................. 16
2.3ShellCommands........................................... 16
2.4LoggingOutput............................................ 16
3gdbCommands........................... 19
3.1CommandSyntax.......................................... 19
3.2CommandCompletion...................................... 19
3.3GettingHelp............................................... 21
4RunningProgramsUndergdb............. 25
4.1CompilingforDebugging................................... 25
4.2StartingyourProgram...................................... 26
4.3YourProgram’sArguments................................. 27
4.4YourProgram’sEnvironment............................... 28
4.5YourProgram’sWorkingDirectory.......................... 29
4.6YourProgram’sInputandOutput........................... 29
4.7DebugginganAlready-runningProcess...................... 30
4.8KillingtheChildProcess................................... 31
4.9DebuggingProgramswithMultipleThreads.................. 31
4.10DebuggingProgramswithMultipleProcesses................ 34
4.11SettingaBookmarktoReturntoLater..................... 35
4.11.1ANon-obviousBenefitofUsingCheckpoints............ 37
5StoppingandContinuing.................. 39
5.1Breakpoints,Watchpoints,andCatchpoints.................. 39
5.1.1SettingBreakpoints.................................... 40
5.1.2SettingWatchpoints................................... 44
5.1.3SettingCatchpoints.................................... 47
5.1.4DeletingBreakpoints................................... 48
ii Debuggingwithgdb
5.1.5DisablingBreakpoints.................................. 49
5.1.6BreakConditions...................................... 50
5.1.7BreakpointCommandLists............................. 51
5.1.8BreakpointMenus..................................... 52
5.1.9“Cannotinsertbreakpoints”............................ 53
5.1.10“Breakpointaddressadjusted...”....................... 53
5.2ContinuingandStepping.................................... 54
5.3Signals.................................................... 57
5.4StoppingandStartingMulti-threadPrograms................ 59
6ExaminingtheStack...................... 61
6.1StackFrames.............................................. 61
6.2Backtraces................................................. 62
6.3SelectingaFrame.......................................... 64
6.4InformationAboutaFrame................................. 65
7ExaminingSourceFiles................... 67
7.1PrintingSourceLines....................................... 67
7.2SpecifyingaLocation....................................... 68
7.3EditingSourceFiles........................................ 69
7.3.1ChoosingyourEditor.................................. 69
7.4SearchingSourceFiles...................................... 70
7.5SpecifyingSourceDirectories................................ 70
7.6SourceandMachineCode................................... 72
8ExaminingData.......................... 75
8.1Expressions................................................ 75
8.2ProgramVariables.......................................... 76
8.3ArtificialArrays............................................ 77
8.4OutputFormats............................................ 78
8.5ExaminingMemory........................................ 79
8.6AutomaticDisplay......................................... 81
8.7PrintSettings.............................................. 82
8.8ValueHistory.............................................. 88
8.9ConvenienceVariables...................................... 89
8.10Registers................................................. 90
8.11FloatingPointHardware................................... 92
8.12VectorUnit............................................... 92
8.13OperatingSystemAuxiliaryInformation.................... 92
8.14MemoryRegionAttributes................................. 93
8.14.1Attributes............................................ 94
8.14.1.1MemoryAccessMode............................ 94
8.14.1.2MemoryAccessSize.............................. 94
8.14.1.3DataCache...................................... 94
8.14.2MemoryAccessChecking.............................. 95
8.15CopyBetweenMemoryandaFile.......................... 95
8.16HowtoProduceaCoreFilefromYourProgram............. 96
Zgłoś jeśli naruszono regulamin