Page MenuHomeFreeBSD

ddb(4): Enhance functionality for specialized ddb commands
ClosedPublic

Authored by cem on Aug 28 2019, 10:06 PM.
Tags
None
Referenced Files
Unknown Object (File)
Thu, Dec 19, 11:42 PM
Unknown Object (File)
Thu, Dec 19, 4:07 PM
Unknown Object (File)
Sun, Dec 15, 2:17 AM
Unknown Object (File)
Sun, Nov 24, 6:52 AM
Unknown Object (File)
Nov 12 2024, 8:56 PM
Unknown Object (File)
Sep 30 2024, 11:27 PM
Unknown Object (File)
Sep 22 2024, 10:19 AM
Unknown Object (File)
Sep 21 2024, 4:28 AM
Subscribers

Details

Summary

The CS_LEX_SPACE command flag causes explicit tWSPACE tokens to be yielded,
instead of silently consuming whitespace between other tokens. This can be
useful for whitespace-sensitive CS_OWN commands.

The db_cmd_radix variable is exposed for commands to explicitly set a radix
for use during db_lex() tNUMBER lexing. This overrides the user-specific
db_radix as well as any auto-sensing.

Both of these additions are scoped to the specific command and reset on
return. Commands cannot themselves scope flags like this because a trap may
abort them prior to cleanup; and a lot of ddb(4) lexing state and options
are global.

Diff Detail

Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 26169
Build 24678: arc lint + arc unit

Event Timeline

I'd like to go ahead and commit this one independent of netdump/debugnet/netgdb, actually, because I have other lexer extensions and ddb commands orthogonal to netdump/debugnet that stack on this. Can I get some eyeballs on this review, please?

This looks fine to me.

Is there some reason it isn't easy to add a variant of db_read_token() that will optionally return tWSPACE and can take a caller-supplied radix? That would seem cleaner than adding more global state.

This revision is now accepted and ready to land.Sep 3 2019, 8:45 PM
cem planned changes to this revision.Sep 3 2019, 10:48 PM

Is there some reason it isn't easy to add a variant of db_read_token() that will optionally return tWSPACE and can take a caller-supplied radix? That would seem cleaner than adding more global state.

I don't know any reason that wouldn't be possible off-hand. That does seem like a better idea — thanks.

In fact, it seems plausible to do the same for basically all of my db lexer changes. No?

The only tricky one is radix, but ddb only really supports base 8, 10, and 16, so that could just be two flag bits.

So I'd propose something like this:

#define DRT_RADIX_MASK 0x3
enum {
  _DRT_WSPACE = 2,
  _DRT_HEX = 3,
};
enum db_read_token_flags {
  DRT_WSPACE = BIT(_DRT_WSPACE),
  DRT_HEX = BIT(_DRT_HEX),
};
enum db_read_token_radices {
  DRT_DEFAULT_RADIX = 0,
  DRT_OCTAL,
  DRT_DECIMAL,
  DRT_HEXADECIMAL,
};

int db_read_token(void)
{
    db_read_token_flags(DRT_DEFAULT_RADIX);  // or just zero
}

int db_read_token_flags(int flags)
{
  ...
}

Switch from globals to per-lex flags.

Sorry for the delay.

sys/ddb/db_lex.h
48

Style: the function name should appear on a new line.

This revision is now accepted and ready to land.Sep 8 2019, 3:57 PM
This revision was automatically updated to reflect the committed changes.
cem marked an inline comment as done.