How to debug aspectd?
Make sure that you've read README.md and can run the example embedded.
Let's take android as an example.
flutter run -d xxxxx --verbose --release
import 'package:flutter_tools/executable.dart' as executable;
void main(List<String> args) {
print("[KWLM]:${args.join(' ')}");
executable.main(args);
}
kylewong@KyleWongs-Work-MBP aspectd % which flutter
/Users/kylewong/Codes/Flutter/alibaba-flutter/StableV1.22.x/taobao/flutter/bin/flutter
kylewong@KyleWongs-Work-MBP aspectd % rm /Users/kylewong/Codes/Flutter/alibaba-flutter/StableV1.22.x/taobao/flutter/bin/cache/flutter_tools.stamp
kylewong@KyleWongs-Work-MBP example % flutter run -d PQY0220C11037930 --verbose --release
[KWLM]:run -d PQY0220C11037930 --verbose --release
*******
[KWLM]:--verbose assemble --depfile
/Users/kylewong/Codes/Flutter/alibaba-flutter/Middleware/aspectd/example/build/app/intermediates/flutter/release/flutter_build.d --output /Users/kylewong/Codes/Flutter/alibaba-flutter/Middleware/aspectd/example/build/app/intermediates/flutter/release -dTargetFile=/Users/kylewong/Codes/Flutter/alibaba-flutter/Middleware/aspectd/example/lib/main.dart -dTargetPlatform=android -dBuildMode=release -dTrackWidgetCreation=true android_aot_bundle_release_android-arm64
Notice that the breakpoint would enter twice as one for example project and another for aspectd_impl. We want to know what parameters are passed to frontend_server.dart.snapshot when building dill for aspectd_impl project.
Evaluate command.join(" ") to get the parameters like below:
/Users/kylewong/Codes/Flutter/alibaba-flutter/StableV1.22.x/taobao/flutter/bin/cache/dart-sdk/bin/dart --disable-dart-dev /Users/kylewong/Codes/Flutter/alibaba-flutter/StableV1.22.x/taobao/flutter/bin/cache/artifacts/engine/darwin-x64/frontend_server.dart.snapshot --sdk-root /Users/kylewong/Codes/Flutter/alibaba-flutter/StableV1.22.x/taobao/flutter/bin/cache/artifacts/engine/common/flutter_patched_sdk_product/ --target=flutter -Ddart.developer.causal_async_stacks=false -Ddart.vm.profile=false -Ddart.vm.product=true --bytecode-options=source-positions --aot --tfa --packages /Users/kylewong/Codes/Flutter/alibaba-flutter/Middleware/aspectd/example/.packages --output-dill /Users/kylewong/Codes/Flutter/alibaba-flutter/Middleware/aspectd/example/.dart_tool/flutter_build/aaf5bbafc04eaf18a1287f2e90c38b60/app.dill --depfile /Users/kylewong/Codes/Flutter/alibaba-flutter/Middleware/aspectd/example/.dart_tool/flutter_build/aaf5bbafc04eaf18a1287f2e90c38b60/kernel_snapshot.d package:example/main.dart
kylewong@KyleWongs-Work-MBP flutter_tools % pwd
/Users/kylewong/Codes/Flutter/alibaba-flutter/StableV1.22.x/taobao/flutter/packages/flutter_tools
kylewong@KyleWongs-Work-MBP flutter_tools % mkdir .dart_tool
In order to debug aspectd package, I mean the dill manipulating logic, a lot of dart sdk dependency is needed. You can copy the package_config.json (aspectd/lib/src/flutter_frontend_server/package_config.json) to aspectd/.dart_tool. Remember to modify package_config.json with absolute path. For example, modify ""../../../third_party/dart/pkg/_fe_analyzer_shared"," to ""rootUri": "file:///Users/kylewong/.pub-cache/git/sdk-e0932796a56a8de60c77923a69b98fdafd0d8db1/pkg/_fe_analyzer_shared",".
In aspectd, we compile the frontend_server.dart.snapshot with starter.dart, so you can launch it in source mode with parameters above for frontend_server.dart.snapshot.
Now you can debug the transformer logic, enjoy.