在本文中,我们将带你了解为什么Qt没有发送debugging消息到Windows中的std错误stream?在这篇文章中,我们将为您详细介绍为什么Qt没有发送debugging消息到Windows中的
在本文中,我们将带你了解为什么Qt没有发送debugging消息到Windows中的std错误stream?在这篇文章中,我们将为您详细介绍为什么Qt没有发送debugging消息到Windows中的std错误stream?的方方面面,并解答qt不能debug常见的疑惑,同时我们还将给您一些技巧,以帮助您实现更有效的C ++ 11 std :: cout <<“UTF-8中的string文字”到Windows cmd控制台? (Visual Studio 2015)、Debugging Chromium on Windows、debugging – 是否有Windowsdebugging器的检查点function?、debugging“服务无法启动”Windows安装程序错误。
本文目录一览:- 为什么Qt没有发送debugging消息到Windows中的std错误stream?(qt不能debug)
- C ++ 11 std :: cout <<“UTF-8中的string文字”到Windows cmd控制台? (Visual Studio 2015)
- Debugging Chromium on Windows
- debugging – 是否有Windowsdebugging器的检查点function?
- debugging“服务无法启动”Windows安装程序错误
为什么Qt没有发送debugging消息到Windows中的std错误stream?(qt不能debug)
我在窗口中的eclipse中使用qDebug(),它不给我任何输出,似乎Qt从Qt的文档发送到debugging器。
The Qt implementation of these functions prints the text to the stderr output under Unix/X11 and Mac OS X. With Windows,if it is a console application,the text is sent to console; otherwise,it is sent to the debugger.
我的目的不是如何在eclipse中打印消息。
我的目的是要知道,为什么Qt不会select发送debugging消息到Windows中的std错误stream,而实际上它将debugging消息发送到Mac Os中的std错误stream。
Windows和Mac Os有什么区别吗?
快速调整mmap文件的大小
replaceXKeycodetoKeysym
使用系统托盘图标创build一个后台进程
只清除控制台输出的一部分
Linux C:交互式输出
感谢帮助。
如何检索USB设备接口GUID?
将GetVersionEx数字转换为操作系统名称
如何在.NET中执行应用程序内通信
读控制台缓冲区/输出C ++
从dll返回多个string
由于问题实际上是“为什么”而不是“如何”,原因是双重的:
在Windows下的GUI程序通常没有一个控制台,他们必须自己打开它(当然特别是发行版本当然不会,这会惹恼用户)。 它们不会继承启动它们的进程的控制台。 Qt GUI程序要像在Windows下的任何其他GUI程序一样运行,除非您另外明确指定(例如为qmake添加CONfig+=console )。
Windows中的调试输出通常使用Windows的调试输出功能( DebugView工具的下载页面中的一些实用信息),例如可能每个Windows IDE都支持它。 Qt只是遵循这个软件开发的平台惯例。
总之,这就是默认和惯例下在Windows下完成的过程。 如果 Qt做了一些不同的事情, 那么有必要有充分的理由。
在Unix(和Linux)下,默认行为是不同的,除非采取额外措施,否则子进程会继承stdin,stdout和stderr到父进程的TTY。 通常程序本身并没有采取任何特殊措施,这取决于父级(例如,从shell /脚本启动程序时,通过添加2>/dev/null )。
注意:我没有时间检查Windows下的Qt应用程序的调试版本是否有点不同,默认情况下输出到控制台,所以在上面的阅读时要考虑到这一点。
您必须要求Qt开发人员确定,但是我的猜测是他们是这样做的,因为在Windows下,当GUI程序运行时,stdout和stderr通常不可见。
在Windows下,如果你想查看GUI应用程序的stdout和/或stderr流,你必须添加一些明确的代码来打开一个控制台窗口并将流重定向到它:
AllocConsole(); freopen(conOutStr,"w",stdout); freopen(conOutStr,stderr);
Qt开发人员可能认为大多数Windows程序员不会这样做,而是希望在他们的IDE /调试器窗口中看到他们的qDebug()输出。
C ++ 11 std :: cout <<“UTF-8中的string文字”到Windows cmd控制台? (Visual Studio 2015)
简介:我应该如何正确打印以UTF-8编码(Windows CP 65001)存储的源代码中定义的string字面值到使用std::coutstream的cmd控制台?
动机:我想修改优秀的Catchunit testing框架 (作为一个实验),以便它能显示带有重音字符的我的文本 。 修改应该简单,可靠,对于其他语言和工作环境也应该是有用的,这样才能被作者接受为增强。 或者如果你知道Catch,如果有其他解决scheme,你可以发布吗?
细节:我们先从捷克版的“快速棕色狐狸”
#include <iostream> #include "windows.h" using namespace std; int main() { cout << "n-------------------------- default cmd encoding = 852 -------------------n"; cout << "Příšerně žluťoučký kůň úpěl ďábelské ódy!" << endl; cout << "n-------- Windows Central European (1250) set for the cmd console --------n"; SetConsoleOutputCP(1250); std::cout << "Příšerně žluťoučký kůň úpěl ďábelské ódy!" << std::endl; cout << "n------------- Windows UTF-8 (65001) set for the cmd console -------------n"; SetConsoleOutputCP(CP_UTF8); std::cout << "Příšerně žluťoučký kůň úpěl ďábelské ódy!" << std::endl; }
它打印以下(字体设置为Lucida控制台):
select()系统调用和bash转义
primefaces访问共享内存
打印所有std :: locale名称(Windows)
Windows上的C ++ 11
在编译和链接C ++文件时关于-ldl标志
cmd默认编码为852,默认的窗口编码为1250,源代码使用65001编码(带有BOM的UTF-8)保存。 SetConsoleOutputCP(1250); 改变cmd编码(编程)与chcp 1250一样。
观察:设置1250编码时,UTF-8string文字被正确打印。 我相信可以这样解释,但这真的很奇怪。 有没有什么体面的, 人性化的方法来解决这个问题?
更新: "narrow string literal"存储使用Windows-1250编码在我的情况下(本地Windows编码为中欧)。 它似乎是独立于源代码的编码。 编译器将其保存在Windows本机编码中 。 因此,将cmd切换到该编码可以提供所需的输出。 它是uggly,但我怎样才能获得编程的本地Windows编码 (将其传递给SetConsoleOutputCP(cpX) )? 我需要的是一个对编译发生的机器有效的常量。 它不应该是运行可执行程序的计算机的本机编码。
C ++ 11也引入了u8"the UTF-8 string literal" ,但它似乎不符合SetConsoleOutputCP(CP_UTF8);
如何开始与c + +中的线程(返回)
如何在Sublime Text 3 C ++和Gtk +中构build系统
在使用asio和C ++ 11接受或接收时,优先停止阻塞或非阻塞的线程
C ++ / gcc / linux中的继续/协程/生成器
关于在CentOS-6.5上安装gcc-6。*的问题
这是通过跳转luk32的链接和确认Melebius的评论发现的部分答案(见下面的问题)。 这不是完整的答案,我很乐意接受你的后续评论。
我刚刚发现了涉及这个问题的UTF-8 Everywhere Manifesto 。 问17.如何在我的C ++代码中编写UTF-8字符串文字? 说(也明确的微软C ++编译器):
然而,最简单的方法是直接编写字符串并保存以UTF-8编码的源文件:
"∃y ∀x ¬(x ≺ y)"
不幸的是,MSVC把它转换成ANSI代码页,破坏了字符串。 要解决此问题,请将文件保存为不含 BOM的UTF-8。 MSVC将假定它在正确的代码页中,不会触及你的字符串。 但是,它使得它不可能使用Unicode标识符和宽字符串文字(您将不会使用)。
我真的很喜欢宣言。 为了简短,使用粗鲁的话,可能过于简单,它说:
忽略wstring , wchar_t之类的东西。 忽略代码页。 忽略像L , u , U , u8这样的字符串文字前缀。 到处使用UTF-8。 写所有的文字"naturally" 。 确保它也存储在编译的二进制文件中。
如果下面的代码与UTF-8一起存储没有BOM …
#include <iomanip> #include <iostream> #include "windows.h" using namespace std; int main() { SetConsoleOutputCP(CP_UTF8); cout << "Příšerně žluťoučký kůň úpěl ďábelské ódy!" << endl; int cnt = 0; for (unsigned int c : "Příšerně žluťoučký kůň úpěl ďábelské ódy!") { cout << hex << setw(2) << setfill('0') << (c & 0xff); ++cnt; if (cnt % 16 == 0) cout << endl; else if (cnt % 8 == 0) cout << " | "; else if (cnt % 4 == 0) cout << " "; else cout << ' '; } cout << endl; }
它打印(应该是UTF-8编码)…
将源文件保存为带有BOM的UTF-8时,将打印不同的结果…
但是,问题仍然存在 – 如何以编程方式设置控制台编码,以便正确打印UTF-8字符串。
我放弃。 cmd控制台简直是残废,从外面修理它是不值得的。 我只接受我自己的评论来解决这个问题。 如果有人发现与Catch单元测试框架相关的体面解决方案(可能完全不同),我会很乐意接受他/她的评论作为答案。
Debugging Chromium on Windows
First see get the code for checkout and build instructions.
Getting started
You can use Visual Studio''s built-in debugger or WinDBG to debug Chromium. You don''t need to use the IDE to build in order to use the debugger: Ninja is used to build Chromium and most developers invoke it from a command prompt, and then open the IDE for debugging as necessary. To start debugging an executable from the command line:
devenv /debugexe out\Debug\chrome.exe <options to Chromium can go here>
Profiles
--user-data-dir=c:\tmp\my_debug_profile (replace the path as necessary)
Chrome debug log
Symbol server
In Visual Studio, this goes in Tools > Options under Debugging > Symbols. You should set up a local cache in a empty directory on your computer.https://chromium-browser-symsrv.commondatastorage.googleapis.com
.sympath+ SRV*c:\Symbols*https://chromium-browser-symsrv.commondatastorage.googleapis.com
_NT_SYMBOL_PATH=SRV*C:\symbols*https://msdl.microsoft.com/download/symbols;SRV*C:\symbols*https://chromium-browser-symsrv.commondatastorage.googleapis.com
Multi-process issues
Chromium can be challenging to debug because of its multi-process architecture. When you select Run in the debugger, only the main browser process will be debugged. The code that actually renders web pages (the Renderer) and the plugins will be in separate processes that''s not (yet!) being debugged. The ProcessExplorer tool has a process tree view where you can see how these processes are related. You can also get the process IDs associated with each tab from the Chrome Task Manager (right-click on an empty area of the window title bar to open).
Automatically attach to child processes
There are two Visual Studio extensions that enable the debugger to automatically attach to all Chrome processes, so you can debug all of Chrome at once. Microsoft''s Child Process Debugging Power Tool is a standalone extension for this, and VsChromium is another option that bundles many other additional features. In addition to installing one of these extensions, you must run Visual Studio as Administrator, or it will silently fail to attach to some of Chrome''s child processes.
Single-process mode
One way to debug issues is to run Chromium in single-process mode. This will allow you to see the entire state of the program without extra work (although it will still have many threads). To use single-process mode, add the command-line flag
--single-process
This approach isn''t perfect because some problems won''t manifest themselves in this mode and some features don''t work and worker threads are still spawned into new processes.
Manually attaching to a child process
--renderer-startup-dialog --no-sandbox
Semi-automatically attaching the debugger to child processes
--wait-for-debugger-children[=filter]The filter, if provided, will fire only if it matches the --type parameter to the process. Values include renderer, plugin (for NPAPI), ppapi, gpu-process, and utility.
--renderer-process-limit=1
Image File Execution Options
Visual Studio hints
Debug visualizers
Don''t step into trivial functions
- For Visual Studio 2015: C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\Packages\Debugger\Visualizers (for all users)
or %USERPROFILE%\My Documents\Visual Studio 2015\Visualizers (for the current user only) - For Visual Studio 2017 Pro: C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\Common7\Packages\Debugger\Visualizers (for all users)
or %USERPROFILE%\My Documents\Visual Studio 2017\Visualizers (for the current user only)
V8 and Chromium
chrome.exe --js-flags="--trace_exception --heap_stats"
Note that some V8 command-line flags exist only in the debug build of V8. For a list of all V8 flags try:
chrome.exe --js-flags="--help"
Graphics debugging
- Graphics Debugging in Visual Studio 2013
- Graphical debugging with NVIDIA NSight
Debugging on another machine
- Make the build machine''s build volume available on the debug machine either by mounting it locally (e.g., Z:\) or by crafting a UNC path to it (e.g., \\builder\src)
- Open up a command prompt and change to a local disk
- Run src\tools\win\copy-installer.bat in the remote checkout by way of the mount (e.g., Z:\PATHTOCHECKOUT\src\...) or UNC path (e.g., \\builder\src\...). This will copy the installer, DLLs, and PDBs into your debug machine''s C:\out or C:\build (depending on if you''re rocking the component=shared_library build or not)
- Run C:\out\Debug\mini_installer.exe with the flags of your choice to install Chrome. This can take some time, especially on a slow machine. Watch the Task Manager and wait until mini_installer.exe exits before trying to launch Chrome (by way of the shortcut(s) created by the installer)
- For extra pleasure, add C:\out\Debug to your _NT_SYMBOL_PATH environment variable
Find memory leaks
- Launch GFlags.exe,
- Enable the user stack trace database (per image below),
- Launch Chrome under the debugger.
- Set a breakpont when chrome.dll loads with "sxe ld chrome.dll".
- Step up, to allow Chrome.dll to initialize.
- Disable the stack trace database in GFlags.exe.
- Continue chrome, optionally detaching the debugger.

umdh -p:<my browser pid> > chrome-browser-leak-umdh-dump.txt
Miscellaneous
- Application Verifier is a free tool from Microsoft (available as part of the Windows SDK) that can be used to flush out programming errors. Starting with M68 Application Verifier can be enabled for chrome.exe without needing to disable the sandbox. After adding chrome.exe to the list of applications to be stressed you need to expand the list of Basics checks and disable the Leak checks. You may also need to disable Handles and Locks checks depending on your graphics driver and specific Chrome version, but the eventual goal is to have Chrome run with Handles and Locks checks enabled. When bugs are found Chrome will trigger a breakpoint so running all Chrome processes under a debugger is recommended. Chrome will run much more slowly because Application Verifier puts every allocation on a separate page.
- You can check the undocumented ''Cuzz'' checkbox in Application Verifier to get the Windows thread scheduler to add some extra randomness in order to help expose race conditions in your code.
- Putting every allocation on a separate page will dramatically affect performance so you may want to only do this for some applications. If you right-click on the Heaps checkbox and select Properties you can edit things like the size range for what allocations go into PageHeap (the page-per-allocation system) and you can set a RandRate percentage to randomly put allocations in PageHeap.
- To put a breakpoint on CreateFile(), add this break point:
{,,kernel32.dll}_CreateFileW@28
- {,,kernel32.dll}specifies the DLL (context operator).
- _ prefix means extern "C".
- @28 postfix means _stdcall with the stack pop at the end of the function. i.e. the number of arguments in BYTES.
- You can use DebugView from SysInternals or sawbuck to view LOG() messages that normally goes to stderr on POSIX.
debugging – 是否有Windowsdebugging器的检查点function?
有一个窗口(win32,.net)debugging器可以做一些像gdb检查点?
http://sourceware.org/gdb/current/onlinedocs/gdb/Checkpoint_002fRestart.html
在我的新窗口安装Image.FromStream不以相同的方式工作
什么是控件的“On_Load”等效表单?
当窗体位于主监视器的上方和左方时,光标变为对angular线resize
.Net Windows服务和FileSystemWatcher问题
获取当前在Windows任务栏中可见的应用程序(或窗口)列表
我在Windows上听到的最接近的功能是IntelliTrace 。 另一个文档在这里: http : //msdn.microsoft.com/en-us/library/dd264915%28VS.100%29.aspx
该功能有很多限制 – 没有64位本地代码,脚本或sql CLR支持
debugging“服务无法启动”Windows安装程序错误
我有一个用WiX编写的简单的msi来安装一个本地的NT服务。 在msi中进行了一些更改后,它在StartServices标准操作中失败,出现错误“服务启动失败,请确认您有足够的权限”。 如果按“忽略”并手动启动服务,则会成功启动。 问题绝对不是没有足够的权限。 我如何诊断/debugging这些问题? Windows安装程序的详细日志似乎不包含任何有用的信息。
Java计划任务(在Windows中)
C#Windows服务不会显示为已启动
Windows服务和Windows进程有什么区别?
在C#服务应用程序中configurationlog4net的步骤
.NET Windows服务 – 一个项目中的多个服务
安装程序将没有任何有用的信息,因为错误只是由安装程序浮出水面。 这是我如何处理这个。
注释掉ServiceControl元素,这样安装程序不会尝试启动服务。 运行安装程序,并完成。 手动启动服务。
如果服务启动,则表示某种竞争条件。 一种常见的情况是服务依赖于安装到GAC或WinSXS的文件。 安装程序使用PublishAssemblies标准操作将这些文件放在那里。 但是由于GAC和WinSXS API不支持跨越式安装,PublishAssemblies会一直等到提交阶段执行工作。 这是安装程序尝试启动服务之后。 另一种常见的情况是,如果您有一些自定义操作正在安装或配置服务所需的某些内容,并且您在安装过程中所做的操作较晚。
如果服务仍然无法启动,这通常会排除竞争条件。 你必须分析服务本身。 使用诸如依赖,ildasm(如.net)和processexplorer(filemon / regmon)等工具来尝试发现缺少的依赖关系。 更新安装程序,然后冲洗并重复。
如您所见,Windows Installer在启动服务失败时不提供有用的信息。 但是,当显示对话框时,机器处于完美状态以确定发生了什么问题。 所以,而不是取消安装,开始调试。 尝试启动服务,看看是否给你更多的信息。 如果没有,请打开调试器并去镇上。
我基本上遵循这个FireGiant知识库文章中描述的过程。 这是找出服务无法启动的最直接的方法。 Windows Installer不能提供更好的信息本身就太糟糕了。
关于为什么Qt没有发送debugging消息到Windows中的std错误stream?和qt不能debug的介绍已经告一段落,感谢您的耐心阅读,如果想了解更多关于C ++ 11 std :: cout <<“UTF-8中的string文字”到Windows cmd控制台? (Visual Studio 2015)、Debugging Chromium on Windows、debugging – 是否有Windowsdebugging器的检查点function?、debugging“服务无法启动”Windows安装程序错误的相关信息,请在本站寻找。
本文标签: