This file is indexed.

/usr/share/doc/cc65-doc/html/debugging.html is in cc65-doc 2.16-2.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<HTML>
<HEAD>
 <LINK REL="stylesheet" TYPE="text/css" HREF="doc.css">
 <META NAME="GENERATOR" CONTENT="LinuxDoc-Tools 0.9.72">
 <TITLE>Using emulators with cc65</TITLE>
</HEAD>
<BODY>
<H1>Using emulators with cc65</H1>

<H2>
<A HREF="mailto:uz@cc65.org">Ullrich von Bassewitz</A></H2>2014-04-11
<HR>
<EM>How to debug your code using the VICE and Oricutron emulators.</EM>
<HR>
<P>
<H2><A NAME="toc1">1.</A> <A HREF="debugging.html#s1">Overview</A></H2>

<P>
<H2><A NAME="toc2">2.</A> <A HREF="debugging.html#s2">What is VICE?</A></H2>

<P>
<H2><A NAME="toc3">3.</A> <A HREF="debugging.html#s3">How to prepare your programs</A></H2>

<P>
<H2><A NAME="toc4">4.</A> <A HREF="debugging.html#s4">How to use the label file with VICE</A></H2>

<P>
<H2><A NAME="toc5">5.</A> <A HREF="debugging.html#s5">How to use the label file with Oricutron</A></H2>


<HR>
<H2><A NAME="s1">1.</A> <A HREF="#toc1">Overview</A></H2>


<P>This document describes how to debug your programs using the cc65 development
tools and the VICE CBM emulator.</P>



<H2><A NAME="s2">2.</A> <A HREF="#toc2">What is VICE?</A></H2>


<P>VICE is an emulator for many of the CBM machines. It runs on Unix, MS-DOS,
Win32, OS/2, Acorn RISC OS, BeOS, QNX 6.x, Amiga, GP2X and Mac OS X. It emulates
the Commodore 64, 128, VIC20, PET and the 600/700 machines. For more information
see the VICE home page:</P>
<P>
<A HREF="http://vice-emu.sourceforge.net/">http://vice-emu.sourceforge.net/</A>.</P>
<P>VICE has a builtin machine language monitor that may be used for debugging
your programs. Using an emulator for debugging has some advantages:</P>
<P>
<UL>
<LI>Since you're using a crossassembler/-compiler anyway, you don't need to
transfer the program to the real machine until it is done.
</LI>
<LI>An emulator allows many things that are almost impossible one of the
original machines. You may set watchpoints (detect read or write access to
arbitary addresses), debug interrupt handlers and even debug routines that run
inside the 1541 floppy.
</LI>
<LI>You may use the label file generated by the linker to make much more use
from the monitor.
</LI>
</UL>
</P>



<H2><A NAME="s3">3.</A> <A HREF="#toc3">How to prepare your programs</A></H2>


<P>VICE support is mostly done via a label file that is generated by the linker
and that may be read by the VICE monitor, so it knows about your program.
Source level debugging is <CODE>not</CODE> available, you have to debug your programs
in the assembler view.</P>
<P>The first step is to generate object files that contain information about
<EM>all</EM> labels in your sources, not just the exported ones. This can be done
by several means:</P>
<P>
<UL>
<LI>Use the -g switch on the assembler command line.
</LI>
<LI>Use the
<BLOCKQUOTE><CODE>
<PRE>
      .debuginfo +
</PRE>
</CODE></BLOCKQUOTE>

command in your source.
</LI>
<LI>Use the <CODE>-g</CODE> switch when invoking the compiler. The compiler will
then place a <CODE>.debuginfo</CODE> command into the generated assembler source.
</LI>
</UL>
</P>
<P>So, if you have just C code, all you need is to invoke the compiler with
<CODE>-g</CODE>. If you're using assembler code, you have to use <CODE>-g</CODE> for the
assembler, or add "<CODE>.debuginfo on</CODE>" to your source files. Since the
generated debug info is not appended to the generated executables, it is a
good idea to always use <CODE>-g</CODE>. It makes the object files and libraries
slightly larger (~30%), but this is usually not a problem.</P>
<P>The second step is to tell the linker that it should generate a VICE label
file. This is done by the <CODE>-Ln</CODE> switch followed by the name of the label
file (I'm usually using a <CODE>.lbl</CODE> extension for these files). An example for
a linker command line would be:</P>
<P>
<BLOCKQUOTE><CODE>
<PRE>
    ld65 -o hello -t c64 -Ln hello.lbl -m hello.map hello.o c64.lib
</PRE>
</CODE></BLOCKQUOTE>

or
<BLOCKQUOTE><CODE>
<PRE>
    ld65 -o hello.tap -t atmos -Ln hello.sym -m hello.map hello.o atmos.lib
</PRE>
</CODE></BLOCKQUOTE>
</P>
<P>This will generate a file named hello.lbl that contains all symbols used in
your program.</P>
<P><B>Note</B>: The runtime libraries and startup files were generated with
debug info, so you don't have to care about this.</P>



<H2><A NAME="s4">4.</A> <A HREF="#toc4">How to use the label file with VICE</A></H2>


<P>Load your program, then enter the monitor and use the "<CODE>ll</CODE>" command to
load your label file like this:</P>
<P>
<BLOCKQUOTE><CODE>
<PRE>
        ll "hello.lbl"
</PRE>
</CODE></BLOCKQUOTE>
</P>
<P>You will get lots of warnings and even a few errors. You may ignore safely all
these warnings and errors as long as they reference any problems VICE thinks
it has with the labels.</P>
<P>After loading the labels, they are used by VICE in the disassembler listing,
and you may use them whereever you need to specify an address. Try</P>
<P>
<BLOCKQUOTE><CODE>
<PRE>
        d ._main
</PRE>
</CODE></BLOCKQUOTE>
</P>
<P>as an example (note that VICE needs a leading dot before all labels, and that
the compiler prepends an underline under most named labels).</P>



<H2><A NAME="s5">5.</A> <A HREF="#toc5">How to use the label file with Oricutron</A></H2>


<P>Load your program, then enter the monitor and use the "<CODE>sl</CODE>" command to
load your label file like this:</P>
<P>
<BLOCKQUOTE><CODE>
<PRE>
        sl hello.sym
</PRE>
</CODE></BLOCKQUOTE>
</P>
<P>After loading the labels, they are used by Oricutron in the disassembler listing,
and you may use them whereever you need to specify an address. Try</P>
<P>
<BLOCKQUOTE><CODE>
<PRE>
        d ._main
</PRE>
</CODE></BLOCKQUOTE>
</P>
<P>as an example (note that VICE needs a leading dot before all labels, and that
the compiler prepends an underline under most named labels).</P>



</BODY>
</HTML>