(
name: &String,
members: &Vec<ParsedMember>,
structure: &mut StructureBuilder,
)
| 303 | } |
| 304 | |
| 305 | pub fn group_structure( |
| 306 | name: &String, |
| 307 | members: &Vec<ParsedMember>, |
| 308 | structure: &mut StructureBuilder, |
| 309 | ) -> Result<()> { |
| 310 | // SO |
| 311 | // PDBs handle trivial unions inside structures by just slamming all the fields together into |
| 312 | // one big overlappy happy family. We need to reverse this and create out union structures |
| 313 | // to properly represent the original source. |
| 314 | |
| 315 | // IN VISUAL FORM (if you are a visual person, like me): |
| 316 | // struct { |
| 317 | // int foos[2]; |
| 318 | // __offset(0): |
| 319 | // int foo1; |
| 320 | // int foo2; |
| 321 | // int bar; |
| 322 | // } |
| 323 | // |
| 324 | // Into |
| 325 | // |
| 326 | // struct { |
| 327 | // union { |
| 328 | // int foos[2]; |
| 329 | // struct { |
| 330 | // int foo1; |
| 331 | // int foo2; |
| 332 | // } |
| 333 | // } |
| 334 | // int bar; |
| 335 | // } |
| 336 | |
| 337 | // Into internal rep |
| 338 | let reps = members |
| 339 | .iter() |
| 340 | .enumerate() |
| 341 | .map(|(i, member)| MemberSize { |
| 342 | index: i, |
| 343 | offset: member.offset, |
| 344 | width: member.ty.contents.width(), |
| 345 | }) |
| 346 | .collect::<Vec<_>>(); |
| 347 | |
| 348 | log(|| format!("{} {:#x?}", name, members)); |
| 349 | log(|| format!("{} {:#x?}", name, reps)); |
| 350 | |
| 351 | // Group them |
| 352 | match resolve_struct_groups(reps) { |
| 353 | Ok(groups) => { |
| 354 | log(|| format!("{} {:#x?}", name, groups)); |
| 355 | |
| 356 | // Apply grouped members |
| 357 | apply_groups(members, structure, groups, 0); |
| 358 | } |
| 359 | Err(e) => { |
| 360 | warn!("{} Could not resolve structure groups: {}", name, e); |
| 361 | for member in members { |
| 362 | structure.insert( |
no test coverage detected