Commit 3219c86c authored by Petr Machata's avatar Petr Machata

Allow typedefs of lenses

This worked for keywords such as enum that are handled specially, because
those behave as types for backward compatibility.  It was however not
possible to typedef e.g. hex.
parent 8c98e401
......@@ -21,7 +21,6 @@
reenablement.
** Create different ltrace processes to trace different children
** Config file syntax
*** typedef should be able to assign a lens to a name
*** named arguments
This would be useful for replacing the arg1, emt2 etc.
......
......@@ -192,12 +192,9 @@ type alias. Instead of writing the same enum or struct on many places
such type, and later just use that name:
.RS
\fBtypedef \fINAME\fB = \fITYPE\fB;\fR
\fBtypedef \fINAME\fB = \fILENS\fB;\fR
.RE
Note that \fITYPE\fR currently cannot be a lens, but must really be a
type.
.SH RECURSIVE STRUCTURES
Ltrace allows you to express recursive structures. Such structures
......
......@@ -445,7 +445,7 @@ parse_typedef(char **str)
eat_spaces(str);
struct typedef_node_t *this_td = new_typedef(name, NULL, 0);
this_td->info = parse_type(str, NULL, 0, &this_td->own_type, this_td);
this_td->info = parse_lens(str, NULL, 0, &this_td->own_type, this_td);
if (this_td->info == NULL) {
free(this_td);
......
......@@ -115,5 +115,28 @@ ltraceMatch1 [ltraceRun -F $conf -e ll -A 5 \
}
}]]] {->ll\({ 9, { 8, { 7, { 6, { 5, \.\.\. } } } } }\) *= <void>} == 1
proc ltraceParamTest {conf cdecl libcode maincode match} {
set conffile [ltraceSource conf $conf]
set lib [ltraceCompile liblib.so [ltraceSource c [concat $cdecl $libcode]]]
set bin [ltraceCompile {} $lib \
[ltraceSource c \
[concat $cdecl "int main(void) {" $maincode "}"]]]
return [ltraceMatch [ltraceRun -F $conffile -- $bin] $match]
}
ltraceParamTest {
typedef hexptr = hex(uint);
void fun(hexptr);
} {
void fun(unsigned *arg);
} {
void fun(unsigned *arg) {}
} {
unsigned u = 0x123;
fun(&u);
} {
{{fun\(0x123\) *= <void>} == 1}
}
ltraceDone
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment