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: c21bc6f3c2
This commit is contained in:
Bojan Novković 2024-07-21 18:45:33 +02:00
parent 24388fccd5
commit 82f5dfc121

View file

@ -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) {