diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 12:03:36 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 12:03:36 +0000 |
commit | 17d40c6057c88f4c432b0d7bac88e1b84cb7e67f (patch) | |
tree | 3f66c4a5918660bb8a758ab6cda5ff8ee4f6cdcd /vendor/gimli/examples | |
parent | Adding upstream version 1.64.0+dfsg1. (diff) | |
download | rustc-f7f0cc2a5d72e2c61c1f6900e70eec992bea4273.tar.xz rustc-f7f0cc2a5d72e2c61c1f6900e70eec992bea4273.zip |
Adding upstream version 1.65.0+dfsg1.upstream/1.65.0+dfsg1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'vendor/gimli/examples')
-rw-r--r-- | vendor/gimli/examples/dwarf-validate.rs | 2 | ||||
-rw-r--r-- | vendor/gimli/examples/dwarfdump.rs | 45 | ||||
-rw-r--r-- | vendor/gimli/examples/simple.rs | 2 | ||||
-rw-r--r-- | vendor/gimli/examples/simple_line.rs | 13 |
4 files changed, 44 insertions, 18 deletions
diff --git a/vendor/gimli/examples/dwarf-validate.rs b/vendor/gimli/examples/dwarf-validate.rs index 1eabccc11..54d8f3a1d 100644 --- a/vendor/gimli/examples/dwarf-validate.rs +++ b/vendor/gimli/examples/dwarf-validate.rs @@ -52,7 +52,7 @@ fn main() { continue; } }; - let file = match unsafe { memmap::Mmap::map(&file) } { + let file = match unsafe { memmap2::Mmap::map(&file) } { Ok(mmap) => mmap, Err(err) => { eprintln!("Failed to map file '{}': {}", path.display(), &err); diff --git a/vendor/gimli/examples/dwarfdump.rs b/vendor/gimli/examples/dwarfdump.rs index 64b233305..4b61fd572 100644 --- a/vendor/gimli/examples/dwarfdump.rs +++ b/vendor/gimli/examples/dwarfdump.rs @@ -490,7 +490,7 @@ fn main() { process::exit(1); } }; - let mmap = match unsafe { memmap::Mmap::map(&file) } { + let mmap = match unsafe { memmap2::Mmap::map(&file) } { Ok(mmap) => mmap, Err(err) => { eprintln!("Failed to map file '{}': {}", path, err); @@ -531,7 +531,7 @@ fn main() { continue; } }; - let file = match unsafe { memmap::Mmap::map(&file) } { + let file = match unsafe { memmap2::Mmap::map(&file) } { Ok(mmap) => mmap, Err(err) => { eprintln!("Failed to map file '{}': {}", file_path, err); @@ -786,17 +786,36 @@ fn dump_eh_frame<R: Reader, W: Write>( // TODO: augmentation writeln!(w, " code_align: {}", cie.code_alignment_factor())?; writeln!(w, " data_align: {}", cie.data_alignment_factor())?; - writeln!(w, " ra_register: {:#x}", cie.return_address_register().0)?; + writeln!( + w, + " ra_register: {}", + register_name(cie.return_address_register()) + )?; if let Some(encoding) = cie.lsda_encoding() { - writeln!(w, " lsda_encoding: {:#02x}", encoding.0)?; + writeln!( + w, + " lsda_encoding: {}/{}", + encoding.application(), + encoding.format() + )?; } if let Some((encoding, personality)) = cie.personality_with_encoding() { - write!(w, " personality: {:#02x} ", encoding.0)?; + write!( + w, + " personality: {}/{} ", + encoding.application(), + encoding.format() + )?; dump_pointer(w, personality)?; writeln!(w)?; } if let Some(encoding) = cie.fde_address_encoding() { - writeln!(w, " fde_encoding: {:#02x}", encoding.0)?; + writeln!( + w, + " fde_encoding: {}/{}", + encoding.application(), + encoding.format() + )?; } let instructions = cie.instructions(&eh_frame, &bases); dump_cfi_instructions(w, instructions, true, register_name)?; @@ -1585,21 +1604,21 @@ fn dump_type_signature<W: Write>(w: &mut W, signature: gimli::DebugTypeSignature fn dump_file_index<R: Reader, W: Write>( w: &mut W, - file: u64, + file_index: u64, unit: &gimli::Unit<R>, dwarf: &gimli::Dwarf<R>, ) -> Result<()> { - if file == 0 { + if file_index == 0 && unit.header.version() <= 4 { return Ok(()); } let header = match unit.line_program { Some(ref program) => program.header(), None => return Ok(()), }; - let file = match header.file(file) { - Some(header) => header, + let file = match header.file(file_index) { + Some(file) => file, None => { - writeln!(w, "Unable to get header for file {}", file)?; + writeln!(w, "Unable to get header for file {}", file_index)?; return Ok(()); } }; @@ -1607,7 +1626,7 @@ fn dump_file_index<R: Reader, W: Write>( if let Some(directory) = file.directory(header) { let directory = dwarf.attr_string(unit, directory)?; let directory = directory.to_string_lossy()?; - if !directory.starts_with('/') { + if file.directory_index() != 0 && !directory.starts_with('/') { if let Some(ref comp_dir) = unit.comp_dir { write!(w, "{}/", comp_dir.to_string_lossy()?,)?; } @@ -2238,7 +2257,7 @@ fn dump_line_program<R: Reader, W: Write>( writeln!(w, "<pc> [lno,col]")?; } let mut rows = program.rows(); - let mut file_index = 0; + let mut file_index = std::u64::MAX; while let Some((header, row)) = rows.next_row()? { let line = match row.line() { Some(line) => line.get(), diff --git a/vendor/gimli/examples/simple.rs b/vendor/gimli/examples/simple.rs index b73ab7552..7c958d45c 100644 --- a/vendor/gimli/examples/simple.rs +++ b/vendor/gimli/examples/simple.rs @@ -6,7 +6,7 @@ use std::{borrow, env, fs}; fn main() { for path in env::args().skip(1) { let file = fs::File::open(&path).unwrap(); - let mmap = unsafe { memmap::Mmap::map(&file).unwrap() }; + let mmap = unsafe { memmap2::Mmap::map(&file).unwrap() }; let object = object::File::parse(&*mmap).unwrap(); let endian = if object.is_little_endian() { gimli::RunTimeEndian::Little diff --git a/vendor/gimli/examples/simple_line.rs b/vendor/gimli/examples/simple_line.rs index bf1114f90..87b224cda 100644 --- a/vendor/gimli/examples/simple_line.rs +++ b/vendor/gimli/examples/simple_line.rs @@ -6,7 +6,7 @@ use std::{borrow, env, fs, path}; fn main() { for path in env::args().skip(1) { let file = fs::File::open(&path).unwrap(); - let mmap = unsafe { memmap::Mmap::map(&file).unwrap() }; + let mmap = unsafe { memmap2::Mmap::map(&file).unwrap() }; let object = object::File::parse(&*mmap).unwrap(); let endian = if object.is_little_endian() { gimli::RunTimeEndian::Little @@ -68,9 +68,16 @@ fn dump_file(object: &object::File, endian: gimli::RunTimeEndian) -> Result<(), let mut path = path::PathBuf::new(); if let Some(file) = row.file(header) { path = comp_dir.clone(); - if let Some(dir) = file.directory(header) { - path.push(dwarf.attr_string(&unit, dir)?.to_string_lossy().as_ref()); + + // The directory index 0 is defined to correspond to the compilation unit directory. + if file.directory_index() != 0 { + if let Some(dir) = file.directory(header) { + path.push( + dwarf.attr_string(&unit, dir)?.to_string_lossy().as_ref(), + ); + } } + path.push( dwarf .attr_string(&unit, file.path_name())? |