emacs-lsp / lsp-dart

lsp-mode :heart: dart
https://emacs-lsp.github.io/lsp-dart
GNU General Public License v3.0
202 stars 24 forks source link

Debug session process exited with status: killed #117

Closed zw963 closed 2 years ago

zw963 commented 3 years ago

Describe the bug

I am a new to dap, when i want to use dap-mode to debug a working flutter, i get following error.

Debug session process exited with status: killed

To Reproduce

Following is minimum config:

(require 'lsp-mode)
(require 'lsp-modeline)
(require 'lsp-headerline)
(require 'dap-mode)
(require 'dap-ui)
(require 'dap-mouse)
(require 'lsp-dart)
(require 'dart-mode)
(add-to-list 'auto-mode-alist '("\\.dart\\'" . dart-mode))

After use this config open a dart file in a flutter project.

run lsp success.

LSP :: Connected to [dart_analysis_server:22531/starting].
LSP :: Unable to autoconfigure company-mode.
LSP :: dart_analysis_server:22531 initialized successfully in folders: (/home/zw963/Dart/myapp/lib)
LSP :: Unable to autoconfigure company-mode.

run lsp-dart-dap-setup successful

LSP :: Starting to download https://github.com/Dart-Code/Dart-Code/releases/download/v3.25.1/dart-code-3.25.1.vsix to /home/zw963/.emacs.d/.extension/github/Dart-Code/Dart-Code/3.25.1/dart-code.zip...
End of buffer
Wrote /home/zw963/.emacs.d/.extension/github/Dart-Code/Dart-Code/3.25.1/dart-code.zip
LSP :: Finished downloading /home/zw963/.emacs.d/.extension/github/Dart-Code/Dart-Code/3.25.1/dart-code.zip...
LSP :: Decompressing /home/zw963/.emacs.d/.extension/github/Dart-Code/Dart-Code/3.25.1/dart-code.zip...
(Shell command succeeded with no output)
LSP :: Decompressed /home/zw963/.emacs.d/.extension/github/Dart-Code/Dart-Code/3.25.1/dart-code...
[LSP Dart] Dart debugger installed successfully!

Try debug on line 4

image

select Flutter::Debug as template

image

select a device to run.

Because both of device can run successful on my local laptop with flutter run -d linux, or flutter run -d web.

so, i just select one of them. linux

image

get following error message

Processing ... Debug session process exited with status: killed

Version

[Flutter SDK] /home/zw963/Dropbox/linux/utils/flutter/
[Flutter project] true
[Project entrypoint] /home/zw963/Dart/myapp/lib/main.dart
zw963 commented 2 years ago

so maybe vscode is passing some flag or doing something lsp-dart is not, we need to debug Dart-Code/Dart-Code code and confirm that

How? i remember one friend debug my flutter app on my laptop use vscode. can you please give me some guide?

ericdallo commented 2 years ago

also maybe @DanTup, Dart-Code's maintainer may have any clue why debugger on lsp-dart doesn't work but it does work on vscode, ref of screen white frozen

ericdallo commented 2 years ago

How? i remember one friend debug my flutter app on my laptop use vscode. can you please give me some guide?

I think most debug code of vscode is here: https://github.com/Dart-Code/Dart-Code/blob/master/src/extension/providers/debug_config_provider.ts

zw963 commented 2 years ago

I don't know, if following meaning debugger not work? because i saw a white background same as emacs?

image

image

image

ericdallo commented 2 years ago

Oh, so it doesn't work on vscode too?

From your screenshot, did you add a breakpoint on runApp? if so that's why the blank screen right?

zw963 commented 2 years ago

From your screenshot, did you add a breakpoint on runApp? if so that's why the blank screen right?

Oops, can you please confirm, if you add a break point, you device just a blank screen? i don't know ... i means it should entry home page.

zw963 commented 2 years ago

After i click continue, it seem like current in a debug session.

image

i can saw app started by VS Code.

image

So, the issue still come from emacs, we never start up app like this from emacs use lsp-dart-run, right?

ericdallo commented 2 years ago

yes, a black screen to me if adding a breakpoint on runApp...

runApp is what run your flutter app, there is no reason to add a breakpoint there for your case IMO

ericdallo commented 2 years ago

could you test dap-debug on emacs?

zw963 commented 2 years ago

could you test dap-debug on emacs?

Okay, don't know why, maybe emulator used by vscode? i get the error like this

error in process filter: -map: Args out of range: 619, 1, 608 error in process filter: Args out of range: 619, 1, 608

(in fact, i meet this error like this most of time when i try to start use emacs dap-debug)

zw963 commented 2 years ago

[{"event":"daemon.connected","params":{"version":"0.6.1","pid":26292}}] [{"event":"daemon.logMessage","params":{"level":"status","message":"Starting device daemon..."}}] [{"id":89635}] [{"event":"device.added","params":{"id":"chrome","name":"Chrome","platform":"web-javascript","emulator":false,"category":"web","platformType":"web","ephemeral":false,"emulatorId":null}}] [{"event":"device.added","params":{"id":"192.168.56.104:5555","name":"Xiaomi Redmi Note 7","platform":"android-x86","emulator":false,"category":"mobile","platformType":"android","ephemeral":true,"emulatorId":null}}]

ericdallo commented 2 years ago

hum, could be a lsp-dart bug, could you try M-x toggle-debug-on-error and then repro the erro again? it should print a stacktrace

ericdallo commented 2 years ago

I need to be off for some time now

zw963 commented 2 years ago

Debugger entered--Lisp error: (args-out-of-range 619 1 608)

((:point 619))

-map(# ((:point 619))) dap--set-breakpoints-request("/home/zw963/Stocks/marketbet_crawler/config/hot_re..." ((:point 619)))

f(compiled-function (file-name file-breakpoints) #<bytecode 0x1ca82cd411872896>)("/home/zw963/Stocks/marketbet_crawler/config/hot_re..." ((:point 619)))

dap--configure-breakpoints(#s(dap--debug-session :name "Flutter :: Debug" :last-id 7 :proc # :response-handlers #<hash-table eql 4/65 0x1576b5813967> :parser #s(dap--parser :waiting-for-response nil :response-result nil :headers nil :body nil :reading-body nil :body-length nil :body-received nil :leftovers "") :output-buffer #<buffer Flutter :: Debug out> :thread-id nil :workspace nil :threads (#<hash-table equal 2/65 0x1576b154549d>) :thread-states #<hash-table eql 1/65 0x1576b5813d9b> :active-frame-id nil :active-frame nil :cursor-marker nil :state pending :breakpoints #<hash-table equal 0/65 0x1576b58149cf> :thread-stack-frames #<hash-table eql 0/65 0x1576b5814e13> :launch-args (:name "Flutter :: Debug" :type "flutter" :request "launch" :dartSdkPath "/home/zw963/flutter/bin/cache/dart-sdk/" :maxLogLineLength 2000 :cwd "/home/zw963/Dart/test_flutter_performance/" :vmAdditionalArgs "" :vmServicePort 0 :debugExternalLibraries nil :debugSdkLibraries nil :evaluateGettersInDebugViews t :evaluateToStringInDebugViews t :flutterSdkPath "/home/zw963/flutter/" :flutterTrackWidgetCreation t :useFlutterStructuredErrors t :useWriteServiceInfo t :debuggerHandlesPathsEverywhereForBreakpoints t :flutterMode "debug" :dap-server-path ("node" "/home/zw963/.emacs.d/.extension/github/Dart-Code/D..." "flutter") :output-filter-function lsp-dart-dap--output-filter-function :program "/home/zw963/Dart/test_flutter_performance/lib/main..." :deviceId "192.168.56.104:5555" :deviceName "Xiaomi Redmi Note 7" :flutterPlatform "default") :current-capabilities #<hash-table equal 10/65 0x1576b18ea4b3> :error-message nil :loaded-sources nil :program-proc nil :metadata #<hash-table eql 0/65 0x1576b18ea46d> :output-displayed t) #<hash-table equal 12/65 0x1576b18b27a7> #f(compiled-function (&rest args2) #<bytecode -0xae5b6245831045d>)) dap--on-event(#s(dap--debug-session :name "Flutter :: Debug" :last-id 7 :proc # :response-handlers #<hash-table eql 4/65 0x1576b5813967> :parser #s(dap--parser :waiting-for-response nil :response-result nil :headers nil :body nil :reading-body nil :body-length nil :body-received nil :leftovers "") :output-buffer #<buffer Flutter :: Debug out> :thread-id nil :workspace nil :threads (#<hash-table equal 2/65 0x1576b154549d>) :thread-states #<hash-table eql 1/65 0x1576b5813d9b> :active-frame-id nil :active-frame nil :cursor-marker nil :state pending :breakpoints #<hash-table equal 0/65 0x1576b58149cf> :thread-stack-frames #<hash-table eql 0/65 0x1576b5814e13> :launch-args (:name "Flutter :: Debug" :type "flutter" :request "launch" :dartSdkPath "/home/zw963/flutter/bin/cache/dart-sdk/" :maxLogLineLength 2000 :cwd "/home/zw963/Dart/test_flutter_performance/" :vmAdditionalArgs "" :vmServicePort 0 :debugExternalLibraries nil :debugSdkLibraries nil :evaluateGettersInDebugViews t :evaluateToStringInDebugViews t :flutterSdkPath "/home/zw963/flutter/" :flutterTrackWidgetCreation t :useFlutterStructuredErrors t :useWriteServiceInfo t :debuggerHandlesPathsEverywhereForBreakpoints t :flutterMode "debug" :dap-server-path ("node" "/home/zw963/.emacs.d/.extension/github/Dart-Code/D..." "flutter") :output-filter-function lsp-dart-dap--output-filter-function :program "/home/zw963/Dart/test_flutter_performance/lib/main..." :deviceId "192.168.56.104:5555" :deviceName "Xiaomi Redmi Note 7" :flutterPlatform "default") :current-capabilities #<hash-table equal 10/65 0x1576b18ea4b3> :error-message nil :loaded-sources nil :program-proc nil :metadata #<hash-table eql 0/65 0x1576b18ea46d> :output-displayed t) #<hash-table equal 3/65 0x1576b3b0cd05>)

f(compiled-function (m) #<bytecode 0x4f683fa56bc2ec7>)("{\"seq\":39,\"type\":\"event\",\"event\":\"initialized\"}")

mapc(#f(compiled-function (m) #<bytecode 0x4f683fa56bc2ec7>) ("{\"seq\":39,\"type\":\"event\",\"event\":\"initialized\"}" "{\"seq\":40,\"type\":\"event\",\"event\":\"dart.serviceRegi..." "{\"seq\":41,\"type\":\"event\",\"event\":\"dart.serviceRegi..." "{\"seq\":42,\"type\":\"event\",\"event\":\"dart.serviceRegi..." "{\"seq\":43,\"type\":\"event\",\"event\":\"dart.serviceRegi..." "{\"seq\":44,\"type\":\"event\",\"event\":\"dart.serviceRegi..." "{\"seq\":45,\"type\":\"event\",\"event\":\"dart.serviceRegi..."))

f(compiled-function (_ msg) #<bytecode 0xa2d204d2092f4eb>)(# "Content-Length: 47\15\n\15\n{\"seq\":39,\"type\":\"event\",\"ev...")

zw963 commented 2 years ago

I need to be off for some time now

Okay, current is 4:05 +0800, before dawn, i am so tired.

zw963 commented 2 years ago

Debugger entered--Lisp error: (args-out-of-range 619 1 608) #((:point 619)) -map(# ((:point 619))) dap--set-breakpoints-request("/home/zw963/Stocks/marketbet_crawler/config/hot_re..." ((:point 619))) #f(compiled-function (file-name file-breakpoints) #<bytecode 0x1ca82cd411872896>)("/home/zw963/Stocks/marketbet_crawler/config/hot_re..." ((:point 619))) dap--configure-breakpoints(#s(dap--debug-session :name "Flutter :: Debug" :last-id 7 :proc # :response-handlers #<hash-table eql 4/65 0x1576b5813967> :parser #s(dap--parser :waiting-for-response nil :response-result nil :headers nil :body nil :reading-body nil :body-length nil :body-received nil :leftovers "") :output-buffer # :thread-id nil :workspace nil :threads (#<hash-table equal 2/65 0x1576b154549d>) :thread-states #<hash-table eql 1/65 0x1576b5813d9b> :active-frame-id nil :active-frame nil :cursor-marker nil :state pending :breakpoints #<hash-table equal 0/65 0x1576b58149cf> :thread-stack-frames #<hash-table eql 0/65 0x1576b5814e13> :launch-args (:name "Flutter :: Debug" :type "flutter" :request "launch" :dartSdkPath "/home/zw963/flutter/bin/cache/dart-sdk/" :maxLogLineLength 2000 :cwd "/home/zw963/Dart/test_flutter_performance/" :vmAdditionalArgs "" :vmServicePort 0 :debugExternalLibraries nil :debugSdkLibraries nil :evaluateGettersInDebugViews t :evaluateToStringInDebugViews t :flutterSdkPath "/home/zw963/flutter/" :flutterTrackWidgetCreation t :useFlutterStructuredErrors t :useWriteServiceInfo t :debuggerHandlesPathsEverywhereForBreakpoints t :flutterMode "debug" :dap-server-path ("node" "/home/zw963/.emacs.d/.extension/github/Dart-Code/D..." "flutter") :output-filter-function lsp-dart-dap--output-filter-function :program "/home/zw963/Dart/test_flutter_performance/lib/main..." :deviceId "192.168.56.104:5555" :deviceName "Xiaomi Redmi Note 7" :flutterPlatform "default") :current-capabilities #<hash-table equal 10/65 0x1576b18ea4b3> :error-message nil :loaded-sources nil :program-proc nil :metadata #<hash-table eql 0/65 0x1576b18ea46d> :output-displayed t) #<hash-table equal 12/65 0x1576b18b27a7> #f(compiled-function (&rest args2) #<bytecode -0xae5b6245831045d>)) dap--on-event(#s(dap--debug-session :name "Flutter :: Debug" :last-id 7 :proc # :response-handlers #<hash-table eql 4/65 0x1576b5813967> :parser #s(dap--parser :waiting-for-response nil :response-result nil :headers nil :body nil :reading-body nil :body-length nil :body-received nil :leftovers "") :output-buffer # :thread-id nil :workspace nil :threads (#<hash-table equal 2/65 0x1576b154549d>) :thread-states #<hash-table eql 1/65 0x1576b5813d9b> :active-frame-id nil :active-frame nil :cursor-marker nil :state pending :breakpoints #<hash-table equal 0/65 0x1576b58149cf> :thread-stack-frames #<hash-table eql 0/65 0x1576b5814e13> :launch-args (:name "Flutter :: Debug" :type "flutter" :request "launch" :dartSdkPath "/home/zw963/flutter/bin/cache/dart-sdk/" :maxLogLineLength 2000 :cwd "/home/zw963/Dart/test_flutter_performance/" :vmAdditionalArgs "" :vmServicePort 0 :debugExternalLibraries nil :debugSdkLibraries nil :evaluateGettersInDebugViews t :evaluateToStringInDebugViews t :flutterSdkPath "/home/zw963/flutter/" :flutterTrackWidgetCreation t :useFlutterStructuredErrors t :useWriteServiceInfo t :debuggerHandlesPathsEverywhereForBreakpoints t :flutterMode "debug" :dap-server-path ("node" "/home/zw963/.emacs.d/.extension/github/Dart-Code/D..." "flutter") :output-filter-function lsp-dart-dap--output-filter-function :program "/home/zw963/Dart/test_flutterperformance/lib/main..." :deviceId "192.168.56.104:5555" :deviceName "Xiaomi Redmi Note 7" :flutterPlatform "default") :current-capabilities #<hash-table equal 10/65 0x1576b18ea4b3> :error-message nil :loaded-sources nil :program-proc nil :metadata #<hash-table eql 0/65 0x1576b18ea46d> :output-displayed t) #<hash-table equal 3/65 0x1576b3b0cd05>) #f(compiled-function (m) #<bytecode 0x4f683fa56bc2ec7>)("{"seq":39,"type":"event","event":"initialized"}") mapc(#f(compiled-function (m) #<bytecode 0x4f683fa56bc2ec7>) ("{"seq":39,"type":"event","event":"initialized"}" "{"seq":40,"type":"event","event":"dart.serviceRegi..." "{"seq":41,"type":"event","event":"dart.serviceRegi..." "{"seq":42,"type":"event","event":"dart.serviceRegi..." "{"seq":43,"type":"event","event":"dart.serviceRegi..." "{"seq":44,"type":"event","event":"dart.serviceRegi..." "{"seq":45,"type":"event","event":"dart.serviceRegi...")) #f(compiled-function ( msg) #<bytecode 0xa2d204d2092f4eb>)(# "Content-Length: 47\15\n\15\n{"seq":39,"type":"event","ev...")

If above backtrace useful? in fact, i give you several times, but, this time, maybe more useful because less noise.

ericdallo commented 2 years ago

Sounds like a issue here, it'd need further debugging on dap-mode side

zw963 commented 2 years ago

Sounds like a issue here

Cool! if we can fix this after tomorrow wake up? i am waiting debug feature working on emacs for a long long time.

zw963 commented 2 years ago

you can go off for you things, if still need more detail? if you need more context, i will send to you, and sleep ...

zw963 commented 2 years ago

I upload all my package + downloaded dart client files https://zw963.github.io/package.zip, if this issue about emacs lisp code (not others), i guess you can reproduce on it, with only following config:

(require 'dart-mode) (require 'lsp-mode) (require 'lsp-dart) (require 'lsp-ui) (require 'lsp-modeline) (require 'lsp-headerline) (require 'lsp-treemacs) (require 'dap-mode) (require 'dap-ui) (require 'dap-mouse) (require 'flycheck) (require 'company)

(setq lsp-dart-flutter-widget-guides nil) (add-hook 'dart-mode-hook 'lsp) (add-to-list 'auto-mode-alist '("\.dart\'" . dart-mode))

BTW: dap-go can work on my emacs.

zw963 commented 2 years ago

Hi, @ericdallo , I really found a issue which exists on my Arch Linux + following official version.

 ╰─ $ flutter --version
Flutter 2.8.1 • channel unknown • unknown source
Framework • revision 77d935af4d (2 weeks ago) • 2021-12-16 08:37:33 -0800
Engine • revision 890a5fca2e
Tools • Dart 2.15.1

When i want to build a flutter project the FIRST TIME for a android emulator device, i must specify my device explicitly.

flutter run -d 192.168.56.101:5555

that, is, if i am not specify it, when i run flutter run, it told me "Launching lib/main.dart on Xiaomi Redmi Note 7 in debug mode..." That device name is right, but, it keep blocking on Running Gradle task 'assembleDebug'.. step, i am waiting for more than ten minutes, it still running, but, when if i specify device explicitly, like this:

but, if only exists one chrome device, it can build successful without specify -d.

it only need less one minutes to start run on my phone.

I don't know if this issue relative to my issue, just report here.

zw963 commented 2 years ago

Okay, that maybe not this issue, because, after i reboot, and create a new project, it works when flutter run.

i guess, we need one successful building to create the connection for flutter with genymotion, anyway, please ignore my message.

DanTup commented 2 years ago

@ericdallo sorry for the delay - I scanned through the above although I'm not certain what the current state of the issue is (I'm unfamiliar with the Emacs integration). If you think it's likely something form Dart-Code's DAP (or that it may require my input to debug), please let me know!

ericdallo commented 2 years ago

Thanks @DanTup, I out of options here as well unfortunately

zw963 commented 2 years ago

Can i help on debug? @DanTup , @ericdallo ?

ericdallo commented 2 years ago

As far as I can tell, there is something the debugger program does that is not doing only for lsp-dart, if you run flutter run works, maybe debug what flags vscode Dart-Code pass to the debugger, lsp-dart ones are here and here

DanTup commented 2 years ago

@zw963 can you describe exactly what the issue is? There were a few different things mentioned above so I'm not sure exactly which issues are remaining.

If the issue only occurs from Emacs and not VS Code, then it may be useful to capture a log from VS Code:

This log will include all of the arguments passed to the debug adapter, so if they are different to Emacs it could be clear. (note: VS Code will pass -d and the ID of the device selected in the status bar).

zw963 commented 2 years ago

@DanTup , okay, wait a seconds, i write somethings now.

zw963 commented 2 years ago

Sorry, it so wired, i guess i run it successful now, right? @ericdallo

image

I update my node to latest 16.13.1 stable version. I update my dart dap extension "3.28.0"

It starts to work now ...

ericdallo commented 2 years ago

yes, you can use dap-continue, dap-step-in, dap-step-out and all dap-mode stuff to debug, it seems to work now :)

ericdallo commented 2 years ago

I should bump dap-extension to latest and do a release if we confirm this issue is "Fixed" now

zw963 commented 2 years ago

I update my node to latest 16.13.1 stable version. I update my dart dap extension "3.28.0"

It starts to work now ...

I test all button, it seem like all feature works, though, i still not familiar debug use emacs, but, anyway, it works!

I am so wired why it start working now, i update to newest version nodejs version several month ago, but because dart dap not work, i downgrade to 14, still not work, then i updated to 17.X newest version, not work, then i install stable 16.13.1 today, it works with this version.

And, i do update dart dap extension use lsp-dart-dap-setup several times yesterday, one once today, i don't know what happen, but it works now!

ericdallo commented 2 years ago

I intend to remove the node extension integration soon for dart sdks that already support the dap debugger, @DanTup thanks for the help! I should release a new version soon @zw963 with those other fixes

zw963 commented 2 years ago

I intend to remove the node extension integration soon for dart sdks that already support the dap debugger, @DanTup thanks for the help!

Okay, happen to hear this. BTW, i test on lsp-dart-run, it works too, i can hot reload code as expected too.

@DanTup , Thank you very much, when i come here, all issue is gone~

ericdallo commented 2 years ago

Released lsp-dart 1.21.0

zw963 commented 2 years ago

Released lsp-dart 1.21.0

Okay, wait a second, i will test on it.

sorry, one more question, should we start lsp mode first, then start dart-mode with lsp, or reverse? which is better?

ericdallo commented 2 years ago

dap-mode require lsp-mode, so lsp-mode first

zw963 commented 2 years ago

Hi, i updated to use 1.21,0, Dart-Code/3.32.0, it works!

zw963 commented 2 years ago

Hi, i don't know why dap start work now after many research, i consider because i keep using old 3.25.1, never update to 3.28.0, but anyway, if this issue happen again, i will find the reason!

zw963 commented 2 years ago

@ericdallo , sorry, need double confirm one question, if we ever support auto add import statement when a class was be checked is missing, or, it always need use click then add import statement?

I remember before lsp-dart can auto insert import statement for me? but after update, it not support anymore, need a click to confirm, or, just because i am remember wrong?

Thank you.

ericdallo commented 2 years ago

AFAIK only via code actions or manually, nothing automatically

DanTup commented 2 years ago

FWIW, the LSP server does support automatically inserting completions (the edits should be included in the additionalTextEdits on a completion item, although it will need resolving first). I don't know whether your LSP client supports this though.

ericdallo commented 2 years ago

@DanTup yes, lsp-mode does supports that and I actually use that with Clojure via clojure-lsp LSP server, it works perfectly, does Dart SDK already has this feature or we would need to add to the analysis_server?

DanTup commented 2 years ago

@ericdallo it's already there. It does require that you're calling completion/resolve for the item being completed though (the edits are computed lazily and not up-front for every item).

ericdallo commented 2 years ago

yes, it makes sense, via the completion/resolveItem right? if so, I think it should work already, do you have an dart code example?

DanTup commented 2 years ago

@ericdallo it should just work everywhere. For example if you open a completely blank .dart file and begin typing File, but select it from the completion, it should add an import for dart:io.

If that doesn't work, could you capture a log and see if resolveItem is being called (and if so, if the additionalTextEdits are in the response)?

ericdallo commented 2 years ago

Yeah, I confirmed it works as expected with dart SDK 2.15.1!

auto-import

DanTup commented 2 years ago

Neat :) I would've expected there to be two entries - one that auto-imports from dart:io and one from dart:html I think. The difference shows up in the details field after resolving. It's possible there's some de-duping going on in the client though? 🤔

ericdallo commented 2 years ago

Hum, good question, but my guess is that we have no dedupe c/c @yyoncho Anyway, thanks for the help as always @DanTup, it seems to be some issue on @zw963 config, maybe a outdated flutter/dart SDK?

DanTup commented 2 years ago

Possible - though it's been in there for a while. It's also possible to disable it with the suggestFromUnimportedLibraries setting, but it defaults to on.