==>'
998 |
|
|
`
|
999 |
|
|
|
1000 |
|
|
`
|
1001 |
|
|
`{ }'
|
1002 |
|
|
|
1003 |
|
|
` ==>'
|
1004 |
|
|
` '
|
1005 |
|
|
|
1006 |
|
|
` ==>'
|
1007 |
|
|
`{}'
|
1008 |
|
|
|
1009 |
|
|
4.2.2 General Conventions
|
1010 |
|
|
-------------------------
|
1011 |
|
|
|
1012 |
|
|
Most `ui_out' routines are of type `void', the exceptions are
|
1013 |
|
|
`ui_out_stream_new' (which returns a pointer to the newly created
|
1014 |
|
|
object) and the `make_cleanup' routines.
|
1015 |
|
|
|
1016 |
|
|
The first parameter is always the `ui_out' vector object, a pointer
|
1017 |
|
|
to a `struct ui_out'.
|
1018 |
|
|
|
1019 |
|
|
The FORMAT parameter is like in `printf' family of functions. When
|
1020 |
|
|
it is present, there must also be a variable list of arguments
|
1021 |
|
|
sufficient used to satisfy the `%' specifiers in the supplied format.
|
1022 |
|
|
|
1023 |
|
|
When a character string argument is not used in a `ui_out' function
|
1024 |
|
|
call, a `NULL' pointer has to be supplied instead.
|
1025 |
|
|
|
1026 |
|
|
4.2.3 Table, Tuple and List Functions
|
1027 |
|
|
-------------------------------------
|
1028 |
|
|
|
1029 |
|
|
This section introduces `ui_out' routines for building lists, tuples
|
1030 |
|
|
and tables. The routines to output the actual data items (fields) are
|
1031 |
|
|
presented in the next section.
|
1032 |
|
|
|
1033 |
|
|
To recap: A "tuple" is a sequence of "fields", each field containing
|
1034 |
|
|
information about an object; a "list" is a sequence of fields where
|
1035 |
|
|
each field describes an identical object.
|
1036 |
|
|
|
1037 |
|
|
Use the "table" functions when your output consists of a list of
|
1038 |
|
|
rows (tuples) and the console output should include a heading. Use this
|
1039 |
|
|
even when you are listing just one object but you still want the header.
|
1040 |
|
|
|
1041 |
|
|
Tables can not be nested. Tuples and lists can be nested up to a
|
1042 |
|
|
maximum of five levels.
|
1043 |
|
|
|
1044 |
|
|
The overall structure of the table output code is something like
|
1045 |
|
|
this:
|
1046 |
|
|
|
1047 |
|
|
ui_out_table_begin
|
1048 |
|
|
ui_out_table_header
|
1049 |
|
|
...
|
1050 |
|
|
ui_out_table_body
|
1051 |
|
|
ui_out_tuple_begin
|
1052 |
|
|
ui_out_field_*
|
1053 |
|
|
...
|
1054 |
|
|
ui_out_tuple_end
|
1055 |
|
|
...
|
1056 |
|
|
ui_out_table_end
|
1057 |
|
|
|
1058 |
|
|
Here is the description of table-, tuple- and list-related `ui_out'
|
1059 |
|
|
functions:
|
1060 |
|
|
|
1061 |
|
|
-- Function: void ui_out_table_begin (struct ui_out *UIOUT, int
|
1062 |
|
|
NBROFCOLS, int NR_ROWS, const char *TBLID)
|
1063 |
|
|
The function `ui_out_table_begin' marks the beginning of the output
|
1064 |
|
|
of a table. It should always be called before any other `ui_out'
|
1065 |
|
|
function for a given table. NBROFCOLS is the number of columns in
|
1066 |
|
|
the table. NR_ROWS is the number of rows in the table. TBLID is
|
1067 |
|
|
an optional string identifying the table. The string pointed to
|
1068 |
|
|
by TBLID is copied by the implementation of `ui_out_table_begin',
|
1069 |
|
|
so the application can free the string if it was `malloc'ed.
|
1070 |
|
|
|
1071 |
|
|
The companion function `ui_out_table_end', described below, marks
|
1072 |
|
|
the end of the table's output.
|
1073 |
|
|
|
1074 |
|
|
-- Function: void ui_out_table_header (struct ui_out *UIOUT, int
|
1075 |
|
|
WIDTH, enum ui_align ALIGNMENT, const char *COLHDR)
|
1076 |
|
|
`ui_out_table_header' provides the header information for a single
|
1077 |
|
|
table column. You call this function several times, one each for
|
1078 |
|
|
every column of the table, after `ui_out_table_begin', but before
|
1079 |
|
|
`ui_out_table_body'.
|
1080 |
|
|
|
1081 |
|
|
The value of WIDTH gives the column width in characters. The
|
1082 |
|
|
value of ALIGNMENT is one of `left', `center', and `right', and it
|
1083 |
|
|
specifies how to align the header: left-justify, center, or
|
1084 |
|
|
right-justify it. COLHDR points to a string that specifies the
|
1085 |
|
|
column header; the implementation copies that string, so column
|
1086 |
|
|
header strings in `malloc'ed storage can be freed after the call.
|
1087 |
|
|
|
1088 |
|
|
-- Function: void ui_out_table_body (struct ui_out *UIOUT)
|
1089 |
|
|
This function delimits the table header from the table body.
|
1090 |
|
|
|
1091 |
|
|
-- Function: void ui_out_table_end (struct ui_out *UIOUT)
|
1092 |
|
|
This function signals the end of a table's output. It should be
|
1093 |
|
|
called after the table body has been produced by the list and
|
1094 |
|
|
field output functions.
|
1095 |
|
|
|
1096 |
|
|
There should be exactly one call to `ui_out_table_end' for each
|
1097 |
|
|
call to `ui_out_table_begin', otherwise the `ui_out' functions
|
1098 |
|
|
will signal an internal error.
|
1099 |
|
|
|
1100 |
|
|
The output of the tuples that represent the table rows must follow
|
1101 |
|
|
the call to `ui_out_table_body' and precede the call to
|
1102 |
|
|
`ui_out_table_end'. You build a tuple by calling `ui_out_tuple_begin'
|
1103 |
|
|
and `ui_out_tuple_end', with suitable calls to functions which actually
|
1104 |
|
|
output fields between them.
|
1105 |
|
|
|
1106 |
|
|
-- Function: void ui_out_tuple_begin (struct ui_out *UIOUT, const char
|
1107 |
|
|
*ID)
|
1108 |
|
|
This function marks the beginning of a tuple output. ID points to
|
1109 |
|
|
an optional string that identifies the tuple; it is copied by the
|
1110 |
|
|
implementation, and so strings in `malloc'ed storage can be freed
|
1111 |
|
|
after the call.
|
1112 |
|
|
|
1113 |
|
|
-- Function: void ui_out_tuple_end (struct ui_out *UIOUT)
|
1114 |
|
|
This function signals an end of a tuple output. There should be
|
1115 |
|
|
exactly one call to `ui_out_tuple_end' for each call to
|
1116 |
|
|
`ui_out_tuple_begin', otherwise an internal GDB error will be
|
1117 |
|
|
signaled.
|
1118 |
|
|
|
1119 |
|
|
-- Function: struct cleanup *make_cleanup_ui_out_tuple_begin_end
|
1120 |
|
|
(struct ui_out *UIOUT, const char *ID)
|
1121 |
|
|
This function first opens the tuple and then establishes a cleanup
|
1122 |
|
|
(*note Cleanups: Coding.) to close the tuple. It provides a
|
1123 |
|
|
convenient and correct implementation of the non-portable(1) code
|
1124 |
|
|
sequence:
|
1125 |
|
|
struct cleanup *old_cleanup;
|
1126 |
|
|
ui_out_tuple_begin (uiout, "...");
|
1127 |
|
|
old_cleanup = make_cleanup ((void(*)(void *)) ui_out_tuple_end,
|
1128 |
|
|
uiout);
|
1129 |
|
|
|
1130 |
|
|
-- Function: void ui_out_list_begin (struct ui_out *UIOUT, const char
|
1131 |
|
|
*ID)
|
1132 |
|
|
This function marks the beginning of a list output. ID points to
|
1133 |
|
|
an optional string that identifies the list; it is copied by the
|
1134 |
|
|
implementation, and so strings in `malloc'ed storage can be freed
|
1135 |
|
|
after the call.
|
1136 |
|
|
|
1137 |
|
|
-- Function: void ui_out_list_end (struct ui_out *UIOUT)
|
1138 |
|
|
This function signals an end of a list output. There should be
|
1139 |
|
|
exactly one call to `ui_out_list_end' for each call to
|
1140 |
|
|
`ui_out_list_begin', otherwise an internal GDB error will be
|
1141 |
|
|
signaled.
|
1142 |
|
|
|
1143 |
|
|
-- Function: struct cleanup *make_cleanup_ui_out_list_begin_end
|
1144 |
|
|
(struct ui_out *UIOUT, const char *ID)
|
1145 |
|
|
Similar to `make_cleanup_ui_out_tuple_begin_end', this function
|
1146 |
|
|
opens a list and then establishes cleanup (*note Cleanups: Coding.)
|
1147 |
|
|
that will close the list.
|
1148 |
|
|
|
1149 |
|
|
4.2.4 Item Output Functions
|
1150 |
|
|
---------------------------
|
1151 |
|
|
|
1152 |
|
|
The functions described below produce output for the actual data items,
|
1153 |
|
|
or fields, which contain information about the object.
|
1154 |
|
|
|
1155 |
|
|
Choose the appropriate function accordingly to your particular needs.
|
1156 |
|
|
|
1157 |
|
|
-- Function: void ui_out_field_fmt (struct ui_out *UIOUT, char
|
1158 |
|
|
*FLDNAME, char *FORMAT, ...)
|
1159 |
|
|
This is the most general output function. It produces the
|
1160 |
|
|
representation of the data in the variable-length argument list
|
1161 |
|
|
according to formatting specifications in FORMAT, a `printf'-like
|
1162 |
|
|
format string. The optional argument FLDNAME supplies the name of
|
1163 |
|
|
the field. The data items themselves are supplied as additional
|
1164 |
|
|
arguments after FORMAT.
|
1165 |
|
|
|
1166 |
|
|
This generic function should be used only when it is not possible
|
1167 |
|
|
to use one of the specialized versions (see below).
|
1168 |
|
|
|
1169 |
|
|
-- Function: void ui_out_field_int (struct ui_out *UIOUT, const char
|
1170 |
|
|
*FLDNAME, int VALUE)
|
1171 |
|
|
This function outputs a value of an `int' variable. It uses the
|
1172 |
|
|
`"%d"' output conversion specification. FLDNAME specifies the
|
1173 |
|
|
name of the field.
|
1174 |
|
|
|
1175 |
|
|
-- Function: void ui_out_field_fmt_int (struct ui_out *UIOUT, int
|
1176 |
|
|
WIDTH, enum ui_align ALIGNMENT, const char *FLDNAME, int
|
1177 |
|
|
VALUE)
|
1178 |
|
|
This function outputs a value of an `int' variable. It differs
|
1179 |
|
|
from `ui_out_field_int' in that the caller specifies the desired
|
1180 |
|
|
WIDTH and ALIGNMENT of the output. FLDNAME specifies the name of
|
1181 |
|
|
the field.
|
1182 |
|
|
|
1183 |
|
|
-- Function: void ui_out_field_core_addr (struct ui_out *UIOUT, const
|
1184 |
|
|
char *FLDNAME, CORE_ADDR ADDRESS)
|
1185 |
|
|
This function outputs an address.
|
1186 |
|
|
|
1187 |
|
|
-- Function: void ui_out_field_string (struct ui_out *UIOUT, const
|
1188 |
|
|
char *FLDNAME, const char *STRING)
|
1189 |
|
|
This function outputs a string using the `"%s"' conversion
|
1190 |
|
|
specification.
|
1191 |
|
|
|
1192 |
|
|
Sometimes, there's a need to compose your output piece by piece using
|
1193 |
|
|
functions that operate on a stream, such as `value_print' or
|
1194 |
|
|
`fprintf_symbol_filtered'. These functions accept an argument of the
|
1195 |
|
|
type `struct ui_file *', a pointer to a `ui_file' object used to store
|
1196 |
|
|
the data stream used for the output. When you use one of these
|
1197 |
|
|
functions, you need a way to pass their results stored in a `ui_file'
|
1198 |
|
|
object to the `ui_out' functions. To this end, you first create a
|
1199 |
|
|
`ui_stream' object by calling `ui_out_stream_new', pass the `stream'
|
1200 |
|
|
member of that `ui_stream' object to `value_print' and similar
|
1201 |
|
|
functions, and finally call `ui_out_field_stream' to output the field
|
1202 |
|
|
you constructed. When the `ui_stream' object is no longer needed, you
|
1203 |
|
|
should destroy it and free its memory by calling `ui_out_stream_delete'.
|
1204 |
|
|
|
1205 |
|
|
-- Function: struct ui_stream *ui_out_stream_new (struct ui_out *UIOUT)
|
1206 |
|
|
This function creates a new `ui_stream' object which uses the same
|
1207 |
|
|
output methods as the `ui_out' object whose pointer is passed in
|
1208 |
|
|
UIOUT. It returns a pointer to the newly created `ui_stream'
|
1209 |
|
|
object.
|
1210 |
|
|
|
1211 |
|
|
-- Function: void ui_out_stream_delete (struct ui_stream *STREAMBUF)
|
1212 |
|
|
This functions destroys a `ui_stream' object specified by
|
1213 |
|
|
STREAMBUF.
|
1214 |
|
|
|
1215 |
|
|
-- Function: void ui_out_field_stream (struct ui_out *UIOUT, const
|
1216 |
|
|
char *FIELDNAME, struct ui_stream *STREAMBUF)
|
1217 |
|
|
This function consumes all the data accumulated in
|
1218 |
|
|
`streambuf->stream' and outputs it like `ui_out_field_string'
|
1219 |
|
|
does. After a call to `ui_out_field_stream', the accumulated data
|
1220 |
|
|
no longer exists, but the stream is still valid and may be used
|
1221 |
|
|
for producing more fields.
|
1222 |
|
|
|
1223 |
|
|
*Important:* If there is any chance that your code could bail out
|
1224 |
|
|
before completing output generation and reaching the point where
|
1225 |
|
|
`ui_out_stream_delete' is called, it is necessary to set up a cleanup,
|
1226 |
|
|
to avoid leaking memory and other resources. Here's a skeleton code to
|
1227 |
|
|
do that:
|
1228 |
|
|
|
1229 |
|
|
struct ui_stream *mybuf = ui_out_stream_new (uiout);
|
1230 |
|
|
struct cleanup *old = make_cleanup (ui_out_stream_delete, mybuf);
|
1231 |
|
|
...
|
1232 |
|
|
do_cleanups (old);
|
1233 |
|
|
|
1234 |
|
|
If the function already has the old cleanup chain set (for other
|
1235 |
|
|
kinds of cleanups), you just have to add your cleanup to it:
|
1236 |
|
|
|
1237 |
|
|
mybuf = ui_out_stream_new (uiout);
|
1238 |
|
|
make_cleanup (ui_out_stream_delete, mybuf);
|
1239 |
|
|
|
1240 |
|
|
Note that with cleanups in place, you should not call
|
1241 |
|
|
`ui_out_stream_delete' directly, or you would attempt to free the same
|
1242 |
|
|
buffer twice.
|
1243 |
|
|
|
1244 |
|
|
4.2.5 Utility Output Functions
|
1245 |
|
|
------------------------------
|
1246 |
|
|
|
1247 |
|
|
-- Function: void ui_out_field_skip (struct ui_out *UIOUT, const char
|
1248 |
|
|
*FLDNAME)
|
1249 |
|
|
This function skips a field in a table. Use it if you have to
|
1250 |
|
|
leave an empty field without disrupting the table alignment. The
|
1251 |
|
|
argument FLDNAME specifies a name for the (missing) filed.
|
1252 |
|
|
|
1253 |
|
|
-- Function: void ui_out_text (struct ui_out *UIOUT, const char
|
1254 |
|
|
*STRING)
|
1255 |
|
|
This function outputs the text in STRING in a way that makes it
|
1256 |
|
|
easy to be read by humans. For example, the console
|
1257 |
|
|
implementation of this method filters the text through a built-in
|
1258 |
|
|
pager, to prevent it from scrolling off the visible portion of the
|
1259 |
|
|
screen.
|
1260 |
|
|
|
1261 |
|
|
Use this function for printing relatively long chunks of text
|
1262 |
|
|
around the actual field data: the text it produces is not aligned
|
1263 |
|
|
according to the table's format. Use `ui_out_field_string' to
|
1264 |
|
|
output a string field, and use `ui_out_message', described below,
|
1265 |
|
|
to output short messages.
|
1266 |
|
|
|
1267 |
|
|
-- Function: void ui_out_spaces (struct ui_out *UIOUT, int NSPACES)
|
1268 |
|
|
This function outputs NSPACES spaces. It is handy to align the
|
1269 |
|
|
text produced by `ui_out_text' with the rest of the table or list.
|
1270 |
|
|
|
1271 |
|
|
-- Function: void ui_out_message (struct ui_out *UIOUT, int VERBOSITY,
|
1272 |
|
|
const char *FORMAT, ...)
|
1273 |
|
|
This function produces a formatted message, provided that the
|
1274 |
|
|
current verbosity level is at least as large as given by
|
1275 |
|
|
VERBOSITY. The current verbosity level is specified by the user
|
1276 |
|
|
with the `set verbositylevel' command.(2)
|
1277 |
|
|
|
1278 |
|
|
-- Function: void ui_out_wrap_hint (struct ui_out *UIOUT, char *INDENT)
|
1279 |
|
|
This function gives the console output filter (a paging filter) a
|
1280 |
|
|
hint of where to break lines which are too long. Ignored for all
|
1281 |
|
|
other output consumers. INDENT, if non-`NULL', is the string to
|
1282 |
|
|
be printed to indent the wrapped text on the next line; it must
|
1283 |
|
|
remain accessible until the next call to `ui_out_wrap_hint', or
|
1284 |
|
|
until an explicit newline is produced by one of the other
|
1285 |
|
|
functions. If INDENT is `NULL', the wrapped text will not be
|
1286 |
|
|
indented.
|
1287 |
|
|
|
1288 |
|
|
-- Function: void ui_out_flush (struct ui_out *UIOUT)
|
1289 |
|
|
This function flushes whatever output has been accumulated so far,
|
1290 |
|
|
if the UI buffers output.
|
1291 |
|
|
|
1292 |
|
|
4.2.6 Examples of Use of `ui_out' functions
|
1293 |
|
|
-------------------------------------------
|
1294 |
|
|
|
1295 |
|
|
This section gives some practical examples of using the `ui_out'
|
1296 |
|
|
functions to generalize the old console-oriented code in GDB. The
|
1297 |
|
|
examples all come from functions defined on the `breakpoints.c' file.
|
1298 |
|
|
|
1299 |
|
|
This example, from the `breakpoint_1' function, shows how to produce
|
1300 |
|
|
a table.
|
1301 |
|
|
|
1302 |
|
|
The original code was:
|
1303 |
|
|
|
1304 |
|
|
if (!found_a_breakpoint++)
|
1305 |
|
|
{
|
1306 |
|
|
annotate_breakpoints_headers ();
|
1307 |
|
|
|
1308 |
|
|
annotate_field (0);
|
1309 |
|
|
printf_filtered ("Num ");
|
1310 |
|
|
annotate_field (1);
|
1311 |
|
|
printf_filtered ("Type ");
|
1312 |
|
|
annotate_field (2);
|
1313 |
|
|
printf_filtered ("Disp ");
|
1314 |
|
|
annotate_field (3);
|
1315 |
|
|
printf_filtered ("Enb ");
|
1316 |
|
|
if (addressprint)
|
1317 |
|
|
{
|
1318 |
|
|
annotate_field (4);
|
1319 |
|
|
printf_filtered ("Address ");
|
1320 |
|
|
}
|
1321 |
|
|
annotate_field (5);
|
1322 |
|
|
printf_filtered ("What\n");
|
1323 |
|
|
|
1324 |
|
|
annotate_breakpoints_table ();
|
1325 |
|
|
}
|
1326 |
|
|
|
1327 |
|
|
Here's the new version:
|
1328 |
|
|
|
1329 |
|
|
nr_printable_breakpoints = ...;
|
1330 |
|
|
|
1331 |
|
|
if (addressprint)
|
1332 |
|
|
ui_out_table_begin (ui, 6, nr_printable_breakpoints, "BreakpointTable");
|
1333 |
|
|
else
|
1334 |
|
|
ui_out_table_begin (ui, 5, nr_printable_breakpoints, "BreakpointTable");
|
1335 |
|
|
|
1336 |
|
|
if (nr_printable_breakpoints > 0)
|
1337 |
|
|
annotate_breakpoints_headers ();
|
1338 |
|
|
if (nr_printable_breakpoints > 0)
|
1339 |
|
|
annotate_field (0);
|
1340 |
|
|
ui_out_table_header (uiout, 3, ui_left, "number", "Num"); /* 1 */
|
1341 |
|
|
if (nr_printable_breakpoints > 0)
|
1342 |
|
|
annotate_field (1);
|
1343 |
|
|
ui_out_table_header (uiout, 14, ui_left, "type", "Type"); /* 2 */
|
1344 |
|
|
if (nr_printable_breakpoints > 0)
|
1345 |
|
|
annotate_field (2);
|
1346 |
|
|
ui_out_table_header (uiout, 4, ui_left, "disp", "Disp"); /* 3 */
|
1347 |
|
|
if (nr_printable_breakpoints > 0)
|
1348 |
|
|
annotate_field (3);
|
1349 |
|
|
ui_out_table_header (uiout, 3, ui_left, "enabled", "Enb"); /* 4 */
|
1350 |
|
|
if (addressprint)
|
1351 |
|
|
{
|
1352 |
|
|
if (nr_printable_breakpoints > 0)
|
1353 |
|
|
annotate_field (4);
|
1354 |
|
|
if (gdbarch_addr_bit (current_gdbarch) <= 32)
|
1355 |
|
|
ui_out_table_header (uiout, 10, ui_left, "addr", "Address");/* 5 */
|
1356 |
|
|
else
|
1357 |
|
|
ui_out_table_header (uiout, 18, ui_left, "addr", "Address");/* 5 */
|
1358 |
|
|
}
|
1359 |
|
|
if (nr_printable_breakpoints > 0)
|
1360 |
|
|
annotate_field (5);
|
1361 |
|
|
ui_out_table_header (uiout, 40, ui_noalign, "what", "What"); /* 6 */
|
1362 |
|
|
ui_out_table_body (uiout);
|
1363 |
|
|
if (nr_printable_breakpoints > 0)
|
1364 |
|
|
annotate_breakpoints_table ();
|
1365 |
|
|
|
1366 |
|
|
This example, from the `print_one_breakpoint' function, shows how to
|
1367 |
|
|
produce the actual data for the table whose structure was defined in
|
1368 |
|
|
the above example. The original code was:
|
1369 |
|
|
|
1370 |
|
|
annotate_record ();
|
1371 |
|
|
annotate_field (0);
|
1372 |
|
|
printf_filtered ("%-3d ", b->number);
|
1373 |
|
|
annotate_field (1);
|
1374 |
|
|
if ((int)b->type > (sizeof(bptypes)/sizeof(bptypes[0]))
|
1375 |
|
|
|| ((int) b->type != bptypes[(int) b->type].type))
|
1376 |
|
|
internal_error ("bptypes table does not describe type #%d.",
|
1377 |
|
|
(int)b->type);
|
1378 |
|
|
printf_filtered ("%-14s ", bptypes[(int)b->type].description);
|
1379 |
|
|
annotate_field (2);
|
1380 |
|
|
printf_filtered ("%-4s ", bpdisps[(int)b->disposition]);
|
1381 |
|
|
annotate_field (3);
|
1382 |
|
|
printf_filtered ("%-3c ", bpenables[(int)b->enable]);
|
1383 |
|
|
...
|
1384 |
|
|
|
1385 |
|
|
This is the new version:
|
1386 |
|
|
|
1387 |
|
|
annotate_record ();
|
1388 |
|
|
ui_out_tuple_begin (uiout, "bkpt");
|
1389 |
|
|
annotate_field (0);
|
1390 |
|
|
ui_out_field_int (uiout, "number", b->number);
|
1391 |
|
|
annotate_field (1);
|
1392 |
|
|
if (((int) b->type > (sizeof (bptypes) / sizeof (bptypes[0])))
|
1393 |
|
|
|| ((int) b->type != bptypes[(int) b->type].type))
|
1394 |
|
|
internal_error ("bptypes table does not describe type #%d.",
|
1395 |
|
|
(int) b->type);
|
1396 |
|
|
ui_out_field_string (uiout, "type", bptypes[(int)b->type].description);
|
1397 |
|
|
annotate_field (2);
|
1398 |
|
|
ui_out_field_string (uiout, "disp", bpdisps[(int)b->disposition]);
|
1399 |
|
|
annotate_field (3);
|
1400 |
|
|
ui_out_field_fmt (uiout, "enabled", "%c", bpenables[(int)b->enable]);
|
1401 |
|
|
...
|
1402 |
|
|
|
1403 |
|
|
This example, also from `print_one_breakpoint', shows how to produce
|
1404 |
|
|
a complicated output field using the `print_expression' functions which
|
1405 |
|
|
requires a stream to be passed. It also shows how to automate stream
|
1406 |
|
|
destruction with cleanups. The original code was:
|
1407 |
|
|
|
1408 |
|
|
annotate_field (5);
|
1409 |
|
|
print_expression (b->exp, gdb_stdout);
|
1410 |
|
|
|
1411 |
|
|
The new version is:
|
1412 |
|
|
|
1413 |
|
|
struct ui_stream *stb = ui_out_stream_new (uiout);
|
1414 |
|
|
struct cleanup *old_chain = make_cleanup_ui_out_stream_delete (stb);
|
1415 |
|
|
...
|
1416 |
|
|
annotate_field (5);
|
1417 |
|
|
print_expression (b->exp, stb->stream);
|
1418 |
|
|
ui_out_field_stream (uiout, "what", local_stream);
|
1419 |
|
|
|
1420 |
|
|
This example, also from `print_one_breakpoint', shows how to use
|
1421 |
|
|
`ui_out_text' and `ui_out_field_string'. The original code was:
|
1422 |
|
|
|
1423 |
|
|
annotate_field (5);
|
1424 |
|
|
if (b->dll_pathname == NULL)
|
1425 |
|
|
printf_filtered (" ");
|
1426 |
|
|
else
|
1427 |
|
|
printf_filtered ("library \"%s\" ", b->dll_pathname);
|
1428 |
|
|
|
1429 |
|
|
It became:
|
1430 |
|
|
|
1431 |
|
|
annotate_field (5);
|
1432 |
|
|
if (b->dll_pathname == NULL)
|
1433 |
|
|
{
|
1434 |
|
|
ui_out_field_string (uiout, "what", "");
|
1435 |
|
|
ui_out_spaces (uiout, 1);
|
1436 |
|
|
}
|
1437 |
|
|
else
|
1438 |
|
|
{
|
1439 |
|
|
ui_out_text (uiout, "library \"");
|
1440 |
|
|
ui_out_field_string (uiout, "what", b->dll_pathname);
|
1441 |
|
|
ui_out_text (uiout, "\" ");
|
1442 |
|
|
}
|
1443 |
|
|
|
1444 |
|
|
The following example from `print_one_breakpoint' shows how to use
|
1445 |
|
|
`ui_out_field_int' and `ui_out_spaces'. The original code was:
|
1446 |
|
|
|
1447 |
|
|
annotate_field (5);
|
1448 |
|
|
if (b->forked_inferior_pid != 0)
|
1449 |
|
|
printf_filtered ("process %d ", b->forked_inferior_pid);
|
1450 |
|
|
|
1451 |
|
|
It became:
|
1452 |
|
|
|
1453 |
|
|
annotate_field (5);
|
1454 |
|
|
if (b->forked_inferior_pid != 0)
|
1455 |
|
|
{
|
1456 |
|
|
ui_out_text (uiout, "process ");
|
1457 |
|
|
ui_out_field_int (uiout, "what", b->forked_inferior_pid);
|
1458 |
|
|
ui_out_spaces (uiout, 1);
|
1459 |
|
|
}
|
1460 |
|
|
|
1461 |
|
|
Here's an example of using `ui_out_field_string'. The original code
|
1462 |
|
|
was:
|
1463 |
|
|
|
1464 |
|
|
annotate_field (5);
|
1465 |
|
|
if (b->exec_pathname != NULL)
|
1466 |
|
|
printf_filtered ("program \"%s\" ", b->exec_pathname);
|
1467 |
|
|
|
1468 |
|
|
It became:
|
1469 |
|
|
|
1470 |
|
|
annotate_field (5);
|
1471 |
|
|
if (b->exec_pathname != NULL)
|
1472 |
|
|
{
|
1473 |
|
|
ui_out_text (uiout, "program \"");
|
1474 |
|
|
ui_out_field_string (uiout, "what", b->exec_pathname);
|
1475 |
|
|
ui_out_text (uiout, "\" ");
|
1476 |
|
|
}
|
1477 |
|
|
|
1478 |
|
|
Finally, here's an example of printing an address. The original
|
1479 |
|
|
code:
|
1480 |
|
|
|
1481 |
|
|
annotate_field (4);
|
1482 |
|
|
printf_filtered ("%s ",
|
1483 |
|
|
hex_string_custom ((unsigned long) b->address, 8));
|
1484 |
|
|
|
1485 |
|
|
It became:
|
1486 |
|
|
|
1487 |
|
|
annotate_field (4);
|
1488 |
|
|
ui_out_field_core_addr (uiout, "Address", b->address);
|
1489 |
|
|
|
1490 |
|
|
4.3 Console Printing
|
1491 |
|
|
====================
|
1492 |
|
|
|
1493 |
|
|
4.4 TUI
|
1494 |
|
|
=======
|
1495 |
|
|
|
1496 |
|
|
---------- Footnotes ----------
|
1497 |
|
|
|
1498 |
|
|
(1) The function cast is not portable ISO C.
|
1499 |
|
|
|
1500 |
|
|
(2) As of this writing (April 2001), setting verbosity level is not
|
1501 |
|
|
yet implemented, and is always returned as zero. So calling
|
1502 |
|
|
`ui_out_message' with a VERBOSITY argument more than zero will cause
|
1503 |
|
|
the message to never be printed.
|
1504 |
|
|
|
1505 |
|
|
|
1506 |
|
|
File: gdbint.info, Node: libgdb, Next: Symbol Handling, Prev: User Interface, Up: Top
|
1507 |
|
|
|
1508 |
|
|
5 libgdb
|
1509 |
|
|
********
|
1510 |
|
|
|
1511 |
|
|
5.1 libgdb 1.0
|
1512 |
|
|
==============
|
1513 |
|
|
|
1514 |
|
|
`libgdb' 1.0 was an abortive project of years ago. The theory was to
|
1515 |
|
|
provide an API to GDB's functionality.
|
1516 |
|
|
|
1517 |
|
|
5.2 libgdb 2.0
|
1518 |
|
|
==============
|
1519 |
|
|
|
1520 |
|
|
`libgdb' 2.0 is an ongoing effort to update GDB so that is better able
|
1521 |
|
|
to support graphical and other environments.
|
1522 |
|
|
|
1523 |
|
|
Since `libgdb' development is on-going, its architecture is still
|
1524 |
|
|
evolving. The following components have so far been identified:
|
1525 |
|
|
|
1526 |
|
|
* Observer - `gdb-events.h'.
|
1527 |
|
|
|
1528 |
|
|
* Builder - `ui-out.h'
|
1529 |
|
|
|
1530 |
|
|
* Event Loop - `event-loop.h'
|
1531 |
|
|
|
1532 |
|
|
* Library - `gdb.h'
|
1533 |
|
|
|
1534 |
|
|
The model that ties these components together is described below.
|
1535 |
|
|
|
1536 |
|
|
5.3 The `libgdb' Model
|
1537 |
|
|
======================
|
1538 |
|
|
|
1539 |
|
|
A client of `libgdb' interacts with the library in two ways.
|
1540 |
|
|
|
1541 |
|
|
* As an observer (using `gdb-events') receiving notifications from
|
1542 |
|
|
`libgdb' of any internal state changes (break point changes, run
|
1543 |
|
|
state, etc).
|
1544 |
|
|
|
1545 |
|
|
* As a client querying `libgdb' (using the `ui-out' builder) to
|
1546 |
|
|
obtain various status values from GDB.
|
1547 |
|
|
|
1548 |
|
|
Since `libgdb' could have multiple clients (e.g., a GUI supporting
|
1549 |
|
|
the existing GDB CLI), those clients must co-operate when controlling
|
1550 |
|
|
`libgdb'. In particular, a client must ensure that `libgdb' is idle
|
1551 |
|
|
(i.e. no other client is using `libgdb') before responding to a
|
1552 |
|
|
`gdb-event' by making a query.
|
1553 |
|
|
|
1554 |
|
|
5.4 CLI support
|
1555 |
|
|
===============
|
1556 |
|
|
|
1557 |
|
|
At present GDB's CLI is very much entangled in with the core of
|
1558 |
|
|
`libgdb'. Consequently, a client wishing to include the CLI in their
|
1559 |
|
|
interface needs to carefully co-ordinate its own and the CLI's
|
1560 |
|
|
requirements.
|
1561 |
|
|
|
1562 |
|
|
It is suggested that the client set `libgdb' up to be bi-modal
|
1563 |
|
|
(alternate between CLI and client query modes). The notes below sketch
|
1564 |
|
|
out the theory:
|
1565 |
|
|
|
1566 |
|
|
* The client registers itself as an observer of `libgdb'.
|
1567 |
|
|
|
1568 |
|
|
* The client create and install `cli-out' builder using its own
|
1569 |
|
|
versions of the `ui-file' `gdb_stderr', `gdb_stdtarg' and
|
1570 |
|
|
`gdb_stdout' streams.
|
1571 |
|
|
|
1572 |
|
|
* The client creates a separate custom `ui-out' builder that is only
|
1573 |
|
|
used while making direct queries to `libgdb'.
|
1574 |
|
|
|
1575 |
|
|
When the client receives input intended for the CLI, it simply
|
1576 |
|
|
passes it along. Since the `cli-out' builder is installed by default,
|
1577 |
|
|
all the CLI output in response to that command is routed (pronounced
|
1578 |
|
|
rooted) through to the client controlled `gdb_stdout' et. al. streams.
|
1579 |
|
|
At the same time, the client is kept abreast of internal changes by
|
1580 |
|
|
virtue of being a `libgdb' observer.
|
1581 |
|
|
|
1582 |
|
|
The only restriction on the client is that it must wait until
|
1583 |
|
|
`libgdb' becomes idle before initiating any queries (using the client's
|
1584 |
|
|
custom builder).
|
1585 |
|
|
|
1586 |
|
|
5.5 `libgdb' components
|
1587 |
|
|
=======================
|
1588 |
|
|
|
1589 |
|
|
Observer - `gdb-events.h'
|
1590 |
|
|
-------------------------
|
1591 |
|
|
|
1592 |
|
|
`gdb-events' provides the client with a very raw mechanism that can be
|
1593 |
|
|
used to implement an observer. At present it only allows for one
|
1594 |
|
|
observer and that observer must, internally, handle the need to delay
|
1595 |
|
|
the processing of any event notifications until after `libgdb' has
|
1596 |
|
|
finished the current command.
|
1597 |
|
|
|
1598 |
|
|
Builder - `ui-out.h'
|
1599 |
|
|
--------------------
|
1600 |
|
|
|
1601 |
|
|
`ui-out' provides the infrastructure necessary for a client to create a
|
1602 |
|
|
builder. That builder is then passed down to `libgdb' when doing any
|
1603 |
|
|
queries.
|
1604 |
|
|
|
1605 |
|
|
Event Loop - `event-loop.h'
|
1606 |
|
|
---------------------------
|
1607 |
|
|
|
1608 |
|
|
`event-loop', currently non-re-entrant, provides a simple event loop.
|
1609 |
|
|
A client would need to either plug its self into this loop or,
|
1610 |
|
|
implement a new event-loop that GDB would use.
|
1611 |
|
|
|
1612 |
|
|
The event-loop will eventually be made re-entrant. This is so that
|
1613 |
|
|
GDB can better handle the problem of some commands blocking instead of
|
1614 |
|
|
returning.
|
1615 |
|
|
|
1616 |
|
|
Library - `gdb.h'
|
1617 |
|
|
-----------------
|
1618 |
|
|
|
1619 |
|
|
`libgdb' is the most obvious component of this system. It provides the
|
1620 |
|
|
query interface. Each function is parameterized by a `ui-out' builder.
|
1621 |
|
|
The result of the query is constructed using that builder before the
|
1622 |
|
|
query function returns.
|
1623 |
|
|
|
1624 |
|
|
|
1625 |
|
|
File: gdbint.info, Node: Symbol Handling, Next: Language Support, Prev: libgdb, Up: Top
|
1626 |
|
|
|
1627 |
|
|
6 Symbol Handling
|
1628 |
|
|
*****************
|
1629 |
|
|
|
1630 |
|
|
Symbols are a key part of GDB's operation. Symbols include variables,
|
1631 |
|
|
functions, and types.
|
1632 |
|
|
|
1633 |
|
|
6.1 Symbol Reading
|
1634 |
|
|
==================
|
1635 |
|
|
|
1636 |
|
|
GDB reads symbols from "symbol files". The usual symbol file is the
|
1637 |
|
|
file containing the program which GDB is debugging. GDB can be
|
1638 |
|
|
directed to use a different file for symbols (with the `symbol-file'
|
1639 |
|
|
command), and it can also read more symbols via the `add-file' and
|
1640 |
|
|
`load' commands, or while reading symbols from shared libraries.
|
1641 |
|
|
|
1642 |
|
|
Symbol files are initially opened by code in `symfile.c' using the
|
1643 |
|
|
BFD library (*note Support Libraries::). BFD identifies the type of
|
1644 |
|
|
the file by examining its header. `find_sym_fns' then uses this
|
1645 |
|
|
identification to locate a set of symbol-reading functions.
|
1646 |
|
|
|
1647 |
|
|
Symbol-reading modules identify themselves to GDB by calling
|
1648 |
|
|
`add_symtab_fns' during their module initialization. The argument to
|
1649 |
|
|
`add_symtab_fns' is a `struct sym_fns' which contains the name (or name
|
1650 |
|
|
prefix) of the symbol format, the length of the prefix, and pointers to
|
1651 |
|
|
four functions. These functions are called at various times to process
|
1652 |
|
|
symbol files whose identification matches the specified prefix.
|
1653 |
|
|
|
1654 |
|
|
The functions supplied by each module are:
|
1655 |
|
|
|
1656 |
|
|
`XYZ_symfile_init(struct sym_fns *sf)'
|
1657 |
|
|
Called from `symbol_file_add' when we are about to read a new
|
1658 |
|
|
symbol file. This function should clean up any internal state
|
1659 |
|
|
(possibly resulting from half-read previous files, for example)
|
1660 |
|
|
and prepare to read a new symbol file. Note that the symbol file
|
1661 |
|
|
which we are reading might be a new "main" symbol file, or might
|
1662 |
|
|
be a secondary symbol file whose symbols are being added to the
|
1663 |
|
|
existing symbol table.
|
1664 |
|
|
|
1665 |
|
|
The argument to `XYZ_symfile_init' is a newly allocated `struct
|
1666 |
|
|
sym_fns' whose `bfd' field contains the BFD for the new symbol
|
1667 |
|
|
file being read. Its `private' field has been zeroed, and can be
|
1668 |
|
|
modified as desired. Typically, a struct of private information
|
1669 |
|
|
will be `malloc''d, and a pointer to it will be placed in the
|
1670 |
|
|
`private' field.
|
1671 |
|
|
|
1672 |
|
|
There is no result from `XYZ_symfile_init', but it can call
|
1673 |
|
|
`error' if it detects an unavoidable problem.
|
1674 |
|
|
|
1675 |
|
|
`XYZ_new_init()'
|
1676 |
|
|
Called from `symbol_file_add' when discarding existing symbols.
|
1677 |
|
|
This function needs only handle the symbol-reading module's
|
1678 |
|
|
internal state; the symbol table data structures visible to the
|
1679 |
|
|
rest of GDB will be discarded by `symbol_file_add'. It has no
|
1680 |
|
|
arguments and no result. It may be called after
|
1681 |
|
|
`XYZ_symfile_init', if a new symbol table is being read, or may be
|
1682 |
|
|
called alone if all symbols are simply being discarded.
|
1683 |
|
|
|
1684 |
|
|
`XYZ_symfile_read(struct sym_fns *sf, CORE_ADDR addr, int mainline)'
|
1685 |
|
|
Called from `symbol_file_add' to actually read the symbols from a
|
1686 |
|
|
symbol-file into a set of psymtabs or symtabs.
|
1687 |
|
|
|
1688 |
|
|
`sf' points to the `struct sym_fns' originally passed to
|
1689 |
|
|
`XYZ_sym_init' for possible initialization. `addr' is the offset
|
1690 |
|
|
between the file's specified start address and its true address in
|
1691 |
|
|
memory. `mainline' is 1 if this is the main symbol table being
|
1692 |
|
|
read, and 0 if a secondary symbol file (e.g., shared library or
|
1693 |
|
|
dynamically loaded file) is being read.
|
1694 |
|
|
|
1695 |
|
|
In addition, if a symbol-reading module creates psymtabs when
|
1696 |
|
|
XYZ_symfile_read is called, these psymtabs will contain a pointer to a
|
1697 |
|
|
function `XYZ_psymtab_to_symtab', which can be called from any point in
|
1698 |
|
|
the GDB symbol-handling code.
|
1699 |
|
|
|
1700 |
|
|
`XYZ_psymtab_to_symtab (struct partial_symtab *pst)'
|
1701 |
|
|
Called from `psymtab_to_symtab' (or the `PSYMTAB_TO_SYMTAB' macro)
|
1702 |
|
|
if the psymtab has not already been read in and had its
|
1703 |
|
|
`pst->symtab' pointer set. The argument is the psymtab to be
|
1704 |
|
|
fleshed-out into a symtab. Upon return, `pst->readin' should have
|
1705 |
|
|
been set to 1, and `pst->symtab' should contain a pointer to the
|
1706 |
|
|
new corresponding symtab, or zero if there were no symbols in that
|
1707 |
|
|
part of the symbol file.
|
1708 |
|
|
|
1709 |
|
|
6.2 Partial Symbol Tables
|
1710 |
|
|
=========================
|
1711 |
|
|
|
1712 |
|
|
GDB has three types of symbol tables:
|
1713 |
|
|
|
1714 |
|
|
* Full symbol tables ("symtabs"). These contain the main
|
1715 |
|
|
information about symbols and addresses.
|
1716 |
|
|
|
1717 |
|
|
* Partial symbol tables ("psymtabs"). These contain enough
|
1718 |
|
|
information to know when to read the corresponding part of the full
|
1719 |
|
|
symbol table.
|
1720 |
|
|
|
1721 |
|
|
* Minimal symbol tables ("msymtabs"). These contain information
|
1722 |
|
|
gleaned from non-debugging symbols.
|
1723 |
|
|
|
1724 |
|
|
This section describes partial symbol tables.
|
1725 |
|
|
|
1726 |
|
|
A psymtab is constructed by doing a very quick pass over an
|
1727 |
|
|
executable file's debugging information. Small amounts of information
|
1728 |
|
|
are extracted--enough to identify which parts of the symbol table will
|
1729 |
|
|
need to be re-read and fully digested later, when the user needs the
|
1730 |
|
|
information. The speed of this pass causes GDB to start up very
|
1731 |
|
|
quickly. Later, as the detailed rereading occurs, it occurs in small
|
1732 |
|
|
pieces, at various times, and the delay therefrom is mostly invisible to
|
1733 |
|
|
the user.
|
1734 |
|
|
|
1735 |
|
|
The symbols that show up in a file's psymtab should be, roughly,
|
1736 |
|
|
those visible to the debugger's user when the program is not running
|
1737 |
|
|
code from that file. These include external symbols and types, static
|
1738 |
|
|
symbols and types, and `enum' values declared at file scope.
|
1739 |
|
|
|
1740 |
|
|
The psymtab also contains the range of instruction addresses that the
|
1741 |
|
|
full symbol table would represent.
|
1742 |
|
|
|
1743 |
|
|
The idea is that there are only two ways for the user (or much of the
|
1744 |
|
|
code in the debugger) to reference a symbol:
|
1745 |
|
|
|
1746 |
|
|
* By its address (e.g., execution stops at some address which is
|
1747 |
|
|
inside a function in this file). The address will be noticed to
|
1748 |
|
|
be in the range of this psymtab, and the full symtab will be read
|
1749 |
|
|
in. `find_pc_function', `find_pc_line', and other `find_pc_...'
|
1750 |
|
|
functions handle this.
|
1751 |
|
|
|
1752 |
|
|
* By its name (e.g., the user asks to print a variable, or set a
|
1753 |
|
|
breakpoint on a function). Global names and file-scope names will
|
1754 |
|
|
be found in the psymtab, which will cause the symtab to be pulled
|
1755 |
|
|
in. Local names will have to be qualified by a global name, or a
|
1756 |
|
|
file-scope name, in which case we will have already read in the
|
1757 |
|
|
symtab as we evaluated the qualifier. Or, a local symbol can be
|
1758 |
|
|
referenced when we are "in" a local scope, in which case the first
|
1759 |
|
|
case applies. `lookup_symbol' does most of the work here.
|
1760 |
|
|
|
1761 |
|
|
The only reason that psymtabs exist is to cause a symtab to be read
|
1762 |
|
|
in at the right moment. Any symbol that can be elided from a psymtab,
|
1763 |
|
|
while still causing that to happen, should not appear in it. Since
|
1764 |
|
|
psymtabs don't have the idea of scope, you can't put local symbols in
|
1765 |
|
|
them anyway. Psymtabs don't have the idea of the type of a symbol,
|
1766 |
|
|
either, so types need not appear, unless they will be referenced by
|
1767 |
|
|
name.
|
1768 |
|
|
|
1769 |
|
|
It is a bug for GDB to behave one way when only a psymtab has been
|
1770 |
|
|
read, and another way if the corresponding symtab has been read in.
|
1771 |
|
|
Such bugs are typically caused by a psymtab that does not contain all
|
1772 |
|
|
the visible symbols, or which has the wrong instruction address ranges.
|
1773 |
|
|
|
1774 |
|
|
The psymtab for a particular section of a symbol file (objfile)
|
1775 |
|
|
could be thrown away after the symtab has been read in. The symtab
|
1776 |
|
|
should always be searched before the psymtab, so the psymtab will never
|
1777 |
|
|
be used (in a bug-free environment). Currently, psymtabs are allocated
|
1778 |
|
|
on an obstack, and all the psymbols themselves are allocated in a pair
|
1779 |
|
|
of large arrays on an obstack, so there is little to be gained by
|
1780 |
|
|
trying to free them unless you want to do a lot more work.
|
1781 |
|
|
|
1782 |
|
|
6.3 Types
|
1783 |
|
|
=========
|
1784 |
|
|
|
1785 |
|
|
Fundamental Types (e.g., `FT_VOID', `FT_BOOLEAN').
|
1786 |
|
|
--------------------------------------------------
|
1787 |
|
|
|
1788 |
|
|
These are the fundamental types that GDB uses internally. Fundamental
|
1789 |
|
|
types from the various debugging formats (stabs, ELF, etc) are mapped
|
1790 |
|
|
into one of these. They are basically a union of all fundamental types
|
1791 |
|
|
that GDB knows about for all the languages that GDB knows about.
|
1792 |
|
|
|
1793 |
|
|
Type Codes (e.g., `TYPE_CODE_PTR', `TYPE_CODE_ARRAY').
|
1794 |
|
|
------------------------------------------------------
|
1795 |
|
|
|
1796 |
|
|
Each time GDB builds an internal type, it marks it with one of these
|
1797 |
|
|
types. The type may be a fundamental type, such as `TYPE_CODE_INT', or
|
1798 |
|
|
a derived type, such as `TYPE_CODE_PTR' which is a pointer to another
|
1799 |
|
|
type. Typically, several `FT_*' types map to one `TYPE_CODE_*' type,
|
1800 |
|
|
and are distinguished by other members of the type struct, such as
|
1801 |
|
|
whether the type is signed or unsigned, and how many bits it uses.
|
1802 |
|
|
|
1803 |
|
|
Builtin Types (e.g., `builtin_type_void', `builtin_type_char').
|
1804 |
|
|
---------------------------------------------------------------
|
1805 |
|
|
|
1806 |
|
|
These are instances of type structs that roughly correspond to
|
1807 |
|
|
fundamental types and are created as global types for GDB to use for
|
1808 |
|
|
various ugly historical reasons. We eventually want to eliminate
|
1809 |
|
|
these. Note for example that `builtin_type_int' initialized in
|
1810 |
|
|
`gdbtypes.c' is basically the same as a `TYPE_CODE_INT' type that is
|
1811 |
|
|
initialized in `c-lang.c' for an `FT_INTEGER' fundamental type. The
|
1812 |
|
|
difference is that the `builtin_type' is not associated with any
|
1813 |
|
|
particular objfile, and only one instance exists, while `c-lang.c'
|
1814 |
|
|
builds as many `TYPE_CODE_INT' types as needed, with each one
|
1815 |
|
|
associated with some particular objfile.
|
1816 |
|
|
|
1817 |
|
|
6.4 Object File Formats
|
1818 |
|
|
=======================
|
1819 |
|
|
|
1820 |
|
|
6.4.1 a.out
|
1821 |
|
|
-----------
|
1822 |
|
|
|
1823 |
|
|
The `a.out' format is the original file format for Unix. It consists
|
1824 |
|
|
of three sections: `text', `data', and `bss', which are for program
|
1825 |
|
|
code, initialized data, and uninitialized data, respectively.
|
1826 |
|
|
|
1827 |
|
|
The `a.out' format is so simple that it doesn't have any reserved
|
1828 |
|
|
place for debugging information. (Hey, the original Unix hackers used
|
1829 |
|
|
`adb', which is a machine-language debugger!) The only debugging
|
1830 |
|
|
format for `a.out' is stabs, which is encoded as a set of normal
|
1831 |
|
|
symbols with distinctive attributes.
|
1832 |
|
|
|
1833 |
|
|
The basic `a.out' reader is in `dbxread.c'.
|
1834 |
|
|
|
1835 |
|
|
6.4.2 COFF
|
1836 |
|
|
----------
|
1837 |
|
|
|
1838 |
|
|
The COFF format was introduced with System V Release 3 (SVR3) Unix.
|
1839 |
|
|
COFF files may have multiple sections, each prefixed by a header. The
|
1840 |
|
|
number of sections is limited.
|
1841 |
|
|
|
1842 |
|
|
The COFF specification includes support for debugging. Although this
|
1843 |
|
|
was a step forward, the debugging information was woefully limited. For
|
1844 |
|
|
instance, it was not possible to represent code that came from an
|
1845 |
|
|
included file.
|
1846 |
|
|
|
1847 |
|
|
The COFF reader is in `coffread.c'.
|
1848 |
|
|
|
1849 |
|
|
6.4.3 ECOFF
|
1850 |
|
|
-----------
|
1851 |
|
|
|
1852 |
|
|
ECOFF is an extended COFF originally introduced for Mips and Alpha
|
1853 |
|
|
workstations.
|
1854 |
|
|
|
1855 |
|
|
The basic ECOFF reader is in `mipsread.c'.
|
1856 |
|
|
|
1857 |
|
|
6.4.4 XCOFF
|
1858 |
|
|
-----------
|
1859 |
|
|
|
1860 |
|
|
The IBM RS/6000 running AIX uses an object file format called XCOFF.
|
1861 |
|
|
The COFF sections, symbols, and line numbers are used, but debugging
|
1862 |
|
|
symbols are `dbx'-style stabs whose strings are located in the `.debug'
|
1863 |
|
|
section (rather than the string table). For more information, see
|
1864 |
|
|
*Note Top: (stabs)Top.
|
1865 |
|
|
|
1866 |
|
|
The shared library scheme has a clean interface for figuring out what
|
1867 |
|
|
shared libraries are in use, but the catch is that everything which
|
1868 |
|
|
refers to addresses (symbol tables and breakpoints at least) needs to be
|
1869 |
|
|
relocated for both shared libraries and the main executable. At least
|
1870 |
|
|
using the standard mechanism this can only be done once the program has
|
1871 |
|
|
been run (or the core file has been read).
|
1872 |
|
|
|
1873 |
|
|
6.4.5 PE
|
1874 |
|
|
--------
|
1875 |
|
|
|
1876 |
|
|
Windows 95 and NT use the PE ("Portable Executable") format for their
|
1877 |
|
|
executables. PE is basically COFF with additional headers.
|
1878 |
|
|
|
1879 |
|
|
While BFD includes special PE support, GDB needs only the basic COFF
|
1880 |
|
|
reader.
|
1881 |
|
|
|
1882 |
|
|
6.4.6 ELF
|
1883 |
|
|
---------
|
1884 |
|
|
|
1885 |
|
|
The ELF format came with System V Release 4 (SVR4) Unix. ELF is similar
|
1886 |
|
|
to COFF in being organized into a number of sections, but it removes
|
1887 |
|
|
many of COFF's limitations.
|
1888 |
|
|
|
1889 |
|
|
The basic ELF reader is in `elfread.c'.
|
1890 |
|
|
|
1891 |
|
|
6.4.7 SOM
|
1892 |
|
|
---------
|
1893 |
|
|
|
1894 |
|
|
SOM is HP's object file and debug format (not to be confused with IBM's
|
1895 |
|
|
SOM, which is a cross-language ABI).
|
1896 |
|
|
|
1897 |
|
|
The SOM reader is in `somread.c'.
|
1898 |
|
|
|
1899 |
|
|
6.5 Debugging File Formats
|
1900 |
|
|
==========================
|
1901 |
|
|
|
1902 |
|
|
This section describes characteristics of debugging information that
|
1903 |
|
|
are independent of the object file format.
|
1904 |
|
|
|
1905 |
|
|
6.5.1 stabs
|
1906 |
|
|
-----------
|
1907 |
|
|
|
1908 |
|
|
`stabs' started out as special symbols within the `a.out' format.
|
1909 |
|
|
Since then, it has been encapsulated into other file formats, such as
|
1910 |
|
|
COFF and ELF.
|
1911 |
|
|
|
1912 |
|
|
While `dbxread.c' does some of the basic stab processing, including
|
1913 |
|
|
for encapsulated versions, `stabsread.c' does the real work.
|
1914 |
|
|
|
1915 |
|
|
6.5.2 COFF
|
1916 |
|
|
----------
|
1917 |
|
|
|
1918 |
|
|
The basic COFF definition includes debugging information. The level of
|
1919 |
|
|
support is minimal and non-extensible, and is not often used.
|
1920 |
|
|
|
1921 |
|
|
6.5.3 Mips debug (Third Eye)
|
1922 |
|
|
----------------------------
|
1923 |
|
|
|
1924 |
|
|
ECOFF includes a definition of a special debug format.
|
1925 |
|
|
|
1926 |
|
|
The file `mdebugread.c' implements reading for this format.
|
1927 |
|
|
|
1928 |
|
|
6.5.4 DWARF 2
|
1929 |
|
|
-------------
|
1930 |
|
|
|
1931 |
|
|
DWARF 2 is an improved but incompatible version of DWARF 1.
|
1932 |
|
|
|
1933 |
|
|
The DWARF 2 reader is in `dwarf2read.c'.
|
1934 |
|
|
|
1935 |
|
|
6.5.5 SOM
|
1936 |
|
|
---------
|
1937 |
|
|
|
1938 |
|
|
Like COFF, the SOM definition includes debugging information.
|
1939 |
|
|
|
1940 |
|
|
6.6 Adding a New Symbol Reader to GDB
|
1941 |
|
|
=====================================
|
1942 |
|
|
|
1943 |
|
|
If you are using an existing object file format (`a.out', COFF, ELF,
|
1944 |
|
|
etc), there is probably little to be done.
|
1945 |
|
|
|
1946 |
|
|
If you need to add a new object file format, you must first add it to
|
1947 |
|
|
BFD. This is beyond the scope of this document.
|
1948 |
|
|
|
1949 |
|
|
You must then arrange for the BFD code to provide access to the
|
1950 |
|
|
debugging symbols. Generally GDB will have to call swapping routines
|
1951 |
|
|
from BFD and a few other BFD internal routines to locate the debugging
|
1952 |
|
|
information. As much as possible, GDB should not depend on the BFD
|
1953 |
|
|
internal data structures.
|
1954 |
|
|
|
1955 |
|
|
For some targets (e.g., COFF), there is a special transfer vector
|
1956 |
|
|
used to call swapping routines, since the external data structures on
|
1957 |
|
|
various platforms have different sizes and layouts. Specialized
|
1958 |
|
|
routines that will only ever be implemented by one object file format
|
1959 |
|
|
may be called directly. This interface should be described in a file
|
1960 |
|
|
`bfd/libXYZ.h', which is included by GDB.
|
1961 |
|
|
|
1962 |
|
|
6.7 Memory Management for Symbol Files
|
1963 |
|
|
======================================
|
1964 |
|
|
|
1965 |
|
|
Most memory associated with a loaded symbol file is stored on its
|
1966 |
|
|
`objfile_obstack'. This includes symbols, types, namespace data, and
|
1967 |
|
|
other information produced by the symbol readers.
|
1968 |
|
|
|
1969 |
|
|
Because this data lives on the objfile's obstack, it is automatically
|
1970 |
|
|
released when the objfile is unloaded or reloaded. Therefore one
|
1971 |
|
|
objfile must not reference symbol or type data from another objfile;
|
1972 |
|
|
they could be unloaded at different times.
|
1973 |
|
|
|
1974 |
|
|
User convenience variables, et cetera, have associated types.
|
1975 |
|
|
Normally these types live in the associated objfile. However, when the
|
1976 |
|
|
objfile is unloaded, those types are deep copied to global memory, so
|
1977 |
|
|
that the values of the user variables and history items are not lost.
|
1978 |
|
|
|
1979 |
|
|
|
1980 |
|
|
File: gdbint.info, Node: Language Support, Next: Host Definition, Prev: Symbol Handling, Up: Top
|
1981 |
|
|
|
1982 |
|
|
7 Language Support
|
1983 |
|
|
******************
|
1984 |
|
|
|
1985 |
|
|
GDB's language support is mainly driven by the symbol reader, although
|
1986 |
|
|
it is possible for the user to set the source language manually.
|
1987 |
|
|
|
1988 |
|
|
GDB chooses the source language by looking at the extension of the
|
1989 |
|
|
file recorded in the debug info; `.c' means C, `.f' means Fortran, etc.
|
1990 |
|
|
It may also use a special-purpose language identifier if the debug
|
1991 |
|
|
format supports it, like with DWARF.
|
1992 |
|
|
|
1993 |
|
|
7.1 Adding a Source Language to GDB
|
1994 |
|
|
===================================
|
1995 |
|
|
|
1996 |
|
|
To add other languages to GDB's expression parser, follow the following
|
1997 |
|
|
steps:
|
1998 |
|
|
|
1999 |
|
|
_Create the expression parser._
|
2000 |
|
|
This should reside in a file `LANG-exp.y'. Routines for building
|
2001 |
|
|
parsed expressions into a `union exp_element' list are in
|
2002 |
|
|
`parse.c'.
|
2003 |
|
|
|
2004 |
|
|
Since we can't depend upon everyone having Bison, and YACC produces
|
2005 |
|
|
parsers that define a bunch of global names, the following lines
|
2006 |
|
|
*must* be included at the top of the YACC parser, to prevent the
|
2007 |
|
|
various parsers from defining the same global names:
|
2008 |
|
|
|
2009 |
|
|
#define yyparse LANG_parse
|
2010 |
|
|
#define yylex LANG_lex
|
2011 |
|
|
#define yyerror LANG_error
|
2012 |
|
|
#define yylval LANG_lval
|
2013 |
|
|
#define yychar LANG_char
|
2014 |
|
|
#define yydebug LANG_debug
|
2015 |
|
|
#define yypact LANG_pact
|
2016 |
|
|
#define yyr1 LANG_r1
|
2017 |
|
|
#define yyr2 LANG_r2
|
2018 |
|
|
#define yydef LANG_def
|
2019 |
|
|
#define yychk LANG_chk
|
2020 |
|
|
#define yypgo LANG_pgo
|
2021 |
|
|
#define yyact LANG_act
|
2022 |
|
|
#define yyexca LANG_exca
|
2023 |
|
|
#define yyerrflag LANG_errflag
|
2024 |
|
|
#define yynerrs LANG_nerrs
|
2025 |
|
|
|
2026 |
|
|
At the bottom of your parser, define a `struct language_defn' and
|
2027 |
|
|
initialize it with the right values for your language. Define an
|
2028 |
|
|
`initialize_LANG' routine and have it call
|
2029 |
|
|
`add_language(LANG_language_defn)' to tell the rest of GDB that
|
2030 |
|
|
your language exists. You'll need some other supporting variables
|
2031 |
|
|
and functions, which will be used via pointers from your
|
2032 |
|
|
`LANG_language_defn'. See the declaration of `struct
|
2033 |
|
|
language_defn' in `language.h', and the other `*-exp.y' files, for
|
2034 |
|
|
more information.
|
2035 |
|
|
|
2036 |
|
|
_Add any evaluation routines, if necessary_
|
2037 |
|
|
If you need new opcodes (that represent the operations of the
|
2038 |
|
|
language), add them to the enumerated type in `expression.h'. Add
|
2039 |
|
|
support code for these operations in the `evaluate_subexp' function
|
2040 |
|
|
defined in the file `eval.c'. Add cases for new opcodes in two
|
2041 |
|
|
functions from `parse.c': `prefixify_subexp' and
|
2042 |
|
|
`length_of_subexp'. These compute the number of `exp_element's
|
2043 |
|
|
that a given operation takes up.
|
2044 |
|
|
|
2045 |
|
|
_Update some existing code_
|
2046 |
|
|
Add an enumerated identifier for your language to the enumerated
|
2047 |
|
|
type `enum language' in `defs.h'.
|
2048 |
|
|
|
2049 |
|
|
Update the routines in `language.c' so your language is included.
|
2050 |
|
|
These routines include type predicates and such, which (in some
|
2051 |
|
|
cases) are language dependent. If your language does not appear
|
2052 |
|
|
in the switch statement, an error is reported.
|
2053 |
|
|
|
2054 |
|
|
Also included in `language.c' is the code that updates the variable
|
2055 |
|
|
`current_language', and the routines that translate the
|
2056 |
|
|
`language_LANG' enumerated identifier into a printable string.
|
2057 |
|
|
|
2058 |
|
|
Update the function `_initialize_language' to include your
|
2059 |
|
|
language. This function picks the default language upon startup,
|
2060 |
|
|
so is dependent upon which languages that GDB is built for.
|
2061 |
|
|
|
2062 |
|
|
Update `allocate_symtab' in `symfile.c' and/or symbol-reading code
|
2063 |
|
|
so that the language of each symtab (source file) is set properly.
|
2064 |
|
|
This is used to determine the language to use at each stack frame
|
2065 |
|
|
level. Currently, the language is set based upon the extension of
|
2066 |
|
|
the source file. If the language can be better inferred from the
|
2067 |
|
|
symbol information, please set the language of the symtab in the
|
2068 |
|
|
symbol-reading code.
|
2069 |
|
|
|
2070 |
|
|
Add helper code to `print_subexp' (in `expprint.c') to handle any
|
2071 |
|
|
new expression opcodes you have added to `expression.h'. Also,
|
2072 |
|
|
add the printed representations of your operators to
|
2073 |
|
|
`op_print_tab'.
|
2074 |
|
|
|
2075 |
|
|
_Add a place of call_
|
2076 |
|
|
Add a call to `LANG_parse()' and `LANG_error' in `parse_exp_1'
|
2077 |
|
|
(defined in `parse.c').
|
2078 |
|
|
|
2079 |
|
|
_Use macros to trim code_
|
2080 |
|
|
The user has the option of building GDB for some or all of the
|
2081 |
|
|
languages. If the user decides to build GDB for the language
|
2082 |
|
|
LANG, then every file dependent on `language.h' will have the
|
2083 |
|
|
macro `_LANG_LANG' defined in it. Use `#ifdef's to leave out
|
2084 |
|
|
large routines that the user won't need if he or she is not using
|
2085 |
|
|
your language.
|
2086 |
|
|
|
2087 |
|
|
Note that you do not need to do this in your YACC parser, since if
|
2088 |
|
|
GDB is not build for LANG, then `LANG-exp.tab.o' (the compiled
|
2089 |
|
|
form of your parser) is not linked into GDB at all.
|
2090 |
|
|
|
2091 |
|
|
See the file `configure.in' for how GDB is configured for
|
2092 |
|
|
different languages.
|
2093 |
|
|
|
2094 |
|
|
_Edit `Makefile.in'_
|
2095 |
|
|
Add dependencies in `Makefile.in'. Make sure you update the macro
|
2096 |
|
|
variables such as `HFILES' and `OBJS', otherwise your code may not
|
2097 |
|
|
get linked in, or, worse yet, it may not get `tar'red into the
|
2098 |
|
|
distribution!
|
2099 |
|
|
|
2100 |
|
|
|
2101 |
|
|
File: gdbint.info, Node: Host Definition, Next: Target Architecture Definition, Prev: Language Support, Up: Top
|
2102 |
|
|
|
2103 |
|
|
8 Host Definition
|
2104 |
|
|
*****************
|
2105 |
|
|
|
2106 |
|
|
With the advent of Autoconf, it's rarely necessary to have host
|
2107 |
|
|
definition machinery anymore. The following information is provided,
|
2108 |
|
|
mainly, as an historical reference.
|
2109 |
|
|
|
2110 |
|
|
8.1 Adding a New Host
|
2111 |
|
|
=====================
|
2112 |
|
|
|
2113 |
|
|
GDB's host configuration support normally happens via Autoconf. New
|
2114 |
|
|
host-specific definitions should not be needed. Older hosts GDB still
|
2115 |
|
|
use the host-specific definitions and files listed below, but these
|
2116 |
|
|
mostly exist for historical reasons, and will eventually disappear.
|
2117 |
|
|
|
2118 |
|
|
`gdb/config/ARCH/XYZ.mh'
|
2119 |
|
|
This file once contained both host and native configuration
|
2120 |
|
|
information (*note Native Debugging::) for the machine XYZ. The
|
2121 |
|
|
host configuration information is now handed by Autoconf.
|
2122 |
|
|
|
2123 |
|
|
Host configuration information included a definition of
|
2124 |
|
|
`XM_FILE=xm-XYZ.h' and possibly definitions for `CC',
|
2125 |
|
|
`SYSV_DEFINE', `XM_CFLAGS', `XM_ADD_FILES', `XM_CLIBS',
|
2126 |
|
|
`XM_CDEPS', etc.; see `Makefile.in'.
|
2127 |
|
|
|
2128 |
|
|
New host only configurations do not need this file.
|
2129 |
|
|
|
2130 |
|
|
`gdb/config/ARCH/xm-XYZ.h'
|
2131 |
|
|
This file once contained definitions and includes required when
|
2132 |
|
|
hosting gdb on machine XYZ. Those definitions and includes are now
|
2133 |
|
|
handled by Autoconf.
|
2134 |
|
|
|
2135 |
|
|
New host and native configurations do not need this file.
|
2136 |
|
|
|
2137 |
|
|
_Maintainer's note: Some hosts continue to use the `xm-xyz.h' file
|
2138 |
|
|
to define the macros HOST_FLOAT_FORMAT, HOST_DOUBLE_FORMAT and
|
2139 |
|
|
HOST_LONG_DOUBLE_FORMAT. That code also needs to be replaced with
|
2140 |
|
|
either an Autoconf or run-time test._
|
2141 |
|
|
|
2142 |
|
|
|
2143 |
|
|
Generic Host Support Files
|
2144 |
|
|
--------------------------
|
2145 |
|
|
|
2146 |
|
|
There are some "generic" versions of routines that can be used by
|
2147 |
|
|
various systems. These can be customized in various ways by macros
|
2148 |
|
|
defined in your `xm-XYZ.h' file. If these routines work for the XYZ
|
2149 |
|
|
host, you can just include the generic file's name (with `.o', not
|
2150 |
|
|
`.c') in `XDEPFILES'.
|
2151 |
|
|
|
2152 |
|
|
Otherwise, if your machine needs custom support routines, you will
|
2153 |
|
|
need to write routines that perform the same functions as the generic
|
2154 |
|
|
file. Put them into `XYZ-xdep.c', and put `XYZ-xdep.o' into
|
2155 |
|
|
`XDEPFILES'.
|
2156 |
|
|
|
2157 |
|
|
`ser-unix.c'
|
2158 |
|
|
This contains serial line support for Unix systems. This is always
|
2159 |
|
|
included, via the makefile variable `SER_HARDWIRE'; override this
|
2160 |
|
|
variable in the `.mh' file to avoid it.
|
2161 |
|
|
|
2162 |
|
|
`ser-go32.c'
|
2163 |
|
|
This contains serial line support for 32-bit programs running
|
2164 |
|
|
under DOS, using the DJGPP (a.k.a. GO32) execution environment.
|
2165 |
|
|
|
2166 |
|
|
`ser-tcp.c'
|
2167 |
|
|
This contains generic TCP support using sockets.
|
2168 |
|
|
|
2169 |
|
|
8.2 Host Conditionals
|
2170 |
|
|
=====================
|
2171 |
|
|
|
2172 |
|
|
When GDB is configured and compiled, various macros are defined or left
|
2173 |
|
|
undefined, to control compilation based on the attributes of the host
|
2174 |
|
|
system. These macros and their meanings (or if the meaning is not
|
2175 |
|
|
documented here, then one of the source files where they are used is
|
2176 |
|
|
indicated) are:
|
2177 |
|
|
|
2178 |
|
|
`GDBINIT_FILENAME'
|
2179 |
|
|
The default name of GDB's initialization file (normally
|
2180 |
|
|
`.gdbinit').
|
2181 |
|
|
|
2182 |
|
|
`NO_STD_REGS'
|
2183 |
|
|
This macro is deprecated.
|
2184 |
|
|
|
2185 |
|
|
`SIGWINCH_HANDLER'
|
2186 |
|
|
If your host defines `SIGWINCH', you can define this to be the name
|
2187 |
|
|
of a function to be called if `SIGWINCH' is received.
|
2188 |
|
|
|
2189 |
|
|
`SIGWINCH_HANDLER_BODY'
|
2190 |
|
|
Define this to expand into code that will define the function
|
2191 |
|
|
named by the expansion of `SIGWINCH_HANDLER'.
|
2192 |
|
|
|
2193 |
|
|
`CRLF_SOURCE_FILES'
|
2194 |
|
|
Define this if host files use `\r\n' rather than `\n' as a line
|
2195 |
|
|
terminator. This will cause source file listings to omit `\r'
|
2196 |
|
|
characters when printing and it will allow `\r\n' line endings of
|
2197 |
|
|
files which are "sourced" by gdb. It must be possible to open
|
2198 |
|
|
files in binary mode using `O_BINARY' or, for fopen, `"rb"'.
|
2199 |
|
|
|
2200 |
|
|
`DEFAULT_PROMPT'
|
2201 |
|
|
The default value of the prompt string (normally `"(gdb) "').
|
2202 |
|
|
|
2203 |
|
|
`DEV_TTY'
|
2204 |
|
|
The name of the generic TTY device, defaults to `"/dev/tty"'.
|
2205 |
|
|
|
2206 |
|
|
`FOPEN_RB'
|
2207 |
|
|
Define this if binary files are opened the same way as text files.
|
2208 |
|
|
|
2209 |
|
|
`HAVE_MMAP'
|
2210 |
|
|
In some cases, use the system call `mmap' for reading symbol
|
2211 |
|
|
tables. For some machines this allows for sharing and quick
|
2212 |
|
|
updates.
|
2213 |
|
|
|
2214 |
|
|
`HAVE_TERMIO'
|
2215 |
|
|
Define this if the host system has `termio.h'.
|
2216 |
|
|
|
2217 |
|
|
`INT_MAX'
|
2218 |
|
|
`INT_MIN'
|
2219 |
|
|
`LONG_MAX'
|
2220 |
|
|
`UINT_MAX'
|
2221 |
|
|
`ULONG_MAX'
|
2222 |
|
|
Values for host-side constants.
|
2223 |
|
|
|
2224 |
|
|
`ISATTY'
|
2225 |
|
|
Substitute for isatty, if not available.
|
2226 |
|
|
|
2227 |
|
|
`LONGEST'
|
2228 |
|
|
This is the longest integer type available on the host. If not
|
2229 |
|
|
defined, it will default to `long long' or `long', depending on
|
2230 |
|
|
`CC_HAS_LONG_LONG'.
|
2231 |
|
|
|
2232 |
|
|
`CC_HAS_LONG_LONG'
|
2233 |
|
|
Define this if the host C compiler supports `long long'. This is
|
2234 |
|
|
set by the `configure' script.
|
2235 |
|
|
|
2236 |
|
|
`PRINTF_HAS_LONG_LONG'
|
2237 |
|
|
Define this if the host can handle printing of long long integers
|
2238 |
|
|
via the printf format conversion specifier `ll'. This is set by
|
2239 |
|
|
the `configure' script.
|
2240 |
|
|
|
2241 |
|
|
`HAVE_LONG_DOUBLE'
|
2242 |
|
|
Define this if the host C compiler supports `long double'. This is
|
2243 |
|
|
set by the `configure' script.
|
2244 |
|
|
|
2245 |
|
|
`PRINTF_HAS_LONG_DOUBLE'
|
2246 |
|
|
Define this if the host can handle printing of long double
|
2247 |
|
|
float-point numbers via the printf format conversion specifier
|
2248 |
|
|
`Lg'. This is set by the `configure' script.
|
2249 |
|
|
|
2250 |
|
|
`SCANF_HAS_LONG_DOUBLE'
|
2251 |
|
|
Define this if the host can handle the parsing of long double
|
2252 |
|
|
float-point numbers via the scanf format conversion specifier
|
2253 |
|
|
`Lg'. This is set by the `configure' script.
|
2254 |
|
|
|
2255 |
|
|
`LSEEK_NOT_LINEAR'
|
2256 |
|
|
Define this if `lseek (n)' does not necessarily move to byte number
|
2257 |
|
|
`n' in the file. This is only used when reading source files. It
|
2258 |
|
|
is normally faster to define `CRLF_SOURCE_FILES' when possible.
|
2259 |
|
|
|
2260 |
|
|
`L_SET'
|
2261 |
|
|
This macro is used as the argument to `lseek' (or, most commonly,
|
2262 |
|
|
`bfd_seek'). FIXME, should be replaced by SEEK_SET instead, which
|
2263 |
|
|
is the POSIX equivalent.
|
2264 |
|
|
|
2265 |
|
|
`NORETURN'
|
2266 |
|
|
If defined, this should be one or more tokens, such as `volatile',
|
2267 |
|
|
that can be used in both the declaration and definition of
|
2268 |
|
|
functions to indicate that they never return. The default is
|
2269 |
|
|
already set correctly if compiling with GCC. This will almost
|
2270 |
|
|
never need to be defined.
|
2271 |
|
|
|
2272 |
|
|
`ATTR_NORETURN'
|
2273 |
|
|
If defined, this should be one or more tokens, such as
|
2274 |
|
|
`__attribute__ ((noreturn))', that can be used in the declarations
|
2275 |
|
|
of functions to indicate that they never return. The default is
|
2276 |
|
|
already set correctly if compiling with GCC. This will almost
|
2277 |
|
|
never need to be defined.
|
2278 |
|
|
|
2279 |
|
|
`SEEK_CUR'
|
2280 |
|
|
`SEEK_SET'
|
2281 |
|
|
Define these to appropriate value for the system `lseek', if not
|
2282 |
|
|
already defined.
|
2283 |
|
|
|
2284 |
|
|
`STOP_SIGNAL'
|
2285 |
|
|
This is the signal for stopping GDB. Defaults to `SIGTSTP'.
|
2286 |
|
|
(Only redefined for the Convex.)
|
2287 |
|
|
|
2288 |
|
|
`USG'
|
2289 |
|
|
Means that System V (prior to SVR4) include files are in use.
|
2290 |
|
|
(FIXME: This symbol is abused in `infrun.c', `regex.c', and
|
2291 |
|
|
`utils.c' for other things, at the moment.)
|
2292 |
|
|
|
2293 |
|
|
`lint'
|
2294 |
|
|
Define this to help placate `lint' in some situations.
|
2295 |
|
|
|
2296 |
|
|
`volatile'
|
2297 |
|
|
Define this to override the defaults of `__volatile__' or `/**/'.
|
2298 |
|
|
|
2299 |
|
|
|
2300 |
|
|
File: gdbint.info, Node: Target Architecture Definition, Next: Target Descriptions, Prev: Host Definition, Up: Top
|
2301 |
|
|
|
2302 |
|
|
9 Target Architecture Definition
|
2303 |
|
|
********************************
|
2304 |
|
|
|
2305 |
|
|
GDB's target architecture defines what sort of machine-language
|
2306 |
|
|
programs GDB can work with, and how it works with them.
|
2307 |
|
|
|
2308 |
|
|
The target architecture object is implemented as the C structure
|
2309 |
|
|
`struct gdbarch *'. The structure, and its methods, are generated
|
2310 |
|
|
using the Bourne shell script `gdbarch.sh'.
|
2311 |
|
|
|
2312 |
|
|
* Menu:
|
2313 |
|
|
|
2314 |
|
|
* OS ABI Variant Handling::
|
2315 |
|
|
* Initialize New Architecture::
|
2316 |
|
|
* Registers and Memory::
|
2317 |
|
|
* Pointers and Addresses::
|
2318 |
|
|
* Address Classes::
|
2319 |
|
|
* Raw and Virtual Registers::
|
2320 |
|
|
* Register and Memory Data::
|
2321 |
|
|
* Frame Interpretation::
|
2322 |
|
|
* Inferior Call Setup::
|
2323 |
|
|
* Compiler Characteristics::
|
2324 |
|
|
* Target Conditionals::
|
2325 |
|
|
* Adding a New Target::
|
2326 |
|
|
|
2327 |
|
|
|
2328 |
|
|
File: gdbint.info, Node: OS ABI Variant Handling, Next: Initialize New Architecture, Up: Target Architecture Definition
|
2329 |
|
|
|
2330 |
|
|
9.1 Operating System ABI Variant Handling
|
2331 |
|
|
=========================================
|
2332 |
|
|
|
2333 |
|
|
GDB provides a mechanism for handling variations in OS ABIs. An OS ABI
|
2334 |
|
|
variant may have influence over any number of variables in the target
|
2335 |
|
|
architecture definition. There are two major components in the OS ABI
|
2336 |
|
|
mechanism: sniffers and handlers.
|
2337 |
|
|
|
2338 |
|
|
A "sniffer" examines a file matching a BFD architecture/flavour pair
|
2339 |
|
|
(the architecture may be wildcarded) in an attempt to determine the OS
|
2340 |
|
|
ABI of that file. Sniffers with a wildcarded architecture are
|
2341 |
|
|
considered to be "generic", while sniffers for a specific architecture
|
2342 |
|
|
are considered to be "specific". A match from a specific sniffer
|
2343 |
|
|
overrides a match from a generic sniffer. Multiple sniffers for an
|
2344 |
|
|
architecture/flavour may exist, in order to differentiate between two
|
2345 |
|
|
different operating systems which use the same basic file format. The
|
2346 |
|
|
OS ABI framework provides a generic sniffer for ELF-format files which
|
2347 |
|
|
examines the `EI_OSABI' field of the ELF header, as well as note
|
2348 |
|
|
sections known to be used by several operating systems.
|
2349 |
|
|
|
2350 |
|
|
A "handler" is used to fine-tune the `gdbarch' structure for the
|
2351 |
|
|
selected OS ABI. There may be only one handler for a given OS ABI for
|
2352 |
|
|
each BFD architecture.
|
2353 |
|
|
|
2354 |
|
|
The following OS ABI variants are defined in `defs.h':
|
2355 |
|
|
|
2356 |
|
|
`GDB_OSABI_UNINITIALIZED'
|
2357 |
|
|
Used for struct gdbarch_info if ABI is still uninitialized.
|
2358 |
|
|
|
2359 |
|
|
`GDB_OSABI_UNKNOWN'
|
2360 |
|
|
The ABI of the inferior is unknown. The default `gdbarch'
|
2361 |
|
|
settings for the architecture will be used.
|
2362 |
|
|
|
2363 |
|
|
`GDB_OSABI_SVR4'
|
2364 |
|
|
UNIX System V Release 4.
|
2365 |
|
|
|
2366 |
|
|
`GDB_OSABI_HURD'
|
2367 |
|
|
GNU using the Hurd kernel.
|
2368 |
|
|
|
2369 |
|
|
`GDB_OSABI_SOLARIS'
|
2370 |
|
|
Sun Solaris.
|
2371 |
|
|
|
2372 |
|
|
`GDB_OSABI_OSF1'
|
2373 |
|
|
OSF/1, including Digital UNIX and Compaq Tru64 UNIX.
|
2374 |
|
|
|
2375 |
|
|
`GDB_OSABI_LINUX'
|
2376 |
|
|
GNU using the Linux kernel.
|
2377 |
|
|
|
2378 |
|
|
`GDB_OSABI_FREEBSD_AOUT'
|
2379 |
|
|
FreeBSD using the `a.out' executable format.
|
2380 |
|
|
|
2381 |
|
|
`GDB_OSABI_FREEBSD_ELF'
|
2382 |
|
|
FreeBSD using the ELF executable format.
|
2383 |
|
|
|
2384 |
|
|
`GDB_OSABI_NETBSD_AOUT'
|
2385 |
|
|
NetBSD using the `a.out' executable format.
|
2386 |
|
|
|
2387 |
|
|
`GDB_OSABI_NETBSD_ELF'
|
2388 |
|
|
NetBSD using the ELF executable format.
|
2389 |
|
|
|
2390 |
|
|
`GDB_OSABI_OPENBSD_ELF'
|
2391 |
|
|
OpenBSD using the ELF executable format.
|
2392 |
|
|
|
2393 |
|
|
`GDB_OSABI_WINCE'
|
2394 |
|
|
Windows CE.
|
2395 |
|
|
|
2396 |
|
|
`GDB_OSABI_GO32'
|
2397 |
|
|
DJGPP.
|
2398 |
|
|
|
2399 |
|
|
`GDB_OSABI_IRIX'
|
2400 |
|
|
Irix.
|
2401 |
|
|
|
2402 |
|
|
`GDB_OSABI_INTERIX'
|
2403 |
|
|
Interix (Posix layer for MS-Windows systems).
|
2404 |
|
|
|
2405 |
|
|
`GDB_OSABI_HPUX_ELF'
|
2406 |
|
|
HP/UX using the ELF executable format.
|
2407 |
|
|
|
2408 |
|
|
`GDB_OSABI_HPUX_SOM'
|
2409 |
|
|
HP/UX using the SOM executable format.
|
2410 |
|
|
|
2411 |
|
|
`GDB_OSABI_QNXNTO'
|
2412 |
|
|
QNX Neutrino.
|
2413 |
|
|
|
2414 |
|
|
`GDB_OSABI_CYGWIN'
|
2415 |
|
|
Cygwin.
|
2416 |
|
|
|
2417 |
|
|
`GDB_OSABI_AIX'
|
2418 |
|
|
AIX.
|
2419 |
|
|
|
2420 |
|
|
|
2421 |
|
|
Here are the functions that make up the OS ABI framework:
|
2422 |
|
|
|
2423 |
|
|
-- Function: const char *gdbarch_osabi_name (enum gdb_osabi OSABI)
|
2424 |
|
|
Return the name of the OS ABI corresponding to OSABI.
|
2425 |
|
|
|
2426 |
|
|
-- Function: void gdbarch_register_osabi (enum bfd_architecture ARCH,
|
2427 |
|
|
unsigned long MACHINE, enum gdb_osabi OSABI, void
|
2428 |
|
|
(*INIT_OSABI)(struct gdbarch_info INFO, struct gdbarch
|
2429 |
|
|
*GDBARCH))
|
2430 |
|
|
Register the OS ABI handler specified by INIT_OSABI for the
|
2431 |
|
|
architecture, machine type and OS ABI specified by ARCH, MACHINE
|
2432 |
|
|
and OSABI. In most cases, a value of zero for the machine type,
|
2433 |
|
|
which implies the architecture's default machine type, will
|
2434 |
|
|
suffice.
|
2435 |
|
|
|
2436 |
|
|
-- Function: void gdbarch_register_osabi_sniffer (enum
|
2437 |
|
|
bfd_architecture ARCH, enum bfd_flavour FLAVOUR, enum
|
2438 |
|
|
gdb_osabi (*SNIFFER)(bfd *ABFD))
|
2439 |
|
|
Register the OS ABI file sniffer specified by SNIFFER for the BFD
|
2440 |
|
|
architecture/flavour pair specified by ARCH and FLAVOUR. If ARCH
|
2441 |
|
|
is `bfd_arch_unknown', the sniffer is considered to be generic,
|
2442 |
|
|
and is allowed to examine FLAVOUR-flavoured files for any
|
2443 |
|
|
architecture.
|
2444 |
|
|
|
2445 |
|
|
-- Function: enum gdb_osabi gdbarch_lookup_osabi (bfd *ABFD)
|
2446 |
|
|
Examine the file described by ABFD to determine its OS ABI. The
|
2447 |
|
|
value `GDB_OSABI_UNKNOWN' is returned if the OS ABI cannot be
|
2448 |
|
|
determined.
|
2449 |
|
|
|
2450 |
|
|
-- Function: void gdbarch_init_osabi (struct gdbarch info INFO, struct
|
2451 |
|
|
gdbarch *GDBARCH, enum gdb_osabi OSABI)
|
2452 |
|
|
Invoke the OS ABI handler corresponding to OSABI to fine-tune the
|
2453 |
|
|
`gdbarch' structure specified by GDBARCH. If a handler
|
2454 |
|
|
corresponding to OSABI has not been registered for GDBARCH's
|
2455 |
|
|
architecture, a warning will be issued and the debugging session
|
2456 |
|
|
will continue with the defaults already established for GDBARCH.
|
2457 |
|
|
|
2458 |
|
|
-- Function: void generic_elf_osabi_sniff_abi_tag_sections (bfd *ABFD,
|
2459 |
|
|
asection *SECT, void *OBJ)
|
2460 |
|
|
Helper routine for ELF file sniffers. Examine the file described
|
2461 |
|
|
by ABFD and look at ABI tag note sections to determine the OS ABI
|
2462 |
|
|
from the note. This function should be called via
|
2463 |
|
|
`bfd_map_over_sections'.
|
2464 |
|
|
|
2465 |
|
|
|
2466 |
|
|
File: gdbint.info, Node: Initialize New Architecture, Next: Registers and Memory, Prev: OS ABI Variant Handling, Up: Target Architecture Definition
|
2467 |
|
|
|
2468 |
|
|
9.2 Initializing a New Architecture
|
2469 |
|
|
===================================
|
2470 |
|
|
|
2471 |
|
|
Each `gdbarch' is associated with a single BFD architecture, via a
|
2472 |
|
|
`bfd_arch_ARCH' constant. The `gdbarch' is registered by a call to
|
2473 |
|
|
`register_gdbarch_init', usually from the file's `_initialize_FILENAME'
|
2474 |
|
|
routine, which will be automatically called during GDB startup. The
|
2475 |
|
|
arguments are a BFD architecture constant and an initialization
|
2476 |
|
|
function.
|
2477 |
|
|
|
2478 |
|
|
The initialization function has this type:
|
2479 |
|
|
|
2480 |
|
|
static struct gdbarch *
|
2481 |
|
|
ARCH_gdbarch_init (struct gdbarch_info INFO,
|
2482 |
|
|
struct gdbarch_list *ARCHES)
|
2483 |
|
|
|
2484 |
|
|
The INFO argument contains parameters used to select the correct
|
2485 |
|
|
architecture, and ARCHES is a list of architectures which have already
|
2486 |
|
|
been created with the same `bfd_arch_ARCH' value.
|
2487 |
|
|
|
2488 |
|
|
The initialization function should first make sure that INFO is
|
2489 |
|
|
acceptable, and return `NULL' if it is not. Then, it should search
|
2490 |
|
|
through ARCHES for an exact match to INFO, and return one if found.
|
2491 |
|
|
Lastly, if no exact match was found, it should create a new
|
2492 |
|
|
architecture based on INFO and return it.
|
2493 |
|
|
|
2494 |
|
|
Only information in INFO should be used to choose the new
|
2495 |
|
|
architecture. Historically, INFO could be sparse, and defaults would
|
2496 |
|
|
be collected from the first element on ARCHES. However, GDB now fills
|
2497 |
|
|
in INFO more thoroughly, so new `gdbarch' initialization functions
|
2498 |
|
|
should not take defaults from ARCHES.
|
2499 |
|
|
|
2500 |
|
|
|
2501 |
|
|
File: gdbint.info, Node: Registers and Memory, Next: Pointers and Addresses, Prev: Initialize New Architecture, Up: Target Architecture Definition
|
2502 |
|
|
|
2503 |
|
|
9.3 Registers and Memory
|
2504 |
|
|
========================
|
2505 |
|
|
|
2506 |
|
|
GDB's model of the target machine is rather simple. GDB assumes the
|
2507 |
|
|
machine includes a bank of registers and a block of memory. Each
|
2508 |
|
|
register may have a different size.
|
2509 |
|
|
|
2510 |
|
|
GDB does not have a magical way to match up with the compiler's idea
|
2511 |
|
|
of which registers are which; however, it is critical that they do
|
2512 |
|
|
match up accurately. The only way to make this work is to get accurate
|
2513 |
|
|
information about the order that the compiler uses, and to reflect that
|
2514 |
|
|
in the `gdbarch_register_name' and related functions.
|
2515 |
|
|
|
2516 |
|
|
GDB can handle big-endian, little-endian, and bi-endian
|
2517 |
|
|
architectures.
|
2518 |
|
|
|
2519 |
|
|
|
2520 |
|
|
File: gdbint.info, Node: Pointers and Addresses, Next: Address Classes, Prev: Registers and Memory, Up: Target Architecture Definition
|
2521 |
|
|
|
2522 |
|
|
9.4 Pointers Are Not Always Addresses
|
2523 |
|
|
=====================================
|
2524 |
|
|
|
2525 |
|
|
On almost all 32-bit architectures, the representation of a pointer is
|
2526 |
|
|
indistinguishable from the representation of some fixed-length number
|
2527 |
|
|
whose value is the byte address of the object pointed to. On such
|
2528 |
|
|
machines, the words "pointer" and "address" can be used interchangeably.
|
2529 |
|
|
However, architectures with smaller word sizes are often cramped for
|
2530 |
|
|
address space, so they may choose a pointer representation that breaks
|
2531 |
|
|
this identity, and allows a larger code address space.
|
2532 |
|
|
|
2533 |
|
|
For example, the Renesas D10V is a 16-bit VLIW processor whose
|
2534 |
|
|
instructions are 32 bits long(1). If the D10V used ordinary byte
|
2535 |
|
|
addresses to refer to code locations, then the processor would only be
|
2536 |
|
|
able to address 64kb of instructions. However, since instructions must
|
2537 |
|
|
be aligned on four-byte boundaries, the low two bits of any valid
|
2538 |
|
|
instruction's byte address are always zero--byte addresses waste two
|
2539 |
|
|
bits. So instead of byte addresses, the D10V uses word addresses--byte
|
2540 |
|
|
addresses shifted right two bits--to refer to code. Thus, the D10V can
|
2541 |
|
|
use 16-bit words to address 256kb of code space.
|
2542 |
|
|
|
2543 |
|
|
However, this means that code pointers and data pointers have
|
2544 |
|
|
different forms on the D10V. The 16-bit word `0xC020' refers to byte
|
2545 |
|
|
address `0xC020' when used as a data address, but refers to byte address
|
2546 |
|
|
`0x30080' when used as a code address.
|
2547 |
|
|
|
2548 |
|
|
(The D10V also uses separate code and data address spaces, which also
|
2549 |
|
|
affects the correspondence between pointers and addresses, but we're
|
2550 |
|
|
going to ignore that here; this example is already too long.)
|
2551 |
|
|
|
2552 |
|
|
To cope with architectures like this--the D10V is not the only
|
2553 |
|
|
one!--GDB tries to distinguish between "addresses", which are byte
|
2554 |
|
|
numbers, and "pointers", which are the target's representation of an
|
2555 |
|
|
address of a particular type of data. In the example above, `0xC020'
|
2556 |
|
|
is the pointer, which refers to one of the addresses `0xC020' or
|
2557 |
|
|
`0x30080', depending on the type imposed upon it. GDB provides
|
2558 |
|
|
functions for turning a pointer into an address and vice versa, in the
|
2559 |
|
|
appropriate way for the current architecture.
|
2560 |
|
|
|
2561 |
|
|
Unfortunately, since addresses and pointers are identical on almost
|
2562 |
|
|
all processors, this distinction tends to bit-rot pretty quickly. Thus,
|
2563 |
|
|
each time you port GDB to an architecture which does distinguish
|
2564 |
|
|
between pointers and addresses, you'll probably need to clean up some
|
2565 |
|
|
architecture-independent code.
|
2566 |
|
|
|
2567 |
|
|
Here are functions which convert between pointers and addresses:
|
2568 |
|
|
|
2569 |
|
|
-- Function: CORE_ADDR extract_typed_address (void *BUF, struct type
|
2570 |
|
|
*TYPE)
|
2571 |
|
|
Treat the bytes at BUF as a pointer or reference of type TYPE, and
|
2572 |
|
|
return the address it represents, in a manner appropriate for the
|
2573 |
|
|
current architecture. This yields an address GDB can use to read
|
2574 |
|
|
target memory, disassemble, etc. Note that BUF refers to a buffer
|
2575 |
|
|
in GDB's memory, not the inferior's.
|
2576 |
|
|
|
2577 |
|
|
For example, if the current architecture is the Intel x86, this
|
2578 |
|
|
function extracts a little-endian integer of the appropriate
|
2579 |
|
|
length from BUF and returns it. However, if the current
|
2580 |
|
|
architecture is the D10V, this function will return a 16-bit
|
2581 |
|
|
integer extracted from BUF, multiplied by four if TYPE is a
|
2582 |
|
|
pointer to a function.
|
2583 |
|
|
|
2584 |
|
|
If TYPE is not a pointer or reference type, then this function
|
2585 |
|
|
will signal an internal error.
|
2586 |
|
|
|
2587 |
|
|
-- Function: CORE_ADDR store_typed_address (void *BUF, struct type
|
2588 |
|
|
*TYPE, CORE_ADDR ADDR)
|
2589 |
|
|
Store the address ADDR in BUF, in the proper format for a pointer
|
2590 |
|
|
of type TYPE in the current architecture. Note that BUF refers to
|
2591 |
|
|
a buffer in GDB's memory, not the inferior's.
|
2592 |
|
|
|
2593 |
|
|
For example, if the current architecture is the Intel x86, this
|
2594 |
|
|
function stores ADDR unmodified as a little-endian integer of the
|
2595 |
|
|
appropriate length in BUF. However, if the current architecture
|
2596 |
|
|
is the D10V, this function divides ADDR by four if TYPE is a
|
2597 |
|
|
pointer to a function, and then stores it in BUF.
|
2598 |
|
|
|
2599 |
|
|
If TYPE is not a pointer or reference type, then this function
|
2600 |
|
|
will signal an internal error.
|
2601 |
|
|
|
2602 |
|
|
-- Function: CORE_ADDR value_as_address (struct value *VAL)
|
2603 |
|
|
Assuming that VAL is a pointer, return the address it represents,
|
2604 |
|
|
as appropriate for the current architecture.
|
2605 |
|
|
|
2606 |
|
|
This function actually works on integral values, as well as
|
2607 |
|
|
pointers. For pointers, it performs architecture-specific
|
2608 |
|
|
conversions as described above for `extract_typed_address'.
|
2609 |
|
|
|
2610 |
|
|
-- Function: CORE_ADDR value_from_pointer (struct type *TYPE,
|
2611 |
|
|
CORE_ADDR ADDR)
|
2612 |
|
|
Create and return a value representing a pointer of type TYPE to
|
2613 |
|
|
the address ADDR, as appropriate for the current architecture.
|
2614 |
|
|
This function performs architecture-specific conversions as
|
2615 |
|
|
described above for `store_typed_address'.
|
2616 |
|
|
|
2617 |
|
|
Here are two functions which architectures can define to indicate the
|
2618 |
|
|
relationship between pointers and addresses. These have default
|
2619 |
|
|
definitions, appropriate for architectures on which all pointers are
|
2620 |
|
|
simple unsigned byte addresses.
|
2621 |
|
|
|
2622 |
|
|
-- Function: CORE_ADDR gdbarch_pointer_to_address (struct gdbarch
|
2623 |
|
|
*CURRENT_GDBARCH, struct type *TYPE, char *BUF)
|
2624 |
|
|
Assume that BUF holds a pointer of type TYPE, in the appropriate
|
2625 |
|
|
format for the current architecture. Return the byte address the
|
2626 |
|
|
pointer refers to.
|
2627 |
|
|
|
2628 |
|
|
This function may safely assume that TYPE is either a pointer or a
|
2629 |
|
|
C++ reference type.
|
2630 |
|
|
|
2631 |
|
|
-- Function: void gdbarch_address_to_pointer (struct gdbarch
|
2632 |
|
|
*CURRENT_GDBARCH, struct type *TYPE, char *BUF, CORE_ADDR
|
2633 |
|
|
ADDR)
|
2634 |
|
|
Store in BUF a pointer of type TYPE representing the address ADDR,
|
2635 |
|
|
in the appropriate format for the current architecture.
|
2636 |
|
|
|
2637 |
|
|
This function may safely assume that TYPE is either a pointer or a
|
2638 |
|
|
C++ reference type.
|
2639 |
|
|
|
2640 |
|
|
---------- Footnotes ----------
|
2641 |
|
|
|
2642 |
|
|
(1) Some D10V instructions are actually pairs of 16-bit
|
2643 |
|
|
sub-instructions. However, since you can't jump into the middle of
|
2644 |
|
|
such a pair, code addresses can only refer to full 32 bit instructions,
|
2645 |
|
|
which is what matters in this explanation.
|
2646 |
|
|
|
2647 |
|
|
|
2648 |
|
|
File: gdbint.info, Node: Address Classes, Next: Raw and Virtual Registers, Prev: Pointers and Addresses, Up: Target Architecture Definition
|
2649 |
|
|
|
2650 |
|
|
9.5 Address Classes
|
2651 |
|
|
===================
|
2652 |
|
|
|
2653 |
|
|
Sometimes information about different kinds of addresses is available
|
2654 |
|
|
via the debug information. For example, some programming environments
|
2655 |
|
|
define addresses of several different sizes. If the debug information
|
2656 |
|
|
distinguishes these kinds of address classes through either the size
|
2657 |
|
|
info (e.g, `DW_AT_byte_size' in DWARF 2) or through an explicit address
|
2658 |
|
|
class attribute (e.g, `DW_AT_address_class' in DWARF 2), the following
|
2659 |
|
|
macros should be defined in order to disambiguate these types within
|
2660 |
|
|
GDB as well as provide the added information to a GDB user when
|
2661 |
|
|
printing type expressions.
|
2662 |
|
|
|
2663 |
|
|
-- Function: int gdbarch_address_class_type_flags (struct gdbarch
|
2664 |
|
|
*CURRENT_GDBARCH, int BYTE_SIZE, int DWARF2_ADDR_CLASS)
|
2665 |
|
|
Returns the type flags needed to construct a pointer type whose
|
2666 |
|
|
size is BYTE_SIZE and whose address class is DWARF2_ADDR_CLASS.
|
2667 |
|
|
This function is normally called from within a symbol reader. See
|
2668 |
|
|
`dwarf2read.c'.
|
2669 |
|
|
|
2670 |
|
|
-- Function: char *gdbarch_address_class_type_flags_to_name (struct
|
2671 |
|
|
gdbarch *CURRENT_GDBARCH, int TYPE_FLAGS)
|
2672 |
|
|
Given the type flags representing an address class qualifier,
|
2673 |
|
|
return its name.
|
2674 |
|
|
|
2675 |
|
|
-- Function: int gdbarch_address_class_name_to_type_flags (struct
|
2676 |
|
|
gdbarch *CURRENT_GDBARCH, int NAME, int *vartype_flags_ptr)
|
2677 |
|
|
Given an address qualifier name, set the `int' referenced by
|
2678 |
|
|
TYPE_FLAGS_PTR to the type flags for that address class qualifier.
|
2679 |
|
|
|
2680 |
|
|
Since the need for address classes is rather rare, none of the
|
2681 |
|
|
address class functions are defined by default. Predicate functions
|
2682 |
|
|
are provided to detect when they are defined.
|
2683 |
|
|
|
2684 |
|
|
Consider a hypothetical architecture in which addresses are normally
|
2685 |
|
|
32-bits wide, but 16-bit addresses are also supported. Furthermore,
|
2686 |
|
|
suppose that the DWARF 2 information for this architecture simply uses
|
2687 |
|
|
a `DW_AT_byte_size' value of 2 to indicate the use of one of these
|
2688 |
|
|
"short" pointers. The following functions could be defined to
|
2689 |
|
|
implement the address class functions:
|
2690 |
|
|
|
2691 |
|
|
somearch_address_class_type_flags (int byte_size,
|
2692 |
|
|
int dwarf2_addr_class)
|
2693 |
|
|
{
|
2694 |
|
|
if (byte_size == 2)
|
2695 |
|
|
return TYPE_FLAG_ADDRESS_CLASS_1;
|
2696 |
|
|
else
|
2697 |
|
|
return 0;
|
2698 |
|
|
}
|
2699 |
|
|
|
2700 |
|
|
static char *
|
2701 |
|
|
somearch_address_class_type_flags_to_name (int type_flags)
|
2702 |
|
|
{
|
2703 |
|
|
if (type_flags & TYPE_FLAG_ADDRESS_CLASS_1)
|
2704 |
|
|
return "short";
|
2705 |
|
|
else
|
2706 |
|
|
return NULL;
|
2707 |
|
|
}
|
2708 |
|
|
|
2709 |
|
|
int
|
2710 |
|
|
somearch_address_class_name_to_type_flags (char *name,
|
2711 |
|
|
int *type_flags_ptr)
|
2712 |
|
|
{
|
2713 |
|
|
if (strcmp (name, "short") == 0)
|
2714 |
|
|
{
|
2715 |
|
|
*type_flags_ptr = TYPE_FLAG_ADDRESS_CLASS_1;
|
2716 |
|
|
return 1;
|
2717 |
|
|
}
|
2718 |
|
|
else
|
2719 |
|
|
return 0;
|
2720 |
|
|
}
|
2721 |
|
|
|
2722 |
|
|
The qualifier `@short' is used in GDB's type expressions to indicate
|
2723 |
|
|
the presence of one of these "short" pointers. E.g, if the debug
|
2724 |
|
|
information indicates that `short_ptr_var' is one of these short
|
2725 |
|
|
pointers, GDB might show the following behavior:
|
2726 |
|
|
|
2727 |
|
|
(gdb) ptype short_ptr_var
|
2728 |
|
|
type = int * @short
|
2729 |
|
|
|
2730 |
|
|
|
2731 |
|
|
File: gdbint.info, Node: Raw and Virtual Registers, Next: Register and Memory Data, Prev: Address Classes, Up: Target Architecture Definition
|
2732 |
|
|
|
2733 |
|
|
9.6 Raw and Virtual Register Representations
|
2734 |
|
|
============================================
|
2735 |
|
|
|
2736 |
|
|
_Maintainer note: This section is pretty much obsolete. The
|
2737 |
|
|
functionality described here has largely been replaced by
|
2738 |
|
|
pseudo-registers and the mechanisms described in *Note Using Different
|
2739 |
|
|
Register and Memory Data Representations: Target Architecture
|
2740 |
|
|
Definition. See also Bug Tracking Database
|
2741 |
|
|
(http://www.gnu.org/software/gdb/bugs/) and ARI Index
|
2742 |
|
|
(http://sources.redhat.com/gdb/current/ari/) for more up-to-date
|
2743 |
|
|
information._
|
2744 |
|
|
|
2745 |
|
|
Some architectures use one representation for a value when it lives
|
2746 |
|
|
in a register, but use a different representation when it lives in
|
2747 |
|
|
memory. In GDB's terminology, the "raw" representation is the one used
|
2748 |
|
|
in the target registers, and the "virtual" representation is the one
|
2749 |
|
|
used in memory, and within GDB `struct value' objects.
|
2750 |
|
|
|
2751 |
|
|
_Maintainer note: Notice that the same mechanism is being used to
|
2752 |
|
|
both convert a register to a `struct value' and alternative register
|
2753 |
|
|
forms._
|
2754 |
|
|
|
2755 |
|
|
For almost all data types on almost all architectures, the virtual
|
2756 |
|
|
and raw representations are identical, and no special handling is
|
2757 |
|
|
needed. However, they do occasionally differ. For example:
|
2758 |
|
|
|
2759 |
|
|
* The x86 architecture supports an 80-bit `long double' type.
|
2760 |
|
|
However, when we store those values in memory, they occupy twelve
|
2761 |
|
|
bytes: the floating-point number occupies the first ten, and the
|
2762 |
|
|
final two bytes are unused. This keeps the values aligned on
|
2763 |
|
|
four-byte boundaries, allowing more efficient access. Thus, the
|
2764 |
|
|
x86 80-bit floating-point type is the raw representation, and the
|
2765 |
|
|
twelve-byte loosely-packed arrangement is the virtual
|
2766 |
|
|
representation.
|
2767 |
|
|
|
2768 |
|
|
* Some 64-bit MIPS targets present 32-bit registers to GDB as 64-bit
|
2769 |
|
|
registers, with garbage in their upper bits. GDB ignores the top
|
2770 |
|
|
32 bits. Thus, the 64-bit form, with garbage in the upper 32
|
2771 |
|
|
bits, is the raw representation, and the trimmed 32-bit
|
2772 |
|
|
representation is the virtual representation.
|
2773 |
|
|
|
2774 |
|
|
In general, the raw representation is determined by the
|
2775 |
|
|
architecture, or GDB's interface to the architecture, while the virtual
|
2776 |
|
|
representation can be chosen for GDB's convenience. GDB's register
|
2777 |
|
|
file, `registers', holds the register contents in raw format, and the
|
2778 |
|
|
GDB remote protocol transmits register values in raw format.
|
2779 |
|
|
|
2780 |
|
|
Your architecture may define the following macros to request
|
2781 |
|
|
conversions between the raw and virtual format:
|
2782 |
|
|
|
2783 |
|
|
-- Target Macro: int REGISTER_CONVERTIBLE (int REG)
|
2784 |
|
|
Return non-zero if register number REG's value needs different raw
|
2785 |
|
|
and virtual formats.
|
2786 |
|
|
|
2787 |
|
|
You should not use `REGISTER_CONVERT_TO_VIRTUAL' for a register
|
2788 |
|
|
unless this macro returns a non-zero value for that register.
|
2789 |
|
|
|
2790 |
|
|
-- Target Macro: int DEPRECATED_REGISTER_RAW_SIZE (int REG)
|
2791 |
|
|
The size of register number REG's raw value. This is the number
|
2792 |
|
|
of bytes the register will occupy in `registers', or in a GDB
|
2793 |
|
|
remote protocol packet.
|
2794 |
|
|
|
2795 |
|
|
-- Target Macro: int DEPRECATED_REGISTER_VIRTUAL_SIZE (int REG)
|
2796 |
|
|
The size of register number REG's value, in its virtual format.
|
2797 |
|
|
This is the size a `struct value''s buffer will have, holding that
|
2798 |
|
|
register's value.
|
2799 |
|
|
|
2800 |
|
|
-- Target Macro: struct type *DEPRECATED_REGISTER_VIRTUAL_TYPE (int
|
2801 |
|
|
REG)
|
2802 |
|
|
This is the type of the virtual representation of register number
|
2803 |
|
|
REG. Note that there is no need for a macro giving a type for the
|
2804 |
|
|
register's raw form; once the register's value has been obtained,
|
2805 |
|
|
GDB always uses the virtual form.
|
2806 |
|
|
|
2807 |
|
|
-- Target Macro: void REGISTER_CONVERT_TO_VIRTUAL (int REG, struct
|
2808 |
|
|
type *TYPE, char *FROM, char *TO)
|
2809 |
|
|
Convert the value of register number REG to TYPE, which should
|
2810 |
|
|
always be `DEPRECATED_REGISTER_VIRTUAL_TYPE (REG)'. The buffer at
|
2811 |
|
|
FROM holds the register's value in raw format; the macro should
|
2812 |
|
|
convert the value to virtual format, and place it at TO.
|
2813 |
|
|
|
2814 |
|
|
Note that `REGISTER_CONVERT_TO_VIRTUAL' and
|
2815 |
|
|
`REGISTER_CONVERT_TO_RAW' take their REG and TYPE arguments in
|
2816 |
|
|
different orders.
|
2817 |
|
|
|
2818 |
|
|
You should only use `REGISTER_CONVERT_TO_VIRTUAL' with registers
|
2819 |
|
|
for which the `REGISTER_CONVERTIBLE' macro returns a non-zero
|
2820 |
|
|
value.
|
2821 |
|
|
|
2822 |
|
|
-- Target Macro: void REGISTER_CONVERT_TO_RAW (struct type *TYPE, int
|
2823 |
|
|
REG, char *FROM, char *TO)
|
2824 |
|
|
Convert the value of register number REG to TYPE, which should
|
2825 |
|
|
always be `DEPRECATED_REGISTER_VIRTUAL_TYPE (REG)'. The buffer at
|
2826 |
|
|
FROM holds the register's value in raw format; the macro should
|
2827 |
|
|
convert the value to virtual format, and place it at TO.
|
2828 |
|
|
|
2829 |
|
|
Note that REGISTER_CONVERT_TO_VIRTUAL and REGISTER_CONVERT_TO_RAW
|
2830 |
|
|
take their REG and TYPE arguments in different orders.
|
2831 |
|
|
|
2832 |
|
|
|
2833 |
|
|
File: gdbint.info, Node: Register and Memory Data, Next: Frame Interpretation, Prev: Raw and Virtual Registers, Up: Target Architecture Definition
|
2834 |
|
|
|
2835 |
|
|
9.7 Using Different Register and Memory Data Representations
|
2836 |
|
|
============================================================
|
2837 |
|
|
|
2838 |
|
|
_Maintainer's note: The way GDB manipulates registers is undergoing
|
2839 |
|
|
significant change. Many of the macros and functions referred to in
|
2840 |
|
|
this section are likely to be subject to further revision. See A.R.
|
2841 |
|
|
Index (http://sources.redhat.com/gdb/current/ari/) and Bug Tracking
|
2842 |
|
|
Database (http://www.gnu.org/software/gdb/bugs) for further
|
2843 |
|
|
information. cagney/2002-05-06._
|
2844 |
|
|
|
2845 |
|
|
Some architectures can represent a data object in a register using a
|
2846 |
|
|
form that is different to the objects more normal memory representation.
|
2847 |
|
|
For example:
|
2848 |
|
|
|
2849 |
|
|
* The Alpha architecture can represent 32 bit integer values in
|
2850 |
|
|
floating-point registers.
|
2851 |
|
|
|
2852 |
|
|
* The x86 architecture supports 80-bit floating-point registers. The
|
2853 |
|
|
`long double' data type occupies 96 bits in memory but only 80 bits
|
2854 |
|
|
when stored in a register.
|
2855 |
|
|
|
2856 |
|
|
|
2857 |
|
|
In general, the register representation of a data type is determined
|
2858 |
|
|
by the architecture, or GDB's interface to the architecture, while the
|
2859 |
|
|
memory representation is determined by the Application Binary Interface.
|
2860 |
|
|
|
2861 |
|
|
For almost all data types on almost all architectures, the two
|
2862 |
|
|
representations are identical, and no special handling is needed.
|
2863 |
|
|
However, they do occasionally differ. Your architecture may define the
|
2864 |
|
|
following macros to request conversions between the register and memory
|
2865 |
|
|
representations of a data type:
|
2866 |
|
|
|
2867 |
|
|
-- Function: int gdbarch_convert_register_p (struct gdbarch *GDBARCH,
|
2868 |
|
|
int REG)
|
2869 |
|
|
Return non-zero if the representation of a data value stored in
|
2870 |
|
|
this register may be different to the representation of that same
|
2871 |
|
|
data value when stored in memory.
|
2872 |
|
|
|
2873 |
|
|
When non-zero, the macros `gdbarch_register_to_value' and
|
2874 |
|
|
`value_to_register' are used to perform any necessary conversion.
|
2875 |
|
|
|
2876 |
|
|
This function should return zero for the register's native type,
|
2877 |
|
|
when no conversion is necessary.
|
2878 |
|
|
|
2879 |
|
|
-- Function: void gdbarch_register_to_value (struct gdbarch *GDBARCH,
|
2880 |
|
|
int REG, struct type *TYPE, char *FROM, char *TO)
|
2881 |
|
|
Convert the value of register number REG to a data object of type
|
2882 |
|
|
TYPE. The buffer at FROM holds the register's value in raw
|
2883 |
|
|
format; the converted value should be placed in the buffer at TO.
|
2884 |
|
|
|
2885 |
|
|
Note that `gdbarch_register_to_value' and
|
2886 |
|
|
`gdbarch_value_to_register' take their REG and TYPE arguments in
|
2887 |
|
|
different orders.
|
2888 |
|
|
|
2889 |
|
|
You should only use `gdbarch_register_to_value' with registers for
|
2890 |
|
|
which the `gdbarch_convert_register_p' function returns a non-zero
|
2891 |
|
|
value.
|
2892 |
|
|
|
2893 |
|
|
-- Function: void gdbarch_value_to_register (struct gdbarch *GDBARCH,
|
2894 |
|
|
struct type *TYPE, int REG, char *FROM, char *TO)
|
2895 |
|
|
Convert a data value of type TYPE to register number REG' raw
|
2896 |
|
|
format.
|
2897 |
|
|
|
2898 |
|
|
Note that `gdbarch_register_to_value' and
|
2899 |
|
|
`gdbarch_value_to_register' take their REG and TYPE arguments in
|
2900 |
|
|
different orders.
|
2901 |
|
|
|
2902 |
|
|
You should only use `gdbarch_value_to_register' with registers for
|
2903 |
|
|
which the `gdbarch_convert_register_p' function returns a non-zero
|
2904 |
|
|
value.
|
2905 |
|
|
|
2906 |
|
|
-- Target Macro: void REGISTER_CONVERT_TO_TYPE (int REGNUM, struct
|
2907 |
|
|
type *TYPE, char *BUF)
|
2908 |
|
|
See `mips-tdep.c'. It does not do what you want.
|
2909 |
|
|
|
2910 |
|
|
|
2911 |
|
|
File: gdbint.info, Node: Frame Interpretation, Next: Inferior Call Setup, Prev: Register and Memory Data, Up: Target Architecture Definition
|
2912 |
|
|
|
2913 |
|
|
9.8 Frame Interpretation
|
2914 |
|
|
========================
|
2915 |
|
|
|
2916 |
|
|
|
2917 |
|
|
File: gdbint.info, Node: Inferior Call Setup, Next: Compiler Characteristics, Prev: Frame Interpretation, Up: Target Architecture Definition
|
2918 |
|
|
|
2919 |
|
|
9.9 Inferior Call Setup
|
2920 |
|
|
=======================
|
2921 |
|
|
|
2922 |
|
|
|
2923 |
|
|
File: gdbint.info, Node: Compiler Characteristics, Next: Target Conditionals, Prev: Inferior Call Setup, Up: Target Architecture Definition
|
2924 |
|
|
|
2925 |
|
|
9.10 Compiler Characteristics
|
2926 |
|
|
=============================
|
2927 |
|
|
|
2928 |
|
|
|
2929 |
|
|
File: gdbint.info, Node: Target Conditionals, Next: Adding a New Target, Prev: Compiler Characteristics, Up: Target Architecture Definition
|
2930 |
|
|
|
2931 |
|
|
9.11 Target Conditionals
|
2932 |
|
|
========================
|
2933 |
|
|
|
2934 |
|
|
This section describes the macros and functions that you can use to
|
2935 |
|
|
define the target machine.
|
2936 |
|
|
|
2937 |
|
|
`CORE_ADDR gdbarch_addr_bits_remove (GDBARCH, ADDR)'
|
2938 |
|
|
If a raw machine instruction address includes any bits that are not
|
2939 |
|
|
really part of the address, then this function is used to zero
|
2940 |
|
|
those bits in ADDR. This is only used for addresses of
|
2941 |
|
|
instructions, and even then not in all contexts.
|
2942 |
|
|
|
2943 |
|
|
For example, the two low-order bits of the PC on the
|
2944 |
|
|
Hewlett-Packard PA 2.0 architecture contain the privilege level of
|
2945 |
|
|
the corresponding instruction. Since instructions must always be
|
2946 |
|
|
aligned on four-byte boundaries, the processor masks out these
|
2947 |
|
|
bits to generate the actual address of the instruction.
|
2948 |
|
|
`gdbarch_addr_bits_remove' would then for example look like that:
|
2949 |
|
|
arch_addr_bits_remove (CORE_ADDR addr)
|
2950 |
|
|
{
|
2951 |
|
|
return (addr &= ~0x3);
|
2952 |
|
|
}
|
2953 |
|
|
|
2954 |
|
|
`int address_class_name_to_type_flags (GDBARCH, NAME, TYPE_FLAGS_PTR)'
|
2955 |
|
|
If NAME is a valid address class qualifier name, set the `int'
|
2956 |
|
|
referenced by TYPE_FLAGS_PTR to the mask representing the qualifier
|
2957 |
|
|
and return 1. If NAME is not a valid address class qualifier name,
|
2958 |
|
|
return 0.
|
2959 |
|
|
|
2960 |
|
|
The value for TYPE_FLAGS_PTR should be one of
|
2961 |
|
|
`TYPE_FLAG_ADDRESS_CLASS_1', `TYPE_FLAG_ADDRESS_CLASS_2', or
|
2962 |
|
|
possibly some combination of these values or'd together. *Note
|
2963 |
|
|
Address Classes: Target Architecture Definition.
|
2964 |
|
|
|
2965 |
|
|
`int address_class_name_to_type_flags_p (GDBARCH)'
|
2966 |
|
|
Predicate which indicates whether
|
2967 |
|
|
`address_class_name_to_type_flags' has been defined.
|
2968 |
|
|
|
2969 |
|
|
`int gdbarch_address_class_type_flags (GDBARCH, BYTE_SIZE, DWARF2_ADDR_CLASS)'
|
2970 |
|
|
Given a pointers byte size (as described by the debug information)
|
2971 |
|
|
and the possible `DW_AT_address_class' value, return the type flags
|
2972 |
|
|
used by GDB to represent this address class. The value returned
|
2973 |
|
|
should be one of `TYPE_FLAG_ADDRESS_CLASS_1',
|
2974 |
|
|
`TYPE_FLAG_ADDRESS_CLASS_2', or possibly some combination of these
|
2975 |
|
|
values or'd together. *Note Address Classes: Target Architecture
|
2976 |
|
|
Definition.
|
2977 |
|
|
|
2978 |
|
|
`int gdbarch_address_class_type_flags_p (GDBARCH)'
|
2979 |
|
|
Predicate which indicates whether
|
2980 |
|
|
`gdbarch_address_class_type_flags_p' has been defined.
|
2981 |
|
|
|
2982 |
|
|
`const char *gdbarch_address_class_type_flags_to_name (GDBARCH, TYPE_FLAGS)'
|
2983 |
|
|
Return the name of the address class qualifier associated with the
|
2984 |
|
|
type flags given by TYPE_FLAGS.
|
2985 |
|
|
|
2986 |
|
|
`int gdbarch_address_class_type_flags_to_name_p (GDBARCH)'
|
2987 |
|
|
Predicate which indicates whether
|
2988 |
|
|
`gdbarch_address_class_type_flags_to_name' has been defined.
|
2989 |
|
|
*Note Address Classes: Target Architecture Definition.
|
2990 |
|
|
|
2991 |
|
|
`void gdbarch_address_to_pointer (GDBARCH, TYPE, BUF, ADDR)'
|
2992 |
|
|
Store in BUF a pointer of type TYPE representing the address ADDR,
|
2993 |
|
|
in the appropriate format for the current architecture. This
|
2994 |
|
|
function may safely assume that TYPE is either a pointer or a C++
|
2995 |
|
|
reference type. *Note Pointers Are Not Always Addresses: Target
|
2996 |
|
|
Architecture Definition.
|
2997 |
|
|
|
2998 |
|
|
`int gdbarch_believe_pcc_promotion (GDBARCH)'
|
2999 |
|
|
Used to notify if the compiler promotes a `short' or `char'
|
3000 |
|
|
parameter to an `int', but still reports the parameter as its
|
3001 |
|
|
original type, rather than the promoted type.
|
3002 |
|
|
|
3003 |
|
|
`gdbarch_bits_big_endian (GDBARCH)'
|
3004 |
|
|
This is used if the numbering of bits in the targets does *not*
|
3005 |
|
|
match the endianness of the target byte order. A value of 1 means
|
3006 |
|
|
that the bits are numbered in a big-endian bit order, 0 means
|
3007 |
|
|
little-endian.
|
3008 |
|
|
|
3009 |
|
|
`set_gdbarch_bits_big_endian (GDBARCH, BITS_BIG_ENDIAN)'
|
3010 |
|
|
Calling set_gdbarch_bits_big_endian with a value of 1 indicates
|
3011 |
|
|
that the bits in the target are numbered in a big-endian bit
|
3012 |
|
|
order, 0 indicates little-endian.
|
3013 |
|
|
|
3014 |
|
|
`BREAKPOINT'
|
3015 |
|
|
This is the character array initializer for the bit pattern to put
|
3016 |
|
|
into memory where a breakpoint is set. Although it's common to
|
3017 |
|
|
use a trap instruction for a breakpoint, it's not required; for
|
3018 |
|
|
instance, the bit pattern could be an invalid instruction. The
|
3019 |
|
|
breakpoint must be no longer than the shortest instruction of the
|
3020 |
|
|
architecture.
|
3021 |
|
|
|
3022 |
|
|
`BREAKPOINT' has been deprecated in favor of
|
3023 |
|
|
`gdbarch_breakpoint_from_pc'.
|
3024 |
|
|
|
3025 |
|
|
`BIG_BREAKPOINT'
|
3026 |
|
|
`LITTLE_BREAKPOINT'
|
3027 |
|
|
Similar to BREAKPOINT, but used for bi-endian targets.
|
3028 |
|
|
|
3029 |
|
|
`BIG_BREAKPOINT' and `LITTLE_BREAKPOINT' have been deprecated in
|
3030 |
|
|
favor of `gdbarch_breakpoint_from_pc'.
|
3031 |
|
|
|
3032 |
|
|
`const gdb_byte *gdbarch_breakpoint_from_pc (GDBARCH, PCPTR, LENPTR)'
|
3033 |
|
|
Use the program counter to determine the contents and size of a
|
3034 |
|
|
breakpoint instruction. It returns a pointer to a string of bytes
|
3035 |
|
|
that encode a breakpoint instruction, stores the length of the
|
3036 |
|
|
string to `*LENPTR', and adjusts the program counter (if
|
3037 |
|
|
necessary) to point to the actual memory location where the
|
3038 |
|
|
breakpoint should be inserted.
|
3039 |
|
|
|
3040 |
|
|
Although it is common to use a trap instruction for a breakpoint,
|
3041 |
|
|
it's not required; for instance, the bit pattern could be an
|
3042 |
|
|
invalid instruction. The breakpoint must be no longer than the
|
3043 |
|
|
shortest instruction of the architecture.
|
3044 |
|
|
|
3045 |
|
|
Replaces all the other BREAKPOINT macros.
|
3046 |
|
|
|
3047 |
|
|
`int gdbarch_memory_insert_breakpoint (GDBARCH, BP_TGT)'
|
3048 |
|
|
`gdbarch_memory_remove_breakpoint (GDBARCH, BP_TGT)'
|
3049 |
|
|
Insert or remove memory based breakpoints. Reasonable defaults
|
3050 |
|
|
(`default_memory_insert_breakpoint' and
|
3051 |
|
|
`default_memory_remove_breakpoint' respectively) have been
|
3052 |
|
|
provided so that it is not necessary to set these for most
|
3053 |
|
|
architectures. Architectures which may want to set
|
3054 |
|
|
`gdbarch_memory_insert_breakpoint' and
|
3055 |
|
|
`gdbarch_memory_remove_breakpoint' will likely have instructions
|
3056 |
|
|
that are oddly sized or are not stored in a conventional manner.
|
3057 |
|
|
|
3058 |
|
|
It may also be desirable (from an efficiency standpoint) to define
|
3059 |
|
|
custom breakpoint insertion and removal routines if
|
3060 |
|
|
`gdbarch_breakpoint_from_pc' needs to read the target's memory for
|
3061 |
|
|
some reason.
|
3062 |
|
|
|
3063 |
|
|
`CORE_ADDR gdbarch_adjust_breakpoint_address (GDBARCH, BPADDR)'
|
3064 |
|
|
Given an address at which a breakpoint is desired, return a
|
3065 |
|
|
breakpoint address adjusted to account for architectural
|
3066 |
|
|
constraints on breakpoint placement. This method is not needed by
|
3067 |
|
|
most targets.
|
3068 |
|
|
|
3069 |
|
|
The FR-V target (see `frv-tdep.c') requires this method. The FR-V
|
3070 |
|
|
is a VLIW architecture in which a number of RISC-like instructions
|
3071 |
|
|
are grouped (packed) together into an aggregate instruction or
|
3072 |
|
|
instruction bundle. When the processor executes one of these
|
3073 |
|
|
bundles, the component instructions are executed in parallel.
|
3074 |
|
|
|
3075 |
|
|
In the course of optimization, the compiler may group instructions
|
3076 |
|
|
from distinct source statements into the same bundle. The line
|
3077 |
|
|
number information associated with one of the latter statements
|
3078 |
|
|
will likely refer to some instruction other than the first one in
|
3079 |
|
|
the bundle. So, if the user attempts to place a breakpoint on one
|
3080 |
|
|
of these latter statements, GDB must be careful to _not_ place the
|
3081 |
|
|
break instruction on any instruction other than the first one in
|
3082 |
|
|
the bundle. (Remember though that the instructions within a
|
3083 |
|
|
bundle execute in parallel, so the _first_ instruction is the
|
3084 |
|
|
instruction at the lowest address and has nothing to do with
|
3085 |
|
|
execution order.)
|
3086 |
|
|
|
3087 |
|
|
The FR-V's `gdbarch_adjust_breakpoint_address' method will adjust a
|
3088 |
|
|
breakpoint's address by scanning backwards for the beginning of
|
3089 |
|
|
the bundle, returning the address of the bundle.
|
3090 |
|
|
|
3091 |
|
|
Since the adjustment of a breakpoint may significantly alter a
|
3092 |
|
|
user's expectation, GDB prints a warning when an adjusted
|
3093 |
|
|
breakpoint is initially set and each time that that breakpoint is
|
3094 |
|
|
hit.
|
3095 |
|
|
|
3096 |
|
|
`int gdbarch_call_dummy_location (GDBARCH)'
|
3097 |
|
|
See the file `inferior.h'.
|
3098 |
|
|
|
3099 |
|
|
This method has been replaced by `gdbarch_push_dummy_code' (*note
|
3100 |
|
|
gdbarch_push_dummy_code::).
|
3101 |
|
|
|
3102 |
|
|
`int gdbarch_cannot_fetch_register (GDBARCH, REGUM)'
|
3103 |
|
|
This function should return nonzero if REGNO cannot be fetched
|
3104 |
|
|
from an inferior process. This is only relevant if
|
3105 |
|
|
`FETCH_INFERIOR_REGISTERS' is not defined.
|
3106 |
|
|
|
3107 |
|
|
`int gdbarch_cannot_store_register (GDBARCH, REGNUM)'
|
3108 |
|
|
This function should return nonzero if REGNO should not be written
|
3109 |
|
|
to the target. This is often the case for program counters,
|
3110 |
|
|
status words, and other special registers. This function returns
|
3111 |
|
|
|
3112 |
|
|
written.
|
3113 |
|
|
|
3114 |
|
|
`int gdbarch_convert_register_p (GDBARCH, REGNUM, struct type *TYPE)'
|
3115 |
|
|
Return non-zero if register REGNUM represents data values of type
|
3116 |
|
|
TYPE in a non-standard form. *Note Using Different Register and
|
3117 |
|
|
Memory Data Representations: Target Architecture Definition.
|
3118 |
|
|
|
3119 |
|
|
`CORE_ADDR gdbarch_decr_pc_after_break (GDBARCH)'
|
3120 |
|
|
This function shall return the amount by which to decrement the PC
|
3121 |
|
|
after the program encounters a breakpoint. This is often the
|
3122 |
|
|
number of bytes in `BREAKPOINT', though not always. For most
|
3123 |
|
|
targets this value will be 0.
|
3124 |
|
|
|
3125 |
|
|
`DISABLE_UNSETTABLE_BREAK (ADDR)'
|
3126 |
|
|
If defined, this should evaluate to 1 if ADDR is in a shared
|
3127 |
|
|
library in which breakpoints cannot be set and so should be
|
3128 |
|
|
disabled.
|
3129 |
|
|
|
3130 |
|
|
`void gdbarch_print_float_info (GDBARCH, FILE, FRAME, ARGS)'
|
3131 |
|
|
If defined, then the `info float' command will print information
|
3132 |
|
|
about the processor's floating point unit.
|
3133 |
|
|
|
3134 |
|
|
`void gdbarch_print_registers_info (GDBARCH, FRAME, REGNUM, ALL)'
|
3135 |
|
|
If defined, pretty print the value of the register REGNUM for the
|
3136 |
|
|
specified FRAME. If the value of REGNUM is -1, pretty print
|
3137 |
|
|
either all registers (ALL is non zero) or a select subset of
|
3138 |
|
|
registers (ALL is zero).
|
3139 |
|
|
|
3140 |
|
|
The default method prints one register per line, and if ALL is
|
3141 |
|
|
zero omits floating-point registers.
|
3142 |
|
|
|
3143 |
|
|
`int gdbarch_print_vector_info (GDBARCH, FILE, FRAME, ARGS)'
|
3144 |
|
|
If defined, then the `info vector' command will call this function
|
3145 |
|
|
to print information about the processor's vector unit.
|
3146 |
|
|
|
3147 |
|
|
By default, the `info vector' command will print all vector
|
3148 |
|
|
registers (the register's type having the vector attribute).
|
3149 |
|
|
|
3150 |
|
|
`int gdbarch_dwarf_reg_to_regnum (GDBARCH, DWARF_REGNR)'
|
3151 |
|
|
Convert DWARF register number DWARF_REGNR into GDB regnum. If not
|
3152 |
|
|
defined, no conversion will be performed.
|
3153 |
|
|
|
3154 |
|
|
`int gdbarch_dwarf2_reg_to_regnum (GDBARCH, DWARF2_REGNR)'
|
3155 |
|
|
Convert DWARF2 register number DWARF2_REGNR into GDB regnum. If
|
3156 |
|
|
not defined, no conversion will be performed.
|
3157 |
|
|
|
3158 |
|
|
`int gdbarch_ecoff_reg_to_regnum (GDBARCH, ECOFF_REGNR)'
|
3159 |
|
|
Convert ECOFF register number ECOFF_REGNR into GDB regnum. If
|
3160 |
|
|
not defined, no conversion will be performed.
|
3161 |
|
|
|
3162 |
|
|
`DEPRECATED_FP_REGNUM'
|
3163 |
|
|
If the virtual frame pointer is kept in a register, then define
|
3164 |
|
|
this macro to be the number (greater than or equal to zero) of
|
3165 |
|
|
that register.
|
3166 |
|
|
|
3167 |
|
|
This should only need to be defined if `DEPRECATED_TARGET_READ_FP'
|
3168 |
|
|
is not defined.
|
3169 |
|
|
|
3170 |
|
|
`DEPRECATED_FRAMELESS_FUNCTION_INVOCATION(FI)'
|
3171 |
|
|
Define this to an expression that returns 1 if the function
|
3172 |
|
|
invocation represented by FI does not have a stack frame
|
3173 |
|
|
associated with it. Otherwise return 0.
|
3174 |
|
|
|
3175 |
|
|
`CORE_ADDR frame_align (GDBARCH, ADDRESS)'
|
3176 |
|
|
Define this to adjust ADDRESS so that it meets the alignment
|
3177 |
|
|
requirements for the start of a new stack frame. A stack frame's
|
3178 |
|
|
alignment requirements are typically stronger than a target
|
3179 |
|
|
processors stack alignment requirements.
|
3180 |
|
|
|
3181 |
|
|
This function is used to ensure that, when creating a dummy frame,
|
3182 |
|
|
both the initial stack pointer and (if needed) the address of the
|
3183 |
|
|
return value are correctly aligned.
|
3184 |
|
|
|
3185 |
|
|
This function always adjusts the address in the direction of stack
|
3186 |
|
|
growth.
|
3187 |
|
|
|
3188 |
|
|
By default, no frame based stack alignment is performed.
|
3189 |
|
|
|
3190 |
|
|
`int gdbarch_frame_red_zone_size (GDBARCH)'
|
3191 |
|
|
The number of bytes, beyond the innermost-stack-address, reserved
|
3192 |
|
|
by the ABI. A function is permitted to use this scratch area
|
3193 |
|
|
(instead of allocating extra stack space).
|
3194 |
|
|
|
3195 |
|
|
When performing an inferior function call, to ensure that it does
|
3196 |
|
|
not modify this area, GDB adjusts the innermost-stack-address by
|
3197 |
|
|
GDBARCH_FRAME_RED_ZONE_SIZE bytes before pushing parameters onto
|
3198 |
|
|
the stack.
|
3199 |
|
|
|
3200 |
|
|
By default, zero bytes are allocated. The value must be aligned
|
3201 |
|
|
(*note frame_align::).
|
3202 |
|
|
|
3203 |
|
|
The AMD64 (nee x86-64) ABI documentation refers to the _red zone_
|
3204 |
|
|
when describing this scratch area.
|
3205 |
|
|
|
3206 |
|
|
`DEPRECATED_FRAME_CHAIN(FRAME)'
|
3207 |
|
|
Given FRAME, return a pointer to the calling frame.
|
3208 |
|
|
|
3209 |
|
|
`DEPRECATED_FRAME_CHAIN_VALID(CHAIN, THISFRAME)'
|
3210 |
|
|
Define this to be an expression that returns zero if the given
|
3211 |
|
|
frame is an outermost frame, with no caller, and nonzero
|
3212 |
|
|
otherwise. Most normal situations can be handled without defining
|
3213 |
|
|
this macro, including `NULL' chain pointers, dummy frames, and
|
3214 |
|
|
frames whose PC values are inside the startup file (e.g.
|
3215 |
|
|
`crt0.o'), inside `main', or inside `_start'.
|
3216 |
|
|
|
3217 |
|
|
`DEPRECATED_FRAME_INIT_SAVED_REGS(FRAME)'
|
3218 |
|
|
See `frame.h'. Determines the address of all registers in the
|
3219 |
|
|
current stack frame storing each in `frame->saved_regs'. Space for
|
3220 |
|
|
`frame->saved_regs' shall be allocated by
|
3221 |
|
|
`DEPRECATED_FRAME_INIT_SAVED_REGS' using `frame_saved_regs_zalloc'.
|
3222 |
|
|
|
3223 |
|
|
`FRAME_FIND_SAVED_REGS' is deprecated.
|
3224 |
|
|
|
3225 |
|
|
`int gdbarch_frame_num_args (GDBARCH, FRAME)'
|
3226 |
|
|
For the frame described by FRAME return the number of arguments
|
3227 |
|
|
that are being passed. If the number of arguments is not known,
|
3228 |
|
|
return `-1'.
|
3229 |
|
|
|
3230 |
|
|
`DEPRECATED_FRAME_SAVED_PC(FRAME)'
|
3231 |
|
|
Given FRAME, return the pc saved there. This is the return
|
3232 |
|
|
address.
|
3233 |
|
|
|
3234 |
|
|
This method is deprecated. *Note gdbarch_unwind_pc::.
|
3235 |
|
|
|
3236 |
|
|
`CORE_ADDR gdbarch_unwind_pc (NEXT_FRAME)'
|
3237 |
|
|
Return the instruction address, in NEXT_FRAME's caller, at which
|
3238 |
|
|
execution will resume after NEXT_FRAME returns. This is commonly
|
3239 |
|
|
referred to as the return address.
|
3240 |
|
|
|
3241 |
|
|
The implementation, which must be frame agnostic (work with any
|
3242 |
|
|
frame), is typically no more than:
|
3243 |
|
|
|
3244 |
|
|
ULONGEST pc;
|
3245 |
|
|
pc = frame_unwind_register_unsigned (next_frame, S390_PC_REGNUM);
|
3246 |
|
|
return gdbarch_addr_bits_remove (gdbarch, pc);
|
3247 |
|
|
|
3248 |
|
|
*Note DEPRECATED_FRAME_SAVED_PC::, which this method replaces.
|
3249 |
|
|
|
3250 |
|
|
`CORE_ADDR gdbarch_unwind_sp (GDBARCH, NEXT_FRAME)'
|
3251 |
|
|
Return the frame's inner most stack address. This is commonly
|
3252 |
|
|
referred to as the frame's "stack pointer".
|
3253 |
|
|
|
3254 |
|
|
The implementation, which must be frame agnostic (work with any
|
3255 |
|
|
frame), is typically no more than:
|
3256 |
|
|
|
3257 |
|
|
ULONGEST sp;
|
3258 |
|
|
sp = frame_unwind_register_unsigned (next_frame, S390_SP_REGNUM);
|
3259 |
|
|
return gdbarch_addr_bits_remove (gdbarch, sp);
|
3260 |
|
|
|
3261 |
|
|
*Note TARGET_READ_SP::, which this method replaces.
|
3262 |
|
|
|
3263 |
|
|
`FUNCTION_EPILOGUE_SIZE'
|
3264 |
|
|
For some COFF targets, the `x_sym.x_misc.x_fsize' field of the
|
3265 |
|
|
function end symbol is 0. For such targets, you must define
|
3266 |
|
|
`FUNCTION_EPILOGUE_SIZE' to expand into the standard size of a
|
3267 |
|
|
function's epilogue.
|
3268 |
|
|
|
3269 |
|
|
`DEPRECATED_FUNCTION_START_OFFSET'
|
3270 |
|
|
An integer, giving the offset in bytes from a function's address
|
3271 |
|
|
(as used in the values of symbols, function pointers, etc.), and
|
3272 |
|
|
the function's first genuine instruction.
|
3273 |
|
|
|
3274 |
|
|
This is zero on almost all machines: the function's address is
|
3275 |
|
|
usually the address of its first instruction. However, on the
|
3276 |
|
|
VAX, for example, each function starts with two bytes containing a
|
3277 |
|
|
bitmask indicating which registers to save upon entry to the
|
3278 |
|
|
function. The VAX `call' instructions check this value, and save
|
3279 |
|
|
the appropriate registers automatically. Thus, since the offset
|
3280 |
|
|
from the function's address to its first instruction is two bytes,
|
3281 |
|
|
`DEPRECATED_FUNCTION_START_OFFSET' would be 2 on the VAX.
|
3282 |
|
|
|
3283 |
|
|
`GCC_COMPILED_FLAG_SYMBOL'
|
3284 |
|
|
`GCC2_COMPILED_FLAG_SYMBOL'
|
3285 |
|
|
If defined, these are the names of the symbols that GDB will look
|
3286 |
|
|
for to detect that GCC compiled the file. The default symbols are
|
3287 |
|
|
`gcc_compiled.' and `gcc2_compiled.', respectively. (Currently
|
3288 |
|
|
only defined for the Delta 68.)
|
3289 |
|
|
|
3290 |
|
|
`gdbarch_get_longjmp_target'
|
3291 |
|
|
For most machines, this is a target-dependent parameter. On the
|
3292 |
|
|
DECstation and the Iris, this is a native-dependent parameter,
|
3293 |
|
|
since the header file `setjmp.h' is needed to define it.
|
3294 |
|
|
|
3295 |
|
|
This macro determines the target PC address that `longjmp' will
|
3296 |
|
|
jump to, assuming that we have just stopped at a `longjmp'
|
3297 |
|
|
breakpoint. It takes a `CORE_ADDR *' as argument, and stores the
|
3298 |
|
|
target PC value through this pointer. It examines the current
|
3299 |
|
|
state of the machine as needed.
|
3300 |
|
|
|
3301 |
|
|
`DEPRECATED_IBM6000_TARGET'
|
3302 |
|
|
Shows that we are configured for an IBM RS/6000 system. This
|
3303 |
|
|
conditional should be eliminated (FIXME) and replaced by
|
3304 |
|
|
feature-specific macros. It was introduced in a haste and we are
|
3305 |
|
|
repenting at leisure.
|
3306 |
|
|
|
3307 |
|
|
`I386_USE_GENERIC_WATCHPOINTS'
|
3308 |
|
|
An x86-based target can define this to use the generic x86
|
3309 |
|
|
watchpoint support; see *Note I386_USE_GENERIC_WATCHPOINTS:
|
3310 |
|
|
Algorithms.
|
3311 |
|
|
|
3312 |
|
|
`int gdbarch_inner_than (GDBARCH, LHS, RHS)'
|
3313 |
|
|
Returns non-zero if stack address LHS is inner than (nearer to the
|
3314 |
|
|
stack top) stack address RHS. Let the function return `lhs < rhs'
|
3315 |
|
|
if the target's stack grows downward in memory, or `lhs > rsh' if
|
3316 |
|
|
the stack grows upward.
|
3317 |
|
|
|
3318 |
|
|
`gdbarch_in_function_epilogue_p (GDBARCH, ADDR)'
|
3319 |
|
|
Returns non-zero if the given ADDR is in the epilogue of a
|
3320 |
|
|
function. The epilogue of a function is defined as the part of a
|
3321 |
|
|
function where the stack frame of the function already has been
|
3322 |
|
|
destroyed up to the final `return from function call' instruction.
|
3323 |
|
|
|
3324 |
|
|
`int gdbarch_in_solib_return_trampoline (GDBARCH, PC, NAME)'
|
3325 |
|
|
Define this function to return nonzero if the program is stopped
|
3326 |
|
|
in the trampoline that returns from a shared library.
|
3327 |
|
|
|
3328 |
|
|
`IN_SOLIB_DYNSYM_RESOLVE_CODE (PC)'
|
3329 |
|
|
Define this to return nonzero if the program is stopped in the
|
3330 |
|
|
dynamic linker.
|
3331 |
|
|
|
3332 |
|
|
`SKIP_SOLIB_RESOLVER (PC)'
|
3333 |
|
|
Define this to evaluate to the (nonzero) address at which execution
|
3334 |
|
|
should continue to get past the dynamic linker's symbol resolution
|
3335 |
|
|
function. A zero value indicates that it is not important or
|
3336 |
|
|
necessary to set a breakpoint to get through the dynamic linker
|
3337 |
|
|
and that single stepping will suffice.
|
3338 |
|
|
|
3339 |
|
|
`CORE_ADDR gdbarch_integer_to_address (GDBARCH, TYPE, BUF)'
|
3340 |
|
|
Define this when the architecture needs to handle non-pointer to
|
3341 |
|
|
address conversions specially. Converts that value to an address
|
3342 |
|
|
according to the current architectures conventions.
|
3343 |
|
|
|
3344 |
|
|
_Pragmatics: When the user copies a well defined expression from
|
3345 |
|
|
their source code and passes it, as a parameter, to GDB's `print'
|
3346 |
|
|
command, they should get the same value as would have been
|
3347 |
|
|
computed by the target program. Any deviation from this rule can
|
3348 |
|
|
cause major confusion and annoyance, and needs to be justified
|
3349 |
|
|
carefully. In other words, GDB doesn't really have the freedom to
|
3350 |
|
|
do these conversions in clever and useful ways. It has, however,
|
3351 |
|
|
been pointed out that users aren't complaining about how GDB casts
|
3352 |
|
|
integers to pointers; they are complaining that they can't take an
|
3353 |
|
|
address from a disassembly listing and give it to `x/i'. Adding
|
3354 |
|
|
an architecture method like `gdbarch_integer_to_address' certainly
|
3355 |
|
|
makes it possible for GDB to "get it right" in all circumstances._
|
3356 |
|
|
|
3357 |
|
|
*Note Pointers Are Not Always Addresses: Target Architecture
|
3358 |
|
|
Definition.
|
3359 |
|
|
|
3360 |
|
|
`CORE_ADDR gdbarch_pointer_to_address (GDBARCH, TYPE, BUF)'
|
3361 |
|
|
Assume that BUF holds a pointer of type TYPE, in the appropriate
|
3362 |
|
|
format for the current architecture. Return the byte address the
|
3363 |
|
|
pointer refers to. *Note Pointers Are Not Always Addresses:
|
3364 |
|
|
Target Architecture Definition.
|
3365 |
|
|
|
3366 |
|
|
`void gdbarch_register_to_value(GDBARCH, FRAME, REGNUM, TYPE, FUR)'
|
3367 |
|
|
Convert the raw contents of register REGNUM into a value of type
|
3368 |
|
|
TYPE. *Note Using Different Register and Memory Data
|
3369 |
|
|
Representations: Target Architecture Definition.
|
3370 |
|
|
|
3371 |
|
|
`register_reggroup_p (GDBARCH, REGNUM, REGGROUP)'
|
3372 |
|
|
Return non-zero if register REGNUM is a member of the register
|
3373 |
|
|
group REGGROUP.
|
3374 |
|
|
|
3375 |
|
|
By default, registers are grouped as follows:
|
3376 |
|
|
|
3377 |
|
|
`float_reggroup'
|
3378 |
|
|
Any register with a valid name and a floating-point type.
|
3379 |
|
|
|
3380 |
|
|
`vector_reggroup'
|
3381 |
|
|
Any register with a valid name and a vector type.
|
3382 |
|
|
|
3383 |
|
|
`general_reggroup'
|
3384 |
|
|
Any register with a valid name and a type other than vector or
|
3385 |
|
|
floating-point. `float_reggroup'.
|
3386 |
|
|
|
3387 |
|
|
`save_reggroup'
|
3388 |
|
|
`restore_reggroup'
|
3389 |
|
|
`all_reggroup'
|
3390 |
|
|
Any register with a valid name.
|
3391 |
|
|
|
3392 |
|
|
`DEPRECATED_REGISTER_VIRTUAL_SIZE (REG)'
|
3393 |
|
|
Return the virtual size of REG; defaults to the size of the
|
3394 |
|
|
register's virtual type. Return the virtual size of REG. *Note
|
3395 |
|
|
Raw and Virtual Register Representations: Target Architecture
|
3396 |
|
|
Definition.
|
3397 |
|
|
|
3398 |
|
|
`DEPRECATED_REGISTER_VIRTUAL_TYPE (REG)'
|
3399 |
|
|
Return the virtual type of REG. *Note Raw and Virtual Register
|
3400 |
|
|
Representations: Target Architecture Definition.
|
3401 |
|
|
|
3402 |
|
|
`struct type *register_type (GDBARCH, REG)'
|
3403 |
|
|
If defined, return the type of register REG. This function
|
3404 |
|
|
supersedes `DEPRECATED_REGISTER_VIRTUAL_TYPE'. *Note Raw and
|
3405 |
|
|
Virtual Register Representations: Target Architecture Definition.
|
3406 |
|
|
|
3407 |
|
|
`REGISTER_CONVERT_TO_VIRTUAL(REG, TYPE, FROM, TO)'
|
3408 |
|
|
Convert the value of register REG from its raw form to its virtual
|
3409 |
|
|
form. *Note Raw and Virtual Register Representations: Target
|
3410 |
|
|
Architecture Definition.
|
3411 |
|
|
|
3412 |
|
|
`REGISTER_CONVERT_TO_RAW(TYPE, REG, FROM, TO)'
|
3413 |
|
|
Convert the value of register REG from its virtual form to its raw
|
3414 |
|
|
form. *Note Raw and Virtual Register Representations: Target
|
3415 |
|
|
Architecture Definition.
|
3416 |
|
|
|
3417 |
|
|
`const struct regset *regset_from_core_section (struct gdbarch * GDBARCH, const char * SECT_NAME, size_t SECT_SIZE)'
|
3418 |
|
|
Return the appropriate register set for a core file section with
|
3419 |
|
|
name SECT_NAME and size SECT_SIZE.
|
3420 |
|
|
|
3421 |
|
|
`SOFTWARE_SINGLE_STEP_P()'
|
3422 |
|
|
Define this as 1 if the target does not have a hardware single-step
|
3423 |
|
|
mechanism. The macro `SOFTWARE_SINGLE_STEP' must also be defined.
|
3424 |
|
|
|
3425 |
|
|
`SOFTWARE_SINGLE_STEP(SIGNAL, INSERT_BREAKPOINTS_P)'
|
3426 |
|
|
A function that inserts or removes (depending on
|
3427 |
|
|
INSERT_BREAKPOINTS_P) breakpoints at each possible destinations of
|
3428 |
|
|
the next instruction. See `sparc-tdep.c' and `rs6000-tdep.c' for
|
3429 |
|
|
examples.
|
3430 |
|
|
|
3431 |
|
|
`set_gdbarch_sofun_address_maybe_missing (GDBARCH, SET)'
|
3432 |
|
|
Somebody clever observed that, the more actual addresses you have
|
3433 |
|
|
in the debug information, the more time the linker has to spend
|
3434 |
|
|
relocating them. So whenever there's some other way the debugger
|
3435 |
|
|
could find the address it needs, you should omit it from the debug
|
3436 |
|
|
info, to make linking faster.
|
3437 |
|
|
|
3438 |
|
|
Calling `set_gdbarch_sofun_address_maybe_missing' with a non-zero
|
3439 |
|
|
argument SET indicates that a particular set of hacks of this sort
|
3440 |
|
|
are in use, affecting `N_SO' and `N_FUN' entries in stabs-format
|
3441 |
|
|
debugging information. `N_SO' stabs mark the beginning and ending
|
3442 |
|
|
addresses of compilation units in the text segment. `N_FUN' stabs
|
3443 |
|
|
mark the starts and ends of functions.
|
3444 |
|
|
|
3445 |
|
|
In this case, GDB assumes two things:
|
3446 |
|
|
|
3447 |
|
|
* `N_FUN' stabs have an address of zero. Instead of using those
|
3448 |
|
|
addresses, you should find the address where the function
|
3449 |
|
|
starts by taking the function name from the stab, and then
|
3450 |
|
|
looking that up in the minsyms (the linker/assembler symbol
|
3451 |
|
|
table). In other words, the stab has the name, and the
|
3452 |
|
|
linker/assembler symbol table is the only place that carries
|
3453 |
|
|
the address.
|
3454 |
|
|
|
3455 |
|
|
* `N_SO' stabs have an address of zero, too. You just look at
|
3456 |
|
|
the `N_FUN' stabs that appear before and after the `N_SO'
|
3457 |
|
|
stab, and guess the starting and ending addresses of the
|
3458 |
|
|
compilation unit from them.
|
3459 |
|
|
|
3460 |
|
|
`int gdbarch_pc_regnum (GDBARCH)'
|
3461 |
|
|
If the program counter is kept in a register, then let this
|
3462 |
|
|
function return the number (greater than or equal to zero) of that
|
3463 |
|
|
register.
|
3464 |
|
|
|
3465 |
|
|
This should only need to be defined if `gdbarch_read_pc' and
|
3466 |
|
|
`gdbarch_write_pc' are not defined.
|
3467 |
|
|
|
3468 |
|
|
`int gdbarch_stabs_argument_has_addr (GDBARCH, TYPE)'
|
3469 |
|
|
Define this function to return nonzero if a function argument of
|
3470 |
|
|
type TYPE is passed by reference instead of value.
|
3471 |
|
|
|
3472 |
|
|
`PROCESS_LINENUMBER_HOOK'
|
3473 |
|
|
A hook defined for XCOFF reading.
|
3474 |
|
|
|
3475 |
|
|
`gdbarch_ps_regnum (GDBARCH'
|
3476 |
|
|
If defined, this function returns the number of the processor
|
3477 |
|
|
status register. (This definition is only used in generic code
|
3478 |
|
|
when parsing "$ps".)
|
3479 |
|
|
|
3480 |
|
|
`CORE_ADDR gdbarch_push_dummy_call (GDBARCH, FUNCTION, REGCACHE, BP_ADDR, NARGS, ARGS, SP, STRUCT_RETURN, STRUCT_ADDR)'
|
3481 |
|
|
Define this to push the dummy frame's call to the inferior
|
3482 |
|
|
function onto the stack. In addition to pushing NARGS, the code
|
3483 |
|
|
should push STRUCT_ADDR (when STRUCT_RETURN is non-zero), and the
|
3484 |
|
|
return address (BP_ADDR).
|
3485 |
|
|
|
3486 |
|
|
FUNCTION is a pointer to a `struct value'; on architectures that
|
3487 |
|
|
use function descriptors, this contains the function descriptor
|
3488 |
|
|
value.
|
3489 |
|
|
|
3490 |
|
|
Returns the updated top-of-stack pointer.
|
3491 |
|
|
|
3492 |
|
|
This method replaces `DEPRECATED_PUSH_ARGUMENTS'.
|
3493 |
|
|
|
3494 |
|
|
`CORE_ADDR gdbarch_push_dummy_code (GDBARCH, SP, FUNADDR, USING_GCC, ARGS, NARGS, VALUE_TYPE, REAL_PC, BP_ADDR, REGCACHE)'
|
3495 |
|
|
Given a stack based call dummy, push the instruction sequence
|
3496 |
|
|
(including space for a breakpoint) to which the called function
|
3497 |
|
|
should return.
|
3498 |
|
|
|
3499 |
|
|
Set BP_ADDR to the address at which the breakpoint instruction
|
3500 |
|
|
should be inserted, REAL_PC to the resume address when starting
|
3501 |
|
|
the call sequence, and return the updated inner-most stack address.
|
3502 |
|
|
|
3503 |
|
|
By default, the stack is grown sufficient to hold a frame-aligned
|
3504 |
|
|
(*note frame_align::) breakpoint, BP_ADDR is set to the address
|
3505 |
|
|
reserved for that breakpoint, and REAL_PC set to FUNADDR.
|
3506 |
|
|
|
3507 |
|
|
This method replaces `gdbarch_call_dummy_location (GDBARCH)' and
|
3508 |
|
|
`DEPRECATED_REGISTER_SIZE'.
|
3509 |
|
|
|
3510 |
|
|
`const char *gdbarch_register_name (GDBARCH, REGNR)'
|
3511 |
|
|
Return the name of register REGNR as a string. May return `NULL'
|
3512 |
|
|
to indicate that REGNR is not a valid register.
|
3513 |
|
|
|
3514 |
|
|
`SAVE_DUMMY_FRAME_TOS (SP)'
|
3515 |
|
|
Used in `call_function_by_hand' to notify the target dependent
|
3516 |
|
|
code of the top-of-stack value that will be passed to the inferior
|
3517 |
|
|
code. This is the value of the `SP' after both the dummy frame
|
3518 |
|
|
and space for parameters/results have been allocated on the stack.
|
3519 |
|
|
*Note gdbarch_unwind_dummy_id::.
|
3520 |
|
|
|
3521 |
|
|
`int gdbarch_sdb_reg_to_regnum (GDBARCH, SDB_REGNR)'
|
3522 |
|
|
Use this function to convert sdb register SDB_REGNR into GDB
|
3523 |
|
|
regnum. If not defined, no conversion will be done.
|
3524 |
|
|
|
3525 |
|
|
`enum return_value_convention gdbarch_return_value (struct gdbarch *GDBARCH, struct type *VALTYPE, struct regcache *REGCACHE, void *READBUF, const void *WRITEBUF)'
|
3526 |
|
|
Given a function with a return-value of type RETTYPE, return which
|
3527 |
|
|
return-value convention that function would use.
|
3528 |
|
|
|
3529 |
|
|
GDB currently recognizes two function return-value conventions:
|
3530 |
|
|
`RETURN_VALUE_REGISTER_CONVENTION' where the return value is found
|
3531 |
|
|
in registers; and `RETURN_VALUE_STRUCT_CONVENTION' where the return
|
3532 |
|
|
value is found in memory and the address of that memory location is
|
3533 |
|
|
passed in as the function's first parameter.
|
3534 |
|
|
|
3535 |
|
|
If the register convention is being used, and WRITEBUF is
|
3536 |
|
|
non-`NULL', also copy the return-value in WRITEBUF into REGCACHE.
|
3537 |
|
|
|
3538 |
|
|
If the register convention is being used, and READBUF is
|
3539 |
|
|
non-`NULL', also copy the return value from REGCACHE into READBUF
|
3540 |
|
|
(REGCACHE contains a copy of the registers from the just returned
|
3541 |
|
|
function).
|
3542 |
|
|
|
3543 |
|
|
_Maintainer note: This method replaces separate predicate, extract,
|
3544 |
|
|
store methods. By having only one method, the logic needed to
|
3545 |
|
|
determine the return-value convention need only be implemented in
|
3546 |
|
|
one place. If GDB were written in an OO language, this method
|
3547 |
|
|
would instead return an object that knew how to perform the
|
3548 |
|
|
register return-value extract and store._
|
3549 |
|
|
|
3550 |
|
|
_Maintainer note: This method does not take a GCC_P parameter, and
|
3551 |
|
|
such a parameter should not be added. If an architecture that
|
3552 |
|
|
requires per-compiler or per-function information be identified,
|
3553 |
|
|
then the replacement of RETTYPE with `struct value' FUNCTION
|
3554 |
|
|
should be pursued._
|
3555 |
|
|
|
3556 |
|
|
_Maintainer note: The REGCACHE parameter limits this methods to
|
3557 |
|
|
the inner most frame. While replacing REGCACHE with a `struct
|
3558 |
|
|
frame_info' FRAME parameter would remove that limitation there has
|
3559 |
|
|
yet to be a demonstrated need for such a change._
|
3560 |
|
|
|
3561 |
|
|
`void gdbarch_skip_permanent_breakpoint (GDBARCH, REGCACHE)'
|
3562 |
|
|
Advance the inferior's PC past a permanent breakpoint. GDB
|
3563 |
|
|
normally steps over a breakpoint by removing it, stepping one
|
3564 |
|
|
instruction, and re-inserting the breakpoint. However, permanent
|
3565 |
|
|
breakpoints are hardwired into the inferior, and can't be removed,
|
3566 |
|
|
so this strategy doesn't work. Calling
|
3567 |
|
|
`gdbarch_skip_permanent_breakpoint' adjusts the processor's state
|
3568 |
|
|
so that execution will resume just after the breakpoint. This
|
3569 |
|
|
function does the right thing even when the breakpoint is in the
|
3570 |
|
|
delay slot of a branch or jump.
|
3571 |
|
|
|
3572 |
|
|
`CORE_ADDR gdbarch_skip_prologue (GDBARCH, IP)'
|
3573 |
|
|
A function that returns the address of the "real" code beyond the
|
3574 |
|
|
function entry prologue found at IP.
|
3575 |
|
|
|
3576 |
|
|
`CORE_ADDR gdbarch_skip_trampoline_code (GDBARCH, FRAME, PC)'
|
3577 |
|
|
If the target machine has trampoline code that sits between
|
3578 |
|
|
callers and the functions being called, then define this function
|
3579 |
|
|
to return a new PC that is at the start of the real function.
|
3580 |
|
|
|
3581 |
|
|
`int gdbarch_sp_regnum (GDBARCH)'
|
3582 |
|
|
If the stack-pointer is kept in a register, then use this function
|
3583 |
|
|
to return the number (greater than or equal to zero) of that
|
3584 |
|
|
register, or -1 if there is no such register.
|
3585 |
|
|
|
3586 |
|
|
`int gdbarch_stab_reg_to_regnum (GDBARCH, STAB_REGNR)'
|
3587 |
|
|
Use this function to convert stab register STAB_REGNR into GDB
|
3588 |
|
|
regnum. If not defined, no conversion will be done.
|
3589 |
|
|
|
3590 |
|
|
`SYMBOL_RELOADING_DEFAULT'
|
3591 |
|
|
The default value of the "symbol-reloading" variable. (Never
|
3592 |
|
|
defined in current sources.)
|
3593 |
|
|
|
3594 |
|
|
`TARGET_CHAR_BIT'
|
3595 |
|
|
Number of bits in a char; defaults to 8.
|
3596 |
|
|
|
3597 |
|
|
`int gdbarch_char_signed (GDBARCH)'
|
3598 |
|
|
Non-zero if `char' is normally signed on this architecture; zero if
|
3599 |
|
|
it should be unsigned.
|
3600 |
|
|
|
3601 |
|
|
The ISO C standard requires the compiler to treat `char' as
|
3602 |
|
|
equivalent to either `signed char' or `unsigned char'; any
|
3603 |
|
|
character in the standard execution set is supposed to be positive.
|
3604 |
|
|
Most compilers treat `char' as signed, but `char' is unsigned on
|
3605 |
|
|
the IBM S/390, RS6000, and PowerPC targets.
|
3606 |
|
|
|
3607 |
|
|
`int gdbarch_double_bit (GDBARCH)'
|
3608 |
|
|
Number of bits in a double float; defaults to
|
3609 |
|
|
`8 * TARGET_CHAR_BIT'.
|
3610 |
|
|
|
3611 |
|
|
`int gdbarch_float_bit (GDBARCH)'
|
3612 |
|
|
Number of bits in a float; defaults to `4 * TARGET_CHAR_BIT'.
|
3613 |
|
|
|
3614 |
|
|
`int gdbarch_int_bit (GDBARCH)'
|
3615 |
|
|
Number of bits in an integer; defaults to `4 * TARGET_CHAR_BIT'.
|
3616 |
|
|
|
3617 |
|
|
`int gdbarch_long_bit (GDBARCH)'
|
3618 |
|
|
Number of bits in a long integer; defaults to
|
3619 |
|
|
`4 * TARGET_CHAR_BIT'.
|
3620 |
|
|
|
3621 |
|
|
`int gdbarch_long_double_bit (GDBARCH)'
|
3622 |
|
|
Number of bits in a long double float; defaults to
|
3623 |
|
|
`2 * gdbarch_double_bit (GDBARCH)'.
|
3624 |
|
|
|
3625 |
|
|
`int gdbarch_long_long_bit (GDBARCH)'
|
3626 |
|
|
Number of bits in a long long integer; defaults to
|
3627 |
|
|
`2 * gdbarch_long_bit (GDBARCH)'.
|
3628 |
|
|
|
3629 |
|
|
`int gdbarch_ptr_bit (GDBARCH)'
|
3630 |
|
|
Number of bits in a pointer; defaults to
|
3631 |
|
|
`gdbarch_int_bit (GDBARCH)'.
|
3632 |
|
|
|
3633 |
|
|
`int gdbarch_short_bit (GDBARCH)'
|
3634 |
|
|
Number of bits in a short integer; defaults to
|
3635 |
|
|
`2 * TARGET_CHAR_BIT'.
|
3636 |
|
|
|
3637 |
|
|
`CORE_ADDR gdbarch_read_pc (GDBARCH, REGCACHE)'
|
3638 |
|
|
`gdbarch_write_pc (GDBARCH, REGCACHE, VAL)'
|
3639 |
|
|
`TARGET_READ_SP'
|
3640 |
|
|
`TARGET_READ_FP'
|
3641 |
|
|
These change the behavior of `gdbarch_read_pc',
|
3642 |
|
|
`gdbarch_write_pc', and `read_sp'. For most targets, these may be
|
3643 |
|
|
left undefined. GDB will call the read and write register
|
3644 |
|
|
functions with the relevant `_REGNUM' argument.
|
3645 |
|
|
|
3646 |
|
|
These macros and functions are useful when a target keeps one of
|
3647 |
|
|
these registers in a hard to get at place; for example, part in a
|
3648 |
|
|
segment register and part in an ordinary register.
|
3649 |
|
|
|
3650 |
|
|
*Note gdbarch_unwind_sp::, which replaces `TARGET_READ_SP'.
|
3651 |
|
|
|
3652 |
|
|
`void gdbarch_virtual_frame_pointer (GDBARCH, PC, FRAME_REGNUM, FRAME_OFFSET)'
|
3653 |
|
|
Returns a `(register, offset)' pair representing the virtual frame
|
3654 |
|
|
pointer in use at the code address PC. If virtual frame pointers
|
3655 |
|
|
are not used, a default definition simply returns
|
3656 |
|
|
`DEPRECATED_FP_REGNUM', with an offset of zero.
|
3657 |
|
|
|
3658 |
|
|
`TARGET_HAS_HARDWARE_WATCHPOINTS'
|
3659 |
|
|
If non-zero, the target has support for hardware-assisted
|
3660 |
|
|
watchpoints. *Note watchpoints: Algorithms, for more details and
|
3661 |
|
|
other related macros.
|
3662 |
|
|
|
3663 |
|
|
`int gdbarch_print_insn (GDBARCH, VMA, INFO)'
|
3664 |
|
|
This is the function used by GDB to print an assembly instruction.
|
3665 |
|
|
It prints the instruction at address VMA in debugged memory and
|
3666 |
|
|
returns the length of the instruction, in bytes. If a target
|
3667 |
|
|
doesn't define its own printing routine, it defaults to an
|
3668 |
|
|
accessor function for the global pointer
|
3669 |
|
|
`deprecated_tm_print_insn'. This usually points to a function in
|
3670 |
|
|
the `opcodes' library (*note Opcodes: Support Libraries.). INFO
|
3671 |
|
|
is a structure (of type `disassemble_info') defined in
|
3672 |
|
|
`include/dis-asm.h' used to pass information to the instruction
|
3673 |
|
|
decoding routine.
|
3674 |
|
|
|
3675 |
|
|
`frame_id gdbarch_unwind_dummy_id (GDBARCH, FRAME)'
|
3676 |
|
|
Given FRAME return a `struct frame_id' that uniquely identifies an
|
3677 |
|
|
inferior function call's dummy frame. The value returned must
|
3678 |
|
|
match the dummy frame stack value previously saved using
|
3679 |
|
|
`SAVE_DUMMY_FRAME_TOS'. *Note SAVE_DUMMY_FRAME_TOS::.
|
3680 |
|
|
|
3681 |
|
|
`DEPRECATED_USE_STRUCT_CONVENTION (GCC_P, TYPE)'
|
3682 |
|
|
If defined, this must be an expression that is nonzero if a value
|
3683 |
|
|
of the given TYPE being returned from a function must have space
|
3684 |
|
|
allocated for it on the stack. GCC_P is true if the function
|
3685 |
|
|
being considered is known to have been compiled by GCC; this is
|
3686 |
|
|
helpful for systems where GCC is known to use different calling
|
3687 |
|
|
convention than other compilers.
|
3688 |
|
|
|
3689 |
|
|
This method has been deprecated in favour of `gdbarch_return_value'
|
3690 |
|
|
(*note gdbarch_return_value::).
|
3691 |
|
|
|
3692 |
|
|
`void gdbarch_value_to_register (GDBARCH, FRAME, TYPE, BUF)'
|
3693 |
|
|
Convert a value of type TYPE into the raw contents of a register.
|
3694 |
|
|
*Note Using Different Register and Memory Data Representations:
|
3695 |
|
|
Target Architecture Definition.
|
3696 |
|
|
|
3697 |
|
|
|
3698 |
|
|
Motorola M68K target conditionals.
|
3699 |
|
|
|
3700 |
|
|
`BPT_VECTOR'
|
3701 |
|
|
Define this to be the 4-bit location of the breakpoint trap
|
3702 |
|
|
vector. If not defined, it will default to `0xf'.
|
3703 |
|
|
|
3704 |
|
|
`REMOTE_BPT_VECTOR'
|
3705 |
|
|
Defaults to `1'.
|
3706 |
|
|
|
3707 |
|
|
`const char *gdbarch_name_of_malloc (GDBARCH)'
|
3708 |
|
|
A string containing the name of the function to call in order to
|
3709 |
|
|
allocate some memory in the inferior. The default value is
|
3710 |
|
|
"malloc".
|
3711 |
|
|
|
3712 |
|
|
|
3713 |
|
|
|
3714 |
|
|
File: gdbint.info, Node: Adding a New Target, Prev: Target Conditionals, Up: Target Architecture Definition
|
3715 |
|
|
|
3716 |
|
|
9.12 Adding a New Target
|
3717 |
|
|
========================
|
3718 |
|
|
|
3719 |
|
|
The following files add a target to GDB:
|
3720 |
|
|
|
3721 |
|
|
`gdb/config/ARCH/TTT.mt'
|
3722 |
|
|
Contains a Makefile fragment specific to this target. Specifies
|
3723 |
|
|
what object files are needed for target TTT, by defining
|
3724 |
|
|
`TDEPFILES=...' and `TDEPLIBS=...'. Also specifies the header
|
3725 |
|
|
file which describes TTT, by defining `TM_FILE= tm-TTT.h'.
|
3726 |
|
|
|
3727 |
|
|
You can also define `TM_CFLAGS', `TM_CLIBS', `TM_CDEPS', but these
|
3728 |
|
|
are now deprecated, replaced by autoconf, and may go away in
|
3729 |
|
|
future versions of GDB.
|
3730 |
|
|
|
3731 |
|
|
`gdb/TTT-tdep.c'
|
3732 |
|
|
Contains any miscellaneous code required for this target machine.
|
3733 |
|
|
On some machines it doesn't exist at all. Sometimes the macros in
|
3734 |
|
|
`tm-TTT.h' become very complicated, so they are implemented as
|
3735 |
|
|
functions here instead, and the macro is simply defined to call the
|
3736 |
|
|
function. This is vastly preferable, since it is easier to
|
3737 |
|
|
understand and debug.
|
3738 |
|
|
|
3739 |
|
|
`gdb/ARCH-tdep.c'
|
3740 |
|
|
`gdb/ARCH-tdep.h'
|
3741 |
|
|
This often exists to describe the basic layout of the target
|
3742 |
|
|
machine's processor chip (registers, stack, etc.). If used, it is
|
3743 |
|
|
included by `TTT-tdep.h'. It can be shared among many targets
|
3744 |
|
|
that use the same processor.
|
3745 |
|
|
|
3746 |
|
|
`gdb/config/ARCH/tm-TTT.h'
|
3747 |
|
|
(`tm.h' is a link to this file, created by `configure'). Contains
|
3748 |
|
|
macro definitions about the target machine's registers, stack frame
|
3749 |
|
|
format and instructions.
|
3750 |
|
|
|
3751 |
|
|
New targets do not need this file and should not create it.
|
3752 |
|
|
|
3753 |
|
|
`gdb/config/ARCH/tm-ARCH.h'
|
3754 |
|
|
This often exists to describe the basic layout of the target
|
3755 |
|
|
machine's processor chip (registers, stack, etc.). If used, it is
|
3756 |
|
|
included by `tm-TTT.h'. It can be shared among many targets that
|
3757 |
|
|
use the same processor.
|
3758 |
|
|
|
3759 |
|
|
New targets do not need this file and should not create it.
|
3760 |
|
|
|
3761 |
|
|
|
3762 |
|
|
If you are adding a new operating system for an existing CPU chip,
|
3763 |
|
|
add a `config/tm-OS.h' file that describes the operating system
|
3764 |
|
|
facilities that are unusual (extra symbol table info; the breakpoint
|
3765 |
|
|
instruction needed; etc.). Then write a `ARCH/tm-OS.h' that just
|
3766 |
|
|
`#include's `tm-ARCH.h' and `config/tm-OS.h'.
|
3767 |
|
|
|
3768 |
|
|
|
3769 |
|
|
File: gdbint.info, Node: Target Descriptions, Next: Target Vector Definition, Prev: Target Architecture Definition, Up: Top
|
3770 |
|
|
|
3771 |
|
|
10 Target Descriptions
|
3772 |
|
|
**********************
|
3773 |
|
|
|
3774 |
|
|
The target architecture definition (*note Target Architecture
|
3775 |
|
|
Definition::) contains GDB's hard-coded knowledge about an
|
3776 |
|
|
architecture. For some platforms, it is handy to have more flexible
|
3777 |
|
|
knowledge about a specific instance of the architecture--for instance,
|
3778 |
|
|
a processor or development board. "Target descriptions" provide a
|
3779 |
|
|
mechanism for the user to tell GDB more about what their target
|
3780 |
|
|
supports, or for the target to tell GDB directly.
|
3781 |
|
|
|
3782 |
|
|
For details on writing, automatically supplying, and manually
|
3783 |
|
|
selecting target descriptions, see *Note Target Descriptions:
|
3784 |
|
|
(gdb)Target Descriptions. This section will cover some related topics
|
3785 |
|
|
about the GDB internals.
|
3786 |
|
|
|
3787 |
|
|
* Menu:
|
3788 |
|
|
|
3789 |
|
|
* Target Descriptions Implementation::
|
3790 |
|
|
* Adding Target Described Register Support::
|
3791 |
|
|
|
3792 |
|
|
|
3793 |
|
|
File: gdbint.info, Node: Target Descriptions Implementation, Next: Adding Target Described Register Support, Up: Target Descriptions
|
3794 |
|
|
|
3795 |
|
|
10.1 Target Descriptions Implementation
|
3796 |
|
|
=======================================
|
3797 |
|
|
|
3798 |
|
|
Before GDB connects to a new target, or runs a new program on an
|
3799 |
|
|
existing target, it discards any existing target description and
|
3800 |
|
|
reverts to a default gdbarch. Then, after connecting, it looks for a
|
3801 |
|
|
new target description by calling `target_find_description'.
|
3802 |
|
|
|
3803 |
|
|
A description may come from a user specified file (XML), the remote
|
3804 |
|
|
`qXfer:features:read' packet (also XML), or from any custom
|
3805 |
|
|
`to_read_description' routine in the target vector. For instance, the
|
3806 |
|
|
remote target supports guessing whether a MIPS target is 32-bit or
|
3807 |
|
|
64-bit based on the size of the `g' packet.
|
3808 |
|
|
|
3809 |
|
|
If any target description is found, GDB creates a new gdbarch
|
3810 |
|
|
incorporating the description by calling `gdbarch_update_p'. Any
|
3811 |
|
|
`' element is handled first, to determine which
|
3812 |
|
|
architecture's gdbarch initialization routine is called to create the
|
3813 |
|
|
new architecture. Then the initialization routine is called, and has a
|
3814 |
|
|
chance to adjust the constructed architecture based on the contents of
|
3815 |
|
|
the target description. For instance, it can recognize any properties
|
3816 |
|
|
set by a `to_read_description' routine. Also see *Note Adding Target
|
3817 |
|
|
Described Register Support::.
|
3818 |
|
|
|
3819 |
|
|
|
3820 |
|
|
File: gdbint.info, Node: Adding Target Described Register Support, Prev: Target Descriptions Implementation, Up: Target Descriptions
|
3821 |
|
|
|
3822 |
|
|
10.2 Adding Target Described Register Support
|
3823 |
|
|
=============================================
|
3824 |
|
|
|
3825 |
|
|
Target descriptions can report additional registers specific to an
|
3826 |
|
|
instance of the target. But it takes a little work in the architecture
|
3827 |
|
|
specific routines to support this.
|
3828 |
|
|
|
3829 |
|
|
A target description must either have no registers or a complete
|
3830 |
|
|
set--this avoids complexity in trying to merge standard registers with
|
3831 |
|
|
the target defined registers. It is the architecture's responsibility
|
3832 |
|
|
to validate that a description with registers has everything it needs.
|
3833 |
|
|
To keep architecture code simple, the same mechanism is used to assign
|
3834 |
|
|
fixed internal register numbers to standard registers.
|
3835 |
|
|
|
3836 |
|
|
If `tdesc_has_registers' returns 1, the description contains
|
3837 |
|
|
registers. The architecture's `gdbarch_init' routine should:
|
3838 |
|
|
|
3839 |
|
|
* Call `tdesc_data_alloc' to allocate storage, early, before
|
3840 |
|
|
searching for a matching gdbarch or allocating a new one.
|
3841 |
|
|
|
3842 |
|
|
* Use `tdesc_find_feature' to locate standard features by name.
|
3843 |
|
|
|
3844 |
|
|
* Use `tdesc_numbered_register' and `tdesc_numbered_register_choices'
|
3845 |
|
|
to locate the expected registers in the standard features.
|
3846 |
|
|
|
3847 |
|
|
* Return `NULL' if a required feature is missing, or if any standard
|
3848 |
|
|
feature is missing expected registers. This will produce a
|
3849 |
|
|
warning that the description was incomplete.
|
3850 |
|
|
|
3851 |
|
|
* Free the allocated data before returning, unless
|
3852 |
|
|
`tdesc_use_registers' is called.
|
3853 |
|
|
|
3854 |
|
|
* Call `set_gdbarch_num_regs' as usual, with a number higher than any
|
3855 |
|
|
fixed number passed to `tdesc_numbered_register'.
|
3856 |
|
|
|
3857 |
|
|
* Call `tdesc_use_registers' after creating a new gdbarch, before
|
3858 |
|
|
returning it.
|
3859 |
|
|
|
3860 |
|
|
|
3861 |
|
|
After `tdesc_use_registers' has been called, the architecture's
|
3862 |
|
|
`register_name', `register_type', and `register_reggroup_p' routines
|
3863 |
|
|
will not be called; that information will be taken from the target
|
3864 |
|
|
description. `num_regs' may be increased to account for any additional
|
3865 |
|
|
registers in the description.
|
3866 |
|
|
|
3867 |
|
|
Pseudo-registers require some extra care:
|
3868 |
|
|
|
3869 |
|
|
* Using `tdesc_numbered_register' allows the architecture to give
|
3870 |
|
|
constant register numbers to standard architectural registers, e.g.
|
3871 |
|
|
as an `enum' in `ARCH-tdep.h'. But because pseudo-registers are
|
3872 |
|
|
always numbered above `num_regs', which may be increased by the
|
3873 |
|
|
description, constant numbers can not be used for pseudos. They
|
3874 |
|
|
must be numbered relative to `num_regs' instead.
|
3875 |
|
|
|
3876 |
|
|
* The description will not describe pseudo-registers, so the
|
3877 |
|
|
architecture must call `set_tdesc_pseudo_register_name',
|
3878 |
|
|
`set_tdesc_pseudo_register_type', and
|
3879 |
|
|
`set_tdesc_pseudo_register_reggroup_p' to supply routines
|
3880 |
|
|
describing pseudo registers. These routines will be passed
|
3881 |
|
|
internal register numbers, so the same routines used for the
|
3882 |
|
|
gdbarch equivalents are usually suitable.
|
3883 |
|
|
|
3884 |
|
|
|
3885 |
|
|
|
3886 |
|
|
File: gdbint.info, Node: Target Vector Definition, Next: Native Debugging, Prev: Target Descriptions, Up: Top
|
3887 |
|
|
|
3888 |
|
|
11 Target Vector Definition
|
3889 |
|
|
***************************
|
3890 |
|
|
|
3891 |
|
|
The target vector defines the interface between GDB's abstract handling
|
3892 |
|
|
of target systems, and the nitty-gritty code that actually exercises
|
3893 |
|
|
control over a process or a serial port. GDB includes some 30-40
|
3894 |
|
|
different target vectors; however, each configuration of GDB includes
|
3895 |
|
|
only a few of them.
|
3896 |
|
|
|
3897 |
|
|
* Menu:
|
3898 |
|
|
|
3899 |
|
|
* Managing Execution State::
|
3900 |
|
|
* Existing Targets::
|
3901 |
|
|
|
3902 |
|
|
|
3903 |
|
|
File: gdbint.info, Node: Managing Execution State, Next: Existing Targets, Up: Target Vector Definition
|
3904 |
|
|
|
3905 |
|
|
11.1 Managing Execution State
|
3906 |
|
|
=============================
|
3907 |
|
|
|
3908 |
|
|
A target vector can be completely inactive (not pushed on the target
|
3909 |
|
|
stack), active but not running (pushed, but not connected to a fully
|
3910 |
|
|
manifested inferior), or completely active (pushed, with an accessible
|
3911 |
|
|
inferior). Most targets are only completely inactive or completely
|
3912 |
|
|
active, but some support persistent connections to a target even when
|
3913 |
|
|
the target has exited or not yet started.
|
3914 |
|
|
|
3915 |
|
|
For example, connecting to the simulator using `target sim' does not
|
3916 |
|
|
create a running program. Neither registers nor memory are accessible
|
3917 |
|
|
until `run'. Similarly, after `kill', the program can not continue
|
3918 |
|
|
executing. But in both cases GDB remains connected to the simulator,
|
3919 |
|
|
and target-specific commands are directed to the simulator.
|
3920 |
|
|
|
3921 |
|
|
A target which only supports complete activation should push itself
|
3922 |
|
|
onto the stack in its `to_open' routine (by calling `push_target'), and
|
3923 |
|
|
unpush itself from the stack in its `to_mourn_inferior' routine (by
|
3924 |
|
|
calling `unpush_target').
|
3925 |
|
|
|
3926 |
|
|
A target which supports both partial and complete activation should
|
3927 |
|
|
still call `push_target' in `to_open', but not call `unpush_target' in
|
3928 |
|
|
`to_mourn_inferior'. Instead, it should call either
|
3929 |
|
|
`target_mark_running' or `target_mark_exited' in its `to_open',
|
3930 |
|
|
depending on whether the target is fully active after connection. It
|
3931 |
|
|
should also call `target_mark_running' any time the inferior becomes
|
3932 |
|
|
fully active (e.g. in `to_create_inferior' and `to_attach'), and
|
3933 |
|
|
`target_mark_exited' when the inferior becomes inactive (in
|
3934 |
|
|
`to_mourn_inferior'). The target should also make sure to call
|
3935 |
|
|
`target_mourn_inferior' from its `to_kill', to return the target to
|
3936 |
|
|
inactive state.
|
3937 |
|
|
|
3938 |
|
|
|
3939 |
|
|
File: gdbint.info, Node: Existing Targets, Prev: Managing Execution State, Up: Target Vector Definition
|
3940 |
|
|
|
3941 |
|
|
11.2 Existing Targets
|
3942 |
|
|
=====================
|
3943 |
|
|
|
3944 |
|
|
11.2.1 File Targets
|
3945 |
|
|
-------------------
|
3946 |
|
|
|
3947 |
|
|
Both executables and core files have target vectors.
|
3948 |
|
|
|
3949 |
|
|
11.2.2 Standard Protocol and Remote Stubs
|
3950 |
|
|
-----------------------------------------
|
3951 |
|
|
|
3952 |
|
|
GDB's file `remote.c' talks a serial protocol to code that runs in the
|
3953 |
|
|
target system. GDB provides several sample "stubs" that can be
|
3954 |
|
|
integrated into target programs or operating systems for this purpose;
|
3955 |
|
|
they are named `*-stub.c'.
|
3956 |
|
|
|
3957 |
|
|
The GDB user's manual describes how to put such a stub into your
|
3958 |
|
|
target code. What follows is a discussion of integrating the SPARC
|
3959 |
|
|
stub into a complicated operating system (rather than a simple
|
3960 |
|
|
program), by Stu Grossman, the author of this stub.
|
3961 |
|
|
|
3962 |
|
|
The trap handling code in the stub assumes the following upon entry
|
3963 |
|
|
to `trap_low':
|
3964 |
|
|
|
3965 |
|
|
1. %l1 and %l2 contain pc and npc respectively at the time of the
|
3966 |
|
|
trap;
|
3967 |
|
|
|
3968 |
|
|
2. traps are disabled;
|
3969 |
|
|
|
3970 |
|
|
3. you are in the correct trap window.
|
3971 |
|
|
|
3972 |
|
|
As long as your trap handler can guarantee those conditions, then
|
3973 |
|
|
there is no reason why you shouldn't be able to "share" traps with the
|
3974 |
|
|
stub. The stub has no requirement that it be jumped to directly from
|
3975 |
|
|
the hardware trap vector. That is why it calls `exceptionHandler()',
|
3976 |
|
|
which is provided by the external environment. For instance, this could
|
3977 |
|
|
set up the hardware traps to actually execute code which calls the stub
|
3978 |
|
|
first, and then transfers to its own trap handler.
|
3979 |
|
|
|
3980 |
|
|
For the most point, there probably won't be much of an issue with
|
3981 |
|
|
"sharing" traps, as the traps we use are usually not used by the kernel,
|
3982 |
|
|
and often indicate unrecoverable error conditions. Anyway, this is all
|
3983 |
|
|
controlled by a table, and is trivial to modify. The most important
|
3984 |
|
|
trap for us is for `ta 1'. Without that, we can't single step or do
|
3985 |
|
|
breakpoints. Everything else is unnecessary for the proper operation
|
3986 |
|
|
of the debugger/stub.
|
3987 |
|
|
|
3988 |
|
|
From reading the stub, it's probably not obvious how breakpoints
|
3989 |
|
|
work. They are simply done by deposit/examine operations from GDB.
|
3990 |
|
|
|
3991 |
|
|
11.2.3 ROM Monitor Interface
|
3992 |
|
|
----------------------------
|
3993 |
|
|
|
3994 |
|
|
11.2.4 Custom Protocols
|
3995 |
|
|
-----------------------
|
3996 |
|
|
|
3997 |
|
|
11.2.5 Transport Layer
|
3998 |
|
|
----------------------
|
3999 |
|
|
|
4000 |
|
|
11.2.6 Builtin Simulator
|
4001 |
|
|
------------------------
|
4002 |
|
|
|
4003 |
|
|
|
4004 |
|
|
File: gdbint.info, Node: Native Debugging, Next: Support Libraries, Prev: Target Vector Definition, Up: Top
|
4005 |
|
|
|
4006 |
|
|
12 Native Debugging
|
4007 |
|
|
*******************
|
4008 |
|
|
|
4009 |
|
|
Several files control GDB's configuration for native support:
|
4010 |
|
|
|
4011 |
|
|
`gdb/config/ARCH/XYZ.mh'
|
4012 |
|
|
Specifies Makefile fragments needed by a _native_ configuration on
|
4013 |
|
|
machine XYZ. In particular, this lists the required
|
4014 |
|
|
native-dependent object files, by defining `NATDEPFILES=...'.
|
4015 |
|
|
Also specifies the header file which describes native support on
|
4016 |
|
|
XYZ, by defining `NAT_FILE= nm-XYZ.h'. You can also define
|
4017 |
|
|
`NAT_CFLAGS', `NAT_ADD_FILES', `NAT_CLIBS', `NAT_CDEPS', etc.; see
|
4018 |
|
|
`Makefile.in'.
|
4019 |
|
|
|
4020 |
|
|
_Maintainer's note: The `.mh' suffix is because this file
|
4021 |
|
|
originally contained `Makefile' fragments for hosting GDB on
|
4022 |
|
|
machine XYZ. While the file is no longer used for this purpose,
|
4023 |
|
|
the `.mh' suffix remains. Perhaps someone will eventually rename
|
4024 |
|
|
these fragments so that they have a `.mn' suffix._
|
4025 |
|
|
|
4026 |
|
|
`gdb/config/ARCH/nm-XYZ.h'
|
4027 |
|
|
(`nm.h' is a link to this file, created by `configure'). Contains
|
4028 |
|
|
C macro definitions describing the native system environment, such
|
4029 |
|
|
as child process control and core file support.
|
4030 |
|
|
|
4031 |
|
|
`gdb/XYZ-nat.c'
|
4032 |
|
|
Contains any miscellaneous C code required for this native support
|
4033 |
|
|
of this machine. On some machines it doesn't exist at all.
|
4034 |
|
|
|
4035 |
|
|
There are some "generic" versions of routines that can be used by
|
4036 |
|
|
various systems. These can be customized in various ways by macros
|
4037 |
|
|
defined in your `nm-XYZ.h' file. If these routines work for the XYZ
|
4038 |
|
|
host, you can just include the generic file's name (with `.o', not
|
4039 |
|
|
`.c') in `NATDEPFILES'.
|
4040 |
|
|
|
4041 |
|
|
Otherwise, if your machine needs custom support routines, you will
|
4042 |
|
|
need to write routines that perform the same functions as the generic
|
4043 |
|
|
file. Put them into `XYZ-nat.c', and put `XYZ-nat.o' into
|
4044 |
|
|
`NATDEPFILES'.
|
4045 |
|
|
|
4046 |
|
|
`inftarg.c'
|
4047 |
|
|
This contains the _target_ops vector_ that supports Unix child
|
4048 |
|
|
processes on systems which use ptrace and wait to control the
|
4049 |
|
|
child.
|
4050 |
|
|
|
4051 |
|
|
`procfs.c'
|
4052 |
|
|
This contains the _target_ops vector_ that supports Unix child
|
4053 |
|
|
processes on systems which use /proc to control the child.
|
4054 |
|
|
|
4055 |
|
|
`fork-child.c'
|
4056 |
|
|
This does the low-level grunge that uses Unix system calls to do a
|
4057 |
|
|
"fork and exec" to start up a child process.
|
4058 |
|
|
|
4059 |
|
|
`infptrace.c'
|
4060 |
|
|
This is the low level interface to inferior processes for systems
|
4061 |
|
|
using the Unix `ptrace' call in a vanilla way.
|
4062 |
|
|
|
4063 |
|
|
12.1 Native core file Support
|
4064 |
|
|
=============================
|
4065 |
|
|
|
4066 |
|
|
`core-aout.c::fetch_core_registers()'
|
4067 |
|
|
Support for reading registers out of a core file. This routine
|
4068 |
|
|
calls `register_addr()', see below. Now that BFD is used to read
|
4069 |
|
|
core files, virtually all machines should use `core-aout.c', and
|
4070 |
|
|
should just provide `fetch_core_registers' in `XYZ-nat.c' (or
|
4071 |
|
|
`REGISTER_U_ADDR' in `nm-XYZ.h').
|
4072 |
|
|
|
4073 |
|
|
`core-aout.c::register_addr()'
|
4074 |
|
|
If your `nm-XYZ.h' file defines the macro `REGISTER_U_ADDR(addr,
|
4075 |
|
|
blockend, regno)', it should be defined to set `addr' to the
|
4076 |
|
|
offset within the `user' struct of GDB register number `regno'.
|
4077 |
|
|
`blockend' is the offset within the "upage" of `u.u_ar0'. If
|
4078 |
|
|
`REGISTER_U_ADDR' is defined, `core-aout.c' will define the
|
4079 |
|
|
`register_addr()' function and use the macro in it. If you do not
|
4080 |
|
|
define `REGISTER_U_ADDR', but you are using the standard
|
4081 |
|
|
`fetch_core_registers()', you will need to define your own version
|
4082 |
|
|
of `register_addr()', put it into your `XYZ-nat.c' file, and be
|
4083 |
|
|
sure `XYZ-nat.o' is in the `NATDEPFILES' list. If you have your
|
4084 |
|
|
own `fetch_core_registers()', you may not need a separate
|
4085 |
|
|
`register_addr()'. Many custom `fetch_core_registers()'
|
4086 |
|
|
implementations simply locate the registers themselves.
|
4087 |
|
|
|
4088 |
|
|
When making GDB run native on a new operating system, to make it
|
4089 |
|
|
possible to debug core files, you will need to either write specific
|
4090 |
|
|
code for parsing your OS's core files, or customize `bfd/trad-core.c'.
|
4091 |
|
|
First, use whatever `#include' files your machine uses to define the
|
4092 |
|
|
struct of registers that is accessible (possibly in the u-area) in a
|
4093 |
|
|
core file (rather than `machine/reg.h'), and an include file that
|
4094 |
|
|
defines whatever header exists on a core file (e.g., the u-area or a
|
4095 |
|
|
`struct core'). Then modify `trad_unix_core_file_p' to use these
|
4096 |
|
|
values to set up the section information for the data segment, stack
|
4097 |
|
|
segment, any other segments in the core file (perhaps shared library
|
4098 |
|
|
contents or control information), "registers" segment, and if there are
|
4099 |
|
|
two discontiguous sets of registers (e.g., integer and float), the
|
4100 |
|
|
"reg2" segment. This section information basically delimits areas in
|
4101 |
|
|
the core file in a standard way, which the section-reading routines in
|
4102 |
|
|
BFD know how to seek around in.
|
4103 |
|
|
|
4104 |
|
|
Then back in GDB, you need a matching routine called
|
4105 |
|
|
`fetch_core_registers'. If you can use the generic one, it's in
|
4106 |
|
|
`core-aout.c'; if not, it's in your `XYZ-nat.c' file. It will be
|
4107 |
|
|
passed a char pointer to the entire "registers" segment, its length,
|
4108 |
|
|
and a zero; or a char pointer to the entire "regs2" segment, its
|
4109 |
|
|
length, and a 2. The routine should suck out the supplied register
|
4110 |
|
|
values and install them into GDB's "registers" array.
|
4111 |
|
|
|
4112 |
|
|
If your system uses `/proc' to control processes, and uses ELF
|
4113 |
|
|
format core files, then you may be able to use the same routines for
|
4114 |
|
|
reading the registers out of processes and out of core files.
|
4115 |
|
|
|
4116 |
|
|
12.2 ptrace
|
4117 |
|
|
===========
|
4118 |
|
|
|
4119 |
|
|
12.3 /proc
|
4120 |
|
|
==========
|
4121 |
|
|
|
4122 |
|
|
12.4 win32
|
4123 |
|
|
==========
|
4124 |
|
|
|
4125 |
|
|
12.5 shared libraries
|
4126 |
|
|
=====================
|
4127 |
|
|
|
4128 |
|
|
12.6 Native Conditionals
|
4129 |
|
|
========================
|
4130 |
|
|
|
4131 |
|
|
When GDB is configured and compiled, various macros are defined or left
|
4132 |
|
|
undefined, to control compilation when the host and target systems are
|
4133 |
|
|
the same. These macros should be defined (or left undefined) in
|
4134 |
|
|
`nm-SYSTEM.h'.
|
4135 |
|
|
|
4136 |
|
|
`CHILD_PREPARE_TO_STORE'
|
4137 |
|
|
If the machine stores all registers at once in the child process,
|
4138 |
|
|
then define this to ensure that all values are correct. This
|
4139 |
|
|
usually entails a read from the child.
|
4140 |
|
|
|
4141 |
|
|
[Note that this is incorrectly defined in `xm-SYSTEM.h' files
|
4142 |
|
|
currently.]
|
4143 |
|
|
|
4144 |
|
|
`FETCH_INFERIOR_REGISTERS'
|
4145 |
|
|
Define this if the native-dependent code will provide its own
|
4146 |
|
|
routines `fetch_inferior_registers' and `store_inferior_registers'
|
4147 |
|
|
in `HOST-nat.c'. If this symbol is _not_ defined, and
|
4148 |
|
|
`infptrace.c' is included in this configuration, the default
|
4149 |
|
|
routines in `infptrace.c' are used for these functions.
|
4150 |
|
|
|
4151 |
|
|
`int gdbarch_fp0_regnum (GDBARCH)'
|
4152 |
|
|
This functions normally returns the number of the first floating
|
4153 |
|
|
point register, if the machine has such registers. As such, it
|
4154 |
|
|
would appear only in target-specific code. However, `/proc'
|
4155 |
|
|
support uses this to decide whether floats are in use on this
|
4156 |
|
|
target.
|
4157 |
|
|
|
4158 |
|
|
`int gdbarch_get_longjmp_target (GDBARCH)'
|
4159 |
|
|
For most machines, this is a target-dependent parameter. On the
|
4160 |
|
|
DECstation and the Iris, this is a native-dependent parameter,
|
4161 |
|
|
since `setjmp.h' is needed to define it.
|
4162 |
|
|
|
4163 |
|
|
This function determines the target PC address that `longjmp' will
|
4164 |
|
|
jump to, assuming that we have just stopped at a longjmp
|
4165 |
|
|
breakpoint. It takes a `CORE_ADDR *' as argument, and stores the
|
4166 |
|
|
target PC value through this pointer. It examines the current
|
4167 |
|
|
state of the machine as needed.
|
4168 |
|
|
|
4169 |
|
|
`I386_USE_GENERIC_WATCHPOINTS'
|
4170 |
|
|
An x86-based machine can define this to use the generic x86
|
4171 |
|
|
watchpoint support; see *Note I386_USE_GENERIC_WATCHPOINTS:
|
4172 |
|
|
Algorithms.
|
4173 |
|
|
|
4174 |
|
|
`ONE_PROCESS_WRITETEXT'
|
4175 |
|
|
Define this to be able to, when a breakpoint insertion fails, warn
|
4176 |
|
|
the user that another process may be running with the same
|
4177 |
|
|
executable.
|
4178 |
|
|
|
4179 |
|
|
`PROC_NAME_FMT'
|
4180 |
|
|
Defines the format for the name of a `/proc' device. Should be
|
4181 |
|
|
defined in `nm.h' _only_ in order to override the default
|
4182 |
|
|
definition in `procfs.c'.
|
4183 |
|
|
|
4184 |
|
|
`SOLIB_ADD (FILENAME, FROM_TTY, TARG, READSYMS)'
|
4185 |
|
|
Define this to expand into an expression that will cause the
|
4186 |
|
|
symbols in FILENAME to be added to GDB's symbol table. If READSYMS
|
4187 |
|
|
is zero symbols are not read but any necessary low level
|
4188 |
|
|
processing for FILENAME is still done.
|
4189 |
|
|
|
4190 |
|
|
`SOLIB_CREATE_INFERIOR_HOOK'
|
4191 |
|
|
Define this to expand into any shared-library-relocation code that
|
4192 |
|
|
you want to be run just after the child process has been forked.
|
4193 |
|
|
|
4194 |
|
|
`START_INFERIOR_TRAPS_EXPECTED'
|
4195 |
|
|
When starting an inferior, GDB normally expects to trap twice;
|
4196 |
|
|
once when the shell execs, and once when the program itself execs.
|
4197 |
|
|
If the actual number of traps is something other than 2, then
|
4198 |
|
|
define this macro to expand into the number expected.
|
4199 |
|
|
|
4200 |
|
|
|
4201 |
|
|
|
4202 |
|
|
File: gdbint.info, Node: Support Libraries, Next: Coding, Prev: Native Debugging, Up: Top
|
4203 |
|
|
|
4204 |
|
|
13 Support Libraries
|
4205 |
|
|
********************
|
4206 |
|
|
|
4207 |
|
|
13.1 BFD
|
4208 |
|
|
========
|
4209 |
|
|
|
4210 |
|
|
BFD provides support for GDB in several ways:
|
4211 |
|
|
|
4212 |
|
|
_identifying executable and core files_
|
4213 |
|
|
BFD will identify a variety of file types, including a.out, coff,
|
4214 |
|
|
and several variants thereof, as well as several kinds of core
|
4215 |
|
|
files.
|
4216 |
|
|
|
4217 |
|
|
_access to sections of files_
|
4218 |
|
|
BFD parses the file headers to determine the names, virtual
|
4219 |
|
|
addresses, sizes, and file locations of all the various named
|
4220 |
|
|
sections in files (such as the text section or the data section).
|
4221 |
|
|
GDB simply calls BFD to read or write section X at byte offset Y
|
4222 |
|
|
for length Z.
|
4223 |
|
|
|
4224 |
|
|
_specialized core file support_
|
4225 |
|
|
BFD provides routines to determine the failing command name stored
|
4226 |
|
|
in a core file, the signal with which the program failed, and
|
4227 |
|
|
whether a core file matches (i.e. could be a core dump of) a
|
4228 |
|
|
particular executable file.
|
4229 |
|
|
|
4230 |
|
|
_locating the symbol information_
|
4231 |
|
|
GDB uses an internal interface of BFD to determine where to find
|
4232 |
|
|
the symbol information in an executable file or symbol-file. GDB
|
4233 |
|
|
itself handles the reading of symbols, since BFD does not
|
4234 |
|
|
"understand" debug symbols, but GDB uses BFD's cached information
|
4235 |
|
|
to find the symbols, string table, etc.
|
4236 |
|
|
|
4237 |
|
|
13.2 opcodes
|
4238 |
|
|
============
|
4239 |
|
|
|
4240 |
|
|
The opcodes library provides GDB's disassembler. (It's a separate
|
4241 |
|
|
library because it's also used in binutils, for `objdump').
|
4242 |
|
|
|
4243 |
|
|
13.3 readline
|
4244 |
|
|
=============
|
4245 |
|
|
|
4246 |
|
|
The `readline' library provides a set of functions for use by
|
4247 |
|
|
applications that allow users to edit command lines as they are typed
|
4248 |
|
|
in.
|
4249 |
|
|
|
4250 |
|
|
13.4 libiberty
|
4251 |
|
|
==============
|
4252 |
|
|
|
4253 |
|
|
The `libiberty' library provides a set of functions and features that
|
4254 |
|
|
integrate and improve on functionality found in modern operating
|
4255 |
|
|
systems. Broadly speaking, such features can be divided into three
|
4256 |
|
|
groups: supplemental functions (functions that may be missing in some
|
4257 |
|
|
environments and operating systems), replacement functions (providing a
|
4258 |
|
|
uniform and easier to use interface for commonly used standard
|
4259 |
|
|
functions), and extensions (which provide additional functionality
|
4260 |
|
|
beyond standard functions).
|
4261 |
|
|
|
4262 |
|
|
GDB uses various features provided by the `libiberty' library, for
|
4263 |
|
|
instance the C++ demangler, the IEEE floating format support functions,
|
4264 |
|
|
the input options parser `getopt', the `obstack' extension, and other
|
4265 |
|
|
functions.
|
4266 |
|
|
|
4267 |
|
|
13.4.1 `obstacks' in GDB
|
4268 |
|
|
------------------------
|
4269 |
|
|
|
4270 |
|
|
The obstack mechanism provides a convenient way to allocate and free
|
4271 |
|
|
chunks of memory. Each obstack is a pool of memory that is managed
|
4272 |
|
|
like a stack. Objects (of any nature, size and alignment) are
|
4273 |
|
|
allocated and freed in a LIFO fashion on an obstack (see `libiberty''s
|
4274 |
|
|
documentation for a more detailed explanation of `obstacks').
|
4275 |
|
|
|
4276 |
|
|
The most noticeable use of the `obstacks' in GDB is in object files.
|
4277 |
|
|
There is an obstack associated with each internal representation of an
|
4278 |
|
|
object file. Lots of things get allocated on these `obstacks':
|
4279 |
|
|
dictionary entries, blocks, blockvectors, symbols, minimal symbols,
|
4280 |
|
|
types, vectors of fundamental types, class fields of types, object
|
4281 |
|
|
files section lists, object files section offset lists, line tables,
|
4282 |
|
|
symbol tables, partial symbol tables, string tables, symbol table
|
4283 |
|
|
private data, macros tables, debug information sections and entries,
|
4284 |
|
|
import and export lists (som), unwind information (hppa), dwarf2
|
4285 |
|
|
location expressions data. Plus various strings such as directory
|
4286 |
|
|
names strings, debug format strings, names of types.
|
4287 |
|
|
|
4288 |
|
|
An essential and convenient property of all data on `obstacks' is
|
4289 |
|
|
that memory for it gets allocated (with `obstack_alloc') at various
|
4290 |
|
|
times during a debugging session, but it is released all at once using
|
4291 |
|
|
the `obstack_free' function. The `obstack_free' function takes a
|
4292 |
|
|
pointer to where in the stack it must start the deletion from (much
|
4293 |
|
|
like the cleanup chains have a pointer to where to start the cleanups).
|
4294 |
|
|
Because of the stack like structure of the `obstacks', this allows to
|
4295 |
|
|
free only a top portion of the obstack. There are a few instances in
|
4296 |
|
|
GDB where such thing happens. Calls to `obstack_free' are done after
|
4297 |
|
|
some local data is allocated to the obstack. Only the local data is
|
4298 |
|
|
deleted from the obstack. Of course this assumes that nothing between
|
4299 |
|
|
the `obstack_alloc' and the `obstack_free' allocates anything else on
|
4300 |
|
|
the same obstack. For this reason it is best and safest to use
|
4301 |
|
|
temporary `obstacks'.
|
4302 |
|
|
|
4303 |
|
|
Releasing the whole obstack is also not safe per se. It is safe only
|
4304 |
|
|
under the condition that we know the `obstacks' memory is no longer
|
4305 |
|
|
needed. In GDB we get rid of the `obstacks' only when we get rid of
|
4306 |
|
|
the whole objfile(s), for instance upon reading a new symbol file.
|
4307 |
|
|
|
4308 |
|
|
13.5 gnu-regex
|
4309 |
|
|
==============
|
4310 |
|
|
|
4311 |
|
|
Regex conditionals.
|
4312 |
|
|
|
4313 |
|
|
`C_ALLOCA'
|
4314 |
|
|
|
4315 |
|
|
`NFAILURES'
|
4316 |
|
|
|
4317 |
|
|
`RE_NREGS'
|
4318 |
|
|
|
4319 |
|
|
`SIGN_EXTEND_CHAR'
|
4320 |
|
|
|
4321 |
|
|
`SWITCH_ENUM_BUG'
|
4322 |
|
|
|
4323 |
|
|
`SYNTAX_TABLE'
|
4324 |
|
|
|
4325 |
|
|
`Sword'
|
4326 |
|
|
|
4327 |
|
|
`sparc'
|
4328 |
|
|
|
4329 |
|
|
13.6 Array Containers
|
4330 |
|
|
=====================
|
4331 |
|
|
|
4332 |
|
|
Often it is necessary to manipulate a dynamic array of a set of
|
4333 |
|
|
objects. C forces some bookkeeping on this, which can get cumbersome
|
4334 |
|
|
and repetitive. The `vec.h' file contains macros for defining and
|
4335 |
|
|
using a typesafe vector type. The functions defined will be inlined
|
4336 |
|
|
when compiling, and so the abstraction cost should be zero. Domain
|
4337 |
|
|
checks are added to detect programming errors.
|
4338 |
|
|
|
4339 |
|
|
An example use would be an array of symbols or section information.
|
4340 |
|
|
The array can be grown as symbols are read in (or preallocated), and
|
4341 |
|
|
the accessor macros provided keep care of all the necessary
|
4342 |
|
|
bookkeeping. Because the arrays are type safe, there is no danger of
|
4343 |
|
|
accidentally mixing up the contents. Think of these as C++ templates,
|
4344 |
|
|
but implemented in C.
|
4345 |
|
|
|
4346 |
|
|
Because of the different behavior of structure objects, scalar
|
4347 |
|
|
objects and of pointers, there are three flavors of vector, one for
|
4348 |
|
|
each of these variants. Both the structure object and pointer variants
|
4349 |
|
|
pass pointers to objects around -- in the former case the pointers are
|
4350 |
|
|
stored into the vector and in the latter case the pointers are
|
4351 |
|
|
dereferenced and the objects copied into the vector. The scalar object
|
4352 |
|
|
variant is suitable for `int'-like objects, and the vector elements are
|
4353 |
|
|
returned by value.
|
4354 |
|
|
|
4355 |
|
|
There are both `index' and `iterate' accessors. The iterator
|
4356 |
|
|
returns a boolean iteration condition and updates the iteration
|
4357 |
|
|
variable passed by reference. Because the iterator will be inlined,
|
4358 |
|
|
the address-of can be optimized away.
|
4359 |
|
|
|
4360 |
|
|
The vectors are implemented using the trailing array idiom, thus they
|
4361 |
|
|
are not resizeable without changing the address of the vector object
|
4362 |
|
|
itself. This means you cannot have variables or fields of vector type
|
4363 |
|
|
-- always use a pointer to a vector. The one exception is the final
|
4364 |
|
|
field of a structure, which could be a vector type. You will have to
|
4365 |
|
|
use the `embedded_size' & `embedded_init' calls to create such objects,
|
4366 |
|
|
and they will probably not be resizeable (so don't use the "safe"
|
4367 |
|
|
allocation variants). The trailing array idiom is used (rather than a
|
4368 |
|
|
pointer to an array of data), because, if we allow `NULL' to also
|
4369 |
|
|
represent an empty vector, empty vectors occupy minimal space in the
|
4370 |
|
|
structure containing them.
|
4371 |
|
|
|
4372 |
|
|
Each operation that increases the number of active elements is
|
4373 |
|
|
available in "quick" and "safe" variants. The former presumes that
|
4374 |
|
|
there is sufficient allocated space for the operation to succeed (it
|
4375 |
|
|
dies if there is not). The latter will reallocate the vector, if
|
4376 |
|
|
needed. Reallocation causes an exponential increase in vector size.
|
4377 |
|
|
If you know you will be adding N elements, it would be more efficient
|
4378 |
|
|
to use the reserve operation before adding the elements with the
|
4379 |
|
|
"quick" operation. This will ensure there are at least as many
|
4380 |
|
|
elements as you ask for, it will exponentially increase if there are
|
4381 |
|
|
too few spare slots. If you want reserve a specific number of slots,
|
4382 |
|
|
but do not want the exponential increase (for instance, you know this
|
4383 |
|
|
is the last allocation), use a negative number for reservation. You
|
4384 |
|
|
can also create a vector of a specific size from the get go.
|
4385 |
|
|
|
4386 |
|
|
You should prefer the push and pop operations, as they append and
|
4387 |
|
|
remove from the end of the vector. If you need to remove several items
|
4388 |
|
|
in one go, use the truncate operation. The insert and remove
|
4389 |
|
|
operations allow you to change elements in the middle of the vector.
|
4390 |
|
|
There are two remove operations, one which preserves the element
|
4391 |
|
|
ordering `ordered_remove', and one which does not `unordered_remove'.
|
4392 |
|
|
The latter function copies the end element into the removed slot,
|
4393 |
|
|
rather than invoke a memmove operation. The `lower_bound' function
|
4394 |
|
|
will determine where to place an item in the array using insert that
|
4395 |
|
|
will maintain sorted order.
|
4396 |
|
|
|
4397 |
|
|
If you need to directly manipulate a vector, then the `address'
|
4398 |
|
|
accessor will return the address of the start of the vector. Also the
|
4399 |
|
|
`space' predicate will tell you whether there is spare capacity in the
|
4400 |
|
|
vector. You will not normally need to use these two functions.
|
4401 |
|
|
|
4402 |
|
|
Vector types are defined using a `DEF_VEC_{O,P,I}(TYPENAME)' macro.
|
4403 |
|
|
Variables of vector type are declared using a `VEC(TYPENAME)' macro.
|
4404 |
|
|
The characters `O', `P' and `I' indicate whether TYPENAME is an object
|
4405 |
|
|
(`O'), pointer (`P') or integral (`I') type. Be careful to pick the
|
4406 |
|
|
correct one, as you'll get an awkward and inefficient API if you use
|
4407 |
|
|
the wrong one. There is a check, which results in a compile-time
|
4408 |
|
|
warning, for the `P' and `I' versions, but there is no check for the
|
4409 |
|
|
`O' versions, as that is not possible in plain C.
|
4410 |
|
|
|
4411 |
|
|
An example of their use would be,
|
4412 |
|
|
|
4413 |
|
|
DEF_VEC_P(tree); // non-managed tree vector.
|
4414 |
|
|
|
4415 |
|
|
struct my_struct {
|
4416 |
|
|
VEC(tree) *v; // A (pointer to) a vector of tree pointers.
|
4417 |
|
|
};
|
4418 |
|
|
|
4419 |
|
|
struct my_struct *s;
|
4420 |
|
|
|
4421 |
|
|
if (VEC_length(tree, s->v)) { we have some contents }
|
4422 |
|
|
VEC_safe_push(tree, s->v, decl); // append some decl onto the end
|
4423 |
|
|
for (ix = 0; VEC_iterate(tree, s->v, ix, elt); ix++)
|
4424 |
|
|
{ do something with elt }
|
4425 |
|
|
|
4426 |
|
|
The `vec.h' file provides details on how to invoke the various
|
4427 |
|
|
accessors provided. They are enumerated here:
|
4428 |
|
|
|
4429 |
|
|
`VEC_length'
|
4430 |
|
|
Return the number of items in the array,
|
4431 |
|
|
|
4432 |
|
|
`VEC_empty'
|
4433 |
|
|
Return true if the array has no elements.
|
4434 |
|
|
|
4435 |
|
|
`VEC_last'
|
4436 |
|
|
`VEC_index'
|
4437 |
|
|
Return the last or arbitrary item in the array.
|
4438 |
|
|
|
4439 |
|
|
`VEC_iterate'
|
4440 |
|
|
Access an array element and indicate whether the array has been
|
4441 |
|
|
traversed.
|
4442 |
|
|
|
4443 |
|
|
`VEC_alloc'
|
4444 |
|
|
`VEC_free'
|
4445 |
|
|
Create and destroy an array.
|
4446 |
|
|
|
4447 |
|
|
`VEC_embedded_size'
|
4448 |
|
|
`VEC_embedded_init'
|
4449 |
|
|
Helpers for embedding an array as the final element of another
|
4450 |
|
|
struct.
|
4451 |
|
|
|
4452 |
|
|
`VEC_copy'
|
4453 |
|
|
Duplicate an array.
|
4454 |
|
|
|
4455 |
|
|
`VEC_space'
|
4456 |
|
|
Return the amount of free space in an array.
|
4457 |
|
|
|
4458 |
|
|
`VEC_reserve'
|
4459 |
|
|
Ensure a certain amount of free space.
|
4460 |
|
|
|
4461 |
|
|
`VEC_quick_push'
|
4462 |
|
|
`VEC_safe_push'
|
4463 |
|
|
Append to an array, either assuming the space is available, or
|
4464 |
|
|
making sure that it is.
|
4465 |
|
|
|
4466 |
|
|
`VEC_pop'
|
4467 |
|
|
Remove the last item from an array.
|
4468 |
|
|
|
4469 |
|
|
`VEC_truncate'
|
4470 |
|
|
Remove several items from the end of an array.
|
4471 |
|
|
|
4472 |
|
|
`VEC_safe_grow'
|
4473 |
|
|
Add several items to the end of an array.
|
4474 |
|
|
|
4475 |
|
|
`VEC_replace'
|
4476 |
|
|
Overwrite an item in the array.
|
4477 |
|
|
|
4478 |
|
|
`VEC_quick_insert'
|
4479 |
|
|
`VEC_safe_insert'
|
4480 |
|
|
Insert an item into the middle of the array. Either the space must
|
4481 |
|
|
already exist, or the space is created.
|
4482 |
|
|
|
4483 |
|
|
`VEC_ordered_remove'
|
4484 |
|
|
`VEC_unordered_remove'
|
4485 |
|
|
Remove an item from the array, preserving order or not.
|
4486 |
|
|
|
4487 |
|
|
`VEC_block_remove'
|
4488 |
|
|
Remove a set of items from the array.
|
4489 |
|
|
|
4490 |
|
|
`VEC_address'
|
4491 |
|
|
Provide the address of the first element.
|
4492 |
|
|
|
4493 |
|
|
`VEC_lower_bound'
|
4494 |
|
|
Binary search the array.
|
4495 |
|
|
|
4496 |
|
|
|
4497 |
|
|
13.7 include
|
4498 |
|
|
============
|
4499 |
|
|
|
4500 |
|
|
|
4501 |
|
|
File: gdbint.info, Node: Coding, Next: Porting GDB, Prev: Support Libraries, Up: Top
|
4502 |
|
|
|
4503 |
|
|
14 Coding
|
4504 |
|
|
*********
|
4505 |
|
|
|
4506 |
|
|
This chapter covers topics that are lower-level than the major
|
4507 |
|
|
algorithms of GDB.
|
4508 |
|
|
|
4509 |
|
|
14.1 Cleanups
|
4510 |
|
|
=============
|
4511 |
|
|
|
4512 |
|
|
Cleanups are a structured way to deal with things that need to be done
|
4513 |
|
|
later.
|
4514 |
|
|
|
4515 |
|
|
When your code does something (e.g., `xmalloc' some memory, or
|
4516 |
|
|
`open' a file) that needs to be undone later (e.g., `xfree' the memory
|
4517 |
|
|
or `close' the file), it can make a cleanup. The cleanup will be done
|
4518 |
|
|
at some future point: when the command is finished and control returns
|
4519 |
|
|
to the top level; when an error occurs and the stack is unwound; or
|
4520 |
|
|
when your code decides it's time to explicitly perform cleanups.
|
4521 |
|
|
Alternatively you can elect to discard the cleanups you created.
|
4522 |
|
|
|
4523 |
|
|
Syntax:
|
4524 |
|
|
|
4525 |
|
|
`struct cleanup *OLD_CHAIN;'
|
4526 |
|
|
Declare a variable which will hold a cleanup chain handle.
|
4527 |
|
|
|
4528 |
|
|
`OLD_CHAIN = make_cleanup (FUNCTION, ARG);'
|
4529 |
|
|
Make a cleanup which will cause FUNCTION to be called with ARG (a
|
4530 |
|
|
`char *') later. The result, OLD_CHAIN, is a handle that can
|
4531 |
|
|
later be passed to `do_cleanups' or `discard_cleanups'. Unless
|
4532 |
|
|
you are going to call `do_cleanups' or `discard_cleanups', you can
|
4533 |
|
|
ignore the result from `make_cleanup'.
|
4534 |
|
|
|
4535 |
|
|
`do_cleanups (OLD_CHAIN);'
|
4536 |
|
|
Do all cleanups added to the chain since the corresponding
|
4537 |
|
|
`make_cleanup' call was made.
|
4538 |
|
|
|
4539 |
|
|
`discard_cleanups (OLD_CHAIN);'
|
4540 |
|
|
Same as `do_cleanups' except that it just removes the cleanups from
|
4541 |
|
|
the chain and does not call the specified functions.
|
4542 |
|
|
|
4543 |
|
|
Cleanups are implemented as a chain. The handle returned by
|
4544 |
|
|
`make_cleanups' includes the cleanup passed to the call and any later
|
4545 |
|
|
cleanups appended to the chain (but not yet discarded or performed).
|
4546 |
|
|
E.g.:
|
4547 |
|
|
|
4548 |
|
|
make_cleanup (a, 0);
|
4549 |
|
|
{
|
4550 |
|
|
struct cleanup *old = make_cleanup (b, 0);
|
4551 |
|
|
make_cleanup (c, 0)
|
4552 |
|
|
...
|
4553 |
|
|
do_cleanups (old);
|
4554 |
|
|
}
|
4555 |
|
|
|
4556 |
|
|
will call `c()' and `b()' but will not call `a()'. The cleanup that
|
4557 |
|
|
calls `a()' will remain in the cleanup chain, and will be done later
|
4558 |
|
|
unless otherwise discarded.
|
4559 |
|
|
|
4560 |
|
|
Your function should explicitly do or discard the cleanups it
|
4561 |
|
|
creates. Failing to do this leads to non-deterministic behavior since
|
4562 |
|
|
the caller will arbitrarily do or discard your functions cleanups.
|
4563 |
|
|
This need leads to two common cleanup styles.
|
4564 |
|
|
|
4565 |
|
|
The first style is try/finally. Before it exits, your code-block
|
4566 |
|
|
calls `do_cleanups' with the old cleanup chain and thus ensures that
|
4567 |
|
|
your code-block's cleanups are always performed. For instance, the
|
4568 |
|
|
following code-segment avoids a memory leak problem (even when `error'
|
4569 |
|
|
is called and a forced stack unwind occurs) by ensuring that the
|
4570 |
|
|
`xfree' will always be called:
|
4571 |
|
|
|
4572 |
|
|
struct cleanup *old = make_cleanup (null_cleanup, 0);
|
4573 |
|
|
data = xmalloc (sizeof blah);
|
4574 |
|
|
make_cleanup (xfree, data);
|
4575 |
|
|
... blah blah ...
|
4576 |
|
|
do_cleanups (old);
|
4577 |
|
|
|
4578 |
|
|
The second style is try/except. Before it exits, your code-block
|
4579 |
|
|
calls `discard_cleanups' with the old cleanup chain and thus ensures
|
4580 |
|
|
that any created cleanups are not performed. For instance, the
|
4581 |
|
|
following code segment, ensures that the file will be closed but only
|
4582 |
|
|
if there is an error:
|
4583 |
|
|
|
4584 |
|
|
FILE *file = fopen ("afile", "r");
|
4585 |
|
|
struct cleanup *old = make_cleanup (close_file, file);
|
4586 |
|
|
... blah blah ...
|
4587 |
|
|
discard_cleanups (old);
|
4588 |
|
|
return file;
|
4589 |
|
|
|
4590 |
|
|
Some functions, e.g., `fputs_filtered()' or `error()', specify that
|
4591 |
|
|
they "should not be called when cleanups are not in place". This means
|
4592 |
|
|
that any actions you need to reverse in the case of an error or
|
4593 |
|
|
interruption must be on the cleanup chain before you call these
|
4594 |
|
|
functions, since they might never return to your code (they `longjmp'
|
4595 |
|
|
instead).
|
4596 |
|
|
|
4597 |
|
|
14.2 Per-architecture module data
|
4598 |
|
|
=================================
|
4599 |
|
|
|
4600 |
|
|
The multi-arch framework includes a mechanism for adding module
|
4601 |
|
|
specific per-architecture data-pointers to the `struct gdbarch'
|
4602 |
|
|
architecture object.
|
4603 |
|
|
|
4604 |
|
|
A module registers one or more per-architecture data-pointers using:
|
4605 |
|
|
|
4606 |
|
|
-- Function: struct gdbarch_data *gdbarch_data_register_pre_init
|
4607 |
|
|
(gdbarch_data_pre_init_ftype *PRE_INIT)
|
4608 |
|
|
PRE_INIT is used to, on-demand, allocate an initial value for a
|
4609 |
|
|
per-architecture data-pointer using the architecture's obstack
|
4610 |
|
|
(passed in as a parameter). Since PRE_INIT can be called during
|
4611 |
|
|
architecture creation, it is not parameterized with the
|
4612 |
|
|
architecture. and must not call modules that use per-architecture
|
4613 |
|
|
data.
|
4614 |
|
|
|
4615 |
|
|
-- Function: struct gdbarch_data *gdbarch_data_register_post_init
|
4616 |
|
|
(gdbarch_data_post_init_ftype *POST_INIT)
|
4617 |
|
|
POST_INIT is used to obtain an initial value for a
|
4618 |
|
|
per-architecture data-pointer _after_. Since POST_INIT is always
|
4619 |
|
|
called after architecture creation, it both receives the fully
|
4620 |
|
|
initialized architecture and is free to call modules that use
|
4621 |
|
|
per-architecture data (care needs to be taken to ensure that those
|
4622 |
|
|
other modules do not try to call back to this module as that will
|
4623 |
|
|
create in cycles in the initialization call graph).
|
4624 |
|
|
|
4625 |
|
|
These functions return a `struct gdbarch_data' that is used to
|
4626 |
|
|
identify the per-architecture data-pointer added for that module.
|
4627 |
|
|
|
4628 |
|
|
The per-architecture data-pointer is accessed using the function:
|
4629 |
|
|
|
4630 |
|
|
-- Function: void *gdbarch_data (struct gdbarch *GDBARCH, struct
|
4631 |
|
|
gdbarch_data *DATA_HANDLE)
|
4632 |
|
|
Given the architecture ARCH and module data handle DATA_HANDLE
|
4633 |
|
|
(returned by `gdbarch_data_register_pre_init' or
|
4634 |
|
|
`gdbarch_data_register_post_init'), this function returns the
|
4635 |
|
|
current value of the per-architecture data-pointer. If the data
|
4636 |
|
|
pointer is `NULL', it is first initialized by calling the
|
4637 |
|
|
corresponding PRE_INIT or POST_INIT method.
|
4638 |
|
|
|
4639 |
|
|
The examples below assume the following definitions:
|
4640 |
|
|
|
4641 |
|
|
struct nozel { int total; };
|
4642 |
|
|
static struct gdbarch_data *nozel_handle;
|
4643 |
|
|
|
4644 |
|
|
A module can extend the architecture vector, adding additional
|
4645 |
|
|
per-architecture data, using the PRE_INIT method. The module's
|
4646 |
|
|
per-architecture data is then initialized during architecture creation.
|
4647 |
|
|
|
4648 |
|
|
In the below, the module's per-architecture _nozel_ is added. An
|
4649 |
|
|
architecture can specify its nozel by calling `set_gdbarch_nozel' from
|
4650 |
|
|
`gdbarch_init'.
|
4651 |
|
|
|
4652 |
|
|
static void *
|
4653 |
|
|
nozel_pre_init (struct obstack *obstack)
|
4654 |
|
|
{
|
4655 |
|
|
struct nozel *data = OBSTACK_ZALLOC (obstack, struct nozel);
|
4656 |
|
|
return data;
|
4657 |
|
|
}
|
4658 |
|
|
|
4659 |
|
|
extern void
|
4660 |
|
|
set_gdbarch_nozel (struct gdbarch *gdbarch, int total)
|
4661 |
|
|
{
|
4662 |
|
|
struct nozel *data = gdbarch_data (gdbarch, nozel_handle);
|
4663 |
|
|
data->total = nozel;
|
4664 |
|
|
}
|
4665 |
|
|
|
4666 |
|
|
A module can on-demand create architecture dependant data structures
|
4667 |
|
|
using `post_init'.
|
4668 |
|
|
|
4669 |
|
|
In the below, the nozel's total is computed on-demand by
|
4670 |
|
|
`nozel_post_init' using information obtained from the architecture.
|
4671 |
|
|
|
4672 |
|
|
static void *
|
4673 |
|
|
nozel_post_init (struct gdbarch *gdbarch)
|
4674 |
|
|
{
|
4675 |
|
|
struct nozel *data = GDBARCH_OBSTACK_ZALLOC (gdbarch, struct nozel);
|
4676 |
|
|
nozel->total = gdbarch... (gdbarch);
|
4677 |
|
|
return data;
|
4678 |
|
|
}
|
4679 |
|
|
|
4680 |
|
|
extern int
|
4681 |
|
|
nozel_total (struct gdbarch *gdbarch)
|
4682 |
|
|
{
|
4683 |
|
|
struct nozel *data = gdbarch_data (gdbarch, nozel_handle);
|
4684 |
|
|
return data->total;
|
4685 |
|
|
}
|
4686 |
|
|
|
4687 |
|
|
14.3 Wrapping Output Lines
|
4688 |
|
|
==========================
|
4689 |
|
|
|
4690 |
|
|
Output that goes through `printf_filtered' or `fputs_filtered' or
|
4691 |
|
|
`fputs_demangled' needs only to have calls to `wrap_here' added in
|
4692 |
|
|
places that would be good breaking points. The utility routines will
|
4693 |
|
|
take care of actually wrapping if the line width is exceeded.
|
4694 |
|
|
|
4695 |
|
|
The argument to `wrap_here' is an indentation string which is
|
4696 |
|
|
printed _only_ if the line breaks there. This argument is saved away
|
4697 |
|
|
and used later. It must remain valid until the next call to
|
4698 |
|
|
`wrap_here' or until a newline has been printed through the
|
4699 |
|
|
`*_filtered' functions. Don't pass in a local variable and then return!
|
4700 |
|
|
|
4701 |
|
|
It is usually best to call `wrap_here' after printing a comma or
|
4702 |
|
|
space. If you call it before printing a space, make sure that your
|
4703 |
|
|
indentation properly accounts for the leading space that will print if
|
4704 |
|
|
the line wraps there.
|
4705 |
|
|
|
4706 |
|
|
Any function or set of functions that produce filtered output must
|
4707 |
|
|
finish by printing a newline, to flush the wrap buffer, before switching
|
4708 |
|
|
to unfiltered (`printf') output. Symbol reading routines that print
|
4709 |
|
|
warnings are a good example.
|
4710 |
|
|
|
4711 |
|
|
14.4 GDB Coding Standards
|
4712 |
|
|
=========================
|
4713 |
|
|
|
4714 |
|
|
GDB follows the GNU coding standards, as described in
|
4715 |
|
|
`etc/standards.texi'. This file is also available for anonymous FTP
|
4716 |
|
|
from GNU archive sites. GDB takes a strict interpretation of the
|
4717 |
|
|
standard; in general, when the GNU standard recommends a practice but
|
4718 |
|
|
does not require it, GDB requires it.
|
4719 |
|
|
|
4720 |
|
|
GDB follows an additional set of coding standards specific to GDB,
|
4721 |
|
|
as described in the following sections.
|
4722 |
|
|
|
4723 |
|
|
14.4.1 ISO C
|
4724 |
|
|
------------
|
4725 |
|
|
|
4726 |
|
|
GDB assumes an ISO/IEC 9899:1990 (a.k.a. ISO C90) compliant compiler.
|
4727 |
|
|
|
4728 |
|
|
GDB does not assume an ISO C or POSIX compliant C library.
|
4729 |
|
|
|
4730 |
|
|
14.4.2 Memory Management
|
4731 |
|
|
------------------------
|
4732 |
|
|
|
4733 |
|
|
GDB does not use the functions `malloc', `realloc', `calloc', `free'
|
4734 |
|
|
and `asprintf'.
|
4735 |
|
|
|
4736 |
|
|
GDB uses the functions `xmalloc', `xrealloc' and `xcalloc' when
|
4737 |
|
|
allocating memory. Unlike `malloc' et.al. these functions do not
|
4738 |
|
|
return when the memory pool is empty. Instead, they unwind the stack
|
4739 |
|
|
using cleanups. These functions return `NULL' when requested to
|
4740 |
|
|
allocate a chunk of memory of size zero.
|
4741 |
|
|
|
4742 |
|
|
_Pragmatics: By using these functions, the need to check every
|
4743 |
|
|
memory allocation is removed. These functions provide portable
|
4744 |
|
|
behavior._
|
4745 |
|
|
|
4746 |
|
|
GDB does not use the function `free'.
|
4747 |
|
|
|
4748 |
|
|
GDB uses the function `xfree' to return memory to the memory pool.
|
4749 |
|
|
Consistent with ISO-C, this function ignores a request to free a `NULL'
|
4750 |
|
|
pointer.
|
4751 |
|
|
|
4752 |
|
|
_Pragmatics: On some systems `free' fails when passed a `NULL'
|
4753 |
|
|
pointer._
|
4754 |
|
|
|
4755 |
|
|
GDB can use the non-portable function `alloca' for the allocation of
|
4756 |
|
|
small temporary values (such as strings).
|
4757 |
|
|
|
4758 |
|
|
_Pragmatics: This function is very non-portable. Some systems
|
4759 |
|
|
restrict the memory being allocated to no more than a few kilobytes._
|
4760 |
|
|
|
4761 |
|
|
GDB uses the string function `xstrdup' and the print function
|
4762 |
|
|
`xstrprintf'.
|
4763 |
|
|
|
4764 |
|
|
_Pragmatics: `asprintf' and `strdup' can fail. Print functions such
|
4765 |
|
|
as `sprintf' are very prone to buffer overflow errors._
|
4766 |
|
|
|
4767 |
|
|
14.4.3 Compiler Warnings
|
4768 |
|
|
------------------------
|
4769 |
|
|
|
4770 |
|
|
With few exceptions, developers should avoid the configuration option
|
4771 |
|
|
`--disable-werror' when building GDB. The exceptions are listed in the
|
4772 |
|
|
file `gdb/MAINTAINERS'. The default, when building with GCC, is
|
4773 |
|
|
`--enable-werror'.
|
4774 |
|
|
|
4775 |
|
|
This option causes GDB (when built using GCC) to be compiled with a
|
4776 |
|
|
carefully selected list of compiler warning flags. Any warnings from
|
4777 |
|
|
those flags are treated as errors.
|
4778 |
|
|
|
4779 |
|
|
The current list of warning flags includes:
|
4780 |
|
|
|
4781 |
|
|
`-Wall'
|
4782 |
|
|
Recommended GCC warnings.
|
4783 |
|
|
|
4784 |
|
|
`-Wdeclaration-after-statement'
|
4785 |
|
|
GCC 3.x (and later) and C99 allow declarations mixed with code,
|
4786 |
|
|
but GCC 2.x and C89 do not.
|
4787 |
|
|
|
4788 |
|
|
`-Wpointer-arith'
|
4789 |
|
|
|
4790 |
|
|
`-Wformat-nonliteral'
|
4791 |
|
|
Non-literal format strings, with a few exceptions, are bugs - they
|
4792 |
|
|
might contain unintended user-supplied format specifiers. Since
|
4793 |
|
|
GDB uses the `format printf' attribute on all `printf' like
|
4794 |
|
|
functions this checks not just `printf' calls but also calls to
|
4795 |
|
|
functions such as `fprintf_unfiltered'.
|
4796 |
|
|
|
4797 |
|
|
`-Wno-pointer-sign'
|
4798 |
|
|
In version 4.0, GCC began warning about pointer argument passing or
|
4799 |
|
|
assignment even when the source and destination differed only in
|
4800 |
|
|
signedness. However, most GDB code doesn't distinguish carefully
|
4801 |
|
|
between `char' and `unsigned char'. In early 2006 the GDB
|
4802 |
|
|
developers decided correcting these warnings wasn't worth the time
|
4803 |
|
|
it would take.
|
4804 |
|
|
|
4805 |
|
|
`-Wno-unused-parameter'
|
4806 |
|
|
Due to the way that GDB is implemented many functions have unused
|
4807 |
|
|
parameters. Consequently this warning is avoided. The macro
|
4808 |
|
|
`ATTRIBUTE_UNUSED' is not used as it leads to false negatives --
|
4809 |
|
|
it is not an error to have `ATTRIBUTE_UNUSED' on a parameter that
|
4810 |
|
|
is being used.
|
4811 |
|
|
|
4812 |
|
|
`-Wno-unused'
|
4813 |
|
|
`-Wno-switch'
|
4814 |
|
|
`-Wno-char-subscripts'
|
4815 |
|
|
These are warnings which might be useful for GDB, but are
|
4816 |
|
|
currently too noisy to enable with `-Werror'.
|
4817 |
|
|
|
4818 |
|
|
|
4819 |
|
|
14.4.4 Formatting
|
4820 |
|
|
-----------------
|
4821 |
|
|
|
4822 |
|
|
The standard GNU recommendations for formatting must be followed
|
4823 |
|
|
strictly.
|
4824 |
|
|
|
4825 |
|
|
A function declaration should not have its name in column zero. A
|
4826 |
|
|
function definition should have its name in column zero.
|
4827 |
|
|
|
4828 |
|
|
/* Declaration */
|
4829 |
|
|
static void foo (void);
|
4830 |
|
|
/* Definition */
|
4831 |
|
|
void
|
4832 |
|
|
foo (void)
|
4833 |
|
|
{
|
4834 |
|
|
}
|
4835 |
|
|
|
4836 |
|
|
_Pragmatics: This simplifies scripting. Function definitions can be
|
4837 |
|
|
found using `^function-name'._
|
4838 |
|
|
|
4839 |
|
|
There must be a space between a function or macro name and the
|
4840 |
|
|
opening parenthesis of its argument list (except for macro definitions,
|
4841 |
|
|
as required by C). There must not be a space after an open
|
4842 |
|
|
paren/bracket or before a close paren/bracket.
|
4843 |
|
|
|
4844 |
|
|
While additional whitespace is generally helpful for reading, do not
|
4845 |
|
|
use more than one blank line to separate blocks, and avoid adding
|
4846 |
|
|
whitespace after the end of a program line (as of 1/99, some 600 lines
|
4847 |
|
|
had whitespace after the semicolon). Excess whitespace causes
|
4848 |
|
|
difficulties for `diff' and `patch' utilities.
|
4849 |
|
|
|
4850 |
|
|
Pointers are declared using the traditional K&R C style:
|
4851 |
|
|
|
4852 |
|
|
void *foo;
|
4853 |
|
|
|
4854 |
|
|
and not:
|
4855 |
|
|
|
4856 |
|
|
void * foo;
|
4857 |
|
|
void* foo;
|
4858 |
|
|
|
4859 |
|
|
14.4.5 Comments
|
4860 |
|
|
---------------
|
4861 |
|
|
|
4862 |
|
|
The standard GNU requirements on comments must be followed strictly.
|
4863 |
|
|
|
4864 |
|
|
Block comments must appear in the following form, with no `/*'- or
|
4865 |
|
|
`*/'-only lines, and no leading `*':
|
4866 |
|
|
|
4867 |
|
|
/* Wait for control to return from inferior to debugger. If inferior
|
4868 |
|
|
gets a signal, we may decide to start it up again instead of
|
4869 |
|
|
returning. That is why there is a loop in this function. When
|
4870 |
|
|
this function actually returns it means the inferior should be left
|
4871 |
|
|
stopped and GDB should read more commands. */
|
4872 |
|
|
|
4873 |
|
|
(Note that this format is encouraged by Emacs; tabbing for a
|
4874 |
|
|
multi-line comment works correctly, and `M-q' fills the block
|
4875 |
|
|
consistently.)
|
4876 |
|
|
|
4877 |
|
|
Put a blank line between the block comments preceding function or
|
4878 |
|
|
variable definitions, and the definition itself.
|
4879 |
|
|
|
4880 |
|
|
In general, put function-body comments on lines by themselves, rather
|
4881 |
|
|
than trying to fit them into the 20 characters left at the end of a
|
4882 |
|
|
line, since either the comment or the code will inevitably get longer
|
4883 |
|
|
than will fit, and then somebody will have to move it anyhow.
|
4884 |
|
|
|
4885 |
|
|
14.4.6 C Usage
|
4886 |
|
|
--------------
|
4887 |
|
|
|
4888 |
|
|
Code must not depend on the sizes of C data types, the format of the
|
4889 |
|
|
host's floating point numbers, the alignment of anything, or the order
|
4890 |
|
|
of evaluation of expressions.
|
4891 |
|
|
|
4892 |
|
|
Use functions freely. There are only a handful of compute-bound
|
4893 |
|
|
areas in GDB that might be affected by the overhead of a function call,
|
4894 |
|
|
mainly in symbol reading. Most of GDB's performance is limited by the
|
4895 |
|
|
target interface (whether serial line or system call).
|
4896 |
|
|
|
4897 |
|
|
However, use functions with moderation. A thousand one-line
|
4898 |
|
|
functions are just as hard to understand as a single thousand-line
|
4899 |
|
|
function.
|
4900 |
|
|
|
4901 |
|
|
_Macros are bad, M'kay._ (But if you have to use a macro, make sure
|
4902 |
|
|
that the macro arguments are protected with parentheses.)
|
4903 |
|
|
|
4904 |
|
|
Declarations like `struct foo *' should be used in preference to
|
4905 |
|
|
declarations like `typedef struct foo { ... } *foo_ptr'.
|
4906 |
|
|
|
4907 |
|
|
14.4.7 Function Prototypes
|
4908 |
|
|
--------------------------
|
4909 |
|
|
|
4910 |
|
|
Prototypes must be used when both _declaring_ and _defining_ a
|
4911 |
|
|
function. Prototypes for GDB functions must include both the argument
|
4912 |
|
|
type and name, with the name matching that used in the actual function
|
4913 |
|
|
definition.
|
4914 |
|
|
|
4915 |
|
|
All external functions should have a declaration in a header file
|
4916 |
|
|
that callers include, except for `_initialize_*' functions, which must
|
4917 |
|
|
be external so that `init.c' construction works, but shouldn't be
|
4918 |
|
|
visible to random source files.
|
4919 |
|
|
|
4920 |
|
|
Where a source file needs a forward declaration of a static function,
|
4921 |
|
|
that declaration must appear in a block near the top of the source file.
|
4922 |
|
|
|
4923 |
|
|
14.4.8 Internal Error Recovery
|
4924 |
|
|
------------------------------
|
4925 |
|
|
|
4926 |
|
|
During its execution, GDB can encounter two types of errors. User
|
4927 |
|
|
errors and internal errors. User errors include not only a user
|
4928 |
|
|
entering an incorrect command but also problems arising from corrupt
|
4929 |
|
|
object files and system errors when interacting with the target.
|
4930 |
|
|
Internal errors include situations where GDB has detected, at run time,
|
4931 |
|
|
a corrupt or erroneous situation.
|
4932 |
|
|
|
4933 |
|
|
When reporting an internal error, GDB uses `internal_error' and
|
4934 |
|
|
`gdb_assert'.
|
4935 |
|
|
|
4936 |
|
|
GDB must not call `abort' or `assert'.
|
4937 |
|
|
|
4938 |
|
|
_Pragmatics: There is no `internal_warning' function. Either the
|
4939 |
|
|
code detected a user error, recovered from it and issued a `warning' or
|
4940 |
|
|
the code failed to correctly recover from the user error and issued an
|
4941 |
|
|
`internal_error'._
|
4942 |
|
|
|
4943 |
|
|
14.4.9 File Names
|
4944 |
|
|
-----------------
|
4945 |
|
|
|
4946 |
|
|
Any file used when building the core of GDB must be in lower case. Any
|
4947 |
|
|
file used when building the core of GDB must be 8.3 unique. These
|
4948 |
|
|
requirements apply to both source and generated files.
|
4949 |
|
|
|
4950 |
|
|
_Pragmatics: The core of GDB must be buildable on many platforms
|
4951 |
|
|
including DJGPP and MacOS/HFS. Every time an unfriendly file is
|
4952 |
|
|
introduced to the build process both `Makefile.in' and `configure.in'
|
4953 |
|
|
need to be modified accordingly. Compare the convoluted conversion
|
4954 |
|
|
process needed to transform `COPYING' into `copying.c' with the
|
4955 |
|
|
conversion needed to transform `version.in' into `version.c'._
|
4956 |
|
|
|
4957 |
|
|
Any file non 8.3 compliant file (that is not used when building the
|
4958 |
|
|
core of GDB) must be added to `gdb/config/djgpp/fnchange.lst'.
|
4959 |
|
|
|
4960 |
|
|
_Pragmatics: This is clearly a compromise._
|
4961 |
|
|
|
4962 |
|
|
When GDB has a local version of a system header file (ex `string.h')
|
4963 |
|
|
the file name based on the POSIX header prefixed with `gdb_'
|
4964 |
|
|
(`gdb_string.h'). These headers should be relatively independent: they
|
4965 |
|
|
should use only macros defined by `configure', the compiler, or the
|
4966 |
|
|
host; they should include only system headers; they should refer only
|
4967 |
|
|
to system types. They may be shared between multiple programs, e.g.
|
4968 |
|
|
GDB and GDBSERVER.
|
4969 |
|
|
|
4970 |
|
|
For other files `-' is used as the separator.
|
4971 |
|
|
|
4972 |
|
|
14.4.10 Include Files
|
4973 |
|
|
---------------------
|
4974 |
|
|
|
4975 |
|
|
A `.c' file should include `defs.h' first.
|
4976 |
|
|
|
4977 |
|
|
A `.c' file should directly include the `.h' file of every
|
4978 |
|
|
declaration and/or definition it directly refers to. It cannot rely on
|
4979 |
|
|
indirect inclusion.
|
4980 |
|
|
|
4981 |
|
|
A `.h' file should directly include the `.h' file of every
|
4982 |
|
|
declaration and/or definition it directly refers to. It cannot rely on
|
4983 |
|
|
indirect inclusion. Exception: The file `defs.h' does not need to be
|
4984 |
|
|
directly included.
|
4985 |
|
|
|
4986 |
|
|
An external declaration should only appear in one include file.
|
4987 |
|
|
|
4988 |
|
|
An external declaration should never appear in a `.c' file.
|
4989 |
|
|
Exception: a declaration for the `_initialize' function that pacifies
|
4990 |
|
|
`-Wmissing-declaration'.
|
4991 |
|
|
|
4992 |
|
|
A `typedef' definition should only appear in one include file.
|
4993 |
|
|
|
4994 |
|
|
An opaque `struct' declaration can appear in multiple `.h' files.
|
4995 |
|
|
Where possible, a `.h' file should use an opaque `struct' declaration
|
4996 |
|
|
instead of an include.
|
4997 |
|
|
|
4998 |
|
|
All `.h' files should be wrapped in:
|
4999 |
|
|
|
5000 |
|
|
#ifndef INCLUDE_FILE_NAME_H
|
5001 |
|
|
#define INCLUDE_FILE_NAME_H
|
5002 |
|
|
header body
|
5003 |
|
|
#endif
|
5004 |
|
|
|
5005 |
|
|
14.4.11 Clean Design and Portable Implementation
|
5006 |
|
|
------------------------------------------------
|
5007 |
|
|
|
5008 |
|
|
In addition to getting the syntax right, there's the little question of
|
5009 |
|
|
semantics. Some things are done in certain ways in GDB because long
|
5010 |
|
|
experience has shown that the more obvious ways caused various kinds of
|
5011 |
|
|
trouble.
|
5012 |
|
|
|
5013 |
|
|
You can't assume the byte order of anything that comes from a target
|
5014 |
|
|
(including VALUEs, object files, and instructions). Such things must
|
5015 |
|
|
be byte-swapped using `SWAP_TARGET_AND_HOST' in GDB, or one of the swap
|
5016 |
|
|
routines defined in `bfd.h', such as `bfd_get_32'.
|
5017 |
|
|
|
5018 |
|
|
You can't assume that you know what interface is being used to talk
|
5019 |
|
|
to the target system. All references to the target must go through the
|
5020 |
|
|
current `target_ops' vector.
|
5021 |
|
|
|
5022 |
|
|
You can't assume that the host and target machines are the same
|
5023 |
|
|
machine (except in the "native" support modules). In particular, you
|
5024 |
|
|
can't assume that the target machine's header files will be available
|
5025 |
|
|
on the host machine. Target code must bring along its own header files
|
5026 |
|
|
- written from scratch or explicitly donated by their owner, to avoid
|
5027 |
|
|
copyright problems.
|
5028 |
|
|
|
5029 |
|
|
Insertion of new `#ifdef''s will be frowned upon. It's much better
|
5030 |
|
|
to write the code portably than to conditionalize it for various
|
5031 |
|
|
systems.
|
5032 |
|
|
|
5033 |
|
|
New `#ifdef''s which test for specific compilers or manufacturers or
|
5034 |
|
|
operating systems are unacceptable. All `#ifdef''s should test for
|
5035 |
|
|
features. The information about which configurations contain which
|
5036 |
|
|
features should be segregated into the configuration files. Experience
|
5037 |
|
|
has proven far too often that a feature unique to one particular system
|
5038 |
|
|
often creeps into other systems; and that a conditional based on some
|
5039 |
|
|
predefined macro for your current system will become worthless over
|
5040 |
|
|
time, as new versions of your system come out that behave differently
|
5041 |
|
|
with regard to this feature.
|
5042 |
|
|
|
5043 |
|
|
Adding code that handles specific architectures, operating systems,
|
5044 |
|
|
target interfaces, or hosts, is not acceptable in generic code.
|
5045 |
|
|
|
5046 |
|
|
One particularly notorious area where system dependencies tend to
|
5047 |
|
|
creep in is handling of file names. The mainline GDB code assumes
|
5048 |
|
|
Posix semantics of file names: absolute file names begin with a forward
|
5049 |
|
|
slash `/', slashes are used to separate leading directories,
|
5050 |
|
|
case-sensitive file names. These assumptions are not necessarily true
|
5051 |
|
|
on non-Posix systems such as MS-Windows. To avoid system-dependent
|
5052 |
|
|
code where you need to take apart or construct a file name, use the
|
5053 |
|
|
following portable macros:
|
5054 |
|
|
|
5055 |
|
|
`HAVE_DOS_BASED_FILE_SYSTEM'
|
5056 |
|
|
This preprocessing symbol is defined to a non-zero value on hosts
|
5057 |
|
|
whose filesystems belong to the MS-DOS/MS-Windows family. Use this
|
5058 |
|
|
symbol to write conditional code which should only be compiled for
|
5059 |
|
|
such hosts.
|
5060 |
|
|
|
5061 |
|
|
`IS_DIR_SEPARATOR (C)'
|
5062 |
|
|
Evaluates to a non-zero value if C is a directory separator
|
5063 |
|
|
character. On Unix and GNU/Linux systems, only a slash `/' is
|
5064 |
|
|
such a character, but on Windows, both `/' and `\' will pass.
|
5065 |
|
|
|
5066 |
|
|
`IS_ABSOLUTE_PATH (FILE)'
|
5067 |
|
|
Evaluates to a non-zero value if FILE is an absolute file name.
|
5068 |
|
|
For Unix and GNU/Linux hosts, a name which begins with a slash `/'
|
5069 |
|
|
is absolute. On DOS and Windows, `d:/foo' and `x:\bar' are also
|
5070 |
|
|
absolute file names.
|
5071 |
|
|
|
5072 |
|
|
`FILENAME_CMP (F1, F2)'
|
5073 |
|
|
Calls a function which compares file names F1 and F2 as
|
5074 |
|
|
appropriate for the underlying host filesystem. For Posix systems,
|
5075 |
|
|
this simply calls `strcmp'; on case-insensitive filesystems it
|
5076 |
|
|
will call `strcasecmp' instead.
|
5077 |
|
|
|
5078 |
|
|
`DIRNAME_SEPARATOR'
|
5079 |
|
|
Evaluates to a character which separates directories in
|
5080 |
|
|
`PATH'-style lists, typically held in environment variables. This
|
5081 |
|
|
character is `:' on Unix, `;' on DOS and Windows.
|
5082 |
|
|
|
5083 |
|
|
`SLASH_STRING'
|
5084 |
|
|
This evaluates to a constant string you should use to produce an
|
5085 |
|
|
absolute filename from leading directories and the file's basename.
|
5086 |
|
|
`SLASH_STRING' is `"/"' on most systems, but might be `"\\"' for
|
5087 |
|
|
some Windows-based ports.
|
5088 |
|
|
|
5089 |
|
|
In addition to using these macros, be sure to use portable library
|
5090 |
|
|
functions whenever possible. For example, to extract a directory or a
|
5091 |
|
|
basename part from a file name, use the `dirname' and `basename'
|
5092 |
|
|
library functions (available in `libiberty' for platforms which don't
|
5093 |
|
|
provide them), instead of searching for a slash with `strrchr'.
|
5094 |
|
|
|
5095 |
|
|
Another way to generalize GDB along a particular interface is with an
|
5096 |
|
|
attribute struct. For example, GDB has been generalized to handle
|
5097 |
|
|
multiple kinds of remote interfaces--not by `#ifdef's everywhere, but
|
5098 |
|
|
by defining the `target_ops' structure and having a current target (as
|
5099 |
|
|
well as a stack of targets below it, for memory references). Whenever
|
5100 |
|
|
something needs to be done that depends on which remote interface we are
|
5101 |
|
|
using, a flag in the current target_ops structure is tested (e.g.,
|
5102 |
|
|
`target_has_stack'), or a function is called through a pointer in the
|
5103 |
|
|
current target_ops structure. In this way, when a new remote interface
|
5104 |
|
|
is added, only one module needs to be touched--the one that actually
|
5105 |
|
|
implements the new remote interface. Other examples of
|
5106 |
|
|
attribute-structs are BFD access to multiple kinds of object file
|
5107 |
|
|
formats, or GDB's access to multiple source languages.
|
5108 |
|
|
|
5109 |
|
|
Please avoid duplicating code. For example, in GDB 3.x all the code
|
5110 |
|
|
interfacing between `ptrace' and the rest of GDB was duplicated in
|
5111 |
|
|
`*-dep.c', and so changing something was very painful. In GDB 4.x,
|
5112 |
|
|
these have all been consolidated into `infptrace.c'. `infptrace.c' can
|
5113 |
|
|
deal with variations between systems the same way any system-independent
|
5114 |
|
|
file would (hooks, `#if defined', etc.), and machines which are
|
5115 |
|
|
radically different don't need to use `infptrace.c' at all.
|
5116 |
|
|
|
5117 |
|
|
All debugging code must be controllable using the `set debug MODULE'
|
5118 |
|
|
command. Do not use `printf' to print trace messages. Use
|
5119 |
|
|
`fprintf_unfiltered(gdb_stdlog, ...'. Do not use `#ifdef DEBUG'.
|
5120 |
|
|
|
5121 |
|
|
|
5122 |
|
|
File: gdbint.info, Node: Porting GDB, Next: Versions and Branches, Prev: Coding, Up: Top
|
5123 |
|
|
|
5124 |
|
|
15 Porting GDB
|
5125 |
|
|
**************
|
5126 |
|
|
|
5127 |
|
|
Most of the work in making GDB compile on a new machine is in
|
5128 |
|
|
specifying the configuration of the machine. This is done in a
|
5129 |
|
|
dizzying variety of header files and configuration scripts, which we
|
5130 |
|
|
hope to make more sensible soon. Let's say your new host is called an
|
5131 |
|
|
XYZ (e.g., `sun4'), and its full three-part configuration name is
|
5132 |
|
|
`ARCH-XVEND-XOS' (e.g., `sparc-sun-sunos4'). In particular:
|
5133 |
|
|
|
5134 |
|
|
* In the top level directory, edit `config.sub' and add ARCH, XVEND,
|
5135 |
|
|
and XOS to the lists of supported architectures, vendors, and
|
5136 |
|
|
operating systems near the bottom of the file. Also, add XYZ as
|
5137 |
|
|
an alias that maps to `ARCH-XVEND-XOS'. You can test your changes
|
5138 |
|
|
by running
|
5139 |
|
|
|
5140 |
|
|
./config.sub XYZ
|
5141 |
|
|
|
5142 |
|
|
and
|
5143 |
|
|
|
5144 |
|
|
./config.sub `ARCH-XVEND-XOS'
|
5145 |
|
|
|
5146 |
|
|
which should both respond with `ARCH-XVEND-XOS' and no error
|
5147 |
|
|
messages.
|
5148 |
|
|
|
5149 |
|
|
You need to port BFD, if that hasn't been done already. Porting
|
5150 |
|
|
BFD is beyond the scope of this manual.
|
5151 |
|
|
|
5152 |
|
|
* To configure GDB itself, edit `gdb/configure.host' to recognize
|
5153 |
|
|
your system and set `gdb_host' to XYZ, and (unless your desired
|
5154 |
|
|
target is already available) also edit `gdb/configure.tgt',
|
5155 |
|
|
setting `gdb_target' to something appropriate (for instance, XYZ).
|
5156 |
|
|
|
5157 |
|
|
_Maintainer's note: Work in progress. The file
|
5158 |
|
|
`gdb/configure.host' originally needed to be modified when either a
|
5159 |
|
|
new native target or a new host machine was being added to GDB.
|
5160 |
|
|
Recent changes have removed this requirement. The file now only
|
5161 |
|
|
needs to be modified when adding a new native configuration. This
|
5162 |
|
|
will likely changed again in the future._
|
5163 |
|
|
|
5164 |
|
|
* Finally, you'll need to specify and define GDB's host-, native-,
|
5165 |
|
|
and target-dependent `.h' and `.c' files used for your
|
5166 |
|
|
configuration.
|
5167 |
|
|
|
5168 |
|
|
|
5169 |
|
|
File: gdbint.info, Node: Versions and Branches, Next: Start of New Year Procedure, Prev: Porting GDB, Up: Top
|
5170 |
|
|
|
5171 |
|
|
16 Versions and Branches
|
5172 |
|
|
************************
|
5173 |
|
|
|
5174 |
|
|
16.1 Versions
|
5175 |
|
|
=============
|
5176 |
|
|
|
5177 |
|
|
GDB's version is determined by the file `gdb/version.in' and takes one
|
5178 |
|
|
of the following forms:
|
5179 |
|
|
|
5180 |
|
|
MAJOR.MINOR
|
5181 |
|
|
MAJOR.MINOR.PATCHLEVEL
|
5182 |
|
|
an official release (e.g., 6.2 or 6.2.1)
|
5183 |
|
|
|
5184 |
|
|
MAJOR.MINOR.PATCHLEVEL.YYYYMMDD
|
5185 |
|
|
a snapshot taken at YYYY-MM-DD-gmt (e.g., 6.1.50.20020302,
|
5186 |
|
|
6.1.90.20020304, or 6.1.0.20020308)
|
5187 |
|
|
|
5188 |
|
|
MAJOR.MINOR.PATCHLEVEL.YYYYMMDD-cvs
|
5189 |
|
|
a CVS check out drawn on YYYY-MM-DD (e.g., 6.1.50.20020302-cvs,
|
5190 |
|
|
6.1.90.20020304-cvs, or 6.1.0.20020308-cvs)
|
5191 |
|
|
|
5192 |
|
|
MAJOR.MINOR.PATCHLEVEL.YYYYMMDD (VENDOR)
|
5193 |
|
|
a vendor specific release of GDB, that while based on
|
5194 |
|
|
MAJOR.MINOR.PATCHLEVEL.YYYYMMDD, may include additional changes
|
5195 |
|
|
|
5196 |
|
|
GDB's mainline uses the MAJOR and MINOR version numbers from the
|
5197 |
|
|
most recent release branch, with a PATCHLEVEL of 50. At the time each
|
5198 |
|
|
new release branch is created, the mainline's MAJOR and MINOR version
|
5199 |
|
|
numbers are updated.
|
5200 |
|
|
|
5201 |
|
|
GDB's release branch is similar. When the branch is cut, the
|
5202 |
|
|
PATCHLEVEL is changed from 50 to 90. As draft releases are drawn from
|
5203 |
|
|
the branch, the PATCHLEVEL is incremented. Once the first release
|
5204 |
|
|
(MAJOR.MINOR) has been made, the PATCHLEVEL is set to 0 and updates
|
5205 |
|
|
have an incremented PATCHLEVEL.
|
5206 |
|
|
|
5207 |
|
|
For snapshots, and CVS check outs, it is also possible to identify
|
5208 |
|
|
the CVS origin:
|
5209 |
|
|
|
5210 |
|
|
MAJOR.MINOR.50.YYYYMMDD
|
5211 |
|
|
drawn from the HEAD of mainline CVS (e.g., 6.1.50.20020302)
|
5212 |
|
|
|
5213 |
|
|
MAJOR.MINOR.90.YYYYMMDD
|
5214 |
|
|
MAJOR.MINOR.91.YYYYMMDD ...
|
5215 |
|
|
drawn from a release branch prior to the release (e.g.,
|
5216 |
|
|
6.1.90.20020304)
|
5217 |
|
|
|
5218 |
|
|
MAJOR.MINOR.0.YYYYMMDD
|
5219 |
|
|
MAJOR.MINOR.1.YYYYMMDD ...
|
5220 |
|
|
drawn from a release branch after the release (e.g.,
|
5221 |
|
|
6.2.0.20020308)
|
5222 |
|
|
|
5223 |
|
|
If the previous GDB version is 6.1 and the current version is 6.2,
|
5224 |
|
|
then, substituting 6 for MAJOR and 1 or 2 for MINOR, here's an
|
5225 |
|
|
illustration of a typical sequence:
|
5226 |
|
|
|
5227 |
|
|
|
5228 |
|
|
|
|
5229 |
|
|
6.1.50.20020302-cvs
|
5230 |
|
|
|
|
5231 |
|
|
+--------------------------.
|
5232 |
|
|
|
|
5233 |
|
|
| |
|
5234 |
|
|
6.2.50.20020303-cvs 6.1.90 (draft #1)
|
5235 |
|
|
| |
|
5236 |
|
|
6.2.50.20020304-cvs 6.1.90.20020304-cvs
|
5237 |
|
|
| |
|
5238 |
|
|
6.2.50.20020305-cvs 6.1.91 (draft #2)
|
5239 |
|
|
| |
|
5240 |
|
|
6.2.50.20020306-cvs 6.1.91.20020306-cvs
|
5241 |
|
|
| |
|
5242 |
|
|
6.2.50.20020307-cvs 6.2 (release)
|
5243 |
|
|
| |
|
5244 |
|
|
6.2.50.20020308-cvs 6.2.0.20020308-cvs
|
5245 |
|
|
| |
|
5246 |
|
|
6.2.50.20020309-cvs 6.2.1 (update)
|
5247 |
|
|
| |
|
5248 |
|
|
6.2.50.20020310-cvs
|
5249 |
|
|
|
|
5250 |
|
|
6.2.50.20020311-cvs
|
5251 |
|
|
|
|
5252 |
|
|
+--------------------------.
|
5253 |
|
|
|
|
5254 |
|
|
| |
|
5255 |
|
|
6.3.50.20020312-cvs 6.2.90 (draft #1)
|
5256 |
|
|
| |
|
5257 |
|
|
|
5258 |
|
|
16.2 Release Branches
|
5259 |
|
|
=====================
|
5260 |
|
|
|
5261 |
|
|
GDB draws a release series (6.2, 6.2.1, ...) from a single release
|
5262 |
|
|
branch, and identifies that branch using the CVS branch tags:
|
5263 |
|
|
|
5264 |
|
|
gdb_MAJOR_MINOR-YYYYMMDD-branchpoint
|
5265 |
|
|
gdb_MAJOR_MINOR-branch
|
5266 |
|
|
gdb_MAJOR_MINOR-YYYYMMDD-release
|
5267 |
|
|
|
5268 |
|
|
_Pragmatics: To help identify the date at which a branch or release
|
5269 |
|
|
is made, both the branchpoint and release tags include the date that
|
5270 |
|
|
they are cut (YYYYMMDD) in the tag. The branch tag, denoting the head
|
5271 |
|
|
of the branch, does not need this._
|
5272 |
|
|
|
5273 |
|
|
16.3 Vendor Branches
|
5274 |
|
|
====================
|
5275 |
|
|
|
5276 |
|
|
To avoid version conflicts, vendors are expected to modify the file
|
5277 |
|
|
`gdb/version.in' to include a vendor unique alphabetic identifier (an
|
5278 |
|
|
official GDB release never uses alphabetic characters in its version
|
5279 |
|
|
identifier). E.g., `6.2widgit2', or `6.2 (Widgit Inc Patch 2)'.
|
5280 |
|
|
|
5281 |
|
|
16.4 Experimental Branches
|
5282 |
|
|
==========================
|
5283 |
|
|
|
5284 |
|
|
16.4.1 Guidelines
|
5285 |
|
|
-----------------
|
5286 |
|
|
|
5287 |
|
|
GDB permits the creation of branches, cut from the CVS repository, for
|
5288 |
|
|
experimental development. Branches make it possible for developers to
|
5289 |
|
|
share preliminary work, and maintainers to examine significant new
|
5290 |
|
|
developments.
|
5291 |
|
|
|
5292 |
|
|
The following are a set of guidelines for creating such branches:
|
5293 |
|
|
|
5294 |
|
|
_a branch has an owner_
|
5295 |
|
|
The owner can set further policy for a branch, but may not change
|
5296 |
|
|
the ground rules. In particular, they can set a policy for
|
5297 |
|
|
commits (be it adding more reviewers or deciding who can commit).
|
5298 |
|
|
|
5299 |
|
|
_all commits are posted_
|
5300 |
|
|
All changes committed to a branch shall also be posted to the GDB
|
5301 |
|
|
patches mailing list . While
|
5302 |
|
|
commentary on such changes are encouraged, people should remember
|
5303 |
|
|
that the changes only apply to a branch.
|
5304 |
|
|
|
5305 |
|
|
_all commits are covered by an assignment_
|
5306 |
|
|
This ensures that all changes belong to the Free Software
|
5307 |
|
|
Foundation, and avoids the possibility that the branch may become
|
5308 |
|
|
contaminated.
|
5309 |
|
|
|
5310 |
|
|
_a branch is focused_
|
5311 |
|
|
A focused branch has a single objective or goal, and does not
|
5312 |
|
|
contain unnecessary or irrelevant changes. Cleanups, where
|
5313 |
|
|
identified, being be pushed into the mainline as soon as possible.
|
5314 |
|
|
|
5315 |
|
|
_a branch tracks mainline_
|
5316 |
|
|
This keeps the level of divergence under control. It also keeps
|
5317 |
|
|
the pressure on developers to push cleanups and other stuff into
|
5318 |
|
|
the mainline.
|
5319 |
|
|
|
5320 |
|
|
_a branch shall contain the entire GDB module_
|
5321 |
|
|
The GDB module `gdb' should be specified when creating a branch
|
5322 |
|
|
(branches of individual files should be avoided). *Note Tags::.
|
5323 |
|
|
|
5324 |
|
|
_a branch shall be branded using `version.in'_
|
5325 |
|
|
The file `gdb/version.in' shall be modified so that it identifies
|
5326 |
|
|
the branch OWNER and branch NAME, e.g.,
|
5327 |
|
|
`6.2.50.20030303_owner_name' or `6.2 (Owner Name)'.
|
5328 |
|
|
|
5329 |
|
|
|
5330 |
|
|
16.4.2 Tags
|
5331 |
|
|
-----------
|
5332 |
|
|
|
5333 |
|
|
To simplify the identification of GDB branches, the following branch
|
5334 |
|
|
tagging convention is strongly recommended:
|
5335 |
|
|
|
5336 |
|
|
`OWNER_NAME-YYYYMMDD-branchpoint'
|
5337 |
|
|
`OWNER_NAME-YYYYMMDD-branch'
|
5338 |
|
|
The branch point and corresponding branch tag. YYYYMMDD is the
|
5339 |
|
|
date that the branch was created. A branch is created using the
|
5340 |
|
|
sequence:
|
5341 |
|
|
cvs rtag OWNER_NAME-YYYYMMDD-branchpoint gdb
|
5342 |
|
|
cvs rtag -b -r OWNER_NAME-YYYYMMDD-branchpoint \
|
5343 |
|
|
OWNER_NAME-YYYYMMDD-branch gdb
|
5344 |
|
|
|
5345 |
|
|
`OWNER_NAME-YYYYMMDD-mergepoint'
|
5346 |
|
|
The tagged point, on the mainline, that was used when merging the
|
5347 |
|
|
branch on YYYYMMDD. To merge in all changes since the branch was
|
5348 |
|
|
cut, use a command sequence like:
|
5349 |
|
|
cvs rtag OWNER_NAME-YYYYMMDD-mergepoint gdb
|
5350 |
|
|
cvs update \
|
5351 |
|
|
-jOWNER_NAME-YYYYMMDD-branchpoint
|
5352 |
|
|
-jOWNER_NAME-YYYYMMDD-mergepoint
|
5353 |
|
|
Similar sequences can be used to just merge in changes since the
|
5354 |
|
|
last merge.
|
5355 |
|
|
|
5356 |
|
|
|
5357 |
|
|
For further information on CVS, see Concurrent Versions System
|
5358 |
|
|
(http://www.gnu.org/software/cvs/).
|
5359 |
|
|
|
5360 |
|
|
|
5361 |
|
|
File: gdbint.info, Node: Start of New Year Procedure, Next: Releasing GDB, Prev: Versions and Branches, Up: Top
|
5362 |
|
|
|
5363 |
|
|
17 Start of New Year Procedure
|
5364 |
|
|
******************************
|
5365 |
|
|
|
5366 |
|
|
At the start of each new year, the following actions should be
|
5367 |
|
|
performed:
|
5368 |
|
|
|
5369 |
|
|
* Rotate the ChangeLog file
|
5370 |
|
|
|
5371 |
|
|
The current `ChangeLog' file should be renamed into
|
5372 |
|
|
`ChangeLog-YYYY' where YYYY is the year that has just passed. A
|
5373 |
|
|
new `ChangeLog' file should be created, and its contents should
|
5374 |
|
|
contain a reference to the previous ChangeLog. The following
|
5375 |
|
|
should also be preserved at the end of the new ChangeLog, in order
|
5376 |
|
|
to provide the appropriate settings when editing this file with
|
5377 |
|
|
Emacs:
|
5378 |
|
|
Local Variables:
|
5379 |
|
|
mode: change-log
|
5380 |
|
|
left-margin: 8
|
5381 |
|
|
fill-column: 74
|
5382 |
|
|
version-control: never
|
5383 |
|
|
End:
|
5384 |
|
|
|
5385 |
|
|
* Add an entry for the newly created ChangeLog file
|
5386 |
|
|
(`ChangeLog-YYYY') in `gdb/config/djgpp/fnchange.lst'.
|
5387 |
|
|
|
5388 |
|
|
* Update the copyright year in the startup message
|
5389 |
|
|
|
5390 |
|
|
Update the copyright year in file `top.c', function
|
5391 |
|
|
`print_gdb_version'.
|
5392 |
|
|
|
5393 |
|
|
* Add the new year in the copyright notices of all source and
|
5394 |
|
|
documentation files. This can be done semi-automatically by
|
5395 |
|
|
running the `copyright.sh' script. This script requires Emacs 22
|
5396 |
|
|
or later to be installed.
|
5397 |
|
|
|
5398 |
|
|
|
5399 |
|
|
|
5400 |
|
|
File: gdbint.info, Node: Releasing GDB, Next: Testsuite, Prev: Start of New Year Procedure, Up: Top
|
5401 |
|
|
|
5402 |
|
|
18 Releasing GDB
|
5403 |
|
|
****************
|
5404 |
|
|
|
5405 |
|
|
18.1 Branch Commit Policy
|
5406 |
|
|
=========================
|
5407 |
|
|
|
5408 |
|
|
The branch commit policy is pretty slack. GDB releases 5.0, 5.1 and
|
5409 |
|
|
5.2 all used the below:
|
5410 |
|
|
|
5411 |
|
|
* The `gdb/MAINTAINERS' file still holds.
|
5412 |
|
|
|
5413 |
|
|
* Don't fix something on the branch unless/until it is also fixed in
|
5414 |
|
|
the trunk. If this isn't possible, mentioning it in the
|
5415 |
|
|
`gdb/PROBLEMS' file is better than committing a hack.
|
5416 |
|
|
|
5417 |
|
|
* When considering a patch for the branch, suggested criteria
|
5418 |
|
|
include: Does it fix a build? Does it fix the sequence `break
|
5419 |
|
|
main; run' when debugging a static binary?
|
5420 |
|
|
|
5421 |
|
|
* The further a change is from the core of GDB, the less likely the
|
5422 |
|
|
change will worry anyone (e.g., target specific code).
|
5423 |
|
|
|
5424 |
|
|
* Only post a proposal to change the core of GDB after you've sent
|
5425 |
|
|
individual bribes to all the people listed in the `MAINTAINERS'
|
5426 |
|
|
file ;-)
|
5427 |
|
|
|
5428 |
|
|
_Pragmatics: Provided updates are restricted to non-core
|
5429 |
|
|
functionality there is little chance that a broken change will be fatal.
|
5430 |
|
|
This means that changes such as adding a new architectures or (within
|
5431 |
|
|
reason) support for a new host are considered acceptable._
|
5432 |
|
|
|
5433 |
|
|
18.2 Obsoleting code
|
5434 |
|
|
====================
|
5435 |
|
|
|
5436 |
|
|
Before anything else, poke the other developers (and around the source
|
5437 |
|
|
code) to see if there is anything that can be removed from GDB (an old
|
5438 |
|
|
target, an unused file).
|
5439 |
|
|
|
5440 |
|
|
Obsolete code is identified by adding an `OBSOLETE' prefix to every
|
5441 |
|
|
line. Doing this means that it is easy to identify something that has
|
5442 |
|
|
been obsoleted when greping through the sources.
|
5443 |
|
|
|
5444 |
|
|
The process is done in stages -- this is mainly to ensure that the
|
5445 |
|
|
wider GDB community has a reasonable opportunity to respond. Remember,
|
5446 |
|
|
everything on the Internet takes a week.
|
5447 |
|
|
|
5448 |
|
|
1. Post the proposal on the GDB mailing list
|
5449 |
|
|
Creating a bug report to track the task's state, is also highly
|
5450 |
|
|
recommended.
|
5451 |
|
|
|
5452 |
|
|
2. Wait a week or so.
|
5453 |
|
|
|
5454 |
|
|
3. Post the proposal on the GDB Announcement mailing list
|
5455 |
|
|
.
|
5456 |
|
|
|
5457 |
|
|
4. Wait a week or so.
|
5458 |
|
|
|
5459 |
|
|
5. Go through and edit all relevant files and lines so that they are
|
5460 |
|
|
prefixed with the word `OBSOLETE'.
|
5461 |
|
|
|
5462 |
|
|
6. Wait until the next GDB version, containing this obsolete code,
|
5463 |
|
|
has been released.
|
5464 |
|
|
|
5465 |
|
|
7. Remove the obsolete code.
|
5466 |
|
|
|
5467 |
|
|
_Maintainer note: While removing old code is regrettable it is
|
5468 |
|
|
hopefully better for GDB's long term development. Firstly it helps the
|
5469 |
|
|
developers by removing code that is either no longer relevant or simply
|
5470 |
|
|
wrong. Secondly since it removes any history associated with the file
|
5471 |
|
|
(effectively clearing the slate) the developer has a much freer hand
|
5472 |
|
|
when it comes to fixing broken files._
|
5473 |
|
|
|
5474 |
|
|
18.3 Before the Branch
|
5475 |
|
|
======================
|
5476 |
|
|
|
5477 |
|
|
The most important objective at this stage is to find and fix simple
|
5478 |
|
|
changes that become a pain to track once the branch is created. For
|
5479 |
|
|
instance, configuration problems that stop GDB from even building. If
|
5480 |
|
|
you can't get the problem fixed, document it in the `gdb/PROBLEMS' file.
|
5481 |
|
|
|
5482 |
|
|
Prompt for `gdb/NEWS'
|
5483 |
|
|
---------------------
|
5484 |
|
|
|
5485 |
|
|
People always forget. Send a post reminding them but also if you know
|
5486 |
|
|
something interesting happened add it yourself. The `schedule' script
|
5487 |
|
|
will mention this in its e-mail.
|
5488 |
|
|
|
5489 |
|
|
Review `gdb/README'
|
5490 |
|
|
-------------------
|
5491 |
|
|
|
5492 |
|
|
Grab one of the nightly snapshots and then walk through the
|
5493 |
|
|
`gdb/README' looking for anything that can be improved. The `schedule'
|
5494 |
|
|
script will mention this in its e-mail.
|
5495 |
|
|
|
5496 |
|
|
Refresh any imported files.
|
5497 |
|
|
---------------------------
|
5498 |
|
|
|
5499 |
|
|
A number of files are taken from external repositories. They include:
|
5500 |
|
|
|
5501 |
|
|
* `texinfo/texinfo.tex'
|
5502 |
|
|
|
5503 |
|
|
* `config.guess' et. al. (see the top-level `MAINTAINERS' file)
|
5504 |
|
|
|
5505 |
|
|
* `etc/standards.texi', `etc/make-stds.texi'
|
5506 |
|
|
|
5507 |
|
|
Check the ARI
|
5508 |
|
|
-------------
|
5509 |
|
|
|
5510 |
|
|
A.R.I. is an `awk' script (Awk Regression Index ;-) that checks for a
|
5511 |
|
|
number of errors and coding conventions. The checks include things
|
5512 |
|
|
like using `malloc' instead of `xmalloc' and file naming problems.
|
5513 |
|
|
There shouldn't be any regressions.
|
5514 |
|
|
|
5515 |
|
|
18.3.1 Review the bug data base
|
5516 |
|
|
-------------------------------
|
5517 |
|
|
|
5518 |
|
|
Close anything obviously fixed.
|
5519 |
|
|
|
5520 |
|
|
18.3.2 Check all cross targets build
|
5521 |
|
|
------------------------------------
|
5522 |
|
|
|
5523 |
|
|
The targets are listed in `gdb/MAINTAINERS'.
|
5524 |
|
|
|
5525 |
|
|
18.4 Cut the Branch
|
5526 |
|
|
===================
|
5527 |
|
|
|
5528 |
|
|
Create the branch
|
5529 |
|
|
-----------------
|
5530 |
|
|
|
5531 |
|
|
$ u=5.1
|
5532 |
|
|
$ v=5.2
|
5533 |
|
|
$ V=`echo $v | sed 's/\./_/g'`
|
5534 |
|
|
$ D=`date -u +%Y-%m-%d`
|
5535 |
|
|
$ echo $u $V $D
|
5536 |
|
|
5.1 5_2 2002-03-03
|
5537 |
|
|
$ echo cvs -f -d :ext:sources.redhat.com:/cvs/src rtag \
|
5538 |
|
|
-D $D-gmt gdb_$V-$D-branchpoint insight
|
5539 |
|
|
cvs -f -d :ext:sources.redhat.com:/cvs/src rtag
|
5540 |
|
|
-D 2002-03-03-gmt gdb_5_2-2002-03-03-branchpoint insight
|
5541 |
|
|
$ ^echo ^^
|
5542 |
|
|
...
|
5543 |
|
|
$ echo cvs -f -d :ext:sources.redhat.com:/cvs/src rtag \
|
5544 |
|
|
-b -r gdb_$V-$D-branchpoint gdb_$V-branch insight
|
5545 |
|
|
cvs -f -d :ext:sources.redhat.com:/cvs/src rtag \
|
5546 |
|
|
-b -r gdb_5_2-2002-03-03-branchpoint gdb_5_2-branch insight
|
5547 |
|
|
$ ^echo ^^
|
5548 |
|
|
...
|
5549 |
|
|
$
|
5550 |
|
|
|
5551 |
|
|
* By using `-D YYYY-MM-DD-gmt', the branch is forced to an exact
|
5552 |
|
|
date/time.
|
5553 |
|
|
|
5554 |
|
|
* The trunk is first tagged so that the branch point can easily be
|
5555 |
|
|
found.
|
5556 |
|
|
|
5557 |
|
|
* Insight, which includes GDB, is tagged at the same time.
|
5558 |
|
|
|
5559 |
|
|
* `version.in' gets bumped to avoid version number conflicts.
|
5560 |
|
|
|
5561 |
|
|
* The reading of `.cvsrc' is disabled using `-f'.
|
5562 |
|
|
|
5563 |
|
|
Update `version.in'
|
5564 |
|
|
-------------------
|
5565 |
|
|
|
5566 |
|
|
$ u=5.1
|
5567 |
|
|
$ v=5.2
|
5568 |
|
|
$ V=`echo $v | sed 's/\./_/g'`
|
5569 |
|
|
$ echo $u $v$V
|
5570 |
|
|
5.1 5_2
|
5571 |
|
|
$ cd /tmp
|
5572 |
|
|
$ echo cvs -f -d :ext:sources.redhat.com:/cvs/src co \
|
5573 |
|
|
-r gdb_$V-branch src/gdb/version.in
|
5574 |
|
|
cvs -f -d :ext:sources.redhat.com:/cvs/src co
|
5575 |
|
|
-r gdb_5_2-branch src/gdb/version.in
|
5576 |
|
|
$ ^echo ^^
|
5577 |
|
|
U src/gdb/version.in
|
5578 |
|
|
$ cd src/gdb
|
5579 |
|
|
$ echo $u.90-0000-00-00-cvs > version.in
|
5580 |
|
|
$ cat version.in
|
5581 |
|
|
5.1.90-0000-00-00-cvs
|
5582 |
|
|
$ cvs -f commit version.in
|
5583 |
|
|
|
5584 |
|
|
* `0000-00-00' is used as a date to pump prime the version.in update
|
5585 |
|
|
mechanism.
|
5586 |
|
|
|
5587 |
|
|
* `.90' and the previous branch version are used as fairly arbitrary
|
5588 |
|
|
initial branch version number.
|
5589 |
|
|
|
5590 |
|
|
Update the web and news pages
|
5591 |
|
|
-----------------------------
|
5592 |
|
|
|
5593 |
|
|
Something?
|
5594 |
|
|
|
5595 |
|
|
Tweak cron to track the new branch
|
5596 |
|
|
----------------------------------
|
5597 |
|
|
|
5598 |
|
|
The file `gdbadmin/cron/crontab' contains gdbadmin's cron table. This
|
5599 |
|
|
file needs to be updated so that:
|
5600 |
|
|
|
5601 |
|
|
* A daily timestamp is added to the file `version.in'.
|
5602 |
|
|
|
5603 |
|
|
* The new branch is included in the snapshot process.
|
5604 |
|
|
|
5605 |
|
|
See the file `gdbadmin/cron/README' for how to install the updated cron
|
5606 |
|
|
table.
|
5607 |
|
|
|
5608 |
|
|
The file `gdbadmin/ss/README' should also be reviewed to reflect any
|
5609 |
|
|
changes. That file is copied to both the branch/ and current/ snapshot
|
5610 |
|
|
directories.
|
5611 |
|
|
|
5612 |
|
|
Update the NEWS and README files
|
5613 |
|
|
--------------------------------
|
5614 |
|
|
|
5615 |
|
|
The `NEWS' file needs to be updated so that on the branch it refers to
|
5616 |
|
|
_changes in the current release_ while on the trunk it also refers to
|
5617 |
|
|
_changes since the current release_.
|
5618 |
|
|
|
5619 |
|
|
The `README' file needs to be updated so that it refers to the
|
5620 |
|
|
current release.
|
5621 |
|
|
|
5622 |
|
|
Post the branch info
|
5623 |
|
|
--------------------
|
5624 |
|
|
|
5625 |
|
|
Send an announcement to the mailing lists:
|
5626 |
|
|
|
5627 |
|
|
* GDB Announcement mailing list
|
5628 |
|
|
|
5629 |
|
|
* GDB Discussion mailing list and GDB
|
5630 |
|
|
Testers mailing list
|
5631 |
|
|
|
5632 |
|
|
_Pragmatics: The branch creation is sent to the announce list to
|
5633 |
|
|
ensure that people people not subscribed to the higher volume discussion
|
5634 |
|
|
list are alerted._
|
5635 |
|
|
|
5636 |
|
|
The announcement should include:
|
5637 |
|
|
|
5638 |
|
|
* The branch tag.
|
5639 |
|
|
|
5640 |
|
|
* How to check out the branch using CVS.
|
5641 |
|
|
|
5642 |
|
|
* The date/number of weeks until the release.
|
5643 |
|
|
|
5644 |
|
|
* The branch commit policy still holds.
|
5645 |
|
|
|
5646 |
|
|
18.5 Stabilize the branch
|
5647 |
|
|
=========================
|
5648 |
|
|
|
5649 |
|
|
Something goes here.
|
5650 |
|
|
|
5651 |
|
|
18.6 Create a Release
|
5652 |
|
|
=====================
|
5653 |
|
|
|
5654 |
|
|
The process of creating and then making available a release is broken
|
5655 |
|
|
down into a number of stages. The first part addresses the technical
|
5656 |
|
|
process of creating a releasable tar ball. The later stages address the
|
5657 |
|
|
process of releasing that tar ball.
|
5658 |
|
|
|
5659 |
|
|
When making a release candidate just the first section is needed.
|
5660 |
|
|
|
5661 |
|
|
18.6.1 Create a release candidate
|
5662 |
|
|
---------------------------------
|
5663 |
|
|
|
5664 |
|
|
The objective at this stage is to create a set of tar balls that can be
|
5665 |
|
|
made available as a formal release (or as a less formal release
|
5666 |
|
|
candidate).
|
5667 |
|
|
|
5668 |
|
|
Freeze the branch
|
5669 |
|
|
.................
|
5670 |
|
|
|
5671 |
|
|
Send out an e-mail notifying everyone that the branch is frozen to
|
5672 |
|
|
.
|
5673 |
|
|
|
5674 |
|
|
Establish a few defaults.
|
5675 |
|
|
.........................
|
5676 |
|
|
|
5677 |
|
|
$ b=gdb_5_2-branch
|
5678 |
|
|
$ v=5.2
|
5679 |
|
|
$ t=/sourceware/snapshot-tmp/gdbadmin-tmp
|
5680 |
|
|
$ echo $t/$b/$v
|
5681 |
|
|
/sourceware/snapshot-tmp/gdbadmin-tmp/gdb_5_2-branch/5.2
|
5682 |
|
|
$ mkdir -p $t/$b/$v
|
5683 |
|
|
$ cd $t/$b/$v
|
5684 |
|
|
$ pwd
|
5685 |
|
|
/sourceware/snapshot-tmp/gdbadmin-tmp/gdb_5_2-branch/5.2
|
5686 |
|
|
$ which autoconf
|
5687 |
|
|
/home/gdbadmin/bin/autoconf
|
5688 |
|
|
$
|
5689 |
|
|
|
5690 |
|
|
Notes:
|
5691 |
|
|
|
5692 |
|
|
* Check the `autoconf' version carefully. You want to be using the
|
5693 |
|
|
version taken from the `binutils' snapshot directory, which can be
|
5694 |
|
|
found at `ftp://sources.redhat.com/pub/binutils/'. It is very
|
5695 |
|
|
unlikely that a system installed version of `autoconf' (e.g.,
|
5696 |
|
|
`/usr/bin/autoconf') is correct.
|
5697 |
|
|
|
5698 |
|
|
Check out the relevant modules:
|
5699 |
|
|
...............................
|
5700 |
|
|
|
5701 |
|
|
$ for m in gdb insight
|
5702 |
|
|
do
|
5703 |
|
|
( mkdir -p $m && cd $m && cvs -q -f -d /cvs/src co -P -r $b $m )
|
5704 |
|
|
done
|
5705 |
|
|
$
|
5706 |
|
|
|
5707 |
|
|
Note:
|
5708 |
|
|
|
5709 |
|
|
* The reading of `.cvsrc' is disabled (`-f') so that there isn't any
|
5710 |
|
|
confusion between what is written here and what your local `cvs'
|
5711 |
|
|
really does.
|
5712 |
|
|
|
5713 |
|
|
Update relevant files.
|
5714 |
|
|
......................
|
5715 |
|
|
|
5716 |
|
|
`gdb/NEWS'
|
5717 |
|
|
Major releases get their comments added as part of the mainline.
|
5718 |
|
|
Minor releases should probably mention any significant bugs that
|
5719 |
|
|
were fixed.
|
5720 |
|
|
|
5721 |
|
|
Don't forget to include the `ChangeLog' entry.
|
5722 |
|
|
|
5723 |
|
|
$ emacs gdb/src/gdb/NEWS
|
5724 |
|
|
...
|
5725 |
|
|
c-x 4 a
|
5726 |
|
|
...
|
5727 |
|
|
c-x c-s c-x c-c
|
5728 |
|
|
$ cp gdb/src/gdb/NEWS insight/src/gdb/NEWS
|
5729 |
|
|
$ cp gdb/src/gdb/ChangeLog insight/src/gdb/ChangeLog
|
5730 |
|
|
|
5731 |
|
|
`gdb/README'
|
5732 |
|
|
You'll need to update:
|
5733 |
|
|
|
5734 |
|
|
* The version.
|
5735 |
|
|
|
5736 |
|
|
* The update date.
|
5737 |
|
|
|
5738 |
|
|
* Who did it.
|
5739 |
|
|
|
5740 |
|
|
$ emacs gdb/src/gdb/README
|
5741 |
|
|
...
|
5742 |
|
|
c-x 4 a
|
5743 |
|
|
...
|
5744 |
|
|
c-x c-s c-x c-c
|
5745 |
|
|
$ cp gdb/src/gdb/README insight/src/gdb/README
|
5746 |
|
|
$ cp gdb/src/gdb/ChangeLog insight/src/gdb/ChangeLog
|
5747 |
|
|
|
5748 |
|
|
_Maintainer note: Hopefully the `README' file was reviewed before
|
5749 |
|
|
the initial branch was cut so just a simple substitute is needed
|
5750 |
|
|
to get it updated._
|
5751 |
|
|
|
5752 |
|
|
_Maintainer note: Other projects generate `README' and `INSTALL'
|
5753 |
|
|
from the core documentation. This might be worth pursuing._
|
5754 |
|
|
|
5755 |
|
|
`gdb/version.in'
|
5756 |
|
|
$ echo $v > gdb/src/gdb/version.in
|
5757 |
|
|
$ cat gdb/src/gdb/version.in
|
5758 |
|
|
5.2
|
5759 |
|
|
$ emacs gdb/src/gdb/version.in
|
5760 |
|
|
...
|
5761 |
|
|
c-x 4 a
|
5762 |
|
|
... Bump to version ...
|
5763 |
|
|
c-x c-s c-x c-c
|
5764 |
|
|
$ cp gdb/src/gdb/version.in insight/src/gdb/version.in
|
5765 |
|
|
$ cp gdb/src/gdb/ChangeLog insight/src/gdb/ChangeLog
|
5766 |
|
|
|
5767 |
|
|
|
5768 |
|
|
Do the dirty work
|
5769 |
|
|
.................
|
5770 |
|
|
|
5771 |
|
|
This is identical to the process used to create the daily snapshot.
|
5772 |
|
|
|
5773 |
|
|
$ for m in gdb insight
|
5774 |
|
|
do
|
5775 |
|
|
( cd $m/src && gmake -f src-release $m.tar )
|
5776 |
|
|
done
|
5777 |
|
|
|
5778 |
|
|
If the top level source directory does not have `src-release' (GDB
|
5779 |
|
|
version 5.3.1 or earlier), try these commands instead:
|
5780 |
|
|
|
5781 |
|
|
$ for m in gdb insight
|
5782 |
|
|
do
|
5783 |
|
|
( cd $m/src && gmake -f Makefile.in $m.tar )
|
5784 |
|
|
done
|
5785 |
|
|
|
5786 |
|
|
Check the source files
|
5787 |
|
|
......................
|
5788 |
|
|
|
5789 |
|
|
You're looking for files that have mysteriously disappeared.
|
5790 |
|
|
`distclean' has the habit of deleting files it shouldn't. Watch out
|
5791 |
|
|
for the `version.in' update `cronjob'.
|
5792 |
|
|
|
5793 |
|
|
$ ( cd gdb/src && cvs -f -q -n update )
|
5794 |
|
|
M djunpack.bat
|
5795 |
|
|
? gdb-5.1.91.tar
|
5796 |
|
|
? proto-toplev
|
5797 |
|
|
... lots of generated files ...
|
5798 |
|
|
M gdb/ChangeLog
|
5799 |
|
|
M gdb/NEWS
|
5800 |
|
|
M gdb/README
|
5801 |
|
|
M gdb/version.in
|
5802 |
|
|
... lots of generated files ...
|
5803 |
|
|
$
|
5804 |
|
|
|
5805 |
|
|
_Don't worry about the `gdb.info-??' or `gdb/p-exp.tab.c'. They were
|
5806 |
|
|
generated (and yes `gdb.info-1' was also generated only something
|
5807 |
|
|
strange with CVS means that they didn't get suppressed). Fixing it
|
5808 |
|
|
would be nice though._
|
5809 |
|
|
|
5810 |
|
|
Create compressed versions of the release
|
5811 |
|
|
.........................................
|
5812 |
|
|
|
5813 |
|
|
$ cp */src/*.tar .
|
5814 |
|
|
$ cp */src/*.bz2 .
|
5815 |
|
|
$ ls -F
|
5816 |
|
|
gdb/ gdb-5.2.tar insight/ insight-5.2.tar
|
5817 |
|
|
$ for m in gdb insight
|
5818 |
|
|
do
|
5819 |
|
|
bzip2 -v -9 -c $m-$v.tar > $m-$v.tar.bz2
|
5820 |
|
|
gzip -v -9 -c $m-$v.tar > $m-$v.tar.gz
|
5821 |
|
|
done
|
5822 |
|
|
$
|
5823 |
|
|
|
5824 |
|
|
Note:
|
5825 |
|
|
|
5826 |
|
|
* A pipe such as `bunzip2 < xxx.bz2 | gzip -9 > xxx.gz' is not since,
|
5827 |
|
|
in that mode, `gzip' does not know the name of the file and, hence,
|
5828 |
|
|
can not include it in the compressed file. This is also why the
|
5829 |
|
|
release process runs `tar' and `bzip2' as separate passes.
|
5830 |
|
|
|
5831 |
|
|
18.6.2 Sanity check the tar ball
|
5832 |
|
|
--------------------------------
|
5833 |
|
|
|
5834 |
|
|
Pick a popular machine (Solaris/PPC?) and try the build on that.
|
5835 |
|
|
|
5836 |
|
|
$ bunzip2 < gdb-5.2.tar.bz2 | tar xpf -
|
5837 |
|
|
$ cd gdb-5.2
|
5838 |
|
|
$ ./configure
|
5839 |
|
|
$ make
|
5840 |
|
|
...
|
5841 |
|
|
$ ./gdb/gdb ./gdb/gdb
|
5842 |
|
|
GNU gdb 5.2
|
5843 |
|
|
...
|
5844 |
|
|
(gdb) b main
|
5845 |
|
|
Breakpoint 1 at 0x80732bc: file main.c, line 734.
|
5846 |
|
|
(gdb) run
|
5847 |
|
|
Starting program: /tmp/gdb-5.2/gdb/gdb
|
5848 |
|
|
|
5849 |
|
|
Breakpoint 1, main (argc=1, argv=0xbffff8b4) at main.c:734
|
5850 |
|
|
734 catch_errors (captured_main, &args, "", RETURN_MASK_ALL);
|
5851 |
|
|
(gdb) print args
|
5852 |
|
|
$1 = {argc = 136426532, argv = 0x821b7f0}
|
5853 |
|
|
(gdb)
|
5854 |
|
|
|
5855 |
|
|
18.6.3 Make a release candidate available
|
5856 |
|
|
-----------------------------------------
|
5857 |
|
|
|
5858 |
|
|
If this is a release candidate then the only remaining steps are:
|
5859 |
|
|
|
5860 |
|
|
1. Commit `version.in' and `ChangeLog'
|
5861 |
|
|
|
5862 |
|
|
2. Tweak `version.in' (and `ChangeLog' to read L.M.N-0000-00-00-cvs
|
5863 |
|
|
so that the version update process can restart.
|
5864 |
|
|
|
5865 |
|
|
3. Make the release candidate available in
|
5866 |
|
|
`ftp://sources.redhat.com/pub/gdb/snapshots/branch'
|
5867 |
|
|
|
5868 |
|
|
4. Notify the relevant mailing lists ( and
|
5869 |
|
|
that the candidate is available.
|
5870 |
|
|
|
5871 |
|
|
18.6.4 Make a formal release available
|
5872 |
|
|
--------------------------------------
|
5873 |
|
|
|
5874 |
|
|
(And you thought all that was required was to post an e-mail.)
|
5875 |
|
|
|
5876 |
|
|
Install on sware
|
5877 |
|
|
................
|
5878 |
|
|
|
5879 |
|
|
Copy the new files to both the release and the old release directory:
|
5880 |
|
|
|
5881 |
|
|
$ cp *.bz2 *.gz ~ftp/pub/gdb/old-releases/
|
5882 |
|
|
$ cp *.bz2 *.gz ~ftp/pub/gdb/releases
|
5883 |
|
|
|
5884 |
|
|
Clean up the releases directory so that only the most recent releases
|
5885 |
|
|
are available (e.g. keep 5.2 and 5.2.1 but remove 5.1):
|
5886 |
|
|
|
5887 |
|
|
$ cd ~ftp/pub/gdb/releases
|
5888 |
|
|
$ rm ...
|
5889 |
|
|
|
5890 |
|
|
Update the file `README' and `.message' in the releases directory:
|
5891 |
|
|
|
5892 |
|
|
$ vi README
|
5893 |
|
|
...
|
5894 |
|
|
$ rm -f .message
|
5895 |
|
|
$ ln README .message
|
5896 |
|
|
|
5897 |
|
|
Update the web pages.
|
5898 |
|
|
.....................
|
5899 |
|
|
|
5900 |
|
|
`htdocs/download/ANNOUNCEMENT'
|
5901 |
|
|
This file, which is posted as the official announcement, includes:
|
5902 |
|
|
* General announcement.
|
5903 |
|
|
|
5904 |
|
|
* News. If making an M.N.1 release, retain the news from
|
5905 |
|
|
earlier M.N release.
|
5906 |
|
|
|
5907 |
|
|
* Errata.
|
5908 |
|
|
|
5909 |
|
|
`htdocs/index.html'
|
5910 |
|
|
`htdocs/news/index.html'
|
5911 |
|
|
`htdocs/download/index.html'
|
5912 |
|
|
These files include:
|
5913 |
|
|
* Announcement of the most recent release.
|
5914 |
|
|
|
5915 |
|
|
* News entry (remember to update both the top level and the
|
5916 |
|
|
news directory).
|
5917 |
|
|
These pages also need to be regenerate using `index.sh'.
|
5918 |
|
|
|
5919 |
|
|
`download/onlinedocs/'
|
5920 |
|
|
You need to find the magic command that is used to generate the
|
5921 |
|
|
online docs from the `.tar.bz2'. The best way is to look in the
|
5922 |
|
|
output from one of the nightly `cron' jobs and then just edit
|
5923 |
|
|
accordingly. Something like:
|
5924 |
|
|
|
5925 |
|
|
$ ~/ss/update-web-docs \
|
5926 |
|
|
~ftp/pub/gdb/releases/gdb-5.2.tar.bz2 \
|
5927 |
|
|
$PWD/www \
|
5928 |
|
|
/www/sourceware/htdocs/gdb/download/onlinedocs \
|
5929 |
|
|
gdb
|
5930 |
|
|
|
5931 |
|
|
`download/ari/'
|
5932 |
|
|
Just like the online documentation. Something like:
|
5933 |
|
|
|
5934 |
|
|
$ /bin/sh ~/ss/update-web-ari \
|
5935 |
|
|
~ftp/pub/gdb/releases/gdb-5.2.tar.bz2 \
|
5936 |
|
|
$PWD/www \
|
5937 |
|
|
/www/sourceware/htdocs/gdb/download/ari \
|
5938 |
|
|
gdb
|
5939 |
|
|
|
5940 |
|
|
|
5941 |
|
|
Shadow the pages onto gnu
|
5942 |
|
|
.........................
|
5943 |
|
|
|
5944 |
|
|
Something goes here.
|
5945 |
|
|
|
5946 |
|
|
Install the GDB tar ball on GNU
|
5947 |
|
|
...............................
|
5948 |
|
|
|
5949 |
|
|
At the time of writing, the GNU machine was `gnudist.gnu.org' in
|
5950 |
|
|
`~ftp/gnu/gdb'.
|
5951 |
|
|
|
5952 |
|
|
Make the `ANNOUNCEMENT'
|
5953 |
|
|
.......................
|
5954 |
|
|
|
5955 |
|
|
Post the `ANNOUNCEMENT' file you created above to:
|
5956 |
|
|
|
5957 |
|
|
* GDB Announcement mailing list
|
5958 |
|
|
|
5959 |
|
|
* General GNU Announcement list (but delay it a
|
5960 |
|
|
day or so to let things get out)
|
5961 |
|
|
|
5962 |
|
|
* GDB Bug Report mailing list
|
5963 |
|
|
|
5964 |
|
|
18.6.5 Cleanup
|
5965 |
|
|
--------------
|
5966 |
|
|
|
5967 |
|
|
The release is out but you're still not finished.
|
5968 |
|
|
|
5969 |
|
|
Commit outstanding changes
|
5970 |
|
|
..........................
|
5971 |
|
|
|
5972 |
|
|
In particular you'll need to commit any changes to:
|
5973 |
|
|
|
5974 |
|
|
* `gdb/ChangeLog'
|
5975 |
|
|
|
5976 |
|
|
* `gdb/version.in'
|
5977 |
|
|
|
5978 |
|
|
* `gdb/NEWS'
|
5979 |
|
|
|
5980 |
|
|
* `gdb/README'
|
5981 |
|
|
|
5982 |
|
|
Tag the release
|
5983 |
|
|
...............
|
5984 |
|
|
|
5985 |
|
|
Something like:
|
5986 |
|
|
|
5987 |
|
|
$ d=`date -u +%Y-%m-%d`
|
5988 |
|
|
$ echo $d
|
5989 |
|
|
2002-01-24
|
5990 |
|
|
$ ( cd insight/src/gdb && cvs -f -q update )
|
5991 |
|
|
$ ( cd insight/src && cvs -f -q tag gdb_5_2-$d-release )
|
5992 |
|
|
|
5993 |
|
|
Insight is used since that contains more of the release than GDB.
|
5994 |
|
|
|
5995 |
|
|
Mention the release on the trunk
|
5996 |
|
|
................................
|
5997 |
|
|
|
5998 |
|
|
Just put something in the `ChangeLog' so that the trunk also indicates
|
5999 |
|
|
when the release was made.
|
6000 |
|
|
|
6001 |
|
|
Restart `gdb/version.in'
|
6002 |
|
|
........................
|
6003 |
|
|
|
6004 |
|
|
If `gdb/version.in' does not contain an ISO date such as `2002-01-24'
|
6005 |
|
|
then the daily `cronjob' won't update it. Having committed all the
|
6006 |
|
|
release changes it can be set to `5.2.0_0000-00-00-cvs' which will
|
6007 |
|
|
restart things (yes the `_' is important - it affects the snapshot
|
6008 |
|
|
process).
|
6009 |
|
|
|
6010 |
|
|
Don't forget the `ChangeLog'.
|
6011 |
|
|
|
6012 |
|
|
Merge into trunk
|
6013 |
|
|
................
|
6014 |
|
|
|
6015 |
|
|
The files committed to the branch may also need changes merged into the
|
6016 |
|
|
trunk.
|
6017 |
|
|
|
6018 |
|
|
Revise the release schedule
|
6019 |
|
|
...........................
|
6020 |
|
|
|
6021 |
|
|
Post a revised release schedule to GDB Discussion List
|
6022 |
|
|
with an updated announcement. The schedule
|
6023 |
|
|
can be generated by running:
|
6024 |
|
|
|
6025 |
|
|
$ ~/ss/schedule `date +%s` schedule
|
6026 |
|
|
|
6027 |
|
|
The first parameter is approximate date/time in seconds (from the epoch)
|
6028 |
|
|
of the most recent release.
|
6029 |
|
|
|
6030 |
|
|
Also update the schedule `cronjob'.
|
6031 |
|
|
|
6032 |
|
|
18.7 Post release
|
6033 |
|
|
=================
|
6034 |
|
|
|
6035 |
|
|
Remove any `OBSOLETE' code.
|
6036 |
|
|
|
6037 |
|
|
|
6038 |
|
|
File: gdbint.info, Node: Testsuite, Next: Hints, Prev: Releasing GDB, Up: Top
|
6039 |
|
|
|
6040 |
|
|
19 Testsuite
|
6041 |
|
|
************
|
6042 |
|
|
|
6043 |
|
|
The testsuite is an important component of the GDB package. While it
|
6044 |
|
|
is always worthwhile to encourage user testing, in practice this is
|
6045 |
|
|
rarely sufficient; users typically use only a small subset of the
|
6046 |
|
|
available commands, and it has proven all too common for a change to
|
6047 |
|
|
cause a significant regression that went unnoticed for some time.
|
6048 |
|
|
|
6049 |
|
|
The GDB testsuite uses the DejaGNU testing framework. The tests
|
6050 |
|
|
themselves are calls to various `Tcl' procs; the framework runs all the
|
6051 |
|
|
procs and summarizes the passes and fails.
|
6052 |
|
|
|
6053 |
|
|
19.1 Using the Testsuite
|
6054 |
|
|
========================
|
6055 |
|
|
|
6056 |
|
|
To run the testsuite, simply go to the GDB object directory (or to the
|
6057 |
|
|
testsuite's objdir) and type `make check'. This just sets up some
|
6058 |
|
|
environment variables and invokes DejaGNU's `runtest' script. While
|
6059 |
|
|
the testsuite is running, you'll get mentions of which test file is in
|
6060 |
|
|
use, and a mention of any unexpected passes or fails. When the
|
6061 |
|
|
testsuite is finished, you'll get a summary that looks like this:
|
6062 |
|
|
|
6063 |
|
|
=== gdb Summary ===
|
6064 |
|
|
|
6065 |
|
|
# of expected passes 6016
|
6066 |
|
|
# of unexpected failures 58
|
6067 |
|
|
# of unexpected successes 5
|
6068 |
|
|
# of expected failures 183
|
6069 |
|
|
# of unresolved testcases 3
|
6070 |
|
|
# of untested testcases 5
|
6071 |
|
|
|
6072 |
|
|
To run a specific test script, type:
|
6073 |
|
|
make check RUNTESTFLAGS='TESTS'
|
6074 |
|
|
where TESTS is a list of test script file names, separated by spaces.
|
6075 |
|
|
|
6076 |
|
|
The ideal test run consists of expected passes only; however, reality
|
6077 |
|
|
conspires to keep us from this ideal. Unexpected failures indicate
|
6078 |
|
|
real problems, whether in GDB or in the testsuite. Expected failures
|
6079 |
|
|
are still failures, but ones which have been decided are too hard to
|
6080 |
|
|
deal with at the time; for instance, a test case might work everywhere
|
6081 |
|
|
except on AIX, and there is no prospect of the AIX case being fixed in
|
6082 |
|
|
the near future. Expected failures should not be added lightly, since
|
6083 |
|
|
you may be masking serious bugs in GDB. Unexpected successes are
|
6084 |
|
|
expected fails that are passing for some reason, while unresolved and
|
6085 |
|
|
untested cases often indicate some minor catastrophe, such as the
|
6086 |
|
|
compiler being unable to deal with a test program.
|
6087 |
|
|
|
6088 |
|
|
When making any significant change to GDB, you should run the
|
6089 |
|
|
testsuite before and after the change, to confirm that there are no
|
6090 |
|
|
regressions. Note that truly complete testing would require that you
|
6091 |
|
|
run the testsuite with all supported configurations and a variety of
|
6092 |
|
|
compilers; however this is more than really necessary. In many cases
|
6093 |
|
|
testing with a single configuration is sufficient. Other useful
|
6094 |
|
|
options are to test one big-endian (Sparc) and one little-endian (x86)
|
6095 |
|
|
host, a cross config with a builtin simulator (powerpc-eabi, mips-elf),
|
6096 |
|
|
or a 64-bit host (Alpha).
|
6097 |
|
|
|
6098 |
|
|
If you add new functionality to GDB, please consider adding tests
|
6099 |
|
|
for it as well; this way future GDB hackers can detect and fix their
|
6100 |
|
|
changes that break the functionality you added. Similarly, if you fix
|
6101 |
|
|
a bug that was not previously reported as a test failure, please add a
|
6102 |
|
|
test case for it. Some cases are extremely difficult to test, such as
|
6103 |
|
|
code that handles host OS failures or bugs in particular versions of
|
6104 |
|
|
compilers, and it's OK not to try to write tests for all of those.
|
6105 |
|
|
|
6106 |
|
|
DejaGNU supports separate build, host, and target machines. However,
|
6107 |
|
|
some GDB test scripts do not work if the build machine and the host
|
6108 |
|
|
machine are not the same. In such an environment, these scripts will
|
6109 |
|
|
give a result of "UNRESOLVED", like this:
|
6110 |
|
|
|
6111 |
|
|
UNRESOLVED: gdb.base/example.exp: This test script does not work on a remote host.
|
6112 |
|
|
|
6113 |
|
|
19.2 Testsuite Organization
|
6114 |
|
|
===========================
|
6115 |
|
|
|
6116 |
|
|
The testsuite is entirely contained in `gdb/testsuite'. While the
|
6117 |
|
|
testsuite includes some makefiles and configury, these are very minimal,
|
6118 |
|
|
and used for little besides cleaning up, since the tests themselves
|
6119 |
|
|
handle the compilation of the programs that GDB will run. The file
|
6120 |
|
|
`testsuite/lib/gdb.exp' contains common utility procs useful for all
|
6121 |
|
|
GDB tests, while the directory `testsuite/config' contains
|
6122 |
|
|
configuration-specific files, typically used for special-purpose
|
6123 |
|
|
definitions of procs like `gdb_load' and `gdb_start'.
|
6124 |
|
|
|
6125 |
|
|
The tests themselves are to be found in `testsuite/gdb.*' and
|
6126 |
|
|
subdirectories of those. The names of the test files must always end
|
6127 |
|
|
with `.exp'. DejaGNU collects the test files by wildcarding in the
|
6128 |
|
|
test directories, so both subdirectories and individual files get
|
6129 |
|
|
chosen and run in alphabetical order.
|
6130 |
|
|
|
6131 |
|
|
The following table lists the main types of subdirectories and what
|
6132 |
|
|
they are for. Since DejaGNU finds test files no matter where they are
|
6133 |
|
|
located, and since each test file sets up its own compilation and
|
6134 |
|
|
execution environment, this organization is simply for convenience and
|
6135 |
|
|
intelligibility.
|
6136 |
|
|
|
6137 |
|
|
`gdb.base'
|
6138 |
|
|
This is the base testsuite. The tests in it should apply to all
|
6139 |
|
|
configurations of GDB (but generic native-only tests may live
|
6140 |
|
|
here). The test programs should be in the subset of C that is
|
6141 |
|
|
valid K&R, ANSI/ISO, and C++ (`#ifdef's are allowed if necessary,
|
6142 |
|
|
for instance for prototypes).
|
6143 |
|
|
|
6144 |
|
|
`gdb.LANG'
|
6145 |
|
|
Language-specific tests for any language LANG besides C. Examples
|
6146 |
|
|
are `gdb.cp' and `gdb.java'.
|
6147 |
|
|
|
6148 |
|
|
`gdb.PLATFORM'
|
6149 |
|
|
Non-portable tests. The tests are specific to a specific
|
6150 |
|
|
configuration (host or target), such as HP-UX or eCos. Example is
|
6151 |
|
|
`gdb.hp', for HP-UX.
|
6152 |
|
|
|
6153 |
|
|
`gdb.COMPILER'
|
6154 |
|
|
Tests specific to a particular compiler. As of this writing (June
|
6155 |
|
|
1999), there aren't currently any groups of tests in this category
|
6156 |
|
|
that couldn't just as sensibly be made platform-specific, but one
|
6157 |
|
|
could imagine a `gdb.gcc', for tests of GDB's handling of GCC
|
6158 |
|
|
extensions.
|
6159 |
|
|
|
6160 |
|
|
`gdb.SUBSYSTEM'
|
6161 |
|
|
Tests that exercise a specific GDB subsystem in more depth. For
|
6162 |
|
|
instance, `gdb.disasm' exercises various disassemblers, while
|
6163 |
|
|
`gdb.stabs' tests pathways through the stabs symbol reader.
|
6164 |
|
|
|
6165 |
|
|
19.3 Writing Tests
|
6166 |
|
|
==================
|
6167 |
|
|
|
6168 |
|
|
In many areas, the GDB tests are already quite comprehensive; you
|
6169 |
|
|
should be able to copy existing tests to handle new cases.
|
6170 |
|
|
|
6171 |
|
|
You should try to use `gdb_test' whenever possible, since it
|
6172 |
|
|
includes cases to handle all the unexpected errors that might happen.
|
6173 |
|
|
However, it doesn't cost anything to add new test procedures; for
|
6174 |
|
|
instance, `gdb.base/exprs.exp' defines a `test_expr' that calls
|
6175 |
|
|
`gdb_test' multiple times.
|
6176 |
|
|
|
6177 |
|
|
Only use `send_gdb' and `gdb_expect' when absolutely necessary.
|
6178 |
|
|
Even if GDB has several valid responses to a command, you can use
|
6179 |
|
|
`gdb_test_multiple'. Like `gdb_test', `gdb_test_multiple' recognizes
|
6180 |
|
|
internal errors and unexpected prompts.
|
6181 |
|
|
|
6182 |
|
|
Do not write tests which expect a literal tab character from GDB.
|
6183 |
|
|
On some operating systems (e.g. OpenBSD) the TTY layer expands tabs to
|
6184 |
|
|
spaces, so by the time GDB's output reaches expect the tab is gone.
|
6185 |
|
|
|
6186 |
|
|
The source language programs do _not_ need to be in a consistent
|
6187 |
|
|
style. Since GDB is used to debug programs written in many different
|
6188 |
|
|
styles, it's worth having a mix of styles in the testsuite; for
|
6189 |
|
|
instance, some GDB bugs involving the display of source lines would
|
6190 |
|
|
never manifest themselves if the programs used GNU coding style
|
6191 |
|
|
uniformly.
|
6192 |
|
|
|
6193 |
|
|
|
6194 |
|
|
File: gdbint.info, Node: Hints, Next: GDB Observers, Prev: Testsuite, Up: Top
|
6195 |
|
|
|
6196 |
|
|
20 Hints
|
6197 |
|
|
********
|
6198 |
|
|
|
6199 |
|
|
Check the `README' file, it often has useful information that does not
|
6200 |
|
|
appear anywhere else in the directory.
|
6201 |
|
|
|
6202 |
|
|
* Menu:
|
6203 |
|
|
|
6204 |
|
|
* Getting Started:: Getting started working on GDB
|
6205 |
|
|
* Debugging GDB:: Debugging GDB with itself
|
6206 |
|
|
|
6207 |
|
|
|
6208 |
|
|
File: gdbint.info, Node: Getting Started, Up: Hints
|
6209 |
|
|
|
6210 |
|
|
20.1 Getting Started
|
6211 |
|
|
====================
|
6212 |
|
|
|
6213 |
|
|
GDB is a large and complicated program, and if you first starting to
|
6214 |
|
|
work on it, it can be hard to know where to start. Fortunately, if you
|
6215 |
|
|
know how to go about it, there are ways to figure out what is going on.
|
6216 |
|
|
|
6217 |
|
|
This manual, the GDB Internals manual, has information which applies
|
6218 |
|
|
generally to many parts of GDB.
|
6219 |
|
|
|
6220 |
|
|
Information about particular functions or data structures are
|
6221 |
|
|
located in comments with those functions or data structures. If you
|
6222 |
|
|
run across a function or a global variable which does not have a
|
6223 |
|
|
comment correctly explaining what is does, this can be thought of as a
|
6224 |
|
|
bug in GDB; feel free to submit a bug report, with a suggested comment
|
6225 |
|
|
if you can figure out what the comment should say. If you find a
|
6226 |
|
|
comment which is actually wrong, be especially sure to report that.
|
6227 |
|
|
|
6228 |
|
|
Comments explaining the function of macros defined in host, target,
|
6229 |
|
|
or native dependent files can be in several places. Sometimes they are
|
6230 |
|
|
repeated every place the macro is defined. Sometimes they are where the
|
6231 |
|
|
macro is used. Sometimes there is a header file which supplies a
|
6232 |
|
|
default definition of the macro, and the comment is there. This manual
|
6233 |
|
|
also documents all the available macros.
|
6234 |
|
|
|
6235 |
|
|
Start with the header files. Once you have some idea of how GDB's
|
6236 |
|
|
internal symbol tables are stored (see `symtab.h', `gdbtypes.h'), you
|
6237 |
|
|
will find it much easier to understand the code which uses and creates
|
6238 |
|
|
those symbol tables.
|
6239 |
|
|
|
6240 |
|
|
You may wish to process the information you are getting somehow, to
|
6241 |
|
|
enhance your understanding of it. Summarize it, translate it to another
|
6242 |
|
|
language, add some (perhaps trivial or non-useful) feature to GDB, use
|
6243 |
|
|
the code to predict what a test case would do and write the test case
|
6244 |
|
|
and verify your prediction, etc. If you are reading code and your eyes
|
6245 |
|
|
are starting to glaze over, this is a sign you need to use a more active
|
6246 |
|
|
approach.
|
6247 |
|
|
|
6248 |
|
|
Once you have a part of GDB to start with, you can find more
|
6249 |
|
|
specifically the part you are looking for by stepping through each
|
6250 |
|
|
function with the `next' command. Do not use `step' or you will
|
6251 |
|
|
quickly get distracted; when the function you are stepping through
|
6252 |
|
|
calls another function try only to get a big-picture understanding
|
6253 |
|
|
(perhaps using the comment at the beginning of the function being
|
6254 |
|
|
called) of what it does. This way you can identify which of the
|
6255 |
|
|
functions being called by the function you are stepping through is the
|
6256 |
|
|
one which you are interested in. You may need to examine the data
|
6257 |
|
|
structures generated at each stage, with reference to the comments in
|
6258 |
|
|
the header files explaining what the data structures are supposed to
|
6259 |
|
|
look like.
|
6260 |
|
|
|
6261 |
|
|
Of course, this same technique can be used if you are just reading
|
6262 |
|
|
the code, rather than actually stepping through it. The same general
|
6263 |
|
|
principle applies--when the code you are looking at calls something
|
6264 |
|
|
else, just try to understand generally what the code being called does,
|
6265 |
|
|
rather than worrying about all its details.
|
6266 |
|
|
|
6267 |
|
|
A good place to start when tracking down some particular area is with
|
6268 |
|
|
a command which invokes that feature. Suppose you want to know how
|
6269 |
|
|
single-stepping works. As a GDB user, you know that the `step' command
|
6270 |
|
|
invokes single-stepping. The command is invoked via command tables
|
6271 |
|
|
(see `command.h'); by convention the function which actually performs
|
6272 |
|
|
the command is formed by taking the name of the command and adding
|
6273 |
|
|
`_command', or in the case of an `info' subcommand, `_info'. For
|
6274 |
|
|
example, the `step' command invokes the `step_command' function and the
|
6275 |
|
|
`info display' command invokes `display_info'. When this convention is
|
6276 |
|
|
not followed, you might have to use `grep' or `M-x tags-search' in
|
6277 |
|
|
emacs, or run GDB on itself and set a breakpoint in `execute_command'.
|
6278 |
|
|
|
6279 |
|
|
If all of the above fail, it may be appropriate to ask for
|
6280 |
|
|
information on `bug-gdb'. But _never_ post a generic question like "I
|
6281 |
|
|
was wondering if anyone could give me some tips about understanding
|
6282 |
|
|
GDB"--if we had some magic secret we would put it in this manual.
|
6283 |
|
|
Suggestions for improving the manual are always welcome, of course.
|
6284 |
|
|
|
6285 |
|
|
|
6286 |
|
|
File: gdbint.info, Node: Debugging GDB, Up: Hints
|
6287 |
|
|
|
6288 |
|
|
20.2 Debugging GDB with itself
|
6289 |
|
|
==============================
|
6290 |
|
|
|
6291 |
|
|
If GDB is limping on your machine, this is the preferred way to get it
|
6292 |
|
|
fully functional. Be warned that in some ancient Unix systems, like
|
6293 |
|
|
Ultrix 4.2, a program can't be running in one process while it is being
|
6294 |
|
|
debugged in another. Rather than typing the command `./gdb ./gdb',
|
6295 |
|
|
which works on Suns and such, you can copy `gdb' to `gdb2' and then
|
6296 |
|
|
type `./gdb ./gdb2'.
|
6297 |
|
|
|
6298 |
|
|
When you run GDB in the GDB source directory, it will read a
|
6299 |
|
|
`.gdbinit' file that sets up some simple things to make debugging gdb
|
6300 |
|
|
easier. The `info' command, when executed without a subcommand in a
|
6301 |
|
|
GDB being debugged by gdb, will pop you back up to the top level gdb.
|
6302 |
|
|
See `.gdbinit' for details.
|
6303 |
|
|
|
6304 |
|
|
If you use emacs, you will probably want to do a `make TAGS' after
|
6305 |
|
|
you configure your distribution; this will put the machine dependent
|
6306 |
|
|
routines for your local machine where they will be accessed first by
|
6307 |
|
|
`M-.'
|
6308 |
|
|
|
6309 |
|
|
Also, make sure that you've either compiled GDB with your local cc,
|
6310 |
|
|
or have run `fixincludes' if you are compiling with gcc.
|
6311 |
|
|
|
6312 |
|
|
20.3 Submitting Patches
|
6313 |
|
|
=======================
|
6314 |
|
|
|
6315 |
|
|
Thanks for thinking of offering your changes back to the community of
|
6316 |
|
|
GDB users. In general we like to get well designed enhancements.
|
6317 |
|
|
Thanks also for checking in advance about the best way to transfer the
|
6318 |
|
|
changes.
|
6319 |
|
|
|
6320 |
|
|
The GDB maintainers will only install "cleanly designed" patches.
|
6321 |
|
|
This manual summarizes what we believe to be clean design for GDB.
|
6322 |
|
|
|
6323 |
|
|
If the maintainers don't have time to put the patch in when it
|
6324 |
|
|
arrives, or if there is any question about a patch, it goes into a
|
6325 |
|
|
large queue with everyone else's patches and bug reports.
|
6326 |
|
|
|
6327 |
|
|
The legal issue is that to incorporate substantial changes requires a
|
6328 |
|
|
copyright assignment from you and/or your employer, granting ownership
|
6329 |
|
|
of the changes to the Free Software Foundation. You can get the
|
6330 |
|
|
standard documents for doing this by sending mail to `gnu@gnu.org' and
|
6331 |
|
|
asking for it. We recommend that people write in "All programs owned
|
6332 |
|
|
by the Free Software Foundation" as "NAME OF PROGRAM", so that changes
|
6333 |
|
|
in many programs (not just GDB, but GAS, Emacs, GCC, etc) can be
|
6334 |
|
|
contributed with only one piece of legalese pushed through the
|
6335 |
|
|
bureaucracy and filed with the FSF. We can't start merging changes
|
6336 |
|
|
until this paperwork is received by the FSF (their rules, which we
|
6337 |
|
|
follow since we maintain it for them).
|
6338 |
|
|
|
6339 |
|
|
Technically, the easiest way to receive changes is to receive each
|
6340 |
|
|
feature as a small context diff or unidiff, suitable for `patch'. Each
|
6341 |
|
|
message sent to me should include the changes to C code and header
|
6342 |
|
|
files for a single feature, plus `ChangeLog' entries for each directory
|
6343 |
|
|
where files were modified, and diffs for any changes needed to the
|
6344 |
|
|
manuals (`gdb/doc/gdb.texinfo' or `gdb/doc/gdbint.texinfo'). If there
|
6345 |
|
|
are a lot of changes for a single feature, they can be split down into
|
6346 |
|
|
multiple messages.
|
6347 |
|
|
|
6348 |
|
|
In this way, if we read and like the feature, we can add it to the
|
6349 |
|
|
sources with a single patch command, do some testing, and check it in.
|
6350 |
|
|
If you leave out the `ChangeLog', we have to write one. If you leave
|
6351 |
|
|
out the doc, we have to puzzle out what needs documenting. Etc., etc.
|
6352 |
|
|
|
6353 |
|
|
The reason to send each change in a separate message is that we will
|
6354 |
|
|
not install some of the changes. They'll be returned to you with
|
6355 |
|
|
questions or comments. If we're doing our job correctly, the message
|
6356 |
|
|
back to you will say what you have to fix in order to make the change
|
6357 |
|
|
acceptable. The reason to have separate messages for separate features
|
6358 |
|
|
is so that the acceptable changes can be installed while one or more
|
6359 |
|
|
changes are being reworked. If multiple features are sent in a single
|
6360 |
|
|
message, we tend to not put in the effort to sort out the acceptable
|
6361 |
|
|
changes from the unacceptable, so none of the features get installed
|
6362 |
|
|
until all are acceptable.
|
6363 |
|
|
|
6364 |
|
|
If this sounds painful or authoritarian, well, it is. But we get a
|
6365 |
|
|
lot of bug reports and a lot of patches, and many of them don't get
|
6366 |
|
|
installed because we don't have the time to finish the job that the bug
|
6367 |
|
|
reporter or the contributor could have done. Patches that arrive
|
6368 |
|
|
complete, working, and well designed, tend to get installed on the day
|
6369 |
|
|
they arrive. The others go into a queue and get installed as time
|
6370 |
|
|
permits, which, since the maintainers have many demands to meet, may not
|
6371 |
|
|
be for quite some time.
|
6372 |
|
|
|
6373 |
|
|
Please send patches directly to the GDB maintainers
|
6374 |
|
|
.
|
6375 |
|
|
|
6376 |
|
|
20.4 Obsolete Conditionals
|
6377 |
|
|
==========================
|
6378 |
|
|
|
6379 |
|
|
Fragments of old code in GDB sometimes reference or set the following
|
6380 |
|
|
configuration macros. They should not be used by new code, and old uses
|
6381 |
|
|
should be removed as those parts of the debugger are otherwise touched.
|
6382 |
|
|
|
6383 |
|
|
`STACK_END_ADDR'
|
6384 |
|
|
This macro used to define where the end of the stack appeared, for
|
6385 |
|
|
use in interpreting core file formats that don't record this
|
6386 |
|
|
address in the core file itself. This information is now
|
6387 |
|
|
configured in BFD, and GDB gets the info portably from there. The
|
6388 |
|
|
values in GDB's configuration files should be moved into BFD
|
6389 |
|
|
configuration files (if needed there), and deleted from all of
|
6390 |
|
|
GDB's config files.
|
6391 |
|
|
|
6392 |
|
|
Any `FOO-xdep.c' file that references STACK_END_ADDR is so old
|
6393 |
|
|
that it has never been converted to use BFD. Now that's old!
|
6394 |
|
|
|
6395 |
|
|
|
6396 |
|
|
20.5 Build Script
|
6397 |
|
|
=================
|
6398 |
|
|
|
6399 |
|
|
The script `gdb_buildall.sh' builds GDB with flag
|
6400 |
|
|
`--enable-targets=all' set. This builds GDB with all supported targets
|
6401 |
|
|
activated. This helps testing GDB when doing changes that affect more
|
6402 |
|
|
than one architecture and is much faster than using `gdb_mbuild.sh'.
|
6403 |
|
|
|
6404 |
|
|
After building GDB the script checks which architectures are
|
6405 |
|
|
supported and then switches the current architecture to each of those
|
6406 |
|
|
to get information about the architecture. The test results are stored
|
6407 |
|
|
in log files in the directory the script was called from.
|
6408 |
|
|
|
6409 |
|
|
|
6410 |
|
|
File: gdbint.info, Node: GDB Observers, Next: GNU Free Documentation License, Prev: Hints, Up: Top
|
6411 |
|
|
|
6412 |
|
|
Appendix A GDB Currently available observers
|
6413 |
|
|
********************************************
|
6414 |
|
|
|
6415 |
|
|
A.1 Implementation rationale
|
6416 |
|
|
============================
|
6417 |
|
|
|
6418 |
|
|
An "observer" is an entity which is interested in being notified when
|
6419 |
|
|
GDB reaches certain states, or certain events occur in GDB. The entity
|
6420 |
|
|
being observed is called the "subject". To receive notifications, the
|
6421 |
|
|
observer attaches a callback to the subject. One subject can have
|
6422 |
|
|
several observers.
|
6423 |
|
|
|
6424 |
|
|
`observer.c' implements an internal generic low-level event
|
6425 |
|
|
notification mechanism. This generic event notification mechanism is
|
6426 |
|
|
then re-used to implement the exported high-level notification
|
6427 |
|
|
management routines for all possible notifications.
|
6428 |
|
|
|
6429 |
|
|
The current implementation of the generic observer provides support
|
6430 |
|
|
for contextual data. This contextual data is given to the subject when
|
6431 |
|
|
attaching the callback. In return, the subject will provide this
|
6432 |
|
|
contextual data back to the observer as a parameter of the callback.
|
6433 |
|
|
|
6434 |
|
|
Note that the current support for the contextual data is only
|
6435 |
|
|
partial, as it lacks a mechanism that would deallocate this data when
|
6436 |
|
|
the callback is detached. This is not a problem so far, as this
|
6437 |
|
|
contextual data is only used internally to hold a function pointer.
|
6438 |
|
|
Later on, if a certain observer needs to provide support for user-level
|
6439 |
|
|
contextual data, then the generic notification mechanism will need to be
|
6440 |
|
|
enhanced to allow the observer to provide a routine to deallocate the
|
6441 |
|
|
data when attaching the callback.
|
6442 |
|
|
|
6443 |
|
|
The observer implementation is also currently not reentrant. In
|
6444 |
|
|
particular, it is therefore not possible to call the attach or detach
|
6445 |
|
|
routines during a notification.
|
6446 |
|
|
|
6447 |
|
|
A.2 Debugging
|
6448 |
|
|
=============
|
6449 |
|
|
|
6450 |
|
|
Observer notifications can be traced using the command `set debug
|
6451 |
|
|
observer 1' (*note Optional messages about internal happenings:
|
6452 |
|
|
(gdb)Debugging Output.).
|
6453 |
|
|
|
6454 |
|
|
A.3 `normal_stop' Notifications
|
6455 |
|
|
===============================
|
6456 |
|
|
|
6457 |
|
|
GDB notifies all `normal_stop' observers when the inferior execution
|
6458 |
|
|
has just stopped, the associated messages and annotations have been
|
6459 |
|
|
printed, and the control is about to be returned to the user.
|
6460 |
|
|
|
6461 |
|
|
Note that the `normal_stop' notification is not emitted when the
|
6462 |
|
|
execution stops due to a breakpoint, and this breakpoint has a
|
6463 |
|
|
condition that is not met. If the breakpoint has any associated
|
6464 |
|
|
commands list, the commands are executed after the notification is
|
6465 |
|
|
emitted.
|
6466 |
|
|
|
6467 |
|
|
The following interfaces are available to manage observers:
|
6468 |
|
|
|
6469 |
|
|
-- Function: extern struct observer *observer_attach_EVENT
|
6470 |
|
|
(observer_EVENT_ftype *F)
|
6471 |
|
|
Using the function F, create an observer that is notified when
|
6472 |
|
|
ever EVENT occurs, return the observer.
|
6473 |
|
|
|
6474 |
|
|
-- Function: extern void observer_detach_EVENT (struct observer
|
6475 |
|
|
*OBSERVER);
|
6476 |
|
|
Remove OBSERVER from the list of observers to be notified when
|
6477 |
|
|
EVENT occurs.
|
6478 |
|
|
|
6479 |
|
|
-- Function: extern void observer_notify_EVENT (void);
|
6480 |
|
|
Send a notification to all EVENT observers.
|
6481 |
|
|
|
6482 |
|
|
The following observable events are defined:
|
6483 |
|
|
|
6484 |
|
|
-- Function: void normal_stop (struct bpstats *BS)
|
6485 |
|
|
The inferior has stopped for real.
|
6486 |
|
|
|
6487 |
|
|
-- Function: void target_changed (struct target_ops *TARGET)
|
6488 |
|
|
The target's register contents have changed.
|
6489 |
|
|
|
6490 |
|
|
-- Function: void executable_changed (void *UNUSED_ARGS)
|
6491 |
|
|
The executable being debugged by GDB has changed: The user decided
|
6492 |
|
|
to debug a different program, or the program he was debugging has
|
6493 |
|
|
been modified since being loaded by the debugger (by being
|
6494 |
|
|
recompiled, for instance).
|
6495 |
|
|
|
6496 |
|
|
-- Function: void inferior_created (struct target_ops *OBJFILE, int
|
6497 |
|
|
FROM_TTY)
|
6498 |
|
|
GDB has just connected to an inferior. For `run', GDB calls this
|
6499 |
|
|
observer while the inferior is still stopped at the entry-point
|
6500 |
|
|
instruction. For `attach' and `core', GDB calls this observer
|
6501 |
|
|
immediately after connecting to the inferior, and before any
|
6502 |
|
|
information on the inferior has been printed.
|
6503 |
|
|
|
6504 |
|
|
-- Function: void solib_loaded (struct so_list *SOLIB)
|
6505 |
|
|
The shared library specified by SOLIB has been loaded. Note that
|
6506 |
|
|
when GDB calls this observer, the library's symbols probably
|
6507 |
|
|
haven't been loaded yet.
|
6508 |
|
|
|
6509 |
|
|
-- Function: void solib_unloaded (struct so_list *SOLIB)
|
6510 |
|
|
The shared library specified by SOLIB has been unloaded.
|
6511 |
|
|
|
6512 |
|
|
-- Function: void new_objfile (struct objfile *OBJFILE)
|
6513 |
|
|
The symbol file specified by OBJFILE has been loaded. Called with
|
6514 |
|
|
OBJFILE equal to `NULL' to indicate previously loaded symbol table
|
6515 |
|
|
data has now been invalidated.
|
6516 |
|
|
|
6517 |
|
|
|
6518 |
|
|
File: gdbint.info, Node: GNU Free Documentation License, Next: Index, Prev: GDB Observers, Up: Top
|
6519 |
|
|
|
6520 |
|
|
Appendix B GNU Free Documentation License
|
6521 |
|
|
*****************************************
|
6522 |
|
|
|
6523 |
|
|
Version 1.2, November 2002
|
6524 |
|
|
|
6525 |
|
|
Copyright (C) 2000,2001,2002 Free Software Foundation, Inc.
|
6526 |
|
|
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
6527 |
|
|
|
6528 |
|
|
Everyone is permitted to copy and distribute verbatim copies
|
6529 |
|
|
of this license document, but changing it is not allowed.
|
6530 |
|
|
|
6531 |
|
|
0. PREAMBLE
|
6532 |
|
|
|
6533 |
|
|
The purpose of this License is to make a manual, textbook, or other
|
6534 |
|
|
functional and useful document "free" in the sense of freedom: to
|
6535 |
|
|
assure everyone the effective freedom to copy and redistribute it,
|
6536 |
|
|
with or without modifying it, either commercially or
|
6537 |
|
|
noncommercially. Secondarily, this License preserves for the
|
6538 |
|
|
author and publisher a way to get credit for their work, while not
|
6539 |
|
|
being considered responsible for modifications made by others.
|
6540 |
|
|
|
6541 |
|
|
This License is a kind of "copyleft", which means that derivative
|
6542 |
|
|
works of the document must themselves be free in the same sense.
|
6543 |
|
|
It complements the GNU General Public License, which is a copyleft
|
6544 |
|
|
license designed for free software.
|
6545 |
|
|
|
6546 |
|
|
We have designed this License in order to use it for manuals for
|
6547 |
|
|
free software, because free software needs free documentation: a
|
6548 |
|
|
free program should come with manuals providing the same freedoms
|
6549 |
|
|
that the software does. But this License is not limited to
|
6550 |
|
|
software manuals; it can be used for any textual work, regardless
|
6551 |
|
|
of subject matter or whether it is published as a printed book.
|
6552 |
|
|
We recommend this License principally for works whose purpose is
|
6553 |
|
|
instruction or reference.
|
6554 |
|
|
|
6555 |
|
|
1. APPLICABILITY AND DEFINITIONS
|
6556 |
|
|
|
6557 |
|
|
This License applies to any manual or other work, in any medium,
|
6558 |
|
|
that contains a notice placed by the copyright holder saying it
|
6559 |
|
|
can be distributed under the terms of this License. Such a notice
|
6560 |
|
|
grants a world-wide, royalty-free license, unlimited in duration,
|
6561 |
|
|
to use that work under the conditions stated herein. The
|
6562 |
|
|
"Document", below, refers to any such manual or work. Any member
|
6563 |
|
|
of the public is a licensee, and is addressed as "you". You
|
6564 |
|
|
accept the license if you copy, modify or distribute the work in a
|
6565 |
|
|
way requiring permission under copyright law.
|
6566 |
|
|
|
6567 |
|
|
A "Modified Version" of the Document means any work containing the
|
6568 |
|
|
Document or a portion of it, either copied verbatim, or with
|
6569 |
|
|
modifications and/or translated into another language.
|
6570 |
|
|
|
6571 |
|
|
A "Secondary Section" is a named appendix or a front-matter section
|
6572 |
|
|
of the Document that deals exclusively with the relationship of the
|
6573 |
|
|
publishers or authors of the Document to the Document's overall
|
6574 |
|
|
subject (or to related matters) and contains nothing that could
|
6575 |
|
|
fall directly within that overall subject. (Thus, if the Document
|
6576 |
|
|
is in part a textbook of mathematics, a Secondary Section may not
|
6577 |
|
|
explain any mathematics.) The relationship could be a matter of
|
6578 |
|
|
historical connection with the subject or with related matters, or
|
6579 |
|
|
of legal, commercial, philosophical, ethical or political position
|
6580 |
|
|
regarding them.
|
6581 |
|
|
|
6582 |
|
|
The "Invariant Sections" are certain Secondary Sections whose
|
6583 |
|
|
titles are designated, as being those of Invariant Sections, in
|
6584 |
|
|
the notice that says that the Document is released under this
|
6585 |
|
|
License. If a section does not fit the above definition of
|
6586 |
|
|
Secondary then it is not allowed to be designated as Invariant.
|
6587 |
|
|
The Document may contain zero Invariant Sections. If the Document
|
6588 |
|
|
does not identify any Invariant Sections then there are none.
|
6589 |
|
|
|
6590 |
|
|
The "Cover Texts" are certain short passages of text that are
|
6591 |
|
|
listed, as Front-Cover Texts or Back-Cover Texts, in the notice
|
6592 |
|
|
that says that the Document is released under this License. A
|
6593 |
|
|
Front-Cover Text may be at most 5 words, and a Back-Cover Text may
|
6594 |
|
|
be at most 25 words.
|
6595 |
|
|
|
6596 |
|
|
A "Transparent" copy of the Document means a machine-readable copy,
|
6597 |
|
|
represented in a format whose specification is available to the
|
6598 |
|
|
general public, that is suitable for revising the document
|
6599 |
|
|
straightforwardly with generic text editors or (for images
|
6600 |
|
|
composed of pixels) generic paint programs or (for drawings) some
|
6601 |
|
|
widely available drawing editor, and that is suitable for input to
|
6602 |
|
|
text formatters or for automatic translation to a variety of
|
6603 |
|
|
formats suitable for input to text formatters. A copy made in an
|
6604 |
|
|
otherwise Transparent file format whose markup, or absence of
|
6605 |
|
|
markup, has been arranged to thwart or discourage subsequent
|
6606 |
|
|
modification by readers is not Transparent. An image format is
|
6607 |
|
|
not Transparent if used for any substantial amount of text. A
|
6608 |
|
|
copy that is not "Transparent" is called "Opaque".
|
6609 |
|
|
|
6610 |
|
|
Examples of suitable formats for Transparent copies include plain
|
6611 |
|
|
ASCII without markup, Texinfo input format, LaTeX input format,
|
6612 |
|
|
SGML or XML using a publicly available DTD, and
|
6613 |
|
|
standard-conforming simple HTML, PostScript or PDF designed for
|
6614 |
|
|
human modification. Examples of transparent image formats include
|
6615 |
|
|
PNG, XCF and JPG. Opaque formats include proprietary formats that
|
6616 |
|
|
can be read and edited only by proprietary word processors, SGML or
|
6617 |
|
|
XML for which the DTD and/or processing tools are not generally
|
6618 |
|
|
available, and the machine-generated HTML, PostScript or PDF
|
6619 |
|
|
produced by some word processors for output purposes only.
|
6620 |
|
|
|
6621 |
|
|
The "Title Page" means, for a printed book, the title page itself,
|
6622 |
|
|
plus such following pages as are needed to hold, legibly, the
|
6623 |
|
|
material this License requires to appear in the title page. For
|
6624 |
|
|
works in formats which do not have any title page as such, "Title
|
6625 |
|
|
Page" means the text near the most prominent appearance of the
|
6626 |
|
|
work's title, preceding the beginning of the body of the text.
|
6627 |
|
|
|
6628 |
|
|
A section "Entitled XYZ" means a named subunit of the Document
|
6629 |
|
|
whose title either is precisely XYZ or contains XYZ in parentheses
|
6630 |
|
|
following text that translates XYZ in another language. (Here XYZ
|
6631 |
|
|
stands for a specific section name mentioned below, such as
|
6632 |
|
|
"Acknowledgements", "Dedications", "Endorsements", or "History".)
|
6633 |
|
|
To "Preserve the Title" of such a section when you modify the
|
6634 |
|
|
Document means that it remains a section "Entitled XYZ" according
|
6635 |
|
|
to this definition.
|
6636 |
|
|
|
6637 |
|
|
The Document may include Warranty Disclaimers next to the notice
|
6638 |
|
|
which states that this License applies to the Document. These
|
6639 |
|
|
Warranty Disclaimers are considered to be included by reference in
|
6640 |
|
|
this License, but only as regards disclaiming warranties: any other
|
6641 |
|
|
implication that these Warranty Disclaimers may have is void and
|
6642 |
|
|
has no effect on the meaning of this License.
|
6643 |
|
|
|
6644 |
|
|
2. VERBATIM COPYING
|
6645 |
|
|
|
6646 |
|
|
You may copy and distribute the Document in any medium, either
|
6647 |
|
|
commercially or noncommercially, provided that this License, the
|
6648 |
|
|
copyright notices, and the license notice saying this License
|
6649 |
|
|
applies to the Document are reproduced in all copies, and that you
|
6650 |
|
|
add no other conditions whatsoever to those of this License. You
|
6651 |
|
|
may not use technical measures to obstruct or control the reading
|
6652 |
|
|
or further copying of the copies you make or distribute. However,
|
6653 |
|
|
you may accept compensation in exchange for copies. If you
|
6654 |
|
|
distribute a large enough number of copies you must also follow
|
6655 |
|
|
the conditions in section 3.
|
6656 |
|
|
|
6657 |
|
|
You may also lend copies, under the same conditions stated above,
|
6658 |
|
|
and you may publicly display copies.
|
6659 |
|
|
|
6660 |
|
|
3. COPYING IN QUANTITY
|
6661 |
|
|
|
6662 |
|
|
If you publish printed copies (or copies in media that commonly
|
6663 |
|
|
have printed covers) of the Document, numbering more than 100, and
|
6664 |
|
|
the Document's license notice requires Cover Texts, you must
|
6665 |
|
|
enclose the copies in covers that carry, clearly and legibly, all
|
6666 |
|
|
these Cover Texts: Front-Cover Texts on the front cover, and
|
6667 |
|
|
Back-Cover Texts on the back cover. Both covers must also clearly
|
6668 |
|
|
and legibly identify you as the publisher of these copies. The
|
6669 |
|
|
front cover must present the full title with all words of the
|
6670 |
|
|
title equally prominent and visible. You may add other material
|
6671 |
|
|
on the covers in addition. Copying with changes limited to the
|
6672 |
|
|
covers, as long as they preserve the title of the Document and
|
6673 |
|
|
satisfy these conditions, can be treated as verbatim copying in
|
6674 |
|
|
other respects.
|
6675 |
|
|
|
6676 |
|
|
If the required texts for either cover are too voluminous to fit
|
6677 |
|
|
legibly, you should put the first ones listed (as many as fit
|
6678 |
|
|
reasonably) on the actual cover, and continue the rest onto
|
6679 |
|
|
adjacent pages.
|
6680 |
|
|
|
6681 |
|
|
If you publish or distribute Opaque copies of the Document
|
6682 |
|
|
numbering more than 100, you must either include a
|
6683 |
|
|
machine-readable Transparent copy along with each Opaque copy, or
|
6684 |
|
|
state in or with each Opaque copy a computer-network location from
|
6685 |
|
|
which the general network-using public has access to download
|
6686 |
|
|
using public-standard network protocols a complete Transparent
|
6687 |
|
|
copy of the Document, free of added material. If you use the
|
6688 |
|
|
latter option, you must take reasonably prudent steps, when you
|
6689 |
|
|
begin distribution of Opaque copies in quantity, to ensure that
|
6690 |
|
|
this Transparent copy will remain thus accessible at the stated
|
6691 |
|
|
location until at least one year after the last time you
|
6692 |
|
|
distribute an Opaque copy (directly or through your agents or
|
6693 |
|
|
retailers) of that edition to the public.
|
6694 |
|
|
|
6695 |
|
|
It is requested, but not required, that you contact the authors of
|
6696 |
|
|
the Document well before redistributing any large number of
|
6697 |
|
|
copies, to give them a chance to provide you with an updated
|
6698 |
|
|
version of the Document.
|
6699 |
|
|
|
6700 |
|
|
4. MODIFICATIONS
|
6701 |
|
|
|
6702 |
|
|
You may copy and distribute a Modified Version of the Document
|
6703 |
|
|
under the conditions of sections 2 and 3 above, provided that you
|
6704 |
|
|
release the Modified Version under precisely this License, with
|
6705 |
|
|
the Modified Version filling the role of the Document, thus
|
6706 |
|
|
licensing distribution and modification of the Modified Version to
|
6707 |
|
|
whoever possesses a copy of it. In addition, you must do these
|
6708 |
|
|
things in the Modified Version:
|
6709 |
|
|
|
6710 |
|
|
A. Use in the Title Page (and on the covers, if any) a title
|
6711 |
|
|
distinct from that of the Document, and from those of
|
6712 |
|
|
previous versions (which should, if there were any, be listed
|
6713 |
|
|
in the History section of the Document). You may use the
|
6714 |
|
|
same title as a previous version if the original publisher of
|
6715 |
|
|
that version gives permission.
|
6716 |
|
|
|
6717 |
|
|
B. List on the Title Page, as authors, one or more persons or
|
6718 |
|
|
entities responsible for authorship of the modifications in
|
6719 |
|
|
the Modified Version, together with at least five of the
|
6720 |
|
|
principal authors of the Document (all of its principal
|
6721 |
|
|
authors, if it has fewer than five), unless they release you
|
6722 |
|
|
from this requirement.
|
6723 |
|
|
|
6724 |
|
|
C. State on the Title page the name of the publisher of the
|
6725 |
|
|
Modified Version, as the publisher.
|
6726 |
|
|
|
6727 |
|
|
D. Preserve all the copyright notices of the Document.
|
6728 |
|
|
|
6729 |
|
|
E. Add an appropriate copyright notice for your modifications
|
6730 |
|
|
adjacent to the other copyright notices.
|
6731 |
|
|
|
6732 |
|
|
F. Include, immediately after the copyright notices, a license
|
6733 |
|
|
notice giving the public permission to use the Modified
|
6734 |
|
|
Version under the terms of this License, in the form shown in
|
6735 |
|
|
the Addendum below.
|
6736 |
|
|
|
6737 |
|
|
G. Preserve in that license notice the full lists of Invariant
|
6738 |
|
|
Sections and required Cover Texts given in the Document's
|
6739 |
|
|
license notice.
|
6740 |
|
|
|
6741 |
|
|
H. Include an unaltered copy of this License.
|
6742 |
|
|
|
6743 |
|
|
I. Preserve the section Entitled "History", Preserve its Title,
|
6744 |
|
|
and add to it an item stating at least the title, year, new
|
6745 |
|
|
authors, and publisher of the Modified Version as given on
|
6746 |
|
|
the Title Page. If there is no section Entitled "History" in
|
6747 |
|
|
the Document, create one stating the title, year, authors,
|
6748 |
|
|
and publisher of the Document as given on its Title Page,
|
6749 |
|
|
then add an item describing the Modified Version as stated in
|
6750 |
|
|
the previous sentence.
|
6751 |
|
|
|
6752 |
|
|
J. Preserve the network location, if any, given in the Document
|
6753 |
|
|
for public access to a Transparent copy of the Document, and
|
6754 |
|
|
likewise the network locations given in the Document for
|
6755 |
|
|
previous versions it was based on. These may be placed in
|
6756 |
|
|
the "History" section. You may omit a network location for a
|
6757 |
|
|
work that was published at least four years before the
|
6758 |
|
|
Document itself, or if the original publisher of the version
|
6759 |
|
|
it refers to gives permission.
|
6760 |
|
|
|
6761 |
|
|
K. For any section Entitled "Acknowledgements" or "Dedications",
|
6762 |
|
|
Preserve the Title of the section, and preserve in the
|
6763 |
|
|
section all the substance and tone of each of the contributor
|
6764 |
|
|
acknowledgements and/or dedications given therein.
|
6765 |
|
|
|
6766 |
|
|
L. Preserve all the Invariant Sections of the Document,
|
6767 |
|
|
unaltered in their text and in their titles. Section numbers
|
6768 |
|
|
or the equivalent are not considered part of the section
|
6769 |
|
|
titles.
|
6770 |
|
|
|
6771 |
|
|
M. Delete any section Entitled "Endorsements". Such a section
|
6772 |
|
|
may not be included in the Modified Version.
|
6773 |
|
|
|
6774 |
|
|
N. Do not retitle any existing section to be Entitled
|
6775 |
|
|
"Endorsements" or to conflict in title with any Invariant
|
6776 |
|
|
Section.
|
6777 |
|
|
|
6778 |
|
|
O. Preserve any Warranty Disclaimers.
|
6779 |
|
|
|
6780 |
|
|
If the Modified Version includes new front-matter sections or
|
6781 |
|
|
appendices that qualify as Secondary Sections and contain no
|
6782 |
|
|
material copied from the Document, you may at your option
|
6783 |
|
|
designate some or all of these sections as invariant. To do this,
|
6784 |
|
|
add their titles to the list of Invariant Sections in the Modified
|
6785 |
|
|
Version's license notice. These titles must be distinct from any
|
6786 |
|
|
other section titles.
|
6787 |
|
|
|
6788 |
|
|
You may add a section Entitled "Endorsements", provided it contains
|
6789 |
|
|
nothing but endorsements of your Modified Version by various
|
6790 |
|
|
parties--for example, statements of peer review or that the text
|
6791 |
|
|
has been approved by an organization as the authoritative
|
6792 |
|
|
definition of a standard.
|
6793 |
|
|
|
6794 |
|
|
You may add a passage of up to five words as a Front-Cover Text,
|
6795 |
|
|
and a passage of up to 25 words as a Back-Cover Text, to the end
|
6796 |
|
|
of the list of Cover Texts in the Modified Version. Only one
|
6797 |
|
|
passage of Front-Cover Text and one of Back-Cover Text may be
|
6798 |
|
|
added by (or through arrangements made by) any one entity. If the
|
6799 |
|
|
Document already includes a cover text for the same cover,
|
6800 |
|
|
previously added by you or by arrangement made by the same entity
|
6801 |
|
|
you are acting on behalf of, you may not add another; but you may
|
6802 |
|
|
replace the old one, on explicit permission from the previous
|
6803 |
|
|
publisher that added the old one.
|
6804 |
|
|
|
6805 |
|
|
The author(s) and publisher(s) of the Document do not by this
|
6806 |
|
|
License give permission to use their names for publicity for or to
|
6807 |
|
|
assert or imply endorsement of any Modified Version.
|
6808 |
|
|
|
6809 |
|
|
5. COMBINING DOCUMENTS
|
6810 |
|
|
|
6811 |
|
|
You may combine the Document with other documents released under
|
6812 |
|
|
this License, under the terms defined in section 4 above for
|
6813 |
|
|
modified versions, provided that you include in the combination
|
6814 |
|
|
all of the Invariant Sections of all of the original documents,
|
6815 |
|
|
unmodified, and list them all as Invariant Sections of your
|
6816 |
|
|
combined work in its license notice, and that you preserve all
|
6817 |
|
|
their Warranty Disclaimers.
|
6818 |
|
|
|
6819 |
|
|
The combined work need only contain one copy of this License, and
|
6820 |
|
|
multiple identical Invariant Sections may be replaced with a single
|
6821 |
|
|
copy. If there are multiple Invariant Sections with the same name
|
6822 |
|
|
but different contents, make the title of each such section unique
|
6823 |
|
|
by adding at the end of it, in parentheses, the name of the
|
6824 |
|
|
original author or publisher of that section if known, or else a
|
6825 |
|
|
unique number. Make the same adjustment to the section titles in
|
6826 |
|
|
the list of Invariant Sections in the license notice of the
|
6827 |
|
|
combined work.
|
6828 |
|
|
|
6829 |
|
|
In the combination, you must combine any sections Entitled
|
6830 |
|
|
"History" in the various original documents, forming one section
|
6831 |
|
|
Entitled "History"; likewise combine any sections Entitled
|
6832 |
|
|
"Acknowledgements", and any sections Entitled "Dedications". You
|
6833 |
|
|
must delete all sections Entitled "Endorsements."
|
6834 |
|
|
|
6835 |
|
|
6. COLLECTIONS OF DOCUMENTS
|
6836 |
|
|
|
6837 |
|
|
You may make a collection consisting of the Document and other
|
6838 |
|
|
documents released under this License, and replace the individual
|
6839 |
|
|
copies of this License in the various documents with a single copy
|
6840 |
|
|
that is included in the collection, provided that you follow the
|
6841 |
|
|
rules of this License for verbatim copying of each of the
|
6842 |
|
|
documents in all other respects.
|
6843 |
|
|
|
6844 |
|
|
You may extract a single document from such a collection, and
|
6845 |
|
|
distribute it individually under this License, provided you insert
|
6846 |
|
|
a copy of this License into the extracted document, and follow
|
6847 |
|
|
this License in all other respects regarding verbatim copying of
|
6848 |
|
|
that document.
|
6849 |
|
|
|
6850 |
|
|
7. AGGREGATION WITH INDEPENDENT WORKS
|
6851 |
|
|
|
6852 |
|
|
A compilation of the Document or its derivatives with other
|
6853 |
|
|
separate and independent documents or works, in or on a volume of
|
6854 |
|
|
a storage or distribution medium, is called an "aggregate" if the
|
6855 |
|
|
copyright resulting from the compilation is not used to limit the
|
6856 |
|
|
legal rights of the compilation's users beyond what the individual
|
6857 |
|
|
works permit. When the Document is included in an aggregate, this
|
6858 |
|
|
License does not apply to the other works in the aggregate which
|
6859 |
|
|
are not themselves derivative works of the Document.
|
6860 |
|
|
|
6861 |
|
|
If the Cover Text requirement of section 3 is applicable to these
|
6862 |
|
|
copies of the Document, then if the Document is less than one half
|
6863 |
|
|
of the entire aggregate, the Document's Cover Texts may be placed
|
6864 |
|
|
on covers that bracket the Document within the aggregate, or the
|
6865 |
|
|
electronic equivalent of covers if the Document is in electronic
|
6866 |
|
|
form. Otherwise they must appear on printed covers that bracket
|
6867 |
|
|
the whole aggregate.
|
6868 |
|
|
|
6869 |
|
|
8. TRANSLATION
|
6870 |
|
|
|
6871 |
|
|
Translation is considered a kind of modification, so you may
|
6872 |
|
|
distribute translations of the Document under the terms of section
|
6873 |
|
|
4. Replacing Invariant Sections with translations requires special
|
6874 |
|
|
permission from their copyright holders, but you may include
|
6875 |
|
|
translations of some or all Invariant Sections in addition to the
|
6876 |
|
|
original versions of these Invariant Sections. You may include a
|
6877 |
|
|
translation of this License, and all the license notices in the
|
6878 |
|
|
Document, and any Warranty Disclaimers, provided that you also
|
6879 |
|
|
include the original English version of this License and the
|
6880 |
|
|
original versions of those notices and disclaimers. In case of a
|
6881 |
|
|
disagreement between the translation and the original version of
|
6882 |
|
|
this License or a notice or disclaimer, the original version will
|
6883 |
|
|
prevail.
|
6884 |
|
|
|
6885 |
|
|
If a section in the Document is Entitled "Acknowledgements",
|
6886 |
|
|
"Dedications", or "History", the requirement (section 4) to
|
6887 |
|
|
Preserve its Title (section 1) will typically require changing the
|
6888 |
|
|
actual title.
|
6889 |
|
|
|
6890 |
|
|
9. TERMINATION
|
6891 |
|
|
|
6892 |
|
|
You may not copy, modify, sublicense, or distribute the Document
|
6893 |
|
|
except as expressly provided for under this License. Any other
|
6894 |
|
|
attempt to copy, modify, sublicense or distribute the Document is
|
6895 |
|
|
void, and will automatically terminate your rights under this
|
6896 |
|
|
License. However, parties who have received copies, or rights,
|
6897 |
|
|
from you under this License will not have their licenses
|
6898 |
|
|
terminated so long as such parties remain in full compliance.
|
6899 |
|
|
|
6900 |
|
|
10. FUTURE REVISIONS OF THIS LICENSE
|
6901 |
|
|
|
6902 |
|
|
The Free Software Foundation may publish new, revised versions of
|
6903 |
|
|
the GNU Free Documentation License from time to time. Such new
|
6904 |
|
|
versions will be similar in spirit to the present version, but may
|
6905 |
|
|
differ in detail to address new problems or concerns. See
|
6906 |
|
|
`http://www.gnu.org/copyleft/'.
|
6907 |
|
|
|
6908 |
|
|
Each version of the License is given a distinguishing version
|
6909 |
|
|
number. If the Document specifies that a particular numbered
|
6910 |
|
|
version of this License "or any later version" applies to it, you
|
6911 |
|
|
have the option of following the terms and conditions either of
|
6912 |
|
|
that specified version or of any later version that has been
|
6913 |
|
|
published (not as a draft) by the Free Software Foundation. If
|
6914 |
|
|
the Document does not specify a version number of this License,
|
6915 |
|
|
you may choose any version ever published (not as a draft) by the
|
6916 |
|
|
Free Software Foundation.
|
6917 |
|
|
|
6918 |
|
|
B.1 ADDENDUM: How to use this License for your documents
|
6919 |
|
|
========================================================
|
6920 |
|
|
|
6921 |
|
|
To use this License in a document you have written, include a copy of
|
6922 |
|
|
the License in the document and put the following copyright and license
|
6923 |
|
|
notices just after the title page:
|
6924 |
|
|
|
6925 |
|
|
Copyright (C) YEAR YOUR NAME.
|
6926 |
|
|
Permission is granted to copy, distribute and/or modify this document
|
6927 |
|
|
under the terms of the GNU Free Documentation License, Version 1.2
|
6928 |
|
|
or any later version published by the Free Software Foundation;
|
6929 |
|
|
with no Invariant Sections, no Front-Cover Texts, and no Back-Cover
|
6930 |
|
|
Texts. A copy of the license is included in the section entitled ``GNU
|
6931 |
|
|
Free Documentation License''.
|
6932 |
|
|
|
6933 |
|
|
If you have Invariant Sections, Front-Cover Texts and Back-Cover
|
6934 |
|
|
Texts, replace the "with...Texts." line with this:
|
6935 |
|
|
|
6936 |
|
|
with the Invariant Sections being LIST THEIR TITLES, with
|
6937 |
|
|
the Front-Cover Texts being LIST, and with the Back-Cover Texts
|
6938 |
|
|
being LIST.
|
6939 |
|
|
|
6940 |
|
|
If you have Invariant Sections without Cover Texts, or some other
|
6941 |
|
|
combination of the three, merge those two alternatives to suit the
|
6942 |
|
|
situation.
|
6943 |
|
|
|
6944 |
|
|
If your document contains nontrivial examples of program code, we
|
6945 |
|
|
recommend releasing these examples in parallel under your choice of
|
6946 |
|
|
free software license, such as the GNU General Public License, to
|
6947 |
|
|
permit their use in free software.
|
6948 |
|
|
|
© copyright 1999-2024
OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.