首页 \ 问答 \ 在VS代码中调试由电子产生的子进程(Debugging child process spawned by electron in VS code)

在VS代码中调试由电子产生的子进程(Debugging child process spawned by electron in VS code)

我正在使用webpack在typescript中构建一个电子应用程序,我遇到了以下vscode调试问题:

信息:主进程通过调用fork('./dist/child', [], {execArgv: ['--debug-brk=3001']})生成子进程。 我的launch.json如下所示:

{
    "name": "Debug child process",
    "type": "node",
    "request": "attach",
    "address": "localhost",
    "port": 3001
}

脚步:

  1. 我在终端启动了我的电子应用程序
  2. 点击F5启动vscode调试器

正如预期的那样,它在我的webpack构建的第一行中为子进程代码打破了一次(由于debug-brk )。 这允许我在我的打字稿源中使用调试器注册其他断点。

  1. 正如预期的那样,一旦继续,vscode会在我的ts源中很好地击中那些断点。 好。

问题:如果我现在重新启动调试器(没有任何源更改或注册新断点)...

  1. 构建中的初始断点未被命中

  2. 我手动添加的断点被标记为忽​​略( 断点被忽略,因为找不到生成的代码(源映射问题?)。

  3. 此时我添加的任何新断点也会被标记为忽​​略。

我意识到Attach的调试与Launch的调试不同,并且需要一个debug-brk fork强制执行的初始中断,以便为连接的节点进程注册断点。

问:但是,我想在调试过程中改进的是,调试器的简单重启不足以重新注册一些新的(或旧的)断点。 我必须完全退出我的应用程序并再次启动它, 然后在重新启动时调试器将再次停止在我的构建的第一行并识别我在该阶段添加的断点。

有没有人可以建议改善这种调试体验? 与启动调试会话相比,我不介意一些额外的步骤,但是必须手动退出并启动我的应用程序只是为了调试它有点麻烦,并且实际上在控制台中实际调试几乎更可取...

谢谢你的建议!


I am building an electron app in typescript with webpack, and I am running into the following vscode debugging problem:

Info: The main process spawns a child process by calling fork('./dist/child', [], {execArgv: ['--debug-brk=3001']}). My launch.json looks as follows:

{
    "name": "Debug child process",
    "type": "node",
    "request": "attach",
    "address": "localhost",
    "port": 3001
}

Steps:

  1. I launch my electron app in a terminal
  2. hit F5 to launch the vscode debugger

As expected, it hits a break at the first line of my webpack build for the child process code (due to debug-brk). This allows me to register additional breakpoints with the debugger in my typescript source.

  1. as expected, upon continuing, vscode hits those breakpoints nicely within my ts source. Good.

Problem: If I now restart the debugger (without any source changes or registering new breakpoints)...

  1. The initial breakpoint in the build is not hit

  2. My manually added breakpoints are marked ignored (Breakpoint ignored because generated code not found (source map problem?).)

  3. Any new breakpoint I add at this point is also marked ignored.

I realize that debugging by Attach is different from debugging by Launch, and that the initial break enforced by a debug-brk fork is needed to give one the opportunity to register breakpoints for a node process that is attached to.

Question: However, what I would like to improve in my debugging experience is that a simple restart of the debugger is not enough to re-register some new (or old) breakpoints. I have to entirely exit my app and start it again, before the debugger upon restart will again halt at the first line of my build and recognize breakpoints I add at that stage.

Is there a way anybody could recommend to improve this debug experience? I don't mind some extra steps as compared to a Launch debugging session, but having to manually quit and start my app just to debug it is a bit cumbersome, and makes actually debugging in the console almost more preferable...

Thanks for any advise!


原文:https://stackoverflow.com/questions/42495365
更新时间:2022-08-28 20:08

最满意答案

使用此代码

-(void)playMovieFinished:(NSNotification*)theNotification
{
    [[NSNotificationCenter defaultCenter]
     removeObserver:self
     name:MPMoviePlayerPlaybackDidFinishNotification
     object:moviePlayer];
    [moviePlayer stop];
    // Change Segue ID Here    

    [self  performSegueWithIdentifier:@"VC_5" sender:self];
}

use this code

-(void)playMovieFinished:(NSNotification*)theNotification
{
    [[NSNotificationCenter defaultCenter]
     removeObserver:self
     name:MPMoviePlayerPlaybackDidFinishNotification
     object:moviePlayer];
    [moviePlayer stop];
    // Change Segue ID Here    

    [self  performSegueWithIdentifier:@"VC_5" sender:self];
}

相关问答

更多
  • 我发现了它不重复的原因。 在我开始电影之后,我开始了一些内存密集型进程,不幸的是,对于我来说,我在主线程中发生了很多事情,当电影结束时,没有足够的内存可供重复使用。 瘸。 所以代码没有问题。 现在我将探索使用其他线程进行某些过程,以便在电影的主线上腾出空间来重复。 I have discovered the reason why it is not repeating. After I start the movie, I start a number of memory intensive process ...
  • 最后通过在moviePlayerPlayBackDidFinish添加其他代码解决了我的问题: self.navigationController?.popViewControllerAnimated(true) 经过大量研究,我从这里找到了解决方案: dismissViewControllerAnimated()不会解除视图控制器 Finally solved my issue by adding the additional code in moviePlayerPlayBackDidFinish: ...
  • 我在这里已经回答了这个问题,代码是:将方向改回肖像 你有一个支持所有方向的应用程序 ,一个只支持肖像的主视图控制器 ,以及一个支持所有方向的子类 MPMoviePlayerController (或者全部,但是颠倒,或只有横向,或任何你想要的......)。 I have answered this here, with code: Change Orientation back to Portrait You have an app that supports all orientations, a ma ...
  • 我的问题解决了,我将解释我迄今为止所做的。 当我找不到这种行为的解决方案/解释(我发现它很奇怪)时,我开始做很多很多的日志记录,所以我注意到当我记录我总是获得的当前位置(在iOS 5.1中) currentPlaybackTime = nan 但在iOS 5中,我获得了0.00000的正常值 所以我做了一个计时器(重复自己)每次记录当前时间 ,所以我注意到它在一段时间后从nan变为0.00000 我所做的结论是,在设置PlaybackTime之前,我需要等一下(不明白为什么),等待1 毫秒 (1/10 ...
  • 使用此代码 -(void)playMovieFinished:(NSNotification*)theNotification { [[NSNotificationCenter defaultCenter] removeObserver:self name:MPMoviePlayerPlaybackDidFinishNotification object:moviePlayer]; [moviePlayer stop]; // Change Segue ...
  • 这几乎直接来自MoviePlayer示例项目,其中overlayView是您定义的视图。 NSArray *windows = [[UIApplication sharedApplication] windows]; if ([windows count] > 1) { // Locate the movie player window UIWindow *moviePlayerWindow = [[UIApplication sharedApplication] keyWindow]; ...
  • 我从来没有得到self.navigationController.parentViewController工作广告,但这对我self.navigationController.parentViewController : NSArray *viewControllerArray = [self.navigationController viewControllers]; int parentViewControllerIndex = [viewControllerArray count] - 2; [[vi ...
  • 我想我看到了你的问题。 您在分配之前释放了player 。 基本上,编译器第一次浏览代码时,它会看到player获得保留计数-1(因为release调用),然后在分配时再次上升到0(因为new调用)。 因此,当您第一次尝试设置任何属性时,没有对象设置属性( player永远不会有保留计数为1)。 你应该做的是检查player的存在,只有它已经存在,然后你释放它。 尝试对makePlayer方法进行此更改: - (void) makePlayer { if (player != nil) { [playe ...
  • 可能问题不是那么清楚......但是如果你想拥有一个播放器的2个实例,一起播放相同的剪辑,你需要有2个AVPlayer实例。 这是我开始的地方: http://iosguy.com/2012/01/11/multiple-video-playback-on-ios/ 很清楚 Probably the question was not that clear… But if you want to have 2 instance of a player, playing together the same cl ...
  • AVPlayerViewController是UIViewController的子类。 因此,不要使用常规视图控制器创建自定义电影播放器控制器,如下所示: 不要子类化AVPlayerViewController。 不支持覆盖此类的方法,并导致未定义的行为。 试试这样: import UIKit import AVKit import AVFoundation class MoviePlayerViewController: AVPlayerViewController { override func ...

相关文章

更多

最新问答

更多
  • 获取MVC 4使用的DisplayMode后缀(Get the DisplayMode Suffix being used by MVC 4)
  • 如何通过引用返回对象?(How is returning an object by reference possible?)
  • 矩阵如何存储在内存中?(How are matrices stored in memory?)
  • 每个请求的Java新会话?(Java New Session For Each Request?)
  • css:浮动div中重叠的标题h1(css: overlapping headlines h1 in floated divs)
  • 无论图像如何,Caffe预测同一类(Caffe predicts same class regardless of image)
  • xcode语法颜色编码解释?(xcode syntax color coding explained?)
  • 在Access 2010 Runtime中使用Office 2000校对工具(Use Office 2000 proofing tools in Access 2010 Runtime)
  • 从单独的Web主机将图像传输到服务器上(Getting images onto server from separate web host)
  • 从旧版本复制文件并保留它们(旧/新版本)(Copy a file from old revision and keep both of them (old / new revision))
  • 西安哪有PLC可控制编程的培训
  • 在Entity Framework中选择基类(Select base class in Entity Framework)
  • 在Android中出现错误“数据集和渲染器应该不为null,并且应该具有相同数量的系列”(Error “Dataset and renderer should be not null and should have the same number of series” in Android)
  • 电脑二级VF有什么用
  • Datamapper Ruby如何添加Hook方法(Datamapper Ruby How to add Hook Method)
  • 金华英语角.
  • 手机软件如何制作
  • 用于Android webview中图像保存的上下文菜单(Context Menu for Image Saving in an Android webview)
  • 注意:未定义的偏移量:PHP(Notice: Undefined offset: PHP)
  • 如何读R中的大数据集[复制](How to read large dataset in R [duplicate])
  • Unity 5 Heighmap与地形宽度/地形长度的分辨率关系?(Unity 5 Heighmap Resolution relationship to terrain width / terrain length?)
  • 如何通知PipedOutputStream线程写入最后一个字节的PipedInputStream线程?(How to notify PipedInputStream thread that PipedOutputStream thread has written last byte?)
  • python的访问器方法有哪些
  • DeviceNetworkInformation:哪个是哪个?(DeviceNetworkInformation: Which is which?)
  • 在Ruby中对组合进行排序(Sorting a combination in Ruby)
  • 网站开发的流程?
  • 使用Zend Framework 2中的JOIN sql检索数据(Retrieve data using JOIN sql in Zend Framework 2)
  • 条带格式类型格式模式编号无法正常工作(Stripes format type format pattern number not working properly)
  • 透明度错误IE11(Transparency bug IE11)
  • linux的基本操作命令。。。