Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disassembly View: Milestone 2 #129762

Open
1 of 11 tasks
yuehuang010 opened this issue Jul 29, 2021 · 35 comments
Open
1 of 11 tasks

Disassembly View: Milestone 2 #129762

yuehuang010 opened this issue Jul 29, 2021 · 35 comments
Assignees
Labels
debug Debug viewlet, configurations, breakpoints, adapter issues debug-disassembly feature-request Request for new features or functionality
Milestone

Comments

@yuehuang010
Copy link
Contributor

yuehuang010 commented Jul 29, 2021

Use this to keep track of work for the next milestone.

Features:

  • Show/Hide source code between instructions.
  • Horizontal Scrolling
  • Enable/Disable/Condition for Instruction Breakpoints Instruction breakpoints can not be disabled #129571
  • Copy Blocks of instruction
  • Show/Hide/Rearrange Columns
  • GoTo Disassembly at a specific address

Bugs from Test Disassembly View #129161

@yuehuang010
Copy link
Contributor Author

@isidorn @weinand

@isidorn isidorn self-assigned this Jul 29, 2021
@isidorn isidorn added the debug Debug viewlet, configurations, breakpoints, adapter issues label Jul 29, 2021
@isidorn isidorn added this to the August 2021 milestone Jul 29, 2021
@isidorn
Copy link
Contributor

isidorn commented Jul 29, 2021

@yuehuang010 Thanks for creating this. We can find all disassembly open issues by looking at what is linked from the test plan item here #129161
And looking at open issues assigned to August that have debug label https://github.com/microsoft/vscode/issues?q=is%3Aopen+is%3Aissue+milestone%3A%22August+2021%22+label%3Adebug

@xisui-MSFT
Copy link
Contributor

@isidorn Can you please help me to investigate how to fix an element from horizontally scrolling in a list? Thanks!

@isidorn
Copy link
Contributor

isidorn commented Aug 6, 2021

@xisui-MSFT yes, but can you clarify, what is the actual issue? Elements should not automatically horizontally scroll as far as I know and there is no programatic way to control horizontal scrolling.

@xisui-MSFT
Copy link
Contributor

xisui-MSFT commented Aug 6, 2021

@isidorn Yes. In the original PR we talked about changing the table to a list, to support horizontal scrolling. However, I wasn't able to find a way to fix the breakpoint column (or elements, since we don't have a column concept in list anymore) from scrolling horizontally. Original discussion: #125737 (comment)

Also another question, we would like to implement show/hide source code function, so the source lines (zero or more) can be shown above the corresponding disassembly lines or hidden. I.e., switching between

...
disassembly 1
disassembly 2
disassembly 3
...

and

...
source A
source B
disassembly 1
source C
disassembly 2
disassembly 3
..

I'm not sure we can do this easily using list? Also looked at trees, doesn't seem to be what we want since this is not a one-to-many map but more like a many-to-many one... It would be great if you could provide some suggestions. Thanks!

@isidorn
Copy link
Contributor

isidorn commented Aug 6, 2021

  1. Aha, so you want to be able to horizontally scroll while still having the breakpoint visible. I suggest to create a new issue and we continue the discussion there. I am not 100% sure how to achieve this but CSS tricks should be possible.
  2. For show / hide source function. I would add a context menu action Show Source Function / Hide Source Function. Once that action is triggered you would splice the whole table and your model should be aware that it now needs to feed in the source lines to the tableDataSource. For source lines you would introduce a new renderer and that is it. So should be possible and not hard.

@yuehuang010
Copy link
Contributor Author

Hi @isidorn, I am looking to adding Show Source Code. From the disassembly, it provides URI and line number.
I see that ITextModel has getLineContent() but I am not sure how to get TextModel. Maybe use NativeTextFileService to open the stream to new TextModel? Another concern is caching, I want to limit open and closing the same file. Are there existing tool for this?
Thanks.

@isidorn
Copy link
Contributor

isidorn commented Aug 18, 2021

@yuehuang010 can you clarify? Do you have an URI and a line number and just want to open an editor for those? In that case just use the editorService.openEditor and pass your uri and lineNumber.

@yuehuang010
Copy link
Contributor Author

@isidorn, here is the view in VS. The source code of cpp has is intereved between disassembly.
MicrosoftTeams-image (1)

The disassemble response contains "Source" information such as filepath, start/end line and column. The viewer needs to render the file content. It is like a simpler "peek" view. Showing "colorization" is an added benefit that is not required. A link to open the file should the user decide to make edits is possible.

@isidorn
Copy link
Contributor

isidorn commented Aug 19, 2021

@yuehuang010 ok great, so you would handle the rendering in your table by having special elements that are actually representing the source lines, that way it would be inter-mingled. You will not have colorisation here easily.

Context menu -> "Open Source in Editor" -> use the editor service to open the URI as I suggested in the comment above.

@yuehuang010
Copy link
Contributor Author

@isidorn, Is using NativeTextFileService nad TextModel the way to go? Or are there another way to open the file?

@isidorn
Copy link
Contributor

isidorn commented Aug 19, 2021

@yuehuang010 you should just use the editorService. Here's an example here https://github.com/microsoft/vscode/blob/main/src/vs/workbench/contrib/debug/common/debugSource.ts#L76

I hope that helps!

@Trass3r
Copy link

Trass3r commented Aug 19, 2021

@isidorn, here is the view in VS. The source code of cpp has is intereved between disassembly.

Could we open the disassembly view in a new tab group to the right until this more involved solution is done? It's annoying having to drag it manually every time just to see both source code and assembly.

Also another thought, when the source code is not available for whatever reason VS automatically shows the disassembly.

@isidorn
Copy link
Contributor

isidorn commented Aug 20, 2021

Always opening the disassembly view On the Side might make sense. Let's see what @yuehuang010 and @xisui-MSFT think

As for the second one (when source not available to automatically show), that sounds like a feature request. I suggest you file a new issue and then we can see to potentially add it in the future. I would not do this for starters, but only once we polish the current view much more.

@yuehuang010
Copy link
Contributor Author

yuehuang010 commented Aug 20, 2021

@Trass3r @isidorn SideBySide source code is ok if the disassembly lines up with one file. But code can jump around between multiple source with inlining, function calls etc.

We might consider it as feature, but won't be on by default.

@Trass3r
Copy link

Trass3r commented Aug 20, 2021

True if you step side-by-side it syncs properly as long as you stay in the same source file but doesn't jump to other files when you reach them.
Can totally be a controlled by a setting.

Also btw, I noticed when testing this with the C++ extension that a disassemble request is sent before I even switch to disassembly. Is this a bug on the vscode side?

@yuehuang010
Copy link
Contributor Author

"disassemble called made when view is closed", Someone else mentioned it, I will look into it. soon.

@xisui-MSFT
Copy link
Contributor

"disassemble called made when view is closed", Someone else mentioned it, I will look into it. soon.

Currently it loads disassembly on pause debugging. We should probably add a focus check.

@jureid
Copy link

jureid commented Nov 4, 2021

A customer at CppCon has a few feature requests for Disassembly View:

  • Support for intel syntax in the disassembly (preferred to AT&T syntax). @WardenGnaw are you the right person to talk to about this?
  • More information in the tab title about what is being disassembled. For example "my_bin (Disassembly)" or "my_func (Disassembly)" would be helpful, depending on whether you're showing disassembly for a single function or a whole binary.

@xisui-MSFT
Copy link
Contributor

More information in the tab title about what is being disassembled. For example "my_bin (Disassembly)" or "my_func (Disassembly)" would be helpful, depending on whether you're showing disassembly for a single function or a whole binary.

@jureid We always show disassembly of the whole binary (load on scroll), and never a single function/file.

@Trass3r
Copy link

Trass3r commented Nov 4, 2021

* Support for intel syntax in the disassembly (preferred to AT&T syntax).

+1 att is horrible.
Workaround is adding set disassembly-flavor intel to .gdbinit.

@yuehuang010
Copy link
Contributor Author

* Support for intel syntax in the disassembly (preferred to AT&T syntax).

+1 att is horrible. Workaround is adding set disassembly-flavor intel to .gdbinit.

Is this something the C++ extension should handle?

@WardenGnaw
Copy link
Member

* Support for intel syntax in the disassembly (preferred to AT&T syntax).

+1 att is horrible. Workaround is adding set disassembly-flavor intel to .gdbinit.

Is this something the C++ extension should handle?

Yes. Disassembly flavor should be set by the debug adapter.

@AnthonyLeonardoGracio
Copy link

Hello!

I was wondering how hard it would be to get a working Disassembly view for other languages that can be debugged through GDB or LLDB? Basically we would like to get the Disassembly view working for the Ada language, but since the view is only available for C/C++ files, I can't get it work.

Does someone have ideas on how could this work? Also, let me know if this discussion should occur on a separate issue, I can open one if needed!

@haneefdm
Copy link
Contributor

The disassembly support is not dependent on the language or even the debugger like gdb/lldb. Your debug adapters (interface between gdb/lldb and VSCode) have to support it and even they do not much care (in many instances) what language is being used.

Not clear what debug adapter (or extension) you are using to debug your ADA program today...and this request would belong to that extension to support the protocols required by the VSCode disassembler (documented in the Debug Adapter Protocol).

If you can debug via gdb/lldb however, then you can even use existing debuggers (cppdbg from cpptools) to debug your executable. For instance, you can debug a program written in Rust because the compiler produces and ELF file that can be debugged via GDB/LLDB

When you setup your launch.json for cppdbg just make sure you are using your elf file if you have one and then you should be able to use it just like C/C++/Rust programmers do.

I can say this because I author a debug adapter extension that supports disassembly and any language is fine with us so long as we can debug with GDB.

@AnthonyLeonardoGracio
Copy link

Thanks for this very detailed answer @haneefdm!

Currently we are using the Native Debug extension to debug Ada code, which launches GDB basically. But when using it I don't get the 'Open disassembly view' contextual menu when debugging.

I tried to usecppdbg do debug my Ada code, but the menu was not available too, while it was the case when debugging C/C++. It may be a setup issue, I will try again. I just wanted to make sure that there is nothing that prevents me to get this feature when using GDB but for other languages such as Ada, and apparently it's the case from what you say ;)

I will try again and keep you posted then!

@haneefdm
Copy link
Contributor

Yes, Native Debug will have to support disassembly. We originally forked from that several years ago,

Note that the launch.json contents will be very different for cppdbg. Just follow instructions/examples for cppdbg as if you have a C++ program. cppdbg will not know the difference.

@AnthonyLeonardoGracio
Copy link

@haneefdm

So I have tried to use cppdg by using a simple launch.json configuration found on the web, and I am able to debug my Ada code properly on simple projects. The Open Disassembly View contextual menu is available, I can see the disassembly in the Debug Console, but I get a new view with Disassembly not available at the end, without knowing exactly why.

Any ideas of what could be wrong? I have attached my launch.json contents and a simple screenshot, if that helps.

launch.txt
Capture d’écran 2022-12-16 à 12 31 39

@haneefdm
Copy link
Contributor

Can you get disassembly from gdb command line? If not neither can cpptools. It has to do with how you compiled (did you compile for debug and saving saving/debug info).

You should file an issue with cpptools if gdb works but cpptools isn't giving you disassembly. Just for fun, try a larger program with at least a few thousand instructions.

@haneefdm
Copy link
Contributor

You can enable logging to see what commands are being sent to gdb, etc. But first, make sure your gdb is working.

@AnthonyLeonardoGracio
Copy link

Yes, I can get disassembly from GDB's command line. Note that I am also able to get the Assembly view working in GNAT Studio (an IDE dedicated to Ada), with the same compiled executable (compiled with -g -O0)

Attaching the whole GDB output: as you can see, the -data-disassemble seems to work fine.

gdb_output.txt

@AnthonyLeonardoGracio
Copy link

Any idea @haneefdm ? ;)

@haneefdm
Copy link
Contributor

haneefdm commented Jan 2, 2023

You should approach the cpptools team for help. It appears they are doing the right thing but why you are seeing an empty Disassembly window, I cannot explain.

https://github.com/microsoft/vscode-cpptools

They may direct you to VSCode main repo

@AnthonyLeonardoGracio
Copy link

Ok I will do that, thanks for your help ;)

@thegecko
Copy link
Contributor

thegecko commented Nov 9, 2023

Can this scope also include a context menu which can be a contribution point for other extensions?

ref: #171548

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
debug Debug viewlet, configurations, breakpoints, adapter issues debug-disassembly feature-request Request for new features or functionality
Projects
None yet
Development

Successfully merging a pull request may close this issue.

10 participants