Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pmap: implement --device #249

Merged
merged 3 commits into from
Nov 8, 2024
Merged

Conversation

cakebaker
Copy link
Contributor

This PR implements -d/--device and creates output in the following format:

13176:   ../hello_world/target/debug/hello_world
Address           Kbytes Mode  Offset           Device    Mapping
000060ab2984a000      24 r---- 0000000000000000 008:00008 hello_world
000060ab29850000     248 r-x-- 0000000000006000 008:00008 hello_world
...
ffffffffff600000       4 --x-- 0000000000000000 000:00000   [ anon ]
mapped: 3060K    writeable/private: 348K    shared: 0K

Copy link

codecov bot commented Oct 9, 2024

Codecov Report

Attention: Patch coverage is 72.82609% with 25 lines in your changes missing coverage. Please review.

Project coverage is 60.76%. Comparing base (0a754bc) to head (cc6d948).
Report is 13 commits behind head on main.

Files with missing lines Patch % Lines
src/uu/pmap/src/maps_format_parser.rs 55.55% 11 Missing and 5 partials ⚠️
src/uu/pmap/src/pmap.rs 80.64% 2 Missing and 4 partials ⚠️
tests/by-util/test_pmap.rs 88.00% 2 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #249      +/-   ##
==========================================
+ Coverage   60.62%   60.76%   +0.13%     
==========================================
  Files          44       44              
  Lines        4500     4577      +77     
  Branches      693      711      +18     
==========================================
+ Hits         2728     2781      +53     
- Misses       1611     1625      +14     
- Partials      161      171      +10     
Flag Coverage Δ
macos_latest 45.47% <0.00%> (-0.63%) ⬇️
ubuntu_latest 58.62% <72.82%> (+0.22%) ⬆️
windows_latest 0.05% <0.00%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

set_exit_code(1);
}
if matches.get_flag(options::DEVICE) {
output_device_format(pid).map_err(|_| set_exit_code(1)).ok();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is it expected that they (the map_err) don't return an error message ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, the original pmap doesn't show an error message if /proc/<PID>/maps can't be read:

$ pmap 1 --device
1:   /sbin/init \vmlinuz-linux
$ echo $?
1

In this example, no memory map is shown because /proc/1/maps is not accessible for a normal user.

@cakebaker cakebaker marked this pull request as ready for review October 24, 2024 15:02
@cakebaker cakebaker requested a review from sylvestre October 24, 2024 15:03
@sylvestre sylvestre merged commit bc66596 into uutils:main Nov 8, 2024
16 checks passed
@cakebaker cakebaker deleted the pmap_device_format branch November 8, 2024 13:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants