Created
August 8, 2023 13:14
-
-
Save mped-oticon/27aa9be1715721fff310e77c1b7cc81b to your computer and use it in GitHub Desktop.
Semantic patch to instrument C code, used in debian_foreign
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@remove_traces@ | |
@@ | |
( | |
- MYTRACE(...); | |
| | |
- MYTRACE_CASE(...); | |
| | |
- MYTRACE_ELSE_ENTER(...); | |
| | |
- MYTRACE_ELSE_LEAVE(...); | |
| | |
- MYTRACE_RETURN_VAL_UNKNOWN_TYPE(...); | |
| | |
- MYTRACE_RETURN_VOID(...); | |
| | |
- MYTRACE_SCALAR_S16(...); | |
| | |
- MYTRACE_SCALAR_S32(...); | |
| | |
- MYTRACE_SCALAR_S64(...); | |
| | |
- MYTRACE_SCALAR_S8(...); | |
| | |
- MYTRACE_SCALAR_U16(...); | |
| | |
- MYTRACE_SCALAR_U32(...); | |
| | |
- MYTRACE_SCALAR_U64(...); | |
| | |
- MYTRACE_SCALAR_U8(...); | |
| | |
- MYTRACE_THEN_ENTER(...); | |
| | |
- MYTRACE_THEN_LEAVE(...); | |
) | |
// @tracecontrolflow@ | |
// type TR; | |
// identifier fun; | |
// expression e1; | |
// @@ | |
// TR fun(...) { <+... | |
// + MYTRACE(e1); /* tracecontrolflow */ | |
// e1; | |
// ...+> } | |
@trace_init_uchar@ | |
type TR; identifier fun; | |
identifier x; | |
expression e; | |
@@ | |
TR fun(...) { <... | |
unsigned char x = e; | |
+ MYTRACE_SCALAR_U8(x); /* trace_init_uchar */ | |
...> } | |
@trace_init_u8_t@ | |
type TR; identifier fun; | |
identifier x; | |
expression e; | |
@@ | |
TR fun(...) { <... | |
u8_t x = e; | |
+ MYTRACE_SCALAR_U8(x); /* trace_init_u8_t */ | |
...> } | |
@trace_init_u16_t@ | |
type TR; identifier fun; | |
identifier x; | |
expression e; | |
@@ | |
TR fun(...) { <... | |
u16_t x = e; | |
+ MYTRACE_SCALAR_U16(x); /* trace_init_u16_t */ | |
...> } | |
@trace_init_u32_t@ | |
type TR; identifier fun; | |
identifier x; | |
expression e; | |
@@ | |
TR fun(...) { <... | |
u32_t x = e; | |
+ MYTRACE_SCALAR_U32(x); /* trace_init_u32_t */ | |
...> } | |
@trace_init_u64_t@ | |
type TR; identifier fun; | |
identifier x; | |
expression e; | |
@@ | |
TR fun(...) { <... | |
u64_t x = e; | |
+ MYTRACE_SCALAR_U64(x); /* trace_init_u64_t */ | |
...> } | |
@trace_init_uint8_t@ | |
type TR; identifier fun; | |
identifier x; | |
expression e; | |
@@ | |
TR fun(...) { <... | |
uint8_t x = e; | |
+ MYTRACE_SCALAR_U8(x); /* trace_init_uint8_t */ | |
...> } | |
@trace_init_uint16_t@ | |
type TR; identifier fun; | |
identifier x; | |
expression e; | |
@@ | |
TR fun(...) { <... | |
uint16_t x = e; | |
+ MYTRACE_SCALAR_U16(x); /* trace_init_uint16_t */ | |
...> } | |
@trace_init_uint32_t@ | |
type TR; identifier fun; | |
identifier x; | |
expression e; | |
@@ | |
TR fun(...) { <... | |
uint32_t x = e; | |
+ MYTRACE_SCALAR_U32(x); /* trace_init_uint32_t */ | |
...> } | |
@trace_init_uint64_t@ | |
type TR; identifier fun; | |
identifier x; | |
expression e; | |
@@ | |
TR fun(...) { <... | |
uint64_t x = e; | |
+ MYTRACE_SCALAR_U64(x); /* trace_init_uint64_t */ | |
...> } | |
@trace_init_int8_t@ | |
type TR; identifier fun; | |
identifier x; | |
expression e; | |
@@ | |
TR fun(...) { <... | |
int8_t x = e; | |
+ MYTRACE_SCALAR_S8(x); /* trace_init_int8_t */ | |
...> } | |
@trace_init_int16_t@ | |
type TR; identifier fun; | |
identifier x; | |
expression e; | |
@@ | |
TR fun(...) { <... | |
int16_t x = e; | |
+ MYTRACE_SCALAR_S16(x); /* trace_init_int16_t */ | |
...> } | |
@trace_init_int32_t@ | |
type TR; identifier fun; | |
identifier x; | |
expression e; | |
@@ | |
TR fun(...) { <... | |
int32_t x = e; | |
+ MYTRACE_SCALAR_S32(x); /* trace_init_int32_t */ | |
...> } | |
@trace_init_int64_t@ | |
type TR; identifier fun; | |
identifier x; | |
expression e; | |
@@ | |
TR fun(...) { <... | |
int64_t x = e; | |
+ MYTRACE_SCALAR_S64(x); /* trace_init_int64_t */ | |
...> } | |
@trace_assignment_scalar_u8@ | |
type TR; identifier fun; | |
{uint8_t, u8_t, unsigned char} x; | |
assignment operator ASSOP = { = , += , -= , *= , /= , %= , <<= , >>= , &= , ^= , |= }; | |
expression e; | |
@@ | |
TR fun(...) { <... | |
x ASSOP e; | |
+ MYTRACE_SCALAR_U8(x); /* trace_assignment_scalar_u8 */ | |
...> } | |
@trace_assignment_scalar_u16@ | |
type TR; identifier fun; | |
{uint16_t, u16_t} x; | |
assignment operator ASSOP = { = , += , -= , *= , /= , %= , <<= , >>= , &= , ^= , |= }; | |
expression e; | |
@@ | |
TR fun(...) { <... | |
x ASSOP e; | |
+ MYTRACE_SCALAR_U16(x); /* trace_assignment_scalar_u16 */ | |
...> } | |
@trace_assignment_scalar_u32@ | |
type TR; identifier fun; | |
{uint32_t, u32_t, unsigned int} x; | |
assignment operator ASSOP = { = , += , -= , *= , /= , %= , <<= , >>= , &= , ^= , |= }; | |
expression e; | |
@@ | |
TR fun(...) { <... | |
x ASSOP e; | |
+ MYTRACE_SCALAR_U32(x); /* trace_assignment_scalar_u32 */ | |
...> } | |
@trace_assignment_scalar_u64@ | |
type TR; identifier fun; | |
{uint64_t, u64_t} x; | |
assignment operator ASSOP = { = , += , -= , *= , /= , %= , <<= , >>= , &= , ^= , |= }; | |
expression e; | |
@@ | |
TR fun(...) { <... | |
x ASSOP e; | |
+ MYTRACE_SCALAR_U64(x); /* trace_assignment_scalar_u64 */ | |
...> } | |
@trace_assignment_scalar_s8@ | |
type TR; identifier fun; | |
{int8_t, char} x; | |
assignment operator ASSOP = { = , += , -= , *= , /= , %= , <<= , >>= , &= , ^= , |= }; | |
expression e; | |
@@ | |
TR fun(...) { <... | |
x ASSOP e; | |
+ MYTRACE_SCALAR_S8(x); /* trace_assignment_scalar_s8 */ | |
...> } | |
@trace_sassignment_scalar_s16@ | |
type TR; identifier fun; | |
int16_t x; | |
assignment operator ASSOP = { = , += , -= , *= , /= , %= , <<= , >>= , &= , ^= , |= }; | |
expression e; | |
@@ | |
TR fun(...) { <... | |
x ASSOP e; | |
+ MYTRACE_SCALAR_S16(x); /* trace_sassignment_scalar_s16 */ | |
...> } | |
@trace_sassignment_scalar_s32@ | |
type TR; identifier fun; | |
{int32_t, int} x; | |
assignment operator ASSOP = { = , += , -= , *= , /= , %= , <<= , >>= , &= , ^= , |= }; | |
expression e; | |
@@ | |
TR fun(...) { <... | |
x ASSOP e; | |
+ MYTRACE_SCALAR_S32(x); /* trace_sassignment_scalar_s32 */ | |
...> } | |
@trace_sassignment_scalar_s64@ | |
type TR; identifier fun; | |
int64_t x; | |
assignment operator ASSOP = { = , += , -= , *= , /= , %= , <<= , >>= , &= , ^= , |= }; | |
expression e; | |
@@ | |
TR fun(...) { <... | |
x ASSOP e; | |
+ MYTRACE_SCALAR_S64(x); /* trace_sassignment_scalar_s64 */ | |
...> } | |
@ensure_return@ | |
identifier fun; | |
@@ | |
void fun(...) { | |
... when != return; | |
+ return; /* ensure_return */ | |
} | |
@trace_return_val_unknown@ | |
expression e; | |
@@ | |
+ MYTRACE_RETURN_VAL_UNKNOWN_TYPE(e); | |
return e; | |
@trace_return_void@ | |
@@ | |
+ MYTRACE_RETURN_VOID(); /* trace_return_void */ | |
return; | |
@trace_return_val_uint8_t@ | |
identifier fun; | |
expression e; | |
@@ | |
uint8_t fun(...) { <... | |
- MYTRACE_RETURN_VAL_UNKNOWN_TYPE(e); | |
+ MYTRACE_SCALAR_U8(e); /* trace_return_val_uint8_t */ | |
...> } | |
@trace_return_val_u8_t@ | |
identifier fun; | |
expression e; | |
@@ | |
u8_t fun(...) { <... | |
- MYTRACE_RETURN_VAL_UNKNOWN_TYPE(e); | |
+ MYTRACE_SCALAR_U8(e); /* trace_return_val_u8_t */ | |
...> } | |
@trace_return_val_uint16_t@ | |
identifier fun; | |
expression e; | |
@@ | |
uint16_t fun(...) { <... | |
- MYTRACE_RETURN_VAL_UNKNOWN_TYPE(e); | |
+ MYTRACE_SCALAR_U16(e); /* trace_return_val_uint16_t */ | |
...> } | |
@trace_return_val_u16_t@ | |
identifier fun; | |
expression e; | |
@@ | |
u16_t fun(...) { <... | |
- MYTRACE_RETURN_VAL_UNKNOWN_TYPE(e); | |
+ MYTRACE_SCALAR_U16(e); /* trace_return_val_u16_t */ | |
...> } | |
@trace_return_val_uint32_t@ | |
identifier fun; | |
expression e; | |
@@ | |
uint32_t fun(...) { <... | |
- MYTRACE_RETURN_VAL_UNKNOWN_TYPE(e); | |
+ MYTRACE_SCALAR_U32(e); /* trace_return_val_uint32_t */ | |
...> } | |
@trace_return_val_u32_t@ | |
identifier fun; | |
expression e; | |
@@ | |
u32_t fun(...) { <... | |
- MYTRACE_RETURN_VAL_UNKNOWN_TYPE(e); | |
+ MYTRACE_SCALAR_U32(e); /* trace_return_val_u32_t */ | |
...> } | |
@trace_return_val_uint64_t@ | |
identifier fun; | |
expression e; | |
@@ | |
uint64_t fun(...) { <... | |
- MYTRACE_RETURN_VAL_UNKNOWN_TYPE(e); | |
+ MYTRACE_SCALAR_U64(e); /* trace_return_val_uint64_t */ | |
...> } | |
@trace_return_val_u64_t@ | |
identifier fun; | |
expression e; | |
@@ | |
u64_t fun(...) { <... | |
- MYTRACE_RETURN_VAL_UNKNOWN_TYPE(e); | |
+ MYTRACE_SCALAR_U64(e); /* trace_return_val_u64_t */ | |
...> } | |
@trace_return_val_int8_t@ | |
identifier fun; | |
expression e; | |
@@ | |
int8_t fun(...) { <... | |
- MYTRACE_RETURN_VAL_UNKNOWN_TYPE(e); | |
+ MYTRACE_SCALAR_S8(e); /* trace_return_val_int8_t */ | |
...> } | |
@trace_return_val_int16_t@ | |
identifier fun; | |
expression e; | |
@@ | |
int16_t fun(...) { <... | |
- MYTRACE_RETURN_VAL_UNKNOWN_TYPE(e); | |
+ MYTRACE_SCALAR_S16(e); /* trace_return_val_int16_t */ | |
...> } | |
@trace_return_val_int32_t@ | |
identifier fun; | |
expression e; | |
@@ | |
int32_t fun(...) { <... | |
- MYTRACE_RETURN_VAL_UNKNOWN_TYPE(e); | |
+ MYTRACE_SCALAR_S32(e); /* trace_return_val_int32_t */ | |
...> } | |
@trace_return_val_int64_t@ | |
identifier fun; | |
expression e; | |
@@ | |
int64_t fun(...) { <... | |
- MYTRACE_RETURN_VAL_UNKNOWN_TYPE(e); | |
+ MYTRACE_SCALAR_S64(e); /* trace_return_val_int64_t */ | |
...> } | |
@trace_switch_case@ | |
statement S; | |
@@ | |
switch (...) | |
{ | |
case ... : | |
+ MYTRACE_CASE(); /* trace_switch_case */ | |
S | |
} | |
@trace_switch_default@ | |
statement S; | |
@@ | |
switch (...) | |
{ | |
default : | |
+ MYTRACE_CASE(); /* trace_switch_default */ | |
S | |
} | |
@trace_branches@ | |
expression e; | |
@@ | |
( | |
if (e) { | |
+ MYTRACE_THEN_ENTER(e); /* trace_branches */ | |
... | |
+ MYTRACE_THEN_LEAVE(); /* trace_branches */ | |
} | |
| | |
if (e) { | |
+ MYTRACE_THEN_ENTER(e); /* trace_branches */ | |
... | |
+ MYTRACE_THEN_LEAVE(); /* trace_branches */ | |
} else { | |
+ MYTRACE_ELSE_ENTER(e); /* trace_branches */ | |
... | |
+ MYTRACE_ELSE_LEAVE(); /* trace_branches */ | |
} | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
If used in Zephyr, these may be placed in
posix_cheats.h
.