public inbox for systemtap@sourceware.org
 help / color / mirror / Atom feed
From: "craig.ringer at 2ndquadrant dot com" <sourceware-bugzilla@sourceware.org>
To: systemtap@sourceware.org
Subject: [Bug translator/25346] support enum context variables
Date: Fri, 18 Dec 2020 06:41:29 +0000	[thread overview]
Message-ID: <bug-25346-6586-mPjbiXfjSd@http.sourceware.org/bugzilla/> (raw)
In-Reply-To: <bug-25346-6586@http.sourceware.org/bugzilla/>

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.

  parent reply	other threads:[~2020-12-18  6:41 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-01-04 18:20 [Bug translator/25346] New: " fche at redhat dot com
2020-12-18  6:33 ` [Bug translator/25346] " craig.ringer at 2ndquadrant dot com
2020-12-18  6:41 ` craig.ringer at 2ndquadrant dot com [this message]
2020-12-18 12:29 ` fweimer at redhat dot com
2021-01-06  0:58 ` craig.ringer at 2ndquadrant dot com
2021-01-08  8:32 ` craig.ringer at 2ndquadrant dot com
2021-01-20 15:21 ` scox at redhat dot com
2021-02-08 18:19 ` scox at redhat dot com

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-25346-6586-mPjbiXfjSd@http.sourceware.org/bugzilla/ \
    --to=sourceware-bugzilla@sourceware.org \
    --cc=systemtap@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).