[Bug translator/25346] support enum context variables

craig.ringer at 2ndquadrant dot com sourceware-bugzilla@sourceware.org
Fri Dec 18 06:41:29 GMT 2020


https://sourceware.org/bugzilla/show_bug.cgi?id=25346

--- Comment #2 from Craig Ringer <craig.ringer at 2ndquadrant dot com> ---
It's also worth noting that a lot of code uses #define macros not true enums .

While embedded C blocks can #include C headers, they can only do so if the
header is safe and sensible to compile as kernel code, with no reference to
standard headers. For many programs this may not be feasible.

At best, the macro definitions can be extracted into a separate mini-header for
systemtap use.

An @enum that used DWARF debuginfo would be fantastic, but would only help for
true enums.

If code is compiled with -ggdb3 it will include DWARF macro information too. In
that case, it becomes possible to look up the textual definitions of macro
symbols, though recursive expansion is not trivial to handle in cases where the
macro is defined in terms of other macros. If the macro expansion can be used
as a valid C const-expression, it could be evaluated with an embedded-C
expression and stored in a static constant, such that some @dwarf_macro("FOO")
or @dwarf_macro("FOO@bar.h") or @dwarf_macro("FOO","/path/to/program") for
macro "#define FOO 1<<4" could expand to definition:

    %{
    static const long _stap_macro_FOO = (1<<4);
    %}

and where referenced expand to %{ _stap_macro_FOO %} .

I had intended to tackle this after I got @enum working, but I got stuck trying
to work out how do make @enum work.

-- 
You are receiving this mail because:
You are the assignee for the bug.


More information about the Systemtap mailing list