Theia: multi-session breakpoint highlighted lines disappear or jump around

Created on 18 Sep 2020  路  4Comments  路  Source: eclipse-theia/theia

Bug Description:

the breakpoint highlighted lines will disappear or jump around between difference debug sessions (it should be noted this issue won't come out for single session breakpoints). For example when debugging multi-process python code, when we only set a breakpoint in main process, but sometimes current breakpoint hightlighted line will disappear and jump to the subprocess debug breakpoint.

Steps to Reproduce:

  1. install latest vscode python plugin
  2. start debug the python code below
from multiprocessing import Process
import threading
import time

class myThread (threading.Thread):
   def __init__(self, threadID, name, counter):
      threading.Thread.__init__(self)
      self.threadID = threadID
      self.name = name
      self.counter = counter
   def run(self):
      print_time(self.name, 10, self.counter)

def print_time(threadName, counter, delay):
   while counter:
      time.sleep(delay)
      counter -= 1

def print_func(continent='Asia'):
    thread1 = myThread(1, "Thread-1", 1)
    thread1.start()
    time.sleep(120)
    print('The name of continent is : ', continent)

if __name__ == "__main__":  # confirms that the code is under main function
    names = ['America', 'Europe', 'Africa']
    procs = []
    proc = Process(target=print_func)  # instantiating without any argument
    procs.append(proc)
    proc.start()

    # instantiating process with arguments
    for name in names:
        proc = Process(target=print_func, args=(name,))
        procs.append(proc)
        proc.start()

    # complete the processes
    for proc in procs:
        proc.join()
  1. add breakpoint to line 36
  2. continue if there is only one session(or one thread), then when the thread of the subprocess exit(wait 10 seconds), the breakpoint highlighted line will jump from line 36 to line 22


normal:
1

abnormal:
2

Additional Information

  • Operating System: ubuntu 18
  • Theia Version: master branch 993b7a8bc73b23bc252735c4c356f8ced89958bc
debug python vscode

All 4 comments

@tom-shan I assume the same scenario works for you correctly in vscode?
I wanted to confirm if it was a bug with the framework or the python extension itself.

@tom-shan I assume the same scenario works for you correctly in vscode?
I wanted to confirm if it was a bug with the framework or the python extension itself.

yes, I think so, it works much better in vscode, the current breakpoint highlighted line will not disappear.

Actually I have found some problems in theia about the manipulation of "thread" DAP event with "started" or "exited" reason.
In short, when theia receives the "thread" event which is generated by another debug session, theia will change to that session see https://github.com/eclipse-theia/theia/blob/master/packages/debug/src/browser/debug-session.tsx#L102-L108

Here is vscode's implementation of the thread DAP event for reference:

this.rawListeners.push(this.raw.onDidThread(event => {
    if (event.body.reason === 'started') {
        // debounce to reduce threadsRequest frequency and improve performance
        if (!this.fetchThreadsScheduler) {
            this.fetchThreadsScheduler = new RunOnceScheduler(() => {
                this.fetchThreads();
            }, 100);
            this.rawListeners.push(this.fetchThreadsScheduler);
        }
        if (!this.fetchThreadsScheduler.isScheduled()) {
            this.fetchThreadsScheduler.schedule();
        }
    } else if (event.body.reason === 'exited') {
        this.model.clearThreads(this.getId(), true, event.body.threadId);
        const viewModel = this.debugService.getViewModel();
        const focusedThread = viewModel.focusedThread;
        if (focusedThread && event.body.threadId === focusedThread.threadId) {
            // De-focus the thread in case it was focused
            this.debugService.focusStackFrame(undefined, undefined, viewModel.focusedSession, false);
        }
    }
}));
Was this page helpful?
0 / 5 - 0 ratings

Related issues

Beetix picture Beetix  路  3Comments

cekvenich picture cekvenich  路  3Comments

kittaakos picture kittaakos  路  3Comments

akosyakov picture akosyakov  路  3Comments

dhananjayharel picture dhananjayharel  路  3Comments