git: 82f5dfc12139 - main - db_pprint: Fix offset calculation for struct members
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Sun, 21 Jul 2024 17:32:27 UTC
The branch main has been updated by bnovkov:
URL: https://cgit.FreeBSD.org/src/commit/?id=82f5dfc121391604b079ea96aa14ea71e6b618c9
commit 82f5dfc121391604b079ea96aa14ea71e6b618c9
Author: Bojan Novković <bnovkov@FreeBSD.org>
AuthorDate: 2024-07-21 16:45:33 +0000
Commit: Bojan Novković <bnovkov@FreeBSD.org>
CommitDate: 2024-07-21 17:31:48 +0000
db_pprint: Fix offset calculation for struct members
The struct pretty-printing code uses the ctm_offset field in
struct ctf_member_v3 to calculate the address of a struct member.
However, the code treats this as a byte offset rather than the
offset in bits, leading to wrong values being printed.
Fix this by diving with ctm_offset by NBBY.
Approved by: markj (mentor)
Fixes: c21bc6f3c242
---
sys/ddb/db_pprint.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/sys/ddb/db_pprint.c b/sys/ddb/db_pprint.c
index 10334ce650c8..2925caedd49d 100644
--- a/sys/ddb/db_pprint.c
+++ b/sys/ddb/db_pprint.c
@@ -117,7 +117,7 @@ db_pprint_struct(db_addr_t addr, struct ctf_type_v3 *type, u_int depth)
return;
}
mtype = db_ctf_typeid_to_type(&sym_data, mp->ctm_type);
- maddr = addr + mp->ctm_offset;
+ maddr = addr + (mp->ctm_offset / NBBY);
mname = db_ctf_stroff_to_str(&sym_data, mp->ctm_name);
db_indent = depth;
if (mname != NULL) {
@@ -140,7 +140,7 @@ db_pprint_struct(db_addr_t addr, struct ctf_type_v3 *type, u_int depth)
return;
}
mtype = db_ctf_typeid_to_type(&sym_data, mp->ctlm_type);
- maddr = addr + CTF_LMEM_OFFSET(mp);
+ maddr = addr + (CTF_LMEM_OFFSET(mp) / NBBY);
mname = db_ctf_stroff_to_str(&sym_data, mp->ctlm_name);
db_indent = depth;
if (mname != NULL) {