adbgen - generate adb script
/usr/lib/adb/adbgen [-m model] filename.adb ...
adbgen makes it possible to write adb(1) scripts that do not contain hard-coded dependencies on structure member offsets. The input to adbgen is a file named filename.adb that contains header information, then a null line, then the name of a structure, and finally an adb script. adbgen only deals with one structure per file; all member names are assumed to be in this structure. The output of adbgen is an adb script in filename. adbgen operates by generating a C program which determines structure member offsets and sizes, which in turn generate the adb script.
The header lines, up to the null line, are copied verbatim into the generated C program. Typically, these are #include statements, which include the headers containing the relevant structure declarations.
The adb script part may contain any valid adb commands (see adb(1)), and may also contain adbgen requests, each enclosed in braces ({}). Request types are:
{POINTER}
{LONGDEC}
{ULONGDEC}
{ULONGHEX}
{LONGOCT}
{ULONGOCT}
adbgen keeps track of the movement of the adb dot and generates adb code to move forward or backward as necessary before printing any structure member in a script. adbgen's model of the behavior of adb's dot is simple: it is assumed that the first line of the script is of the form struct_address/adb text and that subsequent lines are of the form +/adb text. The adb dot then moves in a sane fashion. adbgen does not check the script to ensure that these limitations are met. adbgen also checks the size of the structure member against the size of the adb format code and warns if they are not equal.
The following option is supported:
-m model
The following operand is supported:
filename.adb
Example 1 A sample adbgen file.
For an include file x.h which contained
struct x { char *x_cp; char x_c; int x_i; };
then , an adbgen file (call it script.adb) to print the file x.h would be:
#include "x.h" x ./"x_cp"16t"x_c"8t"x_i"n{x_cp,{POINTER}}{x_c,C}{x_i,D}
After running adbgen as follows,
% /usr/lib/adb/adbgen script.adb
the output file script contains:
./"x_cp"16t"x_c"8t"x_i"nXC3+D
For a macro generated for a 64-bit program using the lp64 data model as follows,
% /usr/lib/adb/adbgen/ -m lp64 script.adb
the output file script would contain:
./"x_cp"16t"x_c"8t"x_i"nJC3+D
To invoke the script, type:
example% adb program x$<script
/usr/platform/platform-name/lib/adb/*
/usr/platform/platform-name/lib/adb/sparcv9/*
/usr/lib/adb/*
/usr/lib/adb/sparcv9/*
See attributes(5) for descriptions of the following attributes:
|
adb(1), uname(1), kadb(1M), attributes(5)
Warnings are given about structure member sizes not equal to adb format items and about badly formatted requests. The C compiler complains if a structure member that does not exist is referenced. It also complains about an ampersand before array names; these complaints may be ignored.
platform-name can be found using the -i option of uname(1).
adb syntax is ugly; there should be a higher level interface for generating scripts.
Structure members which are bit fields cannot be handled because C will not give the address of a bit field. The address is needed to determine the offset.
Закладки на сайте Проследить за страницей |
Created 1996-2024 by Maxim Chirkov Добавить, Поддержать, Вебмастеру |