This is an archive of the discontinued LLVM Phabricator instance.

[lldb][Android] Add PlatformAndroidTest
ClosedPublic

Authored by splhack on Jun 13 2023, 1:56 PM.

Details

Summary

To test D152759 [lldb][Android] Support zip .so file

introduce PlatformAndroidTest with the capability of mocking adb client.

Depends on D152759

Diff Detail

Event Timeline

splhack created this revision.Jun 13 2023, 1:56 PM
Herald added a project: Restricted Project. · View Herald TranscriptJun 13 2023, 1:56 PM
Herald added a subscriber: danielkiss. · View Herald Transcript
splhack updated this revision to Diff 531075.Jun 13 2023, 2:48 PM

update depends

splhack published this revision for review.Jun 13 2023, 3:06 PM

(not sure why build status got merge conflict, probably landing D152494 may resolve)

Herald added a project: Restricted Project. · View Herald TranscriptJun 13 2023, 3:06 PM
splhack updated this revision to Diff 531198.Jun 13 2023, 11:42 PM

sync with D152759 new version

splhack edited the summary of this revision. (Show Details)Jun 14 2023, 9:39 AM
splhack added a reviewer: bulbazord.
splhack updated this revision to Diff 531396.Jun 14 2023, 9:48 AM

remove 'Depend on' from commit message

splhack updated this revision to Diff 531578.Jun 14 2023, 5:07 PM

Fixed diff dependencies in order to fix CI
https://reviews.llvm.org/B238938

clayborg requested changes to this revision.Jun 15 2023, 1:52 PM

Very easy fix for this as suggested in code changes and this will be good to go

lldb/source/Plugins/Platform/Android/PlatformAndroid.h
73

Using the "SP" suffix is for std::shared_ptr, "UP" is for unique pointers.

This revision now requires changes to proceed.Jun 15 2023, 1:52 PM
bulbazord added inline comments.Jun 15 2023, 1:52 PM
lldb/source/Plugins/Platform/Android/PlatformAndroid.cpp
213

GetAdbClient() calls make_unique which can fail. You'll want to add some checks when using all the adb objects in this file.

lldb/source/Plugins/Platform/Android/PlatformAndroid.h
73

SP -> shared_ptr. Was this supposed to be std::shared_ptr? If it's supposed to be a unique_ptr, you probably want AdbClientUP.

74

I feel a little strange about this one because it's possible to create 2 AdbClients from the same PlatformAndroid ID, both are unique pointers and essentially do the same thing. Maybe PlatformAndroid can own an AdbClient that it vends through GetAdbClient?

splhack added inline comments.Jun 15 2023, 2:47 PM
lldb/source/Plugins/Platform/Android/PlatformAndroid.cpp
213

will do!

lldb/source/Plugins/Platform/Android/PlatformAndroid.h
73

@bulbazord @clayborg thanks, and oops didn't realize UP. will fix.

74

Yes, it's a bit strange how PlatformAndroid currently uses AdbClient. But, the scope of this diff is to unblock us first to write PlatformAndroid unittest with gmock + virtual. We will revisit for the structure change later.

splhack updated this revision to Diff 532196.Jun 16 2023, 9:22 AM
  • s/AdbClientSP/AdbClientUP/g
  • Updated Status &error arg to GetAdbClient
  • Added error checks in AndroidPlatform for GetAdbClient
  • Added DownloadModuleSliceWithAdbClientError test for the GetAdbClient error
clayborg added inline comments.Jun 20 2023, 1:25 PM
lldb/source/Plugins/Platform/Android/PlatformAndroid.cpp
204

Do we want the PlatformAndroid object to have a member variable that stores the AdbClientUP as a member variable so we don't need to recreate this all the time? If the object isn't expensive to create and destroy, no worries, but if it is, then we might want to have a member variable

402

We could cache the AdbClient object and return just a pointer here. The idea would be to have a member variable in PlatformAndroid object and then return just a "AdbClient *" from this function. This would stop us from creating and destroying a AdbClient object each time this is called.

clayborg accepted this revision.Jun 20 2023, 1:41 PM

Lets get this patch in so we have testing. We can work on caching the AdbClient internally in an ivar of PlatformAndroid in follow up patches.

This revision is now accepted and ready to land.Jun 20 2023, 1:41 PM

I will submit a diff to deal with how to use the AdbClient in PlatformAndroid later. Most likely we could use only one instance of AdbClient.

This revision was automatically updated to reflect the committed changes.