exbin / bined-intellij-plugin

Hex viewer/editor plugin for JetBrains IntelliJ platform
https://bined.exbin.org/intellij-plugin
Apache License 2.0
60 stars 9 forks source link

Unable to open byte array when debugging #47

Open midoriiro opened 1 year ago

midoriiro commented 1 year ago

Could be useful to open binary editor for certain type of variable like byte array when debugging code. I'm using Rider, I don't know if that already implemented for Idea or other Jetbrains IDE's.

Any thought about it ?

hajdam commented 1 year ago

Hi, support for byte array variables is implemented only for some JetBrains IDEs due to private access to variable values and different implementations for each programming language - api only provides toString() and GUI list of child items for debugger tree... Currently Java, Python and PHP is supported and I already lost many hours while unsuccessfully trying to support C/C++ and Go...

I might try to take a look on how the C# is implemented if any reasonable method is available...

hajdam commented 1 year ago

Released version 0.2.7 with added support for some debug fields extracting data from GUI tree - might be usable for some small arrays if you want to try it...

I still didn't find proper way to access values for Rider thou...

midoriiro commented 1 year ago

I just tested it, like you said its working for small array. For large array it seem working but when I scroll down the UI freezing (I'm talking about +100K bytes in array). Do you think implementing a buffered/stream array read implementation could be possible for that use case ?

Thank for your time.

hajdam commented 1 year ago

I didn't find any stream API methods there in many wasted hours. It might be there, but:

Probably best approach would be to ask JetBrains for documentation / request API addition / pay for it or something. I have only free license from their open-source development program and I don't use Rider personally. My question about this on Slack was not responded to, so it is what it is...

hajdam commented 1 year ago

I asked for advice in JetBrain's YouTrack: https://youtrack.jetbrains.com/issue/RIDER-62867/Hex-Viewer-Like-debugger-view

midoriiro commented 1 year ago

I'm not familiar with Jetbrains API and their IDEs plugin development. But what I meant by "buffered/stream array read implementation" is to implement in the UI to read the bytes array (provided by the debugger if understand correctly) in a stream way.

Lets take an example of a binary viewer with 8 bytes/rows, the viewport show the first 20 rows, then the first 160 bytes are loaded and shown by the UI. If you scroll up/down then the UI load another part of the bytes array.

I implemented that kind of behavior for a matrix which can contains a huge amount of data for another project. This could be a possible and efficient solution, but if that caused the UI to froze is not caused by the UI code it'll not help.

I try to dig a little on the code of the plugin, I did not find anything related to the UI. The UI is provided by Jetbrains SDK or I missing something ?

hajdam commented 1 year ago

Code related to debug fields is in https://github.com/exbin/bined-intellij-plugin/tree/master/src/org/exbin/bined/intellij/debug and it's mostly a mess...

I typically use caching/double paging with 4k chunks of data and it works fine for IntelliJ IDE variant.

Except for .NET I didn't find any method to access specific part of the data - currently used method is to force load more rows into debug view tree UI on the IDE side - it's ugly hack and is causing freezing. Feel free to try to find better way...

UI stuff is typically in gui directories (packages) - not sure what are you missing. Main hex UI component is library / in separate repository https://github.com/exbin/bined-lib-java