[Bug translator/33516] New: automated enum name/value handling
fche at redhat dot com
sourceware-bugzilla@sourceware.org
Thu Oct 2 18:32:21 GMT 2025
https://sourceware.org/bugzilla/show_bug.cgi?id=33516
Bug ID: 33516
Summary: automated enum name/value handling
Product: systemtap
Version: unspecified
Status: NEW
Severity: normal
Priority: P2
Component: translator
Assignee: systemtap at sourceware dot org
Reporter: fche at redhat dot com
Target Milestone: ---
When encountering an enum value at runtime, the translator treats it as an
integer. But DWARF does include a DW_TAG_enumeration_type doohickey which
should in principle let us convert back and forth between number and name.
Possible syntax:
@enumvalue("typename","enumerator_name")
@enumvalue("typename","enumerator_name")
These would be an safe alternative to the existing @const("EXPRESSION") that
maps to a snippet of embedded-C code.
@enumstr("typename", value)
with an optional third parameter for "module,module..." as in @cast.
The most automated would be:
@enumstr($pointer->enumfield)
which $$ pretty-printing should probably also expand to.
Implementing the name-to-number mapping could be a translation-time thing
(i.e., enforce "enumerator_name" = literal_string). But number-to-name will
need to be runtime, therefore probably be expanded into a function that has a
switch/case statement fanning out the known enum values.
This should make several tapset library lookup tables unnecessary, and improve
the quality/simplicity of normal end user scripts.
--
You are receiving this mail because:
You are the assignee for the bug.
More information about the Systemtap
mailing list