Re: git: aada453dcbaa - main - ddb: Properly pretty-print non-labeled enum values

From: Jessica Clarke <jrtc27_at_freebsd.org>
Date: Wed, 03 Apr 2024 17:51:47 UTC
On 3 Apr 2024, at 17:18, Bojan Novković <bnovkov@FreeBSD.org> wrote:
> 
> The branch main has been updated by bnovkov:
> 
> URL: https://cgit.FreeBSD.org/src/commit/?id=aada453dcbaab1b8f7d50b66add5a38eb9e06cc3
> 
> commit aada453dcbaab1b8f7d50b66add5a38eb9e06cc3
> Author:     Bojan Novković <bnovkov@FreeBSD.org>
> AuthorDate: 2024-04-03 15:47:00 +0000
> Commit:     Bojan Novković <bnovkov@FreeBSD.org>
> CommitDate: 2024-04-03 16:17:11 +0000
> 
>    ddb: Properly pretty-print non-labeled enum values
> 
>    The ddb pretty-printer currently does not print out enum values that
>    are not labeled (e.g. X | Y).
>    The enum printer was reworked to print non-labeled values.
> 
>    Reported by:    jrtc27
>    Fixes:  c21bc6f ("ddb: Add CTF-based pretty printing")
>    Approved by:    markj (mentor)
> ---
> sys/ddb/db_pprint.c | 11 ++++++-----
> 1 file changed, 6 insertions(+), 5 deletions(-)
> 
> diff --git a/sys/ddb/db_pprint.c b/sys/ddb/db_pprint.c
> index 8aa14550f068..b4116372cf65 100644
> --- a/sys/ddb/db_pprint.c
> +++ b/sys/ddb/db_pprint.c
> @@ -225,13 +225,14 @@ db_pprint_enum(db_addr_t addr, struct ctf_type_v3 *type, u_int depth)
> for (; ep < endp; ep++) {
> if (val == ep->cte_value) {
> valname = db_ctf_stroff_to_str(&sym_data, ep->cte_name);
> - if (valname != NULL)
> - db_printf("%s (0x%lx)", valname, (long)val);
> - else
> - db_printf("(0x%lx)", (long)val);
> - break;
> + if (valname != NULL) {
> + db_printf("%s (0x%lx)", valname, val);
> + break;
> + }

This ignored the "(well, with 32-bit fixed)" part of my review comment for that
suggestion and rolled back d722901fa3a2 ("ddb: Fix format string errors in
db_pprint.c").

Jess

> }
> }
> + if (ep == endp)
> + db_printf("0x%lx", val);
> }
> 
> /*