Page MenuHomeFreeBSD

io.d updates/enhancements to aid DTrace scripting
ClosedPublic

Authored by dteske on Feb 16 2018, 5:23 AM.

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
Lint
Lint OK
Unit
No Unit Test Coverage
Build Status
Buildable 15081
Build 15174: arc lint + arc unit

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

Looks like you skipped 0x009.

261

Why not use the "UNKNOWN" tag here too?

cddl/lib/libdtrace/io.d
261

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

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.