vadimcn / codelldb

A native debugger extension for VSCode based on LLDB
https://marketplace.visualstudio.com/items?itemName=vadimcn.vscode-lldb
MIT License
2.54k stars 245 forks source link

Please support Apple silicon (M1, arm64-darwin) #397

Closed dguerri closed 3 years ago

dguerri commented 3 years ago

Hello! it would be great if vscode-lldb could support arm64-darwin (the new Mac M1 SoC)

Thanks!

vadimcn commented 3 years ago

I think it'll happen at some point, but don't hold your breath. It will take a while to figure out how to cross-compile native components, and then there's the question of testing - I don't have an arm64 Mac.

tkreindler commented 3 years ago

You could release an experimental branch, I'd be happy to test it and I'm sure others would too.

Jackkakaya commented 3 years ago

I also can help to test it.

vadimcn commented 3 years ago

By the way, what happens today if you install CodeLLDB on an arm mac?

repi commented 3 years ago

The extension installs without any reported errors, but when you try and launch a debug session with it you get:

image

This was with:

Version: 1.53.0-insider Commit: c927a8015b9e26bd454d6e293bb0384aa1975d06 Date: 2020-12-18T05:38:27.291Z Electron: 11.0.5 Chrome: 87.0.4280.88 Node.js: 12.18.3 V8: 8.7.220.29-electron.0 OS: Darwin arm64 20.1.0

vadimcn commented 3 years ago

I wonder if you could just run the x64 version under Rosetta.
If you'd like to try that:

dguerri commented 3 years ago

Folks, I managed to get it working on the Exploration version of VSCode. Pull request above. I am having a hard time building and packing llvm-project stuff. I would appreciate any help :)

Screenshot 2020-12-21 at 14 03 26
dguerri commented 3 years ago

I wonder if you could just run the x64 version under Rosetta.

I didn't try this. I may be wrong, but I don't have much hope..

Also not sure how lldb is attached to the process, but a possible problem with Rosetta is that everything spawned from a process running in emulation is also in emulation.

I had to switch to VSCode Exploratory and build rust analyser, to build and use native Rust binaries...

Lastly I wonder if debugging will work from a process in emulation.

dguerri commented 3 years ago

I could reduce the file size, but I have no idea how to create a package which doesn't depend on my environment...

Anyway, this is it https://www.icloud.com/iclouddrive/0lxZDEqpFo6d_J_rWgaI0cJug#codelldb-aarch64-darwin

Install it, in VSCode Exploratory, after installing the official extension, using the "install from VSIX" option.

dguerri commented 3 years ago

I will write a quick guide later today! ;)

dguerri commented 3 years ago

Build and install vscode-lldb for M1 (aarch64 native)

Official building instructions: https://github.com/vadimcn/vscode-lldb/blob/master/BUILDING.md

Prerequisites

You will need VSCode Exploratory as M1 is still not supported by VSCode Insider or Stable.

Install Xcode tools

xcode-select --install

Install Rust

Rust (rustup) stable is still not available on M1. This will change soon, but for now, see this thread https://github.com/rust-lang/rustup/issues/2413

Install Macports I use Macports, I think Homebrew (native for M1) should work too, bit in this guide I am assuming you bave Macports installed.

https://www.macports.org

[optional] ccache At this stage, if you want native stuff for your Mac, chances are that you are going to build (and rebuild) a lot of stuff. So, I recommend installing ccache.

Of course, this is not going to save you time for llvm (see below), at least the first time.

llvm and vscode-lldb dependecies

sudo port install cmake nodejs15 npm6

Building stuff

build llvm

git clone https://github.com/llvm/llvm-project.git
cd llvm-project ; mkdir build ; cd build
cmake ../llvm -DLLVM_ENABLE_PROJECTS="clang;libcxx;lldb"
make lldb lldb-server

That is going to take a while.

create a zip with llvm

cd lldb
zip -r lldb-m1.zip bin/ lib/liblldb.12.0.0git.dylib lib/liblldb.dylib

The content of the archive will be used by vscode-lldb later. Note that the content of lldb-m1.zip will probably only work on your local machine as a lot of other dependencies are left outside (e.g. debugserver and required libs).

building vscode-lldb

git clone https://github.com/vadimcn/vscode-lldb.git
cd vscode-lldb
git submodule update --init --recursive
npm install
mkdir build ; cd build
mkdir lldb
mv <location of lldb-m1.zip you create belore> lldb/
LLDB_PACKAGE=./lldb-m1.zip cmake ..
make vsix_full

If everything goes well:

mv codelldb-full.vsix codelldb-aarch64-darwin.vsix

Install the official vscode-lldb extension and reload.

Install codelldb-aarch64-darwin.vsix via "Install from VSIX..." in the extension menu of VSCode Exploratory.

vadimcn commented 3 years ago

I didn't try this. I may be wrong, but I don't have much hope..

Could somebody with M1 Mac try this out please?

dguerri commented 3 years ago

Could somebody with M1 Mac try this out please?

On Exploration and Stable, debug fails with -1. In system logs I see:

default 13:31:25.484895+0000    debugserver debugserver will use os_log for internal logging.
default 13:31:25.485389+0000    debugserver debugserver-@(#)PROGRAM:debugserver  PROJECT:debugserver-1001.0.13.3
 for x86_64.
default 13:31:25.485477+0000    debugserver Got a connection, waiting for process information for launching or attaching.
default 13:31:25.523638+0000    debugserver 1 +0.000000 sec [13158/0203]: error: ::task_set_exception_ports ( task = 0x5403, exception_mask = 0x00001bfe, new_port = 0x5303, behavior = 0x80000001, new_flavor = 0x0000000d ) err = (os/kern) invalid argument (0x00000004)
error   13:31:25.523756+0000    debugserver error: Attach failed: "(os/kern) invalid argument".
default 13:31:25.523777+0000    debugserver error: attach failed.
default 13:31:25.523829+0000    debugserver 2 +0.000211 sec [13158/1b03]: error: ::read ( 15, 0x30ccbbb10, 1024 ) => -1 err = Bad file descriptor (0x00000009)
default 13:31:25.523859+0000    debugserver Exiting.

I think this is because the process is aarch64 but debugserver is expecting x86_64.

The Rust binary I am trying to debug is for arm64 as the system rust is native. I wonder what happens using Rosetta and x86 rustc...

FWIW, on Stable I don't need to add "arm64-darwin": "codelldb-x86_64-darwin.vsix" in package.json, maybe because VSCode is telling code-lldb that the platform is x86_64 ?

stefhol commented 3 years ago

I wonder if you could just run the x64 version under Rosetta. If you'd like to try that:

  • Install extension.
  • Open $HOME/.vscode/extensions/vadimcn.vscode-lldb-1.6.0/package.json in a text editor.
  • Find platforms section (near the bottom).
  • Add "arm64-darwin": "codelldb-x86_64-darwin.vsix", line into it.
  • Restart VSCode, see if debugging works.

It does not work. With the VSCode Rosetta Version aka the normal one the debugger loads the default Mac x86 and fails with error 1 Doing it with the arm Insider Version (which displays normally unsupported Plattform) results the same

How is lldb called? Maybe if its called from bash it has to be" arch -x86_64 lldb" instead "lldb" for the x64 version

vadimcn commented 3 years ago

@dguerri: I would prefer not to release code I cannot personally build and test myself, because I am sure there will be problems that other users will hit (they always do) and this will come back to me, and I won't be able to do anything about it.

You could argue that the same may happen if running under Rosetta, and I would agree. I am still not convinced that I want to do this, but at least the extra effort spent on that would be minimal.

Longer term, I hope that cloud CI systems catch up with Apple silicon and figure out how to build and test for it. Maybe somebody will figure out how to emulate arm64 OSX in a VM, or, perhaps, some cloud provider will offer Apple hardware that can be remoted into.

Regarding your findings (and thanks for trying this out!):

On Exploration and Stable, debug fails with -1. In system logs I see:

Could you please also attach codelldb's verbose log?

I think this is because the process is aarch64 but debugserver is expecting x86_64.

There's no obvious reason (to me at least), why x86 debugger could not debug arm executables. After all, this is routinely done during remote debugging.
There's a way to specify target architecture in lldb - you need to use custom launch and use target create --arch aarch64 <filename> to create the debug target.

In case there is indeed a restriction on architecture of the process using debugging APIs, here's another thing to try: set LLDB_DEBUGSERVER_PATH=<path to arm64 debugserver> via lldb.adapterEnv.

Thanks!

stefhol commented 3 years ago

This is with default VSCode Rosetta Version Edit: With Arm Rust Version

`warning: function is never used: `get_adjacent`
   --> src/main.rs:115:4
    |
115 | fn get_adjacent(place : &Place,v: &[Vec<Place>]) -> usize {
    |    ^^^^^^^^^^^^

warning: 34 warnings emitted

    Finished dev [unoptimized + debuginfo] target(s) in 0.02s
Raw artifacts:
{
  fileName: '/Users/user/Documents/git/coding-advent-2020/day11/target/debug/day11',
  name: 'day11',
  kind: 'bin'
}
configuration: {
  type: 'lldb',
  request: 'launch',
  name: 'Cargo launch',
  program: '/Users/user/Documents/git/coding-advent-2020/day11/target/debug/day11',
  args: [],
  __configurationTarget: 5,
  relativePathBase: '/Users/user/Documents/git/coding-advent-2020/day11',
  sourceLanguages: [ 'rust' ]
}
liblldb: /Users/user/.vscode/extensions/vadimcn.vscode-lldb-1.6.0/lldb/lib/liblldb.dylib
environment: {}
params: { sourceLanguages: [ 'rust' ] }
Listening on port 55750
[2020-12-22T13:30:28Z DEBUG codelldb] New debug session
INFO(Python) 14:30:28 formatters: Initializing
INFO(Python) 14:30:28 formatters.rust: Initializing
[2020-12-22T13:30:28Z DEBUG codelldb::dap_codec] --> {"command":"initialize","arguments":{"clientID":"vscode","clientName":"Visual Studio Code","adapterID":"lldb","pathFormat":"path","linesStartAt1":true,"columnsStartAt1":true,"supportsVariableType":true,"supportsVariablePaging":true,"supportsRunInTerminalRequest":true,"locale":"en-us","supportsProgressReporting":true,"supportsInvalidatedEvent":true},"type":"request","seq":1}
[2020-12-22T13:30:28Z DEBUG codelldb::dap_codec] <-- {"type":"response","request_seq":1,"success":true,"command":"initialize","body":{"exceptionBreakpointFilters":[{"default":true,"filter":"rust_panic","label":"Rust: on panic"}],"supportTerminateDebuggee":true,"supportsCancelRequest":true,"supportsCompletionsRequest":true,"supportsConditionalBreakpoints":true,"supportsConfigurationDoneRequest":true,"supportsDataBreakpoints":true,"supportsDelayedStackTraceLoading":true,"supportsEvaluateForHovers":true,"supportsFunctionBreakpoints":true,"supportsGotoTargetsRequest":true,"supportsHitConditionalBreakpoints":true,"supportsLogPoints":true,"supportsReadMemoryRequest":true,"supportsRestartFrame":true,"supportsSetVariable":true}}
[2020-12-22T13:30:28Z DEBUG codelldb::dap_codec] --> {"command":"launch","arguments":{"type":"lldb","request":"launch","name":"Cargo launch","program":"/Users/user/Documents/git/coding-advent-2020/day11/target/debug/day11","args":[],"__configurationTarget":5,"relativePathBase":"/Users/user/Documents/git/coding-advent-2020/day11","sourceLanguages":["rust"],"_adapterSettings":{"displayFormat":"auto","showDisassembly":"auto","dereferencePointers":true,"suppressMissingSourceFiles":true,"evaluationTimeout":5,"consoleMode":"commands","sourceLanguages":null,"terminalPromptClear":null},"__sessionId":"cec01fc1-85d0-4c8f-90c3-0549393de6c7"},"type":"request","seq":2}
[2020-12-22T13:30:28Z DEBUG codelldb::dap_codec] <-- {"type":"event","seq":1,"event":"initialized"}
[2020-12-22T13:30:28Z DEBUG codelldb::dap_codec] <-- {"type":"request","seq":2,"command":"runInTerminal","arguments":{"args":["/Users/user/.vscode/extensions/vadimcn.vscode-lldb-1.6.0/adapter/codelldb","terminal-agent","--port=55752"],"cwd":"","kind":"integrated","title":"Cargo launch"}}
[2020-12-22T13:30:28Z DEBUG codelldb::dap_codec] --> {"command":"setBreakpoints","arguments":{"source":{"name":"main.rs","path":"/Users/user/Documents/git/coding-advent-2020/day11/src/main.rs"},"lines":[13],"breakpoints":[{"line":13}],"sourceModified":false},"type":"request","seq":3}
[2020-12-22T13:30:28Z DEBUG codelldb::dap_codec] <-- {"type":"response","request_seq":3,"success":true,"command":"setBreakpoints","body":{"breakpoints":[{"id":1,"line":13,"message":"Locations: 1","verified":true}]}}
[2020-12-22T13:30:28Z DEBUG codelldb::dap_codec] --> {"command":"setFunctionBreakpoints","arguments":{"breakpoints":[]},"type":"request","seq":4}
[2020-12-22T13:30:28Z DEBUG codelldb::dap_codec] <-- {"type":"response","request_seq":4,"success":true,"command":"setFunctionBreakpoints","body":{"breakpoints":[]}}
[2020-12-22T13:30:28Z DEBUG codelldb::dap_codec] --> {"command":"setDataBreakpoints","arguments":{"breakpoints":[]},"type":"request","seq":5}
[2020-12-22T13:30:28Z DEBUG codelldb::dap_codec] <-- {"type":"response","request_seq":5,"success":true,"command":"setDataBreakpoints","body":{"breakpoints":[]}}
[2020-12-22T13:30:28Z DEBUG codelldb::dap_codec] --> {"command":"setExceptionBreakpoints","arguments":{"filters":["rust_panic"]},"type":"request","seq":6}
[2020-12-22T13:30:28Z DEBUG codelldb::dap_codec] <-- {"type":"response","request_seq":6,"success":true,"command":"setExceptionBreakpoints"}
[2020-12-22T13:30:28Z DEBUG codelldb::dap_codec] --> {"type":"response","seq":7,"command":"runInTerminal","request_seq":2,"success":true,"body":{"shellProcessId":43675}}
[2020-12-22T13:30:28Z DEBUG codelldb::dap_codec] --> {"command":"configurationDone","type":"request","seq":8}
[2020-12-22T13:30:28Z DEBUG codelldb::dap_codec] <-- {"type":"response","request_seq":8,"success":true,"command":"configurationDone"}
[2020-12-22T13:30:28Z DEBUG codelldb::dap_codec] --> {"command":"threads","type":"request","seq":9}
[2020-12-22T13:30:28Z DEBUG codelldb::dap_codec] <-- {"type":"response","request_seq":9,"success":true,"command":"threads","body":{"threads":[]}}
[2020-12-22T13:30:28Z DEBUG codelldb::dap_codec] <-- {"type":"event","seq":3,"event":"output","body":{"output":"Launching: /Users/user/Documents/git/coding-advent-2020/day11/target/debug/day11\n"}}
[2020-12-22T13:30:28Z ERROR codelldb::debug_session] process exited with status -1 (Error 1)
[2020-12-22T13:30:28Z DEBUG codelldb::dap_codec] <-- {"type":"response","request_seq":2,"success":false,"message":"process exited with status -1 (Error 1)","show_user":true}
[2020-12-22T13:30:28Z DEBUG codelldb::dap_codec] --> {"command":"disconnect","arguments":{"restart":false},"type":"request","seq":10}
[2020-12-22T13:30:28Z DEBUG codelldb::dap_codec] <-- {"type":"response","request_seq":10,"success":true,"command":"disconnect"}
[2020-12-22T13:30:28Z DEBUG codelldb::dap_session] Client has disconnected
[2020-12-22T13:30:28Z DEBUG codelldb::debug_session] End of the requests stream
[2020-12-22T13:30:28Z DEBUG codelldb::debug_session] DebugSession::drop()
[2020-12-22T13:30:28Z DEBUG codelldb] Session has ended
[2020-12-22T13:30:28Z DEBUG codelldb] Exiting
Debug adapter exit code=0, signal=null.`

With x86 Rust on x86 VScode


    Finished dev [unoptimized + debuginfo] target(s) in 4.10s
Raw artifacts:
{
  fileName: '/Users/user/Documents/git/coding-advent-2020/day11/target/debug/day11',
  name: 'day11',
  kind: 'bin'
}
configuration: {
  type: 'lldb',
  request: 'launch',
  name: 'Cargo launch',
  program: '/Users/user/Documents/git/coding-advent-2020/day11/target/debug/day11',
  args: [],
  __configurationTarget: 5,
  relativePathBase: '/Users/user/Documents/git/coding-advent-2020/day11',
  sourceLanguages: [ 'rust' ]
}
liblldb: /Users/user/.vscode/extensions/vadimcn.vscode-lldb-1.6.0/lldb/lib/liblldb.dylib
environment: {}
params: { sourceLanguages: [ 'rust' ] }
Listening on port 56184
[2020-12-22T13:52:11Z DEBUG codelldb] New debug session
INFO(Python) 14:52:12 formatters: Initializing
INFO(Python) 14:52:12 formatters.rust: Initializing
[2020-12-22T13:52:12Z DEBUG codelldb::dap_codec] --> {"command":"initialize","arguments":{"clientID":"vscode","clientName":"Visual Studio Code","adapterID":"lldb","pathFormat":"path","linesStartAt1":true,"columnsStartAt1":true,"supportsVariableType":true,"supportsVariablePaging":true,"supportsRunInTerminalRequest":true,"locale":"en-us","supportsProgressReporting":true,"supportsInvalidatedEvent":true},"type":"request","seq":1}
[2020-12-22T13:52:12Z DEBUG codelldb::dap_codec] <-- {"type":"response","request_seq":1,"success":true,"command":"initialize","body":{"exceptionBreakpointFilters":[{"default":true,"filter":"rust_panic","label":"Rust: on panic"}],"supportTerminateDebuggee":true,"supportsCancelRequest":true,"supportsCompletionsRequest":true,"supportsConditionalBreakpoints":true,"supportsConfigurationDoneRequest":true,"supportsDataBreakpoints":true,"supportsDelayedStackTraceLoading":true,"supportsEvaluateForHovers":true,"supportsFunctionBreakpoints":true,"supportsGotoTargetsRequest":true,"supportsHitConditionalBreakpoints":true,"supportsLogPoints":true,"supportsReadMemoryRequest":true,"supportsRestartFrame":true,"supportsSetVariable":true}}
[2020-12-22T13:52:12Z DEBUG codelldb::dap_codec] --> {"command":"launch","arguments":{"type":"lldb","request":"launch","name":"Cargo launch","program":"/Users/user/Documents/git/coding-advent-2020/day11/target/debug/day11","args":[],"__configurationTarget":5,"relativePathBase":"/Users/user/Documents/git/coding-advent-2020/day11","sourceLanguages":["rust"],"_adapterSettings":{"displayFormat":"auto","showDisassembly":"auto","dereferencePointers":true,"suppressMissingSourceFiles":true,"evaluationTimeout":5,"consoleMode":"commands","sourceLanguages":null,"terminalPromptClear":null},"__sessionId":"e55821da-d8df-446b-a1b4-709459004938"},"type":"request","seq":2}
[2020-12-22T13:52:12Z DEBUG codelldb::dap_codec] <-- {"type":"event","seq":1,"event":"initialized"}
[2020-12-22T13:52:12Z DEBUG codelldb::dap_codec] <-- {"type":"request","seq":2,"command":"runInTerminal","arguments":{"args":["/Users/user/.vscode/extensions/vadimcn.vscode-lldb-1.6.0/adapter/codelldb","terminal-agent","--port=56186"],"cwd":"","kind":"integrated","title":"Cargo launch"}}
[2020-12-22T13:52:12Z DEBUG codelldb::dap_codec] --> {"command":"setBreakpoints","arguments":{"source":{"name":"main.rs","path":"/Users/user/Documents/git/coding-advent-2020/day11/src/main.rs"},"lines":[13],"breakpoints":[{"line":13}],"sourceModified":false},"type":"request","seq":3}
[2020-12-22T13:52:12Z DEBUG codelldb::dap_codec] <-- {"type":"response","request_seq":3,"success":true,"command":"setBreakpoints","body":{"breakpoints":[{"id":1,"line":13,"message":"Locations: 1","verified":true}]}}
[2020-12-22T13:52:12Z DEBUG codelldb::dap_codec] --> {"command":"setFunctionBreakpoints","arguments":{"breakpoints":[]},"type":"request","seq":4}
[2020-12-22T13:52:12Z DEBUG codelldb::dap_codec] <-- {"type":"response","request_seq":4,"success":true,"command":"setFunctionBreakpoints","body":{"breakpoints":[]}}
[2020-12-22T13:52:12Z DEBUG codelldb::dap_codec] --> {"command":"setDataBreakpoints","arguments":{"breakpoints":[]},"type":"request","seq":5}
[2020-12-22T13:52:12Z DEBUG codelldb::dap_codec] <-- {"type":"response","request_seq":5,"success":true,"command":"setDataBreakpoints","body":{"breakpoints":[]}}
[2020-12-22T13:52:12Z DEBUG codelldb::dap_codec] --> {"command":"setExceptionBreakpoints","arguments":{"filters":["rust_panic"]},"type":"request","seq":6}
[2020-12-22T13:52:12Z DEBUG codelldb::dap_codec] <-- {"type":"response","request_seq":6,"success":true,"command":"setExceptionBreakpoints"}
[2020-12-22T13:52:12Z DEBUG codelldb::dap_codec] --> {"command":"configurationDone","type":"request","seq":7}
[2020-12-22T13:52:12Z DEBUG codelldb::dap_codec] <-- {"type":"response","request_seq":7,"success":true,"command":"configurationDone"}
[2020-12-22T13:52:12Z DEBUG codelldb::dap_codec] --> {"type":"response","seq":8,"command":"runInTerminal","request_seq":2,"success":true,"body":{"shellProcessId":43675}}
[2020-12-22T13:52:12Z DEBUG codelldb::dap_codec] --> {"command":"threads","type":"request","seq":9}
[2020-12-22T13:52:12Z DEBUG codelldb::dap_codec] <-- {"type":"response","request_seq":9,"success":true,"command":"threads","body":{"threads":[]}}
[2020-12-22T13:52:12Z DEBUG codelldb::dap_codec] <-- {"type":"event","seq":3,"event":"output","body":{"output":"Launching: /Users/user/Documents/git/coding-advent-2020/day11/target/debug/day11\n"}}
[2020-12-22T13:52:17Z ERROR codelldb::debug_session] process resume at entry point failed: Resume timed out.
[2020-12-22T13:52:17Z DEBUG codelldb::dap_codec] <-- {"type":"response","request_seq":2,"success":false,"message":"process resume at entry point failed: Resume timed out.","show_user":true}
[2020-12-22T13:52:17Z DEBUG codelldb::debug_session] Debug event: 0x7f974bc7fed8 Event: broadcaster = 0x7f976c1f2020 (lldb.target), type = 0x00000001 (breakpoint-changed), data = {}
[2020-12-22T13:52:17Z DEBUG codelldb::debug_session] Debug event: 0x7f976bc4e6d8 Event: broadcaster = 0x7f976c1f2020 (lldb.target), type = 0x00000001 (breakpoint-changed), data = {}
[2020-12-22T13:52:17Z DEBUG codelldb::debug_session] Debug event: 0x7f974bc75a98 Event: broadcaster = 0x7f976c1f2020 (lldb.target), type = 0x00000002 (modules-loaded), data = {dyld, runtime}
[2020-12-22T13:52:17Z DEBUG codelldb::dap_codec] <-- {"type":"event","seq":4,"event":"module","body":{"module":{"addressRange":"2000A8000","id":"2000A8000","name":"dyld","path":"/usr/lib/dyld","symbolFilePath":"/usr/lib/dyld","symbolStatus":"Symbols loaded."},"reason":"new"}}
[2020-12-22T13:52:17Z DEBUG codelldb::debug_session] Debug event: 0x7f976bf08b50 Event: broadcaster = 0x7f976d050058 (lldb.process), type = 0x00000001 (state-changed), data = { process = 0x7f976d050018 (pid = 44586), state = running}
[2020-12-22T13:52:17Z DEBUG codelldb::dap_codec] <-- {"type":"event","seq":5,"event":"module","body":{"module":{"addressRange":"7FFDFFF78000","id":"7FFDFFF78000","name":"runtime","path":"/Library/Apple/usr/libexec/oah/runtime","symbolFilePath":"/Library/Apple/usr/libexec/oah/runtime","symbolStatus":"Symbols loaded."},"reason":"new"}}
[2020-12-22T13:52:17Z DEBUG codelldb::debug_session] Debug event: 0x7f976bf46e30 Event: broadcaster = 0x7f976d050058 (lldb.process), type = 0x00000001 (state-changed), data = { process = 0x7f976d050018 (pid = 44586), state = exited}
[2020-12-22T13:52:17Z DEBUG codelldb::dap_codec] <-- {"type":"event","seq":6,"event":"continued","body":{"allThreadsContinued":true,"threadId":0}}
thread '<unnamed>' panicked at 'Whoops! Something that was supposed to have been initialized at this point, wasn't.', adapter/src/must_initialize.rs:32:17
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
dguerri commented 3 years ago

@vadimcn,

I would prefer not to release code I cannot personally build and test myself

100% understandable. No pressure whatsoever and I am willing to help with the Rosetta alternative.

Nevertheless, how would you feel about tagging it as an experimental, unsupported, version? After testing on other platforms the new package.lock, the PR should not touch anything else. I can commit in the medium-short term to test and fix issues with the M1 native version and I am sure others will be happy to participate (for instance, @KulSthl too ;) ).

Alternatively, or at the same time, we could give more evidence to these instructions... After all this is only going to work on Exploration, for now, so it's gong to be aimed to those who feel adventurous.

I see @KulSthl has already submitted some logs, I will try to help with the other tests as soon as I can! Thanks 👍

stefhol commented 3 years ago

There's a way to specify target architecture in lldb - you need to use custom launch and use target create --arch aarch64 to create the debug target.

x86 Rust x86Vscode

configuration: {
  type: 'lldb',
  request: 'launch',
  name: 'Custom launch',
  targetCreateCommands: [
    'target create --arch x86_64-apple-macosx11.0.0 target/debug/day11'
  ],
  processCreateCommands: [ 'process launch --stop-at-entry' ],
  __configurationTarget: 5,
  custom: true,
  relativePathBase: '/Users/user/Documents/git/coding-advent-2020/day11'
}
liblldb: /Users/user/.vscode/extensions/vadimcn.vscode-lldb-1.6.0/lldb/lib/liblldb.dylib
environment: {}
params: {}
Listening on port 56343
[2020-12-22T14:02:23Z DEBUG codelldb] New debug session
INFO(Python) 15:02:23 formatters: Initializing
INFO(Python) 15:02:23 formatters.rust: Initializing
[2020-12-22T14:02:23Z DEBUG codelldb::dap_codec] --> {"command":"initialize","arguments":{"clientID":"vscode","clientName":"Visual Studio Code","adapterID":"lldb","pathFormat":"path","linesStartAt1":true,"columnsStartAt1":true,"supportsVariableType":true,"supportsVariablePaging":true,"supportsRunInTerminalRequest":true,"locale":"en-us","supportsProgressReporting":true,"supportsInvalidatedEvent":true},"type":"request","seq":1}
[2020-12-22T14:02:23Z DEBUG codelldb::dap_codec] <-- {"type":"response","request_seq":1,"success":true,"command":"initialize","body":{"exceptionBreakpointFilters":[{"default":true,"filter":"cpp_throw","label":"C++: on throw"},{"default":false,"filter":"cpp_catch","label":"C++: on catch"}],"supportTerminateDebuggee":true,"supportsCancelRequest":true,"supportsCompletionsRequest":true,"supportsConditionalBreakpoints":true,"supportsConfigurationDoneRequest":true,"supportsDataBreakpoints":true,"supportsDelayedStackTraceLoading":true,"supportsEvaluateForHovers":true,"supportsFunctionBreakpoints":true,"supportsGotoTargetsRequest":true,"supportsHitConditionalBreakpoints":true,"supportsLogPoints":true,"supportsReadMemoryRequest":true,"supportsRestartFrame":true,"supportsSetVariable":true}}
[2020-12-22T14:02:23Z DEBUG codelldb::dap_codec] --> {"command":"launch","arguments":{"type":"lldb","request":"launch","name":"Custom launch","targetCreateCommands":["target create --arch x86_64-apple-macosx11.0.0 target/debug/day11"],"processCreateCommands":["process launch --stop-at-entry"],"__configurationTarget":5,"custom":true,"relativePathBase":"/Users/user/Documents/git/coding-advent-2020/day11","_adapterSettings":{"displayFormat":"auto","showDisassembly":"auto","dereferencePointers":true,"suppressMissingSourceFiles":true,"evaluationTimeout":5,"consoleMode":"commands","sourceLanguages":null,"terminalPromptClear":null},"__sessionId":"ee8078a0-6b20-45b7-ac60-a90ef9681b42"},"type":"request","seq":2}
[2020-12-22T14:02:23Z DEBUG codelldb::dap_codec] <-- {"type":"event","seq":1,"event":"output","body":{"output":"Executing script: targetCreateCommands\n"}}
[2020-12-22T14:02:23Z DEBUG codelldb::debug_session] target create --arch x86_64-apple-macosx11.0.0 target/debug/day11 -> SuccessFinishNoResult, Error:  Success
Output Message:
Current executable set to '/Users/user/Documents/git/coding-advent-2020/day11/target/debug/day11' (x86_64).

[2020-12-22T14:02:23Z DEBUG codelldb::dap_codec] <-- {"type":"event","seq":2,"event":"output","body":{"output":"Current executable set to '/Users/user/Documents/git/coding-advent-2020/day11/target/debug/day11' (x86_64).\n\n"}}
[2020-12-22T14:02:23Z DEBUG codelldb::dap_codec] <-- {"type":"event","seq":3,"event":"initialized"}
[2020-12-22T14:02:23Z DEBUG codelldb::dap_codec] --> {"command":"setBreakpoints","arguments":{"source":{"name":"main.rs","path":"/Users/user/Documents/git/coding-advent-2020/day11/src/main.rs"},"lines":[13],"breakpoints":[{"line":13}],"sourceModified":false},"type":"request","seq":3}
[2020-12-22T14:02:23Z DEBUG codelldb::dap_codec] <-- {"type":"response","request_seq":3,"success":true,"command":"setBreakpoints","body":{"breakpoints":[{"id":1,"line":13,"message":"Locations: 1","verified":true}]}}
[2020-12-22T14:02:23Z DEBUG codelldb::dap_codec] --> {"command":"setFunctionBreakpoints","arguments":{"breakpoints":[]},"type":"request","seq":4}
[2020-12-22T14:02:23Z DEBUG codelldb::dap_codec] <-- {"type":"response","request_seq":4,"success":true,"command":"setFunctionBreakpoints","body":{"breakpoints":[]}}
[2020-12-22T14:02:23Z DEBUG codelldb::dap_codec] --> {"command":"setDataBreakpoints","arguments":{"breakpoints":[]},"type":"request","seq":5}
[2020-12-22T14:02:23Z DEBUG codelldb::dap_codec] <-- {"type":"response","request_seq":5,"success":true,"command":"setDataBreakpoints","body":{"breakpoints":[]}}
[2020-12-22T14:02:23Z DEBUG codelldb::dap_codec] --> {"command":"setExceptionBreakpoints","arguments":{"filters":["cpp_throw"]},"type":"request","seq":6}
[2020-12-22T14:02:23Z DEBUG codelldb::dap_codec] <-- {"type":"response","request_seq":6,"success":true,"command":"setExceptionBreakpoints"}
[2020-12-22T14:02:23Z DEBUG codelldb::dap_codec] --> {"command":"configurationDone","type":"request","seq":7}
[2020-12-22T14:02:23Z DEBUG codelldb::dap_codec] <-- {"type":"response","request_seq":7,"success":true,"command":"configurationDone"}
[2020-12-22T14:02:23Z DEBUG codelldb::dap_codec] <-- {"type":"event","seq":4,"event":"output","body":{"output":"Executing script: processCreateCommands\n"}}
[2020-12-22T14:02:23Z DEBUG codelldb::dap_codec] --> {"command":"threads","type":"request","seq":8}
[2020-12-22T14:02:25Z DEBUG codelldb::debug_session] process launch --stop-at-entry -> SuccessFinishResult, Error:  Success
Output Message:
Process 44929 launched: '/Users/user/Documents/git/coding-advent-2020/day11/target/debug/day11' (x86_64)

[2020-12-22T14:02:25Z DEBUG codelldb::dap_codec] <-- {"type":"event","seq":5,"event":"output","body":{"output":"Process 44929 launched: '/Users/user/Documents/git/coding-advent-2020/day11/target/debug/day11' (x86_64)\n\n"}}
[2020-12-22T14:02:25Z DEBUG codelldb::dap_codec] <-- {"type":"response","request_seq":2,"success":true,"command":"launch"}
[2020-12-22T14:02:25Z DEBUG codelldb::debug_session] Debug event: 0x7fbd46c20188 Event: broadcaster = 0x7fbd5004c020 (lldb.target), type = 0x00000001 (breakpoint-changed), data = {}
[2020-12-22T14:02:25Z DEBUG codelldb::debug_session] Debug event: 0x7fbd46c13d38 Event: broadcaster = 0x7fbd5004c020 (lldb.target), type = 0x00000001 (breakpoint-changed), data = {}
[2020-12-22T14:02:25Z DEBUG codelldb::dap_codec] <-- {"type":"response","request_seq":8,"success":true,"command":"threads","body":{"threads":[{"id":339615,"name":"1: tid=339615"}]}}
[2020-12-22T14:02:25Z DEBUG codelldb::debug_session] Debug event: 0x7fbd46d542d8 Event: broadcaster = 0x7fbd5004c020 (lldb.target), type = 0x00000002 (modules-loaded), data = {dyld, runtime}
[2020-12-22T14:02:25Z DEBUG codelldb::dap_codec] <-- {"type":"event","seq":6,"event":"module","body":{"module":{"addressRange":"2000A8000","id":"2000A8000","name":"dyld","path":"/usr/lib/dyld","symbolFilePath":"/usr/lib/dyld","symbolStatus":"Symbols loaded."},"reason":"new"}}
[2020-12-22T14:02:25Z DEBUG codelldb::dap_codec] <-- {"type":"event","seq":7,"event":"module","body":{"module":{"addressRange":"7FFDFFF78000","id":"7FFDFFF78000","name":"runtime","path":"/Library/Apple/usr/libexec/oah/runtime","symbolFilePath":"/Library/Apple/usr/libexec/oah/runtime","symbolStatus":"Symbols loaded."},"reason":"new"}}

This is not showing an error but debugging vscode ui is not working. Maybe my configuration is wrong?

stefhol commented 3 years ago

Arm Rust x86 Vscode

configuration: {
  type: 'lldb',
  request: 'launch',
  name: 'Custom launch',
  preLaunchTask: 'cbuild',
  targetCreateCommands: [
    'target create --arch arm64-apple-macosx11.0.0 target/debug/day11'
  ],
  processCreateCommands: [ 'process launch --stop-at-entry' ],
  __configurationTarget: 5,
  custom: true,
  relativePathBase: '/Users/user/Documents/git/coding-advent-2020/day11'
}
liblldb: /Users/user/.vscode/extensions/vadimcn.vscode-lldb-1.6.0/lldb/lib/liblldb.dylib
environment: {}
params: {}
Listening on port 56681
[2020-12-22T14:24:01Z DEBUG codelldb] New debug session
INFO(Python) 15:24:01 formatters: Initializing
INFO(Python) 15:24:01 formatters.rust: Initializing
[2020-12-22T14:24:01Z DEBUG codelldb::dap_codec] --> {"command":"initialize","arguments":{"clientID":"vscode","clientName":"Visual Studio Code","adapterID":"lldb","pathFormat":"path","linesStartAt1":true,"columnsStartAt1":true,"supportsVariableType":true,"supportsVariablePaging":true,"supportsRunInTerminalRequest":true,"locale":"en-us","supportsProgressReporting":true,"supportsInvalidatedEvent":true},"type":"request","seq":1}
[2020-12-22T14:24:01Z DEBUG codelldb::dap_codec] <-- {"type":"response","request_seq":1,"success":true,"command":"initialize","body":{"exceptionBreakpointFilters":[{"default":true,"filter":"cpp_throw","label":"C++: on throw"},{"default":false,"filter":"cpp_catch","label":"C++: on catch"}],"supportTerminateDebuggee":true,"supportsCancelRequest":true,"supportsCompletionsRequest":true,"supportsConditionalBreakpoints":true,"supportsConfigurationDoneRequest":true,"supportsDataBreakpoints":true,"supportsDelayedStackTraceLoading":true,"supportsEvaluateForHovers":true,"supportsFunctionBreakpoints":true,"supportsGotoTargetsRequest":true,"supportsHitConditionalBreakpoints":true,"supportsLogPoints":true,"supportsReadMemoryRequest":true,"supportsRestartFrame":true,"supportsSetVariable":true}}
[2020-12-22T14:24:01Z DEBUG codelldb::dap_codec] --> {"command":"launch","arguments":{"type":"lldb","request":"launch","name":"Custom launch","preLaunchTask":"cbuild","targetCreateCommands":["target create --arch arm64-apple-macosx11.0.0 target/debug/day11"],"processCreateCommands":["process launch --stop-at-entry"],"__configurationTarget":5,"custom":true,"relativePathBase":"/Users/user/Documents/git/coding-advent-2020/day11","_adapterSettings":{"displayFormat":"auto","showDisassembly":"auto","dereferencePointers":true,"suppressMissingSourceFiles":true,"evaluationTimeout":5,"consoleMode":"commands","sourceLanguages":null,"terminalPromptClear":null},"__sessionId":"cc8d4839-747c-4b15-abb7-4ae3542d97f1"},"type":"request","seq":2}
[2020-12-22T14:24:01Z DEBUG codelldb::dap_codec] <-- {"type":"event","seq":1,"event":"output","body":{"output":"Executing script: targetCreateCommands\n"}}
[2020-12-22T14:24:01Z DEBUG codelldb::debug_session] target create --arch arm64-apple-macosx11.0.0 target/debug/day11 -> SuccessFinishNoResult, Error:  Success
Output Message:
Current executable set to '/Users/user/Documents/git/coding-advent-2020/day11/target/debug/day11' (arm64).

[2020-12-22T14:24:01Z DEBUG codelldb::dap_codec] <-- {"type":"event","seq":2,"event":"output","body":{"output":"Current executable set to '/Users/user/Documents/git/coding-advent-2020/day11/target/debug/day11' (arm64).\n\n"}}
[2020-12-22T14:24:01Z DEBUG codelldb::dap_codec] <-- {"type":"event","seq":3,"event":"initialized"}
[2020-12-22T14:24:01Z DEBUG codelldb::dap_codec] --> {"command":"setBreakpoints","arguments":{"source":{"name":"main.rs","path":"/Users/user/Documents/git/coding-advent-2020/day11/src/main.rs"},"lines":[13],"breakpoints":[{"line":13}],"sourceModified":false},"type":"request","seq":3}
[2020-12-22T14:24:01Z DEBUG codelldb::dap_codec] <-- {"type":"response","request_seq":3,"success":true,"command":"setBreakpoints","body":{"breakpoints":[{"id":1,"line":13,"message":"Locations: 1","verified":true}]}}
[2020-12-22T14:24:01Z DEBUG codelldb::dap_codec] --> {"command":"setFunctionBreakpoints","arguments":{"breakpoints":[]},"type":"request","seq":4}
[2020-12-22T14:24:01Z DEBUG codelldb::dap_codec] <-- {"type":"response","request_seq":4,"success":true,"command":"setFunctionBreakpoints","body":{"breakpoints":[]}}
[2020-12-22T14:24:01Z DEBUG codelldb::dap_codec] --> {"command":"setDataBreakpoints","arguments":{"breakpoints":[]},"type":"request","seq":5}
[2020-12-22T14:24:01Z DEBUG codelldb::dap_codec] <-- {"type":"response","request_seq":5,"success":true,"command":"setDataBreakpoints","body":{"breakpoints":[]}}
[2020-12-22T14:24:01Z DEBUG codelldb::dap_codec] --> {"command":"setExceptionBreakpoints","arguments":{"filters":["cpp_throw"]},"type":"request","seq":6}
[2020-12-22T14:24:01Z DEBUG codelldb::dap_codec] <-- {"type":"response","request_seq":6,"success":true,"command":"setExceptionBreakpoints"}
[2020-12-22T14:24:01Z DEBUG codelldb::dap_codec] --> {"command":"configurationDone","type":"request","seq":7}
[2020-12-22T14:24:01Z DEBUG codelldb::dap_codec] <-- {"type":"response","request_seq":7,"success":true,"command":"configurationDone"}
[2020-12-22T14:24:01Z DEBUG codelldb::dap_codec] <-- {"type":"event","seq":4,"event":"output","body":{"output":"Executing script: processCreateCommands\n"}}
[2020-12-22T14:24:01Z DEBUG codelldb::dap_codec] --> {"command":"threads","type":"request","seq":8}
[2020-12-22T14:24:03Z DEBUG codelldb::debug_session] process launch --stop-at-entry -> SuccessFinishResult, Error:  Success
Output Message:
Process 46161 launched: '/Users/user/Documents/git/coding-advent-2020/day11/target/debug/day11' (arm64)

[2020-12-22T14:24:03Z DEBUG codelldb::dap_codec] <-- {"type":"event","seq":5,"event":"output","body":{"output":"Process 46161 launched: '/Users/user/Documents/git/coding-advent-2020/day11/target/debug/day11' (arm64)\n\n"}}
[2020-12-22T14:24:03Z DEBUG codelldb::dap_codec] <-- {"type":"response","request_seq":2,"success":true,"command":"launch"}
[2020-12-22T14:24:03Z DEBUG codelldb::dap_codec] <-- {"type":"response","request_seq":8,"success":true,"command":"threads","body":{"threads":[]}}
[2020-12-22T14:24:06Z DEBUG codelldb::debug_session] Debug event: 0x7fac9de645d0 Event: broadcaster = 0x7fac9e107058 (lldb.process), type = 0x00000001 (state-changed), data = { process = 0x7fac9e107018 (pid = 46161), state = exited}
[2020-12-22T14:24:06Z DEBUG codelldb::dap_codec] <-- {"type":"event","seq":6,"event":"output","body":{"output":"Process exited with code -1.\n"}}
[2020-12-22T14:24:06Z DEBUG codelldb::dap_codec] <-- {"type":"event","seq":7,"event":"exited","body":{"exitCode":-1}}
[2020-12-22T14:24:06Z DEBUG codelldb::dap_codec] <-- {"type":"event","seq":8,"event":"terminated","body":{}}
[2020-12-22T14:24:06Z DEBUG codelldb::dap_codec] --> {"command":"disconnect","arguments":{"restart":false},"type":"request","seq":9}
[2020-12-22T14:24:06Z DEBUG codelldb::dap_codec] <-- {"type":"response","request_seq":9,"success":true,"command":"disconnect"}
[2020-12-22T14:24:06Z DEBUG codelldb::dap_session] Client has disconnected
[2020-12-22T14:24:06Z DEBUG codelldb::debug_session] End of the requests stream
[2020-12-22T14:24:06Z DEBUG codelldb::debug_session] DebugSession::drop()
[2020-12-22T14:24:06Z DEBUG codelldb] Session has ended
[2020-12-22T14:24:06Z DEBUG codelldb] Exiting
Debug adapter exit code=0, signal=null.

Prints error

stefhol commented 3 years ago

x86 Rust x86 Vscode

In case there is indeed a restriction on architecture of the process using debugging APIs, here's another thing to try: set LLDB_DEBUGSERVER_PATH= via lldb.adapterEnv.

  type: 'lldb',
  request: 'launch',
  name: 'Custom launch',
  preLaunchTask: 'cbuild',
  targetCreateCommands: [
    'target create --arch x86_64-apple-macosx11.0.0 target/debug/day11'
  ],
  processCreateCommands: [ 'process launch --stop-at-entry' ],
  __configurationTarget: 5,
  custom: true,
  relativePathBase: '/Users/user/Documents/git/coding-advent-2020/day11'
}
liblldb: /Users/user/.vscode/extensions/vadimcn.vscode-lldb-1.6.0/lldb/lib/liblldb.dylib
environment: {
  LLDB_DEBUGSERVER_PATH: '/Users/user/llvm-project/build/bin/lldb-server'
}
params: {}
Listening on port 57022
[2020-12-22T14:42:57Z DEBUG codelldb] New debug session
INFO(Python) 15:42:58 formatters: Initializing
INFO(Python) 15:42:58 formatters.rust: Initializing
[2020-12-22T14:42:58Z DEBUG codelldb::dap_codec] --> {"command":"initialize","arguments":{"clientID":"vscode","clientName":"Visual Studio Code","adapterID":"lldb","pathFormat":"path","linesStartAt1":true,"columnsStartAt1":true,"supportsVariableType":true,"supportsVariablePaging":true,"supportsRunInTerminalRequest":true,"locale":"en-us","supportsProgressReporting":true,"supportsInvalidatedEvent":true},"type":"request","seq":1}
[2020-12-22T14:42:58Z DEBUG codelldb::dap_codec] <-- {"type":"response","request_seq":1,"success":true,"command":"initialize","body":{"exceptionBreakpointFilters":[{"default":true,"filter":"cpp_throw","label":"C++: on throw"},{"default":false,"filter":"cpp_catch","label":"C++: on catch"}],"supportTerminateDebuggee":true,"supportsCancelRequest":true,"supportsCompletionsRequest":true,"supportsConditionalBreakpoints":true,"supportsConfigurationDoneRequest":true,"supportsDataBreakpoints":true,"supportsDelayedStackTraceLoading":true,"supportsEvaluateForHovers":true,"supportsFunctionBreakpoints":true,"supportsGotoTargetsRequest":true,"supportsHitConditionalBreakpoints":true,"supportsLogPoints":true,"supportsReadMemoryRequest":true,"supportsRestartFrame":true,"supportsSetVariable":true}}
[2020-12-22T14:42:58Z DEBUG codelldb::dap_codec] --> {"command":"launch","arguments":{"type":"lldb","request":"launch","name":"Custom launch","preLaunchTask":"cbuild","targetCreateCommands":["target create --arch x86_64-apple-macosx11.0.0 target/debug/day11"],"processCreateCommands":["process launch --stop-at-entry"],"__configurationTarget":5,"custom":true,"relativePathBase":"/Users/user/Documents/git/coding-advent-2020/day11","_adapterSettings":{"displayFormat":"auto","showDisassembly":"auto","dereferencePointers":true,"suppressMissingSourceFiles":true,"evaluationTimeout":5,"consoleMode":"commands","sourceLanguages":null,"terminalPromptClear":null},"__sessionId":"7d1c4acd-a3e2-4a86-8272-a9b4b20dbf97"},"type":"request","seq":2}
[2020-12-22T14:42:58Z DEBUG codelldb::dap_codec] <-- {"type":"event","seq":1,"event":"output","body":{"output":"Executing script: targetCreateCommands\n"}}
[2020-12-22T14:42:58Z DEBUG codelldb::debug_session] target create --arch x86_64-apple-macosx11.0.0 target/debug/day11 -> SuccessFinishNoResult, Error:  Success
Output Message:
Current executable set to '/Users/user/Documents/git/coding-advent-2020/day11/target/debug/day11' (x86_64).

[2020-12-22T14:42:58Z DEBUG codelldb::dap_codec] <-- {"type":"event","seq":2,"event":"output","body":{"output":"Current executable set to '/Users/user/Documents/git/coding-advent-2020/day11/target/debug/day11' (x86_64).\n\n"}}
[2020-12-22T14:42:58Z DEBUG codelldb::dap_codec] <-- {"type":"event","seq":3,"event":"initialized"}
[2020-12-22T14:42:58Z DEBUG codelldb::dap_codec] --> {"command":"setBreakpoints","arguments":{"source":{"name":"main.rs","path":"/Users/user/Documents/git/coding-advent-2020/day11/src/main.rs"},"lines":[13],"breakpoints":[{"line":13}],"sourceModified":false},"type":"request","seq":3}
[2020-12-22T14:42:58Z DEBUG codelldb::dap_codec] <-- {"type":"response","request_seq":3,"success":true,"command":"setBreakpoints","body":{"breakpoints":[{"id":1,"line":13,"message":"Locations: 1","verified":true}]}}
[2020-12-22T14:42:58Z DEBUG codelldb::dap_codec] --> {"command":"setFunctionBreakpoints","arguments":{"breakpoints":[]},"type":"request","seq":4}
[2020-12-22T14:42:58Z DEBUG codelldb::dap_codec] <-- {"type":"response","request_seq":4,"success":true,"command":"setFunctionBreakpoints","body":{"breakpoints":[]}}
[2020-12-22T14:42:58Z DEBUG codelldb::dap_codec] --> {"command":"setDataBreakpoints","arguments":{"breakpoints":[]},"type":"request","seq":5}
[2020-12-22T14:42:58Z DEBUG codelldb::dap_codec] <-- {"type":"response","request_seq":5,"success":true,"command":"setDataBreakpoints","body":{"breakpoints":[]}}
[2020-12-22T14:42:58Z DEBUG codelldb::dap_codec] --> {"command":"setExceptionBreakpoints","arguments":{"filters":["cpp_throw"]},"type":"request","seq":6}
[2020-12-22T14:42:58Z DEBUG codelldb::dap_codec] <-- {"type":"response","request_seq":6,"success":true,"command":"setExceptionBreakpoints"}
[2020-12-22T14:42:58Z DEBUG codelldb::dap_codec] --> {"command":"configurationDone","type":"request","seq":7}
[2020-12-22T14:42:58Z DEBUG codelldb::dap_codec] <-- {"type":"response","request_seq":7,"success":true,"command":"configurationDone"}
[2020-12-22T14:42:58Z DEBUG codelldb::dap_codec] <-- {"type":"event","seq":4,"event":"output","body":{"output":"Executing script: processCreateCommands\n"}}
[2020-12-22T14:42:58Z DEBUG codelldb::dap_codec] --> {"command":"threads","type":"request","seq":8}
[2020-12-22T14:42:59Z DEBUG codelldb::debug_session] process launch --stop-at-entry -> Failed, Error:  Fail
Error Message:
error: failed to get reply to handshake packet

[2020-12-22T14:42:59Z ERROR codelldb::debug_session] error: failed to get reply to handshake packet

[2020-12-22T14:42:59Z DEBUG codelldb::dap_codec] <-- {"type":"event","seq":5,"event":"output","body":{"category":"stderr","output":"error: failed to get reply to handshake packet\n\n"}}
[2020-12-22T14:42:59Z DEBUG codelldb::dap_codec] <-- {"type":"response","request_seq":2,"success":false,"message":"error: failed to get reply to handshake packet\n","show_user":true}
[2020-12-22T14:42:59Z DEBUG codelldb::dap_codec] <-- {"type":"response","request_seq":8,"success":true,"command":"threads","body":{"threads":[]}}
[2020-12-22T14:42:59Z DEBUG codelldb::dap_codec] --> {"command":"disconnect","arguments":{"restart":false},"type":"request","seq":9}
[2020-12-22T14:42:59Z DEBUG codelldb::dap_codec] <-- {"type":"response","request_seq":9,"success":true,"command":"disconnect"}
[2020-12-22T14:42:59Z DEBUG codelldb::dap_session] Client has disconnected
[2020-12-22T14:42:59Z DEBUG codelldb::debug_session] End of the requests stream
[2020-12-22T14:42:59Z DEBUG codelldb::debug_session] DebugSession::drop()
[2020-12-22T14:42:59Z DEBUG codelldb] Session has ended
[2020-12-22T14:42:59Z DEBUG codelldb] Exiting
Debug adapter exit code=0, signal=null.

Arm Rust x86 Vscode

configuration: {
  type: 'lldb',
  request: 'launch',
  name: 'Custom launch',
  preLaunchTask: 'cbuild',
  targetCreateCommands: [
    'target create --arch arm64-apple-macosx11.0.0 target/debug/day11'
  ],
  processCreateCommands: [ 'process launch --stop-at-entry' ],
  __configurationTarget: 5,
  custom: true,
  relativePathBase: '/Users/user/Documents/git/coding-advent-2020/day11'
}
liblldb: /Users/user/.vscode/extensions/vadimcn.vscode-lldb-1.6.0/lldb/lib/liblldb.dylib
environment: {
  LLDB_DEBUGSERVER_PATH: '/Users/user/llvm-project/build/bin/lldb-server'
}
params: {}
Listening on port 57146
[2020-12-22T14:49:57Z DEBUG codelldb] New debug session
INFO(Python) 15:49:58 formatters: Initializing
INFO(Python) 15:49:58 formatters.rust: Initializing
[2020-12-22T14:49:58Z DEBUG codelldb::dap_codec] --> {"command":"initialize","arguments":{"clientID":"vscode","clientName":"Visual Studio Code","adapterID":"lldb","pathFormat":"path","linesStartAt1":true,"columnsStartAt1":true,"supportsVariableType":true,"supportsVariablePaging":true,"supportsRunInTerminalRequest":true,"locale":"en-us","supportsProgressReporting":true,"supportsInvalidatedEvent":true},"type":"request","seq":1}
[2020-12-22T14:49:58Z DEBUG codelldb::dap_codec] <-- {"type":"response","request_seq":1,"success":true,"command":"initialize","body":{"exceptionBreakpointFilters":[{"default":true,"filter":"cpp_throw","label":"C++: on throw"},{"default":false,"filter":"cpp_catch","label":"C++: on catch"}],"supportTerminateDebuggee":true,"supportsCancelRequest":true,"supportsCompletionsRequest":true,"supportsConditionalBreakpoints":true,"supportsConfigurationDoneRequest":true,"supportsDataBreakpoints":true,"supportsDelayedStackTraceLoading":true,"supportsEvaluateForHovers":true,"supportsFunctionBreakpoints":true,"supportsGotoTargetsRequest":true,"supportsHitConditionalBreakpoints":true,"supportsLogPoints":true,"supportsReadMemoryRequest":true,"supportsRestartFrame":true,"supportsSetVariable":true}}
[2020-12-22T14:49:58Z DEBUG codelldb::dap_codec] --> {"command":"launch","arguments":{"type":"lldb","request":"launch","name":"Custom launch","preLaunchTask":"cbuild","targetCreateCommands":["target create --arch arm64-apple-macosx11.0.0 target/debug/day11"],"processCreateCommands":["process launch --stop-at-entry"],"__configurationTarget":5,"custom":true,"relativePathBase":"/Users/user/Documents/git/coding-advent-2020/day11","_adapterSettings":{"displayFormat":"auto","showDisassembly":"auto","dereferencePointers":true,"suppressMissingSourceFiles":true,"evaluationTimeout":5,"consoleMode":"commands","sourceLanguages":null,"terminalPromptClear":null},"__sessionId":"c71684c8-77d4-4f2d-a75b-2136fb7a6c58"},"type":"request","seq":2}
[2020-12-22T14:49:58Z DEBUG codelldb::dap_codec] <-- {"type":"event","seq":1,"event":"output","body":{"output":"Executing script: targetCreateCommands\n"}}
[2020-12-22T14:49:58Z DEBUG codelldb::debug_session] target create --arch arm64-apple-macosx11.0.0 target/debug/day11 -> SuccessFinishNoResult, Error:  Success
Output Message:
Current executable set to '/Users/user/Documents/git/coding-advent-2020/day11/target/debug/day11' (arm64).

[2020-12-22T14:49:58Z DEBUG codelldb::dap_codec] <-- {"type":"event","seq":2,"event":"output","body":{"output":"Current executable set to '/Users/user/Documents/git/coding-advent-2020/day11/target/debug/day11' (arm64).\n\n"}}
[2020-12-22T14:49:58Z DEBUG codelldb::dap_codec] <-- {"type":"event","seq":3,"event":"initialized"}
[2020-12-22T14:49:58Z DEBUG codelldb::dap_codec] --> {"command":"setBreakpoints","arguments":{"source":{"name":"main.rs","path":"/Users/user/Documents/git/coding-advent-2020/day11/src/main.rs"},"lines":[13],"breakpoints":[{"line":13}],"sourceModified":false},"type":"request","seq":3}
[2020-12-22T14:49:58Z DEBUG codelldb::dap_codec] <-- {"type":"response","request_seq":3,"success":true,"command":"setBreakpoints","body":{"breakpoints":[{"id":1,"line":13,"message":"Locations: 1","verified":true}]}}
[2020-12-22T14:49:58Z DEBUG codelldb::dap_codec] --> {"command":"setFunctionBreakpoints","arguments":{"breakpoints":[]},"type":"request","seq":4}
[2020-12-22T14:49:58Z DEBUG codelldb::dap_codec] <-- {"type":"response","request_seq":4,"success":true,"command":"setFunctionBreakpoints","body":{"breakpoints":[]}}
[2020-12-22T14:49:58Z DEBUG codelldb::dap_codec] --> {"command":"setDataBreakpoints","arguments":{"breakpoints":[]},"type":"request","seq":5}
[2020-12-22T14:49:58Z DEBUG codelldb::dap_codec] <-- {"type":"response","request_seq":5,"success":true,"command":"setDataBreakpoints","body":{"breakpoints":[]}}
[2020-12-22T14:49:58Z DEBUG codelldb::dap_codec] --> {"command":"setExceptionBreakpoints","arguments":{"filters":["cpp_throw"]},"type":"request","seq":6}
[2020-12-22T14:49:58Z DEBUG codelldb::dap_codec] <-- {"type":"response","request_seq":6,"success":true,"command":"setExceptionBreakpoints"}
[2020-12-22T14:49:58Z DEBUG codelldb::dap_codec] --> {"command":"configurationDone","type":"request","seq":7}
[2020-12-22T14:49:58Z DEBUG codelldb::dap_codec] <-- {"type":"response","request_seq":7,"success":true,"command":"configurationDone"}
[2020-12-22T14:49:58Z DEBUG codelldb::dap_codec] <-- {"type":"event","seq":4,"event":"output","body":{"output":"Executing script: processCreateCommands\n"}}
[2020-12-22T14:49:58Z DEBUG codelldb::dap_codec] --> {"command":"threads","type":"request","seq":8}
[2020-12-22T14:49:58Z DEBUG codelldb::debug_session] process launch --stop-at-entry -> Failed, Error:  Fail
Error Message:
error: failed to get reply to handshake packet

[2020-12-22T14:49:58Z ERROR codelldb::debug_session] error: failed to get reply to handshake packet

[2020-12-22T14:49:58Z DEBUG codelldb::dap_codec] <-- {"type":"event","seq":5,"event":"output","body":{"category":"stderr","output":"error: failed to get reply to handshake packet\n\n"}}
[2020-12-22T14:49:58Z DEBUG codelldb::dap_codec] <-- {"type":"response","request_seq":2,"success":false,"message":"error: failed to get reply to handshake packet\n","show_user":true}
[2020-12-22T14:49:58Z DEBUG codelldb::dap_codec] <-- {"type":"response","request_seq":8,"success":true,"command":"threads","body":{"threads":[]}}
[2020-12-22T14:49:58Z DEBUG codelldb::dap_codec] --> {"command":"disconnect","arguments":{"restart":false},"type":"request","seq":9}
[2020-12-22T14:49:58Z DEBUG codelldb::dap_codec] <-- {"type":"response","request_seq":9,"success":true,"command":"disconnect"}
[2020-12-22T14:49:58Z DEBUG codelldb::dap_session] Client has disconnected
[2020-12-22T14:49:58Z DEBUG codelldb::debug_session] End of the requests stream
[2020-12-22T14:49:58Z DEBUG codelldb::debug_session] DebugSession::drop()
[2020-12-22T14:49:58Z DEBUG codelldb] Session has ended
[2020-12-22T14:49:58Z DEBUG codelldb] Exiting
Debug adapter exit code=0, signal=null.
stefhol commented 3 years ago

@dguerri

Alternatively, or at the same time, we could give more evidence to these instructions... After all this is only going to work on Exploration, for now, so it's gong to be aimed to those who feel adventurous. With prebuild package

Insider is on Arm https://code.visualstudio.com/insiders/ the ARM64 zip under the big download button

I only have Insider ARM version and it does not work. Maybe you really need exploratory

Error: "\"dlopen(/Users/user/.vscode-insiders/extensions/vadimcn.vscode-lldb-1.6.0-dev.2012211644/lldb/lib/liblldb.12.0.0git.dylib, 9): no suitable image found.  Did find:\\n\\t/Users/user/.vscode-insiders/extensions/vadimcn.vscode-lldb-1.6.0-dev.2012211644/lldb/lib/liblldb.12.0.0git.dylib: mach-o, but wrong architecture\\n\\t/Users/user/.vscode-insiders/extensions/vadimcn.vscode-lldb-1.6.0-dev.2012211644/lldb/lib/liblldb.12.0.0git.dylib: stat() failed with errno=102\""

make vsix_full

needs x86 Rust which is confusing too me

error[E0463]: can't find crate for `core`
  |
  = note: the `x86_64-apple-darwin` target may not be installed

Prebuild does also not work on insider

Error: "\"dlopen(/Users/user/.vscode-insiders/extensions/vadimcn.vscode-lldb-1.6.0-dev.2012192238/lldb/lib/liblldb.12.0.0git.dylib, 9): Library not loaded: /opt/local/lib/libform.6.dylib\\n  Referenced from: /Users/user/.vscode-insiders/extensions/vadimcn.vscode-lldb-1.6.0-dev.2012192238/lldb/lib/liblldb.12.0.0git.dylib\\n  Reason: image not found\""

At this point I am also confused in which version I should test it in Arm or x86, but only maybe because I tested so much 😅

dguerri commented 3 years ago

@KulSthl I assume you are using my PR, totally forgot to mention it in the guide 😅

Will try insider later tonight!

dguerri commented 3 years ago

make vsix_full

needs x86 Rust which is confusing too me

This shouldn't be. I think Rosetta kicked in at some point. Are you using Macports or Homebrew?

dguerri commented 3 years ago

Prebuild does also not work on insider

Error: "\"dlopen(/Users/user/.vscode-insiders/extensions/vadimcn.vscode-lldb-1.6.0-dev.2012192238/lldb/lib/liblldb.12.0.0git.dylib, 9): Library not loaded: /opt/local/lib/libform.6.dylib\n Referenced from: /Users/user/.vscode-insiders/extensions/vadimcn.vscode-lldb-1.6.0-dev.2012192238/lldb/lib/liblldb.12.0.0git.dylib\n Reason: image not found\""

Can you please check whether the lib is actually there?

At this point I am also confused in which version I should test

Sorry about that 😅

If you have the chance it'd be great to make a test with Exploratory :)

dguerri commented 3 years ago

@KulSthl

Ah yeah,

/opt/local/lib/libform.6.dylib

This is because I am not sure how to build a self contained environment... I will have to use otool and follow dependencies, and create another package. Thanks for testing!

In the meanwhile, please try to install the dependencies via MacPorts, by hand, as long as it fails to load.

stefhol commented 3 years ago

I assume you are using my PR

could you elaborate

Are you using Macports or Homebrew? I think Rosetta kicked in at some point.

Homebrew ARM and Homebrew x86 so could be

stefhol commented 3 years ago

https://github.com/vadimcn/vscode-lldb/issues/397#issuecomment-749556362

As this looks promising I think I wait till @vadimcn has time to investigate

dguerri commented 3 years ago

I assume you are using my PR

could you elaborate

I made some adjustments to allow building from source on M1 in this PR: https://github.com/vadimcn/vscode-lldb/pull/401

Are you using Macports or Homebrew?

I think Rosetta kicked in at some point.

Homebrew ARM and Homebrew x86 so could be

Homebrew ARM should do, but the dependencies will all be in a different location, so the prebuilt version won't work.

I will provide another package later :)

dguerri commented 3 years ago

@KulSthl, I think I managed to get a self-contained lldb in this vsix package.

Basically, I made a quick script to recursively enumerate dylibs of each binary and dylib needed by lldb, copied them inside the lib/ directory and then run install_name_tool -change ... to relocate the dependencies.

I am pretty sure this is not a clean solution, and I see that the official releases of vscode-lldb (for x86_64) don't depend on libncurses, to name one... Maybe there are some options I can pass to cmake when building project-llvm...

Anyway, I tested the attached vsix on Insiders (thanks @KulSthl! I didn't notice MS released an ARM64 version for Mac). I removed my /opt/local/lib directory (it's used/populated by Macports) and everything worked. If you are willing to give it a go, I would like to know if it worked for you.

vadimcn commented 3 years ago

@KulSthl: Thanks for running these tests! Unfortunately, I can't figure out from these logs what is going on there :( To clarify what configuration I had in mind:

Why did you use target create --arch arm64-apple-macosx11.0.0 ... rather than target create --arch aarch64 ...? AFAIK, LLVM calls this architecture "aarch64".

dguerri commented 3 years ago

To clarify what configuration I had in mind

That should work. I don't have my laptop right now, but one possible issue is that binaries in Big Sur are universal, and so is debugserver (need to double check, but I am fairly sure). So, if debugserver is started from a x86 process, I think it will end up being emulated as well...

I see code-lldb ships with its own debugserver, so we need to use the system one and we need to make sure it's started in native mode.

dguerri commented 3 years ago

Running lldb and debug server on the CLI, in the configuration suggested by @vadimcn:

Screenshot 2020-12-23 at 10 32 34

seems to work well :)

stefhol commented 3 years ago

Why did you use target create --arch arm64-apple-macosx11.0.0 ... rather than target create --arch aarch64 ...? AFAIK, LLVM calls this architecture "aarch64".

Because it said I should use this instead

Bildschirmfoto 2020-12-23 um 13 47 11
dguerri commented 3 years ago

Why did you use target create --arch arm64-apple-macosx11.0.0 ... rather than target create --arch aarch64 ...? AFAIK, LLVM calls this architecture "aarch64".

Because it said I should use this instead

Bildschirmfoto 2020-12-23 um 13 47 11

I think you ended up with a binary for x86 (the one to be debugged, in day11)

stefhol commented 3 years ago

On the first try I did not compile my code again and then though oh I have to use the String in the error message not realizing my error.

I tried it again with arm rust using the aarch64. I also deactivated the custom lldb env so this should match https://github.com/vadimcn/vscode-lldb/issues/397#issuecomment-749566437

configuration: {
  type: 'lldb',
  request: 'launch',
  name: 'Custom launch',
  preLaunchTask: 'cbuild',
  targetCreateCommands: [ 'target create --arch aarch64 target/debug/day11' ],
  processCreateCommands: [ 'process launch --stop-at-entry' ],
  __configurationTarget: 5,
  custom: true,
  relativePathBase: '/Users/user/Documents/git/coding-advent-2020/day11'
}
liblldb: /Users/user/.vscode/extensions/vadimcn.vscode-lldb-1.6.0/lldb/lib/liblldb.dylib
environment: {}
params: {}
Listening on port 62218
[2020-12-23T16:10:21Z DEBUG codelldb] New debug session
INFO(Python) 17:10:21 formatters: Initializing
INFO(Python) 17:10:21 formatters.rust: Initializing
[2020-12-23T16:10:21Z DEBUG codelldb::dap_codec] --> {"command":"initialize","arguments":{"clientID":"vscode","clientName":"Visual Studio Code","adapterID":"lldb","pathFormat":"path","linesStartAt1":true,"columnsStartAt1":true,"supportsVariableType":true,"supportsVariablePaging":true,"supportsRunInTerminalRequest":true,"locale":"en-us","supportsProgressReporting":true,"supportsInvalidatedEvent":true},"type":"request","seq":1}
[2020-12-23T16:10:21Z DEBUG codelldb::dap_codec] <-- {"type":"response","request_seq":1,"success":true,"command":"initialize","body":{"exceptionBreakpointFilters":[{"default":true,"filter":"cpp_throw","label":"C++: on throw"},{"default":false,"filter":"cpp_catch","label":"C++: on catch"}],"supportTerminateDebuggee":true,"supportsCancelRequest":true,"supportsCompletionsRequest":true,"supportsConditionalBreakpoints":true,"supportsConfigurationDoneRequest":true,"supportsDataBreakpoints":true,"supportsDelayedStackTraceLoading":true,"supportsEvaluateForHovers":true,"supportsFunctionBreakpoints":true,"supportsGotoTargetsRequest":true,"supportsHitConditionalBreakpoints":true,"supportsLogPoints":true,"supportsReadMemoryRequest":true,"supportsRestartFrame":true,"supportsSetVariable":true}}
[2020-12-23T16:10:21Z DEBUG codelldb::dap_codec] --> {"command":"launch","arguments":{"type":"lldb","request":"launch","name":"Custom launch","preLaunchTask":"cbuild","targetCreateCommands":["target create --arch aarch64 target/debug/day11"],"processCreateCommands":["process launch --stop-at-entry"],"__configurationTarget":5,"custom":true,"relativePathBase":"/Users/user/Documents/git/coding-advent-2020/day11","_adapterSettings":{"displayFormat":"auto","showDisassembly":"auto","dereferencePointers":true,"suppressMissingSourceFiles":true,"evaluationTimeout":5,"consoleMode":"commands","sourceLanguages":null,"terminalPromptClear":null},"__sessionId":"0b49fe30-1927-4e3b-b68c-17ce04d94ed9"},"type":"request","seq":2}
[2020-12-23T16:10:21Z DEBUG codelldb::dap_codec] <-- {"type":"event","seq":1,"event":"output","body":{"output":"Executing script: targetCreateCommands\n"}}
[2020-12-23T16:10:21Z DEBUG codelldb::debug_session] target create --arch aarch64 target/debug/day11 -> SuccessFinishNoResult, Error:  Success
Output Message:
Current executable set to '/Users/user/Documents/git/coding-advent-2020/day11/target/debug/day11' (arm64).

[2020-12-23T16:10:21Z DEBUG codelldb::dap_codec] <-- {"type":"event","seq":2,"event":"output","body":{"output":"Current executable set to '/Users/user/Documents/git/coding-advent-2020/day11/target/debug/day11' (arm64).\n\n"}}
[2020-12-23T16:10:21Z DEBUG codelldb::dap_codec] <-- {"type":"event","seq":3,"event":"initialized"}
[2020-12-23T16:10:21Z DEBUG codelldb::dap_codec] --> {"command":"setBreakpoints","arguments":{"source":{"name":"main.rs","path":"/Users/user/Documents/git/coding-advent-2020/day11/src/main.rs"},"lines":[13],"breakpoints":[{"line":13}],"sourceModified":false},"type":"request","seq":3}
[2020-12-23T16:10:21Z DEBUG codelldb::dap_codec] <-- {"type":"response","request_seq":3,"success":true,"command":"setBreakpoints","body":{"breakpoints":[{"id":1,"line":13,"message":"Locations: 1","verified":true}]}}
[2020-12-23T16:10:21Z DEBUG codelldb::dap_codec] --> {"command":"setFunctionBreakpoints","arguments":{"breakpoints":[]},"type":"request","seq":4}
[2020-12-23T16:10:21Z DEBUG codelldb::dap_codec] <-- {"type":"response","request_seq":4,"success":true,"command":"setFunctionBreakpoints","body":{"breakpoints":[]}}
[2020-12-23T16:10:21Z DEBUG codelldb::dap_codec] --> {"command":"setDataBreakpoints","arguments":{"breakpoints":[]},"type":"request","seq":5}
[2020-12-23T16:10:21Z DEBUG codelldb::dap_codec] <-- {"type":"response","request_seq":5,"success":true,"command":"setDataBreakpoints","body":{"breakpoints":[]}}
[2020-12-23T16:10:21Z DEBUG codelldb::dap_codec] --> {"command":"setExceptionBreakpoints","arguments":{"filters":["cpp_throw"]},"type":"request","seq":6}
[2020-12-23T16:10:21Z DEBUG codelldb::dap_codec] <-- {"type":"response","request_seq":6,"success":true,"command":"setExceptionBreakpoints"}
[2020-12-23T16:10:21Z DEBUG codelldb::dap_codec] --> {"command":"configurationDone","type":"request","seq":7}
[2020-12-23T16:10:21Z DEBUG codelldb::dap_codec] <-- {"type":"event","seq":4,"event":"output","body":{"output":"Executing script: processCreateCommands\n"}}
[2020-12-23T16:10:24Z DEBUG codelldb::debug_session] process launch --stop-at-entry -> SuccessFinishResult, Error:  Success
Output Message:
Process 54353 launched: '/Users/user/Documents/git/coding-advent-2020/day11/target/debug/day11' (arm64)

[2020-12-23T16:10:24Z DEBUG codelldb::dap_codec] <-- {"type":"event","seq":5,"event":"output","body":{"output":"Process 54353 launched: '/Users/user/Documents/git/coding-advent-2020/day11/target/debug/day11' (arm64)\n\n"}}
[2020-12-23T16:10:24Z DEBUG codelldb::dap_codec] <-- {"type":"response","request_seq":2,"success":true,"command":"launch"}
[2020-12-23T16:10:24Z DEBUG codelldb::dap_codec] <-- {"type":"response","request_seq":7,"success":true,"command":"configurationDone"}
[2020-12-23T16:10:24Z DEBUG codelldb::dap_codec] --> {"command":"threads","type":"request","seq":8}
[2020-12-23T16:10:24Z DEBUG codelldb::dap_codec] <-- {"type":"response","request_seq":8,"success":true,"command":"threads","body":{"threads":[]}}
[2020-12-23T16:10:27Z DEBUG codelldb::debug_session] Debug event: 0x7fc640d16aa0 Event: broadcaster = 0x7fc631827058 (lldb.process), type = 0x00000001 (state-changed), data = { process = 0x7fc631827018 (pid = 54353), state = exited}
[2020-12-23T16:10:27Z DEBUG codelldb::dap_codec] <-- {"type":"event","seq":6,"event":"output","body":{"output":"Process exited with code -1.\n"}}
[2020-12-23T16:10:27Z DEBUG codelldb::dap_codec] <-- {"type":"event","seq":7,"event":"exited","body":{"exitCode":-1}}
[2020-12-23T16:10:27Z DEBUG codelldb::dap_codec] <-- {"type":"event","seq":8,"event":"terminated","body":{}}
[2020-12-23T16:10:27Z DEBUG codelldb::dap_codec] --> {"command":"disconnect","arguments":{"restart":false},"type":"request","seq":9}
[2020-12-23T16:10:27Z DEBUG codelldb::dap_codec] <-- {"type":"response","request_seq":9,"success":true,"command":"disconnect"}
[2020-12-23T16:10:27Z DEBUG codelldb::dap_session] Client has disconnected
[2020-12-23T16:10:27Z DEBUG codelldb::debug_session] End of the requests stream
[2020-12-23T16:10:27Z DEBUG codelldb::debug_session] DebugSession::drop()
[2020-12-23T16:10:27Z DEBUG codelldb] Session has ended
[2020-12-23T16:10:27Z DEBUG codelldb] Exiting
Debug adapter exit code=0, signal=null.
stefhol commented 3 years ago

@dguerri https://github.com/vadimcn/vscode-lldb/issues/397#issuecomment-749810022

Is working without a problem on ARM VScode insider with Rust x86 and Rust ARM

On current default x86 VScode it is working with Rust x86 and fails with Rust ARM

dguerri commented 3 years ago

On current default x86 VScode it is working with Rust x86 and fails with Rust ARM

Although this is expected, you made me think about a possible use case I didn’t consider before. @vadimcn, this is really interesting as x86 and arm are going to coexist form some time and maybe they should both be supported (within code-lldb)... what’s your take on this?

stefhol commented 3 years ago

I made a mistake. My settings were not on default

settings.json
{
    "lldb.library": "/Library/Developer/CommandLineTools/Library/PrivateFrameworks/LLDB.framework/Versions/A/LLDB"
   //or
    "lldb.library": "/Applications/Xcode.app/Contents/SharedFrameworks/LLDB.framework/Versions/A/LLDB"
}

activates x86 debugging

on vscode insider and vscode

Update: Default x86 VSCode you only need to add this settings.json and have a running x86 Rust debugger

this settings.json can also be generated by LLDB use alternate Backend : /usr/bin/lldb or LLDB use alternate Backend: /Library/Developer/CommandLineTools/usr/bin/lldb

vadimcn commented 3 years ago

This is really interesting as x86 and arm are going to coexist form some time and maybe they should both be supported (within code-lldb)... what’s your take on this?

Sure, I'm all for it, but we need to figure out how this would work. For example, I am not sure how Rosetta presents emulated x86 binaries to the debugger: as arm instructions or as original x86 instructions? In the former case - does it also translate the debug info? This will also need special handling in the debugger, as the executable file will be of the wrong architecture.

Tonyce commented 3 years ago

With @dguerri's share file and @KulSthl's config suggest. it worked for me , thanks .

截屏2020-12-31 下午9 29 09

rustc 1.51.0-nightly (e22670468 2020-12-30) with Rustup 1.23.1 install

serge-rgb commented 3 years ago

M1 macbook with x86 vscode and x86 rust. @KulSthl 's settings worked for me. Thanks!

vadimcn commented 3 years ago

Is working without a problem on ARM VScode insider with Rust x86 and Rust ARM

Great!
Note, though, that if you load a system LLDB backend via "lldb.library", it won't have Rust-specific support code. As a result, you may notice problems with visualization of some data types (such as enums).

dcow commented 3 years ago

Hey! I've run into this issue as well. I installed VSCode stable today as well as CodeLLDB (and rust-analyzer). What's the path to resolution and can I help us get there?

dcow commented 3 years ago

Also, might I suggest we label this confirmed rather than simply enhancement. The issue presents as a bug and is rather confusing to make sense of for a newcomer (to these tools and this project).

dguerri commented 3 years ago

Hi @dcow, from my perspective this is not a bug. M1 is an additional platform this project could officially support one day.

If you want to debug stuff on Darwin ARM64 right now, you can follow the guide I wrote in a comment above while using my PR to compile vscode-lldb (and llvm) from source. Alternatively, you can use the vsix package I have prepared. It's linked in a comment above.

In both cases, you need to use vscode insiders. Keep in mind that you will loose the ability to debug x86 code and that heap dump is bugged for llvm on M1 apparently (see comments on my PR).

Cheers

dcow commented 3 years ago

M1 is an additional platform this project could officially support one day.

Perhaps then a blurb in the README is in order linking this issue. I spent a large amount of time trying to figure out why my setup does not work after following instructions and being presented with:

process exited with status -1 (Error 1)

I even posted to the mailing list. Nothing indicated this was an issue with the instruction set that my processor uses. If it's not a bug then it would be helpful if it was made clear to newcomers that this extension only works for debugging x86 binaries at the moment (set expectations).

@dguerri I'll take a look at your stuff. Part of why I asked is because I don't want to use your stop-gap if a resolution for this issue is in progress and will be landing soon. I can wait a little while for things to come around so also just curious how close we are since this thread went silent for a few weeks other than people affirming their success using the workaround.

dcow commented 3 years ago

The additional context in https://github.com/vadimcn/vscode-lldb/pull/401 is helpful!

adamnemecek commented 3 years ago

@dcow For what it's worth, I ran into the same exact issue. I tried both Visual Studio Code and the VS Code Insiders edition, I saw this reddit thread indicating that that might make it work but to no avail.

stefhol commented 3 years ago

@adamnemecek @dcow

Hi rust arm-darwin is now stable. So you have as a default native rust installed. But the extension does not provide support for native m1.

run this command

 rustup default stable-x86_64-apple-darwin

start your intel vscode and add the alternate backend in the workspace you need it and start debugging

for the unofficial custom extension to work https://github.com/vadimcn/vscode-lldb/issues/397#issuecomment-749810022 (best performing) use insider arm vscode install from vsix in vscode (shift+p) install the default toolchain

 rustup default stable-aarch64-apple-darwin

and ideally do not use alternate backend (look at .vscode/settings.json and remove the "lldb.library" line)

adamnemecek commented 3 years ago

@KulSthl that worked! i can't believe i missed the vsix file. thanks so much!