Repository navigation
pmap: accept a 0x prefix in --range addresses - #819
jayhemnani9910 wants to merge 2 commits into
Conversation
-A/--range only took bare hex digits, so "pmap -A 0x7f0000000000, PID" failed with "failed to parse argument", while procps-ng pmap takes the addresses with or without 0x (or 0X). Strip the prefix before parsing.
There was a problem hiding this comment.
Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.
An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing. Review the Copilot code review billing settings.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #819 +/- ##
==========================================
+ Coverage 19.20% 19.45% +0.25%
==========================================
Files 68 68
Lines 10156 10238 +82
Branches 546 552 +6
==========================================
+ Hits 1950 1992 +42
- Misses 8206 8246 +40
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
|
||
| /// Parse an address for --range: hexadecimal, with or without a 0x prefix, | ||
| /// as procps-ng takes it. | ||
| fn parse_address(address: &str) -> Result<u64, std::num::ParseIntError> { |
There was a problem hiding this comment.
since you are touching the three callers, could parse_address return the USimpleError directly?
the same map_err is there 3 times
There was a problem hiding this comment.
Done in 2e673d2: parse_address takes the whole argument for the message and returns the USimpleError, so the three callers just use ?.
There was a problem hiding this comment.
Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota.
An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing. Review the Copilot code review billing settings.
-A/--rangeonly takes bare hex digits, so an address with a0xin front fails:procps-ng takes the addresses with or without
0x(or0X). A smallparse_addressnow strips the prefix beforefrom_str_radix. It's used for the single address and for both ends of a range. Whitespace and values overu64stay errors, as the existing test wants.Tests:
test_range_arggets0xc00fee,0Xc00fee,0xc00,0xfeeand,0xffffffffffffffffas valid, and0x,0x,and0x0xc00feeas invalid. The valid ones fail on main.cargo test: 224 passed, same as main, clippy and rustfmt clean. Against procps-ng 4.0.4's pmap on a runningsleep, 16-Aforms (with and without the prefix, upper case, open ends,+,0xalone, a doubled prefix, junk) give the same output now.