I am trying to inspect the result of a Ktor HTTP c...
# kotlin-native
p
I am trying to inspect the result of a Ktor HTTP call in Native using the lldb debugger. I’ve ran this line, which pretty prints the
result
of the call.
Copy code
(lldb) command script import konan_lldb.py
(lldb) p result
(ObjHeader *) $1776 = {'exception': {'stackTraceStrings$delegate': '...', 'message': 'Bad response: HttpResponse[<https://example.com/v1.0/authentication>, 401 Unauthorized]', 'cause': None, 'stackTrace': ['0x0000000100064397', '0x000000010005d7f5', '0x000000010005d3b5', '0x000000010005d995', '0x00000001002e916f', '0x00000001002e8c00', '0x00000001002ea3ea', '0x00000001002ea980', '0x00000001002f29cd', '0x00000001002f2d04'], 'response': '...'}}
How would I now display the
response
property of the result? What is the best way to access it and display it in a readable format?
v
It’s recommended to use IDE, otherwise you can use python scripts to access children.
p
How do I use the IDE? It doesn't work for me right now, breakpoints are just skipped.
k
Patrick, 1. assuming you are using IDEA 2019.3; 2. with “Native Debug for IntelliJ” plugin installed/turned on; 3. if you are using last IDE Kotlin plugin so far
1.3.70-eap-184
then pick
Kotlin Line Breakpoint
4. othervise just
Line Breakpoint
. This is supposed to work when your executable is being run by gradle task from within IDEA.
r
Native Debug for IntelliJ
plugin does not allow you to specify a binary to run (CLion allows it) which is useful if you are debugging a shared library built in kotlin native. CLion support is quite buggy - it's quite slow to show debug variables. I had better experience debugging a shared library built with kotlin native in QtCreator than in CLion.
k
@raniejade Ranie, thanks for your feedback. Could you please elaborate a little? In IDEA you could use different Gradle tasks (they are supposed to be generated for each binary in your project). Is there are some binaries, which are not covered or just an overall experience of switching Gradle tasks is not comfy?
r
As I've said I wanted to debug a shared library not an executable. CLion's run configuration allows me to setup a different executable to run (that executable will load the shared library), but IJ's run configuration does not.
This is the run configuration for IJ
And this is for CLion. As you can see it has the
Executable
dropdown - which allows me to choose an external executable.
Also while I got your attention, Kotlin\Native plugin for CLion breaks the attach to process feature. https://youtrack.jetbrains.com/issue/KT-35869. I had to downgrade to earlier JBR version (JBR 8 to be exact).
k
Now I understood. Thanks again for this use case. We will think about what to do with it.
r
@Kirill Shmakov [JB] since the Kotlin Native plugin for CLion is being deprecated, are we getting the ability to select external executable when debugging KN binaries in IntelliJ IDEA Ultimate?
🙏 1
k
@raniejade we want to support attach to process functionality in IDEA (this issue is planned for some time, but is being postponed due to more important work). Thanks for your question, I’ve added your request as a prerequisite for it: https://youtrack.jetbrains.com/issue/KT-40954
r
Cool, thanks! I couldn't see the ticket you linked, is it an internal one?
1