Page MenuHomeFreeBSD

io.d updates/enhancements to aid DTrace scripting
ClosedPublic

Authored by dteske on Feb 16 2018, 5:23 AM.
Tags
None
Referenced Files
F81656470: D14396.diff
Fri, Apr 19, 1:33 PM
Unknown Object (File)
Thu, Apr 18, 1:35 AM
Unknown Object (File)
Jan 29 2024, 12:04 PM
Unknown Object (File)
Jan 29 2024, 12:04 PM
Unknown Object (File)
Jan 29 2024, 12:04 PM
Unknown Object (File)
Jan 27 2024, 11:34 PM
Unknown Object (File)
Jan 27 2024, 11:12 PM
Unknown Object (File)
Dec 20 2023, 3:28 AM
Subscribers

Details

Summary

The following changes are included:

+ Add dev_type to devinfo_t
+ Add b_cmd to bufinfo_t
+ Add constants for BIO_* and DEVSTAT_TYPE_*
+ Add inline for converting BIO_* int to string
+ Add inline for converting DEVSTAT_TYPE_* int to string
+ Add mask for dev_type & DEVSTAT_TYPE_MASK to string
+ Add mask for dev_type & DEVSTAT_TYPE_IF_MASK to string

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

I really wish we didn't have to duplicate C defines this way. I do believe that cpp #defines are encoded in DWARF info, so we should in principle be able to include them in CTF...?

cddl/lib/libdtrace/io.d
178 ↗(On Diff #39375)

Looks like you skipped 0x009.

261 ↗(On Diff #39375)

Why not use the "UNKNOWN" tag here too?

cddl/lib/libdtrace/io.d
261 ↗(On Diff #39375)

Because I rely on NULL fallback in the following recipe for building a string of bitfields that are set:

this string bio_flags;
this int b_flags;

inline string append_bio_flag[int flags, int flag] = this->bio_flags =
        strjoin(this->bio_flags,
        strjoin(this->bio_flags == "" ? "" : (flags & flag) == flag ? "|" : "",
                bio_flag_string[flags & flag]));

io:::start, io:::done {
        # ...
        this->b_flags = (int)this->bufinfo.b_flags;
        this->bio_flags = bio_flag_string[this->b_flags & BIO_ERROR];
        this->bio_flags = strjoin(this->bio_flags, this->bufinfo.b_error ?
                strjoin(this->bio_flags == "" ?
                        bio_flag_string[BIO_ERROR] : "",
                        strjoin("#", lltostr(this->bufinfo.b_error))) :
                "");
        append_bio_flag[this->b_flags, BIO_DONE];
        append_bio_flag[this->b_flags, BIO_ONQUEUE];
        append_bio_flag[this->b_flags, BIO_ORDERED];
        append_bio_flag[this->b_flags, BIO_UNMAPPED];
        append_bio_flag[this->b_flags, BIO_TRANSIENT_MAPPING];
        append_bio_flag[this->b_flags, BIO_VLIST];
        this->bio_flags = this->bio_flags == "" ? "-" : this->bio_flags;
        # ...
}

The net effect is that bio_flags is something like "DONE|ONQUEUE" (each bitfield that is enabled is shown, separated by pipe.

If I used "UNKNOWN" as a fall-back in bio_flag_string, I would have to add a test to the inline to map UNKNOWN to the NUL string to prevent UNKNOWN from being appended.

Although, now that I think about it, maybe it would be desirable to show bits that are set but don't map to a known macro name. Unfortunately, the word "UNKNOWN" is pretty useless unless you mention which specific bit was set for which we didn't have a known macro. A potential solution to that would be to append the position of the unknown bit.

cddl/lib/libdtrace/io.d
178 ↗(On Diff #39375)

Good catch. Will fix in next update.

I really wish we didn't have to duplicate C defines this way. I do believe that cpp #defines are encoded in DWARF info, so we should in principle be able to include them in CTF...?

How would one do that? I'm not familiar.

This comment was removed by dteske.

Fix incorrect value (off-by-one) for several DEVSTAT_TYPE_* values

I really wish we didn't have to duplicate C defines this way. I do believe that cpp #defines are encoded in DWARF info, so we should in principle be able to include them in CTF...?

How would one do that? I'm not familiar.

It would probably involve extending CTF in some way and would be a large undertaking regardless. Ignore my comment, I was just thinking out loud.

This revision was not accepted when it landed; it landed in state Needs Review.Feb 24 2018, 5:13 PM
This revision was automatically updated to reflect the committed changes.