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

r2 fails to parse /proc/maps from the Android device via gdb remote protocol #21813

Closed
detunized opened this issue May 31, 2023 · 10 comments
Closed
Assignees

Comments

@detunized
Copy link

Environment

Wed May 31 19:11:45 CEST 2023
radare2 5.8.6 0 @ darwin-arm-64
birth: git.5.8.6 2023-05-05__15:36:00
commit: 5.8.6
options: gpl release -O1 checks=2
Darwin arm64

Description

When I connect to a gdbserver running on an Android Arm64 phone I get the following:

r_debug_gdb_map_get: Unable to parse "/proc/27546/maps"
Content:
12c00000-12cc0000 rw-p 00000000 00:00 0                                  [anon:dalvik-main space (region space)]

It seems to fails to parse the /proc/maps for the target process. I checked the r2 code and seems to expect something more of a filename in last place. Would it be possible to ignore the regions that don't parse or fix up their name to be able to proceed with the debugging? At this point the parsing function aborts the debugger.

Test

I run the gdbserver on the phone like this:

gdbserver :1234 --attach $(pidof my.app.package.id)

I forward the the port to the host with adb:

adb forward tcp:1234 tcp:1234

And I simply launch r2 and run the following command there and the following output:

[0x0000c500]> doof gdb://localhost:1234

WARN: Duplicated register definition for 'SP' has been ignored
r_debug_gdb_map_get: Unable to parse "/proc/28834/maps"
Content:
12c00000-12c80000 rw-p 00000000 00:00 0                                  [anon:dalvik-main space (region space)]
r_debug_gdb_map_get: Unable to parse "/proc/28834/maps"
Content:
12c00000-12c80000 rw-p 00000000 00:00 0                                  [anon:dalvik-main space (region space)]

No debugging is possible after this.

@trufae
Copy link
Collaborator

trufae commented May 31, 2023

Can you try this branch? #21815 and see if my blindfix works?

@detunized
Copy link
Author

@trufae Wow, quick fix. I need to setup the dev env for this first. I have not tried to build yet. I simply installed with brew. r2env installation failed for me.

@detunized
Copy link
Author

I managed to build with ./configure && make and install it into ~/bin via make user-install but it conflicts with the system installation of r2 and I don't want to delete it. Is there any way to run this locally from the source folder?

@trufae trufae closed this as completed in cc37f0c Jun 1, 2023
@detunized
Copy link
Author

@trufae I tested this via brew install --HEAD radare2. I still get a similar error:

[0x0000c500]> doof gdb://localhost:1234
WARN: Duplicated register definition for 'SP' has been ignored
WARN: Cannot parse "/proc/11344/maps" with content: 12c00000-12c40000 rw-p 00000000 00:00 0                                  [anon:dalvik-main space (region space)]
WARN: Cannot parse "/proc/11344/maps" with content: 12c00000-12c40000 rw-p 00000000 00:00 0                                  [anon:dalvik-main space (region space)]

There's no way for me to reopen this ticket. Should I open a new one?

@trufae trufae reopened this Jun 1, 2023
@trufae
Copy link
Collaborator

trufae commented Jun 1, 2023

I have reopen permissions 😎

@trufae
Copy link
Collaborator

trufae commented Jun 7, 2023

Untested pr. need to find some time to test with real device #21858 can you give it a try? its not merged yet

trufae pushed a commit that referenced this issue Jun 7, 2023
@trufae
Copy link
Collaborator

trufae commented Jun 8, 2023

got the device setup and testing now

@trufae
Copy link
Collaborator

trufae commented Jun 8, 2023

Fixed and tested :)

@trufae trufae closed this as completed Jun 8, 2023
@detunized
Copy link
Author

Thank you, @trufae! I will install from git soon and try. A local build doesn't work for me, only via brew install --HEAD.

@trufae
Copy link
Collaborator

trufae commented Jun 8, 2023

Theres room for improvement but ill do that for the next release as its not a blocker. This should be good now :) thanks for reporting

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

No branches or pull requests

2 participants