Conversation
…he automated build system is unhappy about naming conventions on 1.42.0
9839937 to
75e65e7
Compare
…gjubilee Add support for QNX Neutrino to standard library This change: - adds standard library support for QNX Neutrino (7.1). - upgrades `libc` to version `0.2.139` which supports QNX Neutrino `@gh-tr`⚠️ Backtraces on QNX require rust-lang/backtrace-rs#507 which is not yet merged! (But everything else works without these changes)⚠️ Tested mainly with a x86_64 virtual machine (see qnx-nto.md) and partially with an aarch64 hardware (some tests fail due to constrained resources).
Add support for QNX Neutrino to standard library This change: - adds standard library support for QNX Neutrino (7.1). - upgrades `libc` to version `0.2.139` which supports QNX Neutrino `@gh-tr`⚠️ Backtraces on QNX require rust-lang/backtrace-rs#507 which is not yet merged! (But everything else works without these changes)⚠️ Tested mainly with a x86_64 virtual machine (see qnx-nto.md) and partially with an aarch64 hardware (some tests fail due to constrained resources).
Add support for QNX Neutrino to standard library This change: - adds standard library support for QNX Neutrino (7.1). - upgrades `libc` to version `0.2.139` which supports QNX Neutrino `@gh-tr`⚠️ Backtraces on QNX require rust-lang/backtrace-rs#507 which is not yet merged! (But everything else works without these changes)⚠️ Tested mainly with a x86_64 virtual machine (see qnx-nto.md) and partially with an aarch64 hardware (some tests fail due to constrained resources).
There was a problem hiding this comment.
I had half-expected someone else with a bit more experience to come by and review this, so I kept my earlier comments minimal, but it looks like I probably now know the most about QNX Neutrino amongst the libs reviewers, so I might as well sit down with this. Sorry about the holdup.
| fn concat_str(a: &str, b: &str) -> String { | ||
| let mut e = String::from(a); | ||
| e += b; | ||
| e | ||
| } | ||
|
|
||
| fn read_file(file: &str) -> Result<String, String> { | ||
| let mut proc_self_maps = | ||
| File::open("/proc/self/maps").map_err(|_| "Couldn't open /proc/self/maps")?; | ||
| File::open(file).map_err(|_| concat_str("Couldn't open file: ", file))?; | ||
| let mut buf = String::new(); | ||
| let _bytes_read = proc_self_maps | ||
| .read_to_string(&mut buf) | ||
| .map_err(|_| "Couldn't read /proc/self/maps")?; | ||
| for line in buf.lines() { | ||
| v.push(line.parse()?); | ||
| } | ||
| .map_err(|_| concat_str("Couldn't read file: ", file))?; | ||
| Ok(buf) | ||
| } |
There was a problem hiding this comment.
This machinery is a reimplementation of fs::read_to_string. You can import fs by changing
- use super::mystd::fs::File;
+ use super::mystd::fs::{self, File};If you must, you can use map_err for the Err variant.
| #[cfg(not(target_os = "nto"))] | ||
| pub fn config() -> (&'static str, usize) { | ||
| ("/proc/self/maps", 0) | ||
| } |
There was a problem hiding this comment.
This moves to runtime what can be known at compile-time. Please describe a static and a const instead, with appropriate names. If you wish, you can put them in a mod config {}.
| parse_maps_lines(&content, skip) | ||
| } | ||
|
|
||
| fn parse_maps_lines(content: &str, skip: usize) -> Result<Vec<MapsEntry>, String> { |
There was a problem hiding this comment.
I believe this is still functionally identical if we simply delete these lines?
| parse_maps_lines(&content, skip) | |
| } | |
| fn parse_maps_lines(content: &str, skip: usize) -> Result<Vec<MapsEntry>, String> { |
| assert_eq!( | ||
| "7f5985f46000-7f5985f48000 rw-p 00039000 103:06 76021795 \ | ||
| /usr/lib/x86_64-linux-gnu/ld-linux-x86-64.so.2" | ||
| /usr/lib/x86_64-linux-gnu/ld-linux-x86-64.so.2" |
There was a problem hiding this comment.
Is there a reason for diffing this line?
| assert_eq!( | ||
| "ffffffffff600000-ffffffffff601000 --xp 00000000 00:00 0 \ | ||
| [vsyscall]" | ||
| [vsyscall]" |
There was a problem hiding this comment.
Is there a reason for diffing this line?
| let vaddr_str = parts.next().ok_or("Couldn't find virtual address")?; | ||
| let size_str = parts.next().ok_or("Couldn't find size")?; | ||
| let _flags_str = parts.next().ok_or("Couldn't find flags")?; | ||
| let prot_str = parts.next().ok_or("Couldn't find protection")?; | ||
| let _maxprot_str = parts.next().ok_or("Couldn't find maximum protection")?; | ||
| let dev_str = parts.next().ok_or("Couldn't find device")?; | ||
| let ino_str = parts.next().ok_or("Couldn't find inode")?; | ||
| let offset_str = parts.next().ok_or("Couldn't find offset")?; | ||
| let _rsv_str = parts.next().ok_or("Couldn't find reserved pages")?; | ||
| let _guardsize_str = parts.next().ok_or("Couldn't find guard size")?; | ||
| let _refcnt_str = parts.next().ok_or("Couldn't find reference count")?; | ||
| let _mapcnt_str = parts.next().ok_or("Couldn't find mapped count")?; |
There was a problem hiding this comment.
Just to be clear, on QNX Neutrino these are all required fields? Is there somewhere this format is documented for Neutrino? It seems to be a superset of the other format described here?
| Ok(v) | ||
| pub(super) fn parse_maps() -> Result<Vec<MapsEntry>, String> { | ||
| let (file, skip) = config(); | ||
| let content = read_file(file)?; |
There was a problem hiding this comment.
| let content = read_file(file)?; | |
| let content = fs::read_to_string(file).map_err(|e| e.to_string())?; |
| |s: &str| usize::from_str_radix(&s[2..], 16).map_err(|_| "Couldn't parse hex number"); | ||
| let address = { (hex(vaddr_str)?, hex(vaddr_str)? + hex(size_str)?) }; | ||
|
|
||
| // TODO: Probably a rust'ier way of doing this |
There was a problem hiding this comment.
You could probably cook something up using array::from_fn but I'm not going to block this on that. If you decide not to, though, please remove the TODO.
Add support for QNX Neutrino to standard library This change: - adds standard library support for QNX Neutrino (7.1). - upgrades `libc` to version `0.2.139` which supports QNX Neutrino `@gh-tr`⚠️ Backtraces on QNX require rust-lang/backtrace-rs#507 which is not yet merged! (But everything else works without these changes)⚠️ Tested mainly with a x86_64 virtual machine (see qnx-nto.md) and partially with an aarch64 hardware (some tests fail due to constrained resources).
Add support for QNX Neutrino to standard library This change: - adds standard library support for QNX Neutrino (7.1). - upgrades `libc` to version `0.2.139` which supports QNX Neutrino `@gh-tr`⚠️ Backtraces on QNX require rust-lang/backtrace-rs#507 which is not yet merged! (But everything else works without these changes)⚠️ Tested mainly with a x86_64 virtual machine (see qnx-nto.md) and partially with an aarch64 hardware (some tests fail due to constrained resources).
|
this PR can be closed now that #648 has landed (648 adds support for both QNX 7.0 and 7.1) |
|
@japaric The QNX |
Add support for QNX Neutrino.
-- Tested on a Neutrino target for both aarch64 and x86_64 running 7.1.
Change Description:
default) into one module and thentointo another/proc/self/pmap