Fix dotnet-dsrouter Android port reverse local/remote ports.#4342
Merged
lateralusX merged 1 commit intodotnet:mainfrom Oct 19, 2023
Merged
Conversation
Member
|
I built a local branch based on this PR and validated that dotnet-dsrouter
Started an Android app with dotnet-trace
|
jonathanpeppers
approved these changes
Oct 19, 2023
Member
jonathanpeppers
left a comment
There was a problem hiding this comment.
Appears to work for me, too:
D:\src\dotnet\diagnostics\src\Tools\dotnet-dsrouter [lateralusX/fix-android-port-reverse]> dotnet run -- android -v debug
WARNING: dotnet-dsrouter is a development tool not intended for production environments.
How to connect current dotnet-dsrouter pid=12968 with android device and diagnostics tooling.
Start an application on android device with ONE of the following environment variables set:
[Default Tracing]
DOTNET_DiagnosticPorts=127.0.0.1:9000,nosuspend,connect
[Startup Tracing]
DOTNET_DiagnosticPorts=127.0.0.1:9000,suspend,connect
Run diagnotic tool connecting application on android device through dotnet-dsrouter pid=12968:
dotnet-trace collect -p 12968
See https://learn.microsoft.com/en-us/dotnet/core/diagnostics/dotnet-dsrouter for additional details and examples.
info: dotnet-dsrouter-12968[0]
Starting dotnet-dsrouter using pid=12968
dbug: dotnet-dsrouter-12968[0]
Using default IPC server path, dotnet-diagnostic-dsrouter-12968.
dbug: dotnet-dsrouter-12968[0]
Attach to default dotnet-dsrouter IPC server using --process-id 12968 diagnostic tooling argument.
dbug: dotnet-dsrouter-12968[0]
Executing D:\android-toolchain\sdk\platform-tools\adb reverse --list.
fail: dotnet-dsrouter-12968[0]
stderr: * daemon not running; starting now at tcp:5037
* daemon started successfully
dbug: dotnet-dsrouter-12968[0]
Executing D:\android-toolchain\sdk\platform-tools\adb reverse tcp:9000 tcp:9001.
info: dotnet-dsrouter-12968[0]
Starting IPC server (dotnet-diagnostic-dsrouter-12968) <--> TCP server (127.0.0.1:9001) router.
Then I can get a profile from a device:
> dotnet-trace collect -p 12968 --format speedscope
No profile or providers specified, defaulting to trace profile 'cpu-sampling'
Provider Name Keywords Level Enabled By
Microsoft-DotNETCore-SampleProfiler 0x0000F00000000000 Informational(4) --profile
Microsoft-Windows-DotNETRuntime 0x00000014C14FCCBD Informational(4) --profile
Process : D:\src\dotnet\diagnostics\artifacts\bin\dotnet-dsrouter\Debug\net6.0\dotnet-dsrouter.exe
Output File : D:\src\dotnet-dsrouter.exe_20231019_102830.nettrace
[00:00:00:04] Recording trace 2.7577 (MB)
Press <Enter> or <Ctrl+C> to exit...
Stopping the trace. This may take several minutes depending on the application being traced.
Trace completed.
Writing: D:\src\dotnet-dsrouter.exe_20231019_102830.speedscope.json
Conversion complete
tommcdon
approved these changes
Oct 19, 2023
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The use of automatic port forwarding on Android device used the same port as local and remote, that should be possible, but turns out there is some issue with
adbaround that configuration when running against a physical Android device (works when using port forwarding/reverse against Android emulator).This PR change the port defaults and align to Xamarin Android documentation as well as using different ports for local and remove when using -
tcpsor -tcpcarguments together with--forward-port android.When running using the "Android" connect profile,
dotnet-dsrouter androidwe will default to 9001 as local/host and 9000 as remote/device port.When running with -
tcpsor -tcpcwe will use passed port as local/host port and then set the remote/device port to local/host port - 1 in call toadb reverse|forward.Fixes #4337