Intel XENIX 286 Programmers Guide (86) - Tenox.tc

Intel XENIX 286 Programmers Guide (86) - Tenox.tc Intel XENIX 286 Programmers Guide (86) - Tenox.tc

09.06.2013 Views

CHAPTER 6 adb: PROGRAM DEBUGGER adb is a debugging tool for C and assembly language programs. It controls program execution and provides commands to examine and modify a program's data and text areas. This chapter explains how to use adb. In particular, it explains how to • Start the debugger. • Display program instructions and data. • Run, set breakpoints, or single-step a program. • Patch program files and memory. It also illustrates techniques for debugging C programs and explains how to display information in non-ASCII data files. Starting and Stopping adb adb provides a powerful set of commands to examine, debug, and repair executable binary files as well as examine non-ASCII data files. To use these commands you must invoke adb from a shell command line and specify the file or files you wish to debug. The following sections explain how to start adb and describe the types of files available for debugging. Starting with a Program File You can debug any executable C or assembly language program file by typing a command line of the form adb [filename 1 where filename is the name of the program file to be debugged. adb opens the file and prepares its text (instructions) and data for subsequent debugging. For example, the command adb sample prepares the program sample for examination and execution. 6-1

adb: Program Debugger XENIX Programming Once started, adb normally prompts with an asterisk (*) and waits for you to type commands. If you have given the name of a file that does not exist or is in the wrong format, adb will display an error message first, then wait for commands. For example, if you invoke adb with the command adb sample and the file sample does not exist, adb displays the message "adb: cannot open 'sample' " · You may also start adb without a file name. In this case, adb searches for the default file a.out in your current working directory and prepares it for debugging. Thus, the command a db is the same as typing adb a.out adb displays an error message and waits for a com mand if the a.out file does not exist. Sta rting with a Core Image File adb can also examine the core image files of programs that caused fatal system errors. Core image files contain the contents of the CPU registers, stack, and memory areas of the program at the time of the error and provide a way to determine the cause of an error. To examine a core image file with its corresponding program, you must give the name of both the core file and the program file. The command line has the form adb programfile corefile where programfile is the program that caused the error, and corefile is the core image file generated by the system. adb then uses information from both files to provide responses to your commands. If you do not give a core image file, adb searches for the default core file, named core, in your current working directory. If it is found, adb uses it regardless of whether or not the file belongs to the given program. You can prevent adb from opening this file by using the hyphen (-) in place of the core file name. For example, the command adb sample - prevents adb from searching your current working directory for a core file. 6-2

CHAPTER 6<br />

adb: PROGRAM DEBUGGER<br />

adb is a debugging tool for C and assembly language programs. It controls program<br />

execution and provides commands to examine and modify a program's data and text<br />

areas.<br />

This chapter explains how to use adb. In particular, it explains how to<br />

• Start the debugger.<br />

• Display program instructions and data.<br />

• Run, set breakpoints, or single-step a program.<br />

• Pa<strong>tc</strong>h program files and memory.<br />

It also illustrates techniques for debugging C programs and explains how to display<br />

information in non-ASCII data files.<br />

Starting and Stopping adb<br />

adb provides a powerful set of commands to examine, debug, and repair executable<br />

binary files as well as examine non-ASCII data files. To use these commands you must<br />

invoke adb from a shell command line and specify the file or files you wish to debug.<br />

The following sections explain how to start adb and describe the types of files available<br />

for debugging.<br />

Starting with a Program File<br />

You can debug any executable C or assembly language program file by typing a<br />

command line of the form<br />

adb [filename 1<br />

where filename is the name of the program file to be debugged. adb opens the file and<br />

prepares its text (instructions) and data for subsequent debugging. For example, the<br />

command<br />

adb sample<br />

prepares the program sample for examination and execution.<br />

6-1

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!