采用一个简单的 C++ 文件,如下所示:
#include <iostream>
using namespace std;
int main(void)
{
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
cout << "Hello World";
return 0;
}
Run Code Online (Sandbox Code Playgroud)
设置断点在return 0. 设置此启动配置:
{
"name": "g++ build and debug active file",
"type": "cppdbg",
"request": "launch",
"program": "${fileDirname}/${fileBasenameNoExtension}",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"environment": [],
"externalConsole": false,
"MIMode": "gdb",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
],
"preLaunchTask": "g++ build active file",
"miDebuggerPath": "/usr/bin/gdb"
}
Run Code Online (Sandbox Code Playgroud)
转到左侧边栏中的调试选项卡,然后单击绿色运行按钮。
预期情况:我能看到Hello World某处。 …
经过几天令人沮丧的运行之后,我需要考虑在 VSCode 中调试 celery 工作进程。这是遵循 Celery 文档中创建消息处理程序的建议流程,而不是从同一应用程序发布/订阅。
celery.py 文件:
from __future__ import absolute_import, unicode_literals
import os
import json
from celery import Celery, bootsteps
from kombu import Consumer, Exchange, Queue
dataFeedQueue = Queue('statistical_forecasting', Exchange('forecasting_event_bus', 'direct', durable=False), 'DataFeedUpdatedIntegrationEvent')
# set the default Django settings module for the 'celery' program.
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'config.settings.local')
app = Celery('statistical_forecasting')
app.config_from_object('django.conf:settings', namespace='CELERY')
# Not required yet as handler is within this file
#app.autodiscover_tasks()
class DataFeedUpdatedHandler(bootsteps.ConsumerStep):
def get_consumers(self, channel):
return [Consumer(channel, queues=[dataFeedQueue], callbacks=[self.handle_message], accept=['json'])]
def handle_message(self, body, message):
event …Run Code Online (Sandbox Code Playgroud) 我正在调试 Python 脚本。我的配置看起来像这样:
{
"name": "debug script.py",
"type": "python",
"request": "launch",
"program": "/path/to/script.py",
"console": "integratedTerminal"
}
Run Code Online (Sandbox Code Playgroud)
运行脚本时,我需要在其前面加上可执行文件前缀,aws-access以便自己能够访问 AWS 上的某些资源(否则会出现Permission Denied错误):
aws-access python script.py
Run Code Online (Sandbox Code Playgroud)
如何将此前缀添加到调试命令中?
请注意,使用Code Runner插件执行我的代码时,这很容易做到:
"code-runner.executorMap": {
"python": "aws-access $pythonPath -u $fullFileName"
}
Run Code Online (Sandbox Code Playgroud) 我在某些 PHP 代码上使用 XDebug 和 Visual Studio Code 调试器,并且变量部分没有显示我的对象之一的所有属性。下面的屏幕截图显示,如果我添加$this->_data到“监视”部分,该属性确实存在。但是,在“变量”部分中_data并未显示为属性。$this为什么 Visual Studio Code 不显示 中的所有属性$this,以及如何让它显示所有属性?
我一直在研究交给我的 Powershell 脚本。以前从未处理过 powershell 脚本,我有很多东西要学习。到目前为止,我一直在使用 Visual Studio Code 来运行/调试它。它一直运行良好,但是,我在处理多个线程的特定区域遇到了问题。我无法在特定断点处暂停 Powershell 脚本。
经过过去几天的研究,看来线程是可以在 Visual Studio 中处理的东西。我下载了 Visual Studio Community 2019 并尝试安装“ Powershell Tools for Visual Studio ”套件。根据包管理器的说法,它已经安装没有问题。但是,我无法创建 Powershell 项目(我应该能够做到),并且我无法在 Visual Studio 2019 的扩展管理器中看到它。为了确保这不是我的错误,我尝试了安装多次并使用不同的方法。
我还研究了 Windows 内置 Powershell ISE 进行调试,但遇到了与 Visual Studio Code 相同的问题。这使得我无法在我需要查看的特定位置进行正确调试。然而,我已经使用了Write-Host大部分脚本,因为这是交给我的脚本,我宁愿能够暂停并查看给定状态下的所有变量,而不必将它们全部打印出来。
有没有办法在 Visual Studio Code 中轻松调试多线程应用程序?如果没有,除了添加 或类似的 cmdlet 之外,还有什么Write-Host建议Write-Debug。
powershell visual-studio-code vscode-debugger visual-studio-2019
我安装了 chrome 扩展的调试器。我使用运行我的应用程序
webpack-dev-server -d --config webpack.dev.js --inline
Run Code Online (Sandbox Code Playgroud)
我正在运行一个 React 应用程序,所有源代码都位于 /src 文件夹下。我有 js、ts 和 tsx 文件。当我在渲染函数上放置断点时,编辑器会正确中断执行,但是当我在按钮的 onClick 事件上放置断点时,它不会中断,它只是继续执行代码。
我的 webpack 配置的相关部分如下:
mode: 'development',
devtool: 'source-map',
entry: {
bundle: [
'@babel/polyfill',
'react-hot-loader/patch',
`webpack-dev-server/client?http://${host}:${devPort}`,
'webpack/hot/only-dev-server',
path.resolve(__dirname, 'src/index.js'),
],
},
output: {
path: path.resolve(__dirname, 'public'),
publicPath: '/',
filename: '[name].[hash:16].js',
chunkFilename: '[id].[hash:16].js',
},
devServer: {
inline: true,
port: devPort,
contentBase: path.resolve(__dirname, 'public'),
hot: true,
writeToDisk: true,
publicPath: '/',
historyApiFallback: true,
host,
}
Run Code Online (Sandbox Code Playgroud)
我的 launch.json 如下:
{
"type": "chrome",
"request": "launch",
"name": "Launch Chrome", …Run Code Online (Sandbox Code Playgroud) reactjs webpack webpack-dev-server visual-studio-code vscode-debugger
我正在尝试在我的 Mac 上设置 vscode 环境。我按照网站上的步骤进行操作https://code.visualstudio.com/docs/cpp/config-clang-mac 但是当我尝试调试我的程序时,它显示错误并且无法跳过。我不确定是因为版本还是其他什么原因。
#include <iostream>
#include <vector>
#include <string>
using namespace std;
int main()
{
vector<string> msg {"Hello", "C++++", "World", "from", "VS Code", "and the C++ extension!"};
for (const string& word : msg)
{
cout << word << " ";
}
vector<string> aaa {"H", "E", "L", "L", "O"};
for (const string& word : aaa)
{
cout << word << " ";
}
cout << endl;
}
Run Code Online (Sandbox Code Playgroud)
并且错误消息显示
预计 ; 在声明的末尾 [9, 23] 期望 ; 声明末尾 [16, …
我按照默认步骤操作
cd ~/projects && dotnet new web -o my-api && cd my-api && code .)但这不会启动网络服务器,也不会在断点处停止...它确实构建了项目,因为我可以看到 bin/Debug/netcoreapp3.1/ 中生成的文件
在项目根目录中运行dotnet run,构建(恢复)并运行网络服务器,我可以浏览到https://localhost:5001和http://localhost:5000。但无法调试...
这是创建的vscode文件
launch.json
{
// Use IntelliSense to find out which attributes exist for C# debugging
// Use hover for the description of the existing attributes
// For further information visit …Run Code Online (Sandbox Code Playgroud) c# visual-studio-code ubuntu-16.04 vscode-debugger asp.net-core-3.1
我是一名 C#、C++ 开发人员。如果我有外部 dll 的代码和 pdb,我可以通过将 IDE 指向代码和/或 PDB 来单步执行外部 dll 的代码。我想用 Java JAR 做类似的事情
我使用 Visual Studio 代码在 java 中创建了一个微服务框架。这会编译成一个 jar 文件。我有另一个应用程序正在使用这个 jar 文件。当我调试应用程序时,如何单步执行微服务 jar 的代码?
我正在使用 VS Code 1.45.1、zulu 14、maven 3.6.3
假设我有一个名为 MyMaths.jar 的 jar 文件,里面有一个 mybasicmaths 类
public class MyBasicMaths{
public int addNums(int a, int b) {
return a+b;
}
}
Run Code Online (Sandbox Code Playgroud)
该 jar 正在被另一个使用 MyMaths.jar 的应用程序使用。我已经使用 Maven 解决了依赖关系。在客户端应用程序中,我有类似的代码
public class MyMathsConsumer {
public static void main(String[] args) {
int a = 10;
int b = 20
MyBasicMaths …Run Code Online (Sandbox Code Playgroud) 使用 GDB 在 VSCode 中调试 C 项目时,到 stdout 的输出(通过 printf())不会出现在调试控制台上。cppvsdebug然而,当使用 时,它可以工作。
这是我的 launch.json:
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Debug",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceFolder}/${fileBasenameNoExtension}",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"environment": [],
"externalConsole": false,
"MIMode": "gdb",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": false
}
],
"windows": {
"miDebuggerPath": …Run Code Online (Sandbox Code Playgroud)