31i73 / atom-dbg

An Atom package - An interactive debugger frontend
https://atom.io/packages/dbg
MIT License
30 stars 4 forks source link

Can someone contribute some usage examples #4

Closed QwertyZW closed 7 years ago

QwertyZW commented 7 years ago

Hi,

It would be great if someone can contribute a basic example backend that interacts with this frontend. I tried to use it, I stared at the api for quite a bit, created a stub consumer/provider, it felt like something was working but I didn't really understand what was happening:

The atom services API seems to be lacking documentation (It's just the 2 or 3 paragraphs I found here http://flight-manual.atom.io/behind-atom/sections/interacting-with-other-packages-via-services/). For instance I have several questions that remain unanswered:

1) Are provider services global? can all packages consume them? Can you be explicit about which packages to provide to and which packages to consume from? Those kind of questions lead me into thinking about packages depending on each other which lead me to here: https://discuss.atom.io/t/depending-on-other-packages/2360/31 The discussion suggests that in order to depend on another package you need to depend on yet another 3rd party package https://atom.io/packages/atom-package-dependencies. 2) If so how does this package select the backend to provide the frontend to? Does it support multiple 'provider/consumer' instance pairs?

The key take away from the minute services documentation I felt were those two sentences: "These methods will be called any time a package is activated that consumes their corresponding service" "These methods will be called any time a package is activated that provides their corresponding service."

So then the question becomes, in the case cyclic dependencies as is the case with this package; who gets toggled first?

If someone can shed any light on this I would greatly appreciate it

ProPuke commented 7 years ago

Usage examples sound good.

Currently the only example would be the dbg-gdb package.

Docs for atom are pretty lacking. I think most of us tend to just stumble through for a little while, take a few things apart, then eventually stuff make sense :S

To clarify a bit on your line of questioning:

dbg consumes services called dbgProvider, which are expected to conform to the dbgProvider pattern documented here. So debug providers identify themselves to dbg by providing that service. Thus each provider provides its own functions for start(), stop(), continue(), pause() etc.

If dbg is told to debug something, but is not told which provider to use it will loop through each provider, calling their canHandleOptions() function. The first function that says "yes, I can debug with those options" is selected. (canHandleOptions() should return a Promise. The first promise to fulfill as true is chosen. This way they can do file loading etc in the background if they need to check things.)

dbg also provides a service of its own, called dbg so that it can be remotely controlled. This has functions like debug(), stop(), addBreakpoint() etc. that can be called by other packages. When calling debug() you can also explicitly choose which provider to use, by name, and pass across provider-specific that it may understand.

Does this mostly make sense?

QwertyZW commented 7 years ago

Yea that's fair enough..I guess providing a stub implementation of the interfaces might help ease people into using this frontend Thank you