Developer Blog - Inventic.eu
  • Skipper - The ORM Designer
  • VsBuilds - Parallel building
  • Pulpo - Free Skipper CLI

Category: Windows

Docker links

13 Dec 2016

Posted by: ludek.vodicka

Linux Windows #Linux #Windows #docker #virtualization

Cmder, Cygwin and other

15 Oct 2016

Posted by: ludek.vodicka

Windows #Windows #Bash #cygwin #command line

Qt - This application failed to start because it could not find or load the Qt platform plugin "windows"

This application failed to start because it could not find or load the Qt platform plugin "windows".

As temporary fix, set following environment variable in VS (Debugging->Environment):


QT_PLUGIN_PATH=q:\SharedLibraries\Qt32\bin\plugins

23 Sep 2015

Posted by: ludek.vodicka

Qt Windows #Qt #plugins

Windows 8.1 tuning (to look and behave like win7)

Use Windows 8.1 in default configuration as developer machine is hell on the earth. So, here are the steps how to turn Windows 8.1 back to classic...

 

  • Configure your user as TRUE administrator (link)
  • Replace metro by classic start menu (link)
  • split monitor to more areas (WinSplit revolution, alternative ownload link)
  • Windows firewall extension to notify about outgoing connections (link)
  • Disable local http server on port 80 (after visual studio installation!!) (link) HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\HTTP\start =  4
  • Enable administrative sharing for c$,d$, ... (superuserHKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System\LocalAccountTokenFilterPolicy=
  • Disable top left/right corner clip HKEY_CURRENT_USER\Control Panel\Desktop\MouseCornerClipLength=0
30 Sep 2014

Posted by: ludek.vodicka

Windows #windows 8 #metro #classic

Qt5 application crashed with error 0xc0000005

This is very interesting crash and I think it should be considered as Qt bug. This problem arise only under very special circumstances. But one after another.

You will identify this problem when your application stopped/exited immediately after the start without any visible error message. It looks like the application isn't executed at all. When you check application log (Computer -> manage -> Event viewer -> Windows logs -> Application), you will see Error logs:

Windows applications logs

The most interesting part of this log is crash location: ntdll.dll

Faulting application name: Skipper.exe, version: 3.0.1.1120, time stamp: 0x53e9c8d7<br />
Faulting module name: ntdll.dll, version: 6.1.7601.18247, time stamp: 0x521ea8e7<br />
Exception code: 0xc0000005<br />
Fault offset: 0x0002e3be<br />
Faulting process id: 0x1c88<br />
Faulting application start time: 0x01cfb606553e594b<br />
Faulting application path: T:\S2\Skipper.exe<br />
Faulting module path: C:\Windows\SysWOW64\ntdll.dll<br />
Report Id: 98cc8228-21f9-11e4-ab5d-005056c00008<br />

At first sight it seems like some problem inside the windows. But the opposite is true, the problem (as almost always) is inside your app ;-).

As the next step, you can try to debug this executable via Visual Studio to see what happens inside. Simply open executable as project together with .pdb files and execute it. Now you can see that application is correctly executed but crashes as soon as it touches Qt library. The location of crash is inside ntdll.dll in RtlHeapFree() function.

Debuging crash in VisualStudio 2013

So the problem is inside the Qt, right? Almost true, but not for the 100%. When I tried to run this application on computers of my colleagues, everything works ok. So why the application doesn't work on my computer too?

Resolution

The problem is in new Qt5 plugin system. Besides the common Qt5*.dll files which are loaded immediately after the application start, Qt5 is also loading plugins/platform-plugins dynamically when the application is executed. To locate this plugins, Qt5 uses following method to identify directories where to search for plugins:

QStringList QCoreApplication::libraryPaths()<br />

For some strange reason this library returns as first directory path where Qt5 libraries were compiled and after that location based on the executable. So if your Qt5 path is C:\Qt5, this will be the first path where all plugins are searched for, no matter if the correct version of plugin is located in APP\plugins or APP\platforms. **I think this is serious bug in Qt5**.

Where is the problem?

And here we're getting to the core of the whole problem.

**If application is compiled on computer with one compiler and used on second  computer which contains the same path to which original computer has installed Qt, the application will load all plugins from your folder instead of itself folder.**

In case your computer will contain different version of Qt, different compiler or different platform, application loads incorrect libraries and crashes. Completely, silently and without easy way to determine what's wrong.

Solution?

The solution is simple, but it isn't achievable from outside of the Qt library. It would be necessary to Qt as first tried to load libraries from application directory. And only if no plugins were found in application directory, the application would try to search for plugins in Qt directory.

Qt change solution

The simplest way how to fix this issue inside the Qt library would be to rename/update appendApplicationPathToLibraryPaths  function to prependApplicationPathToLibraryPaths and change

void QCoreApplicationPrivate::prependApplicationPathToLibraryPaths()<br />
{<br />
#ifndef QT_NO_LIBRARY<br />
    QStringList *app_libpaths = coreappdata()-&gt;app_libpaths;<br />
    if (!app_libpaths)<br />
        coreappdata()-&gt;app_libpaths = app_libpaths = new QStringList;<br />
    QString app_location = QCoreApplication::applicationFilePath();<br />
    app_location.truncate(app_location.lastIndexOf(QLatin1Char('/')));<br />
#ifdef Q_OS_WINRT<br />
    if (app_location.isEmpty())<br />
        app_location.append(QLatin1Char('/'));<br />
#endif<br />
    app_location = QDir(app_location).canonicalPath();<br />
    if (QFile::exists(app_location) &amp;&amp; !app_libpaths-&gt;contains(app_location))<br />
        //CHANGE THIS ROW: app_libpaths-&gt;append(app_location);<br />
        //TO FOLLOWING<br />
        app_libpaths-&gt;prepend(app_location);<br />
#endif<br />
}<br />

InApp solution

Unfortunately it isn't possible to simply change this behavior from your app. All of these operations happen directly in QCoreApplication constructor so if you try to change it after, it's too late.

The temporary solution before this problem will be resolved is to reinitialize library paths before QCoreApplication is initialized. It's necessary to clean libray paths, compute new paths and re-initialize QCoreApplication::libraryPaths before QCoreApplication object is initialized. This can be done in main.cpp of your application before you will create QApplication/QCoreApplication object.

  QString executable = argv[0];<br />
  QString executablePath = executable.mid(0,executable.lastIndexOf(&quot;\\&quot;));<br />
  QString installPathPlugins = QLibraryInfo::location(QLibraryInfo::PluginsPath);<br />
  QCoreApplication::removeLibraryPath(installPathPlugins);<br />
  QCoreApplication::addLibraryPath(installPathPlugins);<br />
  QCoreApplication::addLibraryPath(executablePath);<br />

It's not a nice solution, but it works. I tried  to report this issue also to bugreports.QtProject, so maybe in later version this will be fixed.

12 Aug 2014

How to create .pdb files also for Release version of Qt library

For debugging purposes it's a good idea to keep .pdb files also for release version of your libraries. Unfortunately in default configuration Qt library doesn't generate .pdb files. It's a not big deal, create .pdb files for release version it's pretty simple.

1) Add compilation flags to .pro file

The easiest way how to create pdb files is pass /Zi switch to compiler and /Debug to linker.

QMAKE_CXXFLAGS+=/Zi<br />
QMAKE_LFLAGS+= /INCREMENTAL:NO /Debug<br />

2) Solution via mkspec

As pointed out in this QtProject article, another way is to edit mkspec so any future compilations will have this option turned on. It's necessary to modify correct mkspec file, for example

Qt&lt;/span&gt;\mkspecs\win32-msvc2005\qmake.conf<br />

and add following lines (it should be sufficient to add only /Zi and /Debug switch):

QMAKE_CFLAGS_RELEASE += /Zi<br />
QMAKE_LFLAGS_RELEASE += /INCREMENTAL:NO /DEBUG<br />
12 Aug 2014

Posted by: ludek.vodicka

Qt Windows #Qt #Windows #debugging #pdb

Tips for versioning systems (Git, svn, mercurial,...)

Get packed archive of changed files from git directory (more info)

zip changes.zip $(git diff --name-only)<br />

Packed last changes of git:

 git archive -o qt-changes.zip head $(git diff --name-only)<br />

How to upgrade svn to 1.7 on Ubuntu 10.4

Here is nice step-by-step manual.

09 Aug 2014

Visual Studio 2013 - Visualizers

One of very useful feature of Visual Studio is custom variables views. It's possible to configure own views to each of your class. For this, VS2013 (and VS2012) uses .natvis files located in following directories:

%VSINSTALLDIR%\Common7\Packages\Debugger\Visualizers<br />
%USERPROFILE%\My Documents\Visual Studio 2013\Visualizers<br />

Files are stored in common .xml format and has following format:

&lt;AutoVisualizer xmlns=&quot;http://schemas.microsoft.com/vstudio/debugger/natvis/2010&quot;&gt;<br />
  &lt;Type Name=&quot;String::CStringHolder&amp;lt;String::string_trait&amp;lt;char&amp;gt; &amp;gt;&quot;&gt;<br />
    &lt;DisplayString&gt;{m_pszData,s8}&lt;/DisplayString&gt;<br />
    &lt;StringView&gt;m_pszData&lt;/StringView&gt;<br />
    &lt;Expand&gt;<br />
      &lt;Item Name=&quot;[m_pszData]&quot;&gt;m_pszData&lt;/Item&gt;<br />
      &lt;Item Name=&quot;[nDataLength]&quot;&gt;m_pStringData-&gt;nDataLength&lt;/Item&gt;<br />
      &lt;Item Name=&quot;[nAllocLength]&quot;&gt;m_pStringData-&gt;nAllocLength&lt;/Item&gt;<br />
      &lt;Item Name=&quot;[nRefs]&quot;&gt;m_pStringData-&gt;nRefs&lt;/Item&gt;<br />
    &lt;/Expand&gt;<br />
  &lt;/Type&gt;<br />
&lt;/AutoVisualizer&gt;<br />

Debugging .natvis files

Visual studio contains a way how to catch syntax and logical errors in natvis format. All warnings/errors can be displayed to Visual Studio output panel by specifying following registry key to "1".

HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\12.0_Config\Debugger<br />
&quot;EnableNatvisDiagnostics&quot;=dword:00000001<br />

Note: It's necessary to restart Visual studio to turn on this feature

Other usefull links

06 Aug 2014

NGINX + FastCGI - usefull commands

Start / stop nginx server

//execute<br />
nginx</p>
<p>//stop<br />
nginx -s stop</p>
<p>//reload configurations<br />
nginx -s reload</p>
<p>//reopen log files<br />
nginx -s reload<br />

24 Jul 2014

Posted by: ludek.vodicka

Linux Windows Web tools #nginx #fast-cgi

Bitcoint mining

Notes & links:

Command line

mining_proxy.exe<br />
RPCMiner2013-cuda.exe -url=http://localhost:8332 -user=ludekvodicka.worker1 -password=SsENgEGJ<br />
12 Dec 2013

Posted by: ludek.vodicka

Windows #bitcoint #mining

Parse HTTP data to more suitable form

18 Nov 2013

Posted by: ludek.vodicka

Linux Windows Mac OS #nginx

nginx and fast-cgi - tips and tricks

How to pass full path to fast-cgi app

It's necessary to configure which parameters are passed to fast-cgi application from nginx server. For this purposes serves fastcgi_param keyword. It's a good practice to keeps all fastcgi params together. For this purposes nginx has fastcgi.conf file. This file already contains most of useful fastcgi_param bindings.

fastcgi_param  QUERY_STRING       $query_string;<br />
fastcgi_param  REQUEST_METHOD     $request_method;<br />
fastcgi_param  CONTENT_TYPE       $content_type;<br />
...<br />

To include this file use include statement:

location / {<br />
   include fastcgi_params;<br />
   fastcgi_pass 127.0.0.1:9345;<br />
 }<br />

How to pass custom headers to fast-cgi app

Default configuration pass only default headers to fast-cgi. It's necessary to add few more configurations statements:

fastcgi_pass_request_headers on;<br />

After that headers are passed as HTTP_* parameters:

HTTP_HEADER1=2222<br />

External links

18 Nov 2013

Posted by: ludek.vodicka

Programming Linux Windows Mac OS #nginx

How to run fastcgi and nginx on windows

Step by step guide how to configure nginx on windows....

Download and installation

Download nginx package from nginx site. Unpack it and installation is done ;-)

Example of fast-cgi application

No create and complie fast-cgi application. (How to compile fast-cgi on windows)

    #include &quot;fcgi_stdio.h&quot;<br />
    #include &amp;lt;stdlib.h&amp;gt;</p>
<p>    void main(void)<br />
    {<br />
        int count = 0;<br />
        while(FCGI_Accept() &amp;gt;= 0)<br />
            printf(&quot;Content-type: text/html\r\n&quot;<br />
                   &quot;\r\n&quot;<br />
                   &quot;&amp;lt;title&amp;gt;FastCGI Hello!&amp;lt;/title&amp;gt;&quot;<br />
                   &quot;&amp;lt;h1&amp;gt;FastCGI Hello!&amp;lt;/h1&amp;gt;&quot;<br />
                   &quot;Request number %d running on host &amp;lt;i&amp;gt;%s&amp;lt;/i&amp;gt;\n&quot;,<br />
                    ++count, getenv(&quot;SERVER_NAME&quot;));<br />
    }<br />

How to connect fast-cgi with web-server

There are two ways. When web-server supports fast-cgi you will be able to connect fast-cgi directly with web-server via configuration files. In all other cases fast-cgi offers cgi-fcgi  executable as bridge between webserver and your app. More info about both these approaches you can find here http://www.fastcgi.com/devkit/doc/fcgi-devel-kit.htm#S4.

Working way how to get fastcgi apps working

None of two ways described in previous article and in official documentation works for me on windows. I wasn't able to get cgi-fcgi or spawn-fcgi running. First mentioned crashed everytime app tries to initialize STD_OUT, the second one isn't possible to compile it because of missing unistd.h header.

Fortunately there is one more way. FCGI library offers one more way how to utilize FCGI mechanism. It's necessary add two more lines to example above and everything works perfectly.

    #include &quot;fcgi_stdio.h&quot;<br />
    #include &amp;lt;stdlib.h&amp;gt;</p>
<p>    void main(void)<br />
    {<br />
        //initialize library &amp;amp; open listening socket at port 9345<br />
        FCGX_Init();<br />
        FCGX_OpenSocket(&quot;:9345&quot;,500);</p>
<p>        //rest is the same as in example above<br />
        while(FCGI_Accept() &amp;gt;= 0) ...<br />
    }<br />

After this change application initialize listening port and waits for incoming data. All you need to do is directly execute the app.

Configure nginx to connect with fast-cgi

This step compared to previous ones is pretty easy. You need to tell nginx server what and where to pass. Open file nginx.conf and add following statement:

http {<br />
  server {<br />
    location / {<br />
      fastcgi_pass 127.0.0.1:9345;<br />
     }<br />
  }<br />
}<br />

fastcgi_pass statement forward all requests to localhost:9345 address. Now when you start your nginx server, everything should work as expected.

nginx server cfg

Troubleshooting

bind() to 0.0.0.0:80 failed

This error is caused by another application which uses port 80. In my case it was Skype which automatically uses port 80.

nginx: [emerg] bind() to 0.0.0.0:80 failed (10013: An attempt was made to access a socket in a way forbidden by its access permissions)<br />

External links

18 Nov 2013

Posted by: ludek.vodicka

Windows #nginx

How to compile FastCGI library in Visual Studio 2010 C++

FastCGI comes with Win32 project for VisualStudio6. Unfortunately when you try to open it in VisualStudio2010 the project will be corrupted. To correctly compile it for VS2010 it's necessary to download library sources, get patches from cybozu.co.jp site and apply it.

Download library

Download latest version of Development Kit here and extract it to standalone directory.

FastCGI

Get and update patches

Download all five patches from Cybozu site. Now when you have patches it's necessary to convert all files to correct windows-ending format. This can be done for example in Notepad++.

Convert to windows EOL

Get patch.exe application

Now you need some application capable to apply the patches. Unfortunately windows doesn't contain any application for this task and also lot of comparing/merging applications can't do that.

The simplest way is to download windows conversion of linux patch.exe app. Get it from gnuwin32 site - patch for windows.

Apply patch to project files

Apply patches

Open directory with fastcgi library, copy all patch files to this directory and open command line. As next run patch command for all fives patches:

...\fcgi-2.4.1-SNAP-0311112127&gt;patch -Np1 &lt; 4-vc9.patch<br />
patching file Win32/FastCGI.sln<br />
patching file Win32/authorizer.vcproj<br />
patching file Win32/cgifcgi.vcproj<br />
patching file Win32/config_h.vcproj<br />
patching file Win32/echo-cpp.vcproj<br />
patching file Win32/echo.vcproj<br />
patching file Win32/echox.vcproj<br />
patching file Win32/libfcgi.vcproj<br />
patching file Win32/logdump.vcproj<br />
patching file Win32/size.vcproj<br />
patching file Win32/threaded.vcproj<br />

In case you will see following error message:

patching file Win32/FastCGI.sln<br />
Assertion failed: hunk, file ../patch-2.5.9-src/patch.c, line 354</p>
<p>This application has requested the Runtime to terminate it in an unusual way.<br />
Please contact the application's support team for more information.<br />

it's necessary to convert ALL patch files to correct Windows format (correct EOL) as mentioned in previous section.

More patches...

When you apply patches by cybozu it's time to apply my own patches ;-).

Manually updated rejected file

As first, it's probably that you will see following message:

1 out of 26 hunks FAILED -- saving rejects to file libfcgi/os_win32.c.rej<br />

It's because original patch is for older version of library and file os_win32.c  is slightly different. To fix that, edit this file at line 841 and manually update following line:

//original<br />
int len = p - bindPath + 1;</p>
<p>//updated line<br />
intptr_t len = p - bindPath + 1;<br />

Update VS project file

Now turn off generating the Map Files in project configuration. These files aren't necessary and it isn't possible to compile project correctly with this settings.

Turn off .map files

DONE

And that's all. Now you will be able to sucesfully compile fast-cgi library.

Compilation complete

External links

18 Nov 2013

Posted by: ludek.vodicka

Programming Windows #C++ #fastcgi #nginx

FastCGI c++ library for all platforms (Windows, Mac and Linux)

List of existing libraries

Snippets

Stackoverflow articles

Tutorials

Other links

CGICC - how to update it for VS2010 COMPILATION

  •  **error C2668: 'cgicc::copy_if' : ambiguous call to overloaded function** - add cgicc:: to all cgicc::copy_if instances
  •  **error LNK2019: unresolved external symbol** - add compiled .lib path (...Debug\cgicc.lib) to all dependend projects
17 Nov 2013

Posted by: ludek.vodicka

Programming Linux Windows Mac OS #C++ #fastcgi #nginx

C++ Code coverage tools for Windows and Linux (DRAFT)

Linux

  • CovTool - Free test coverage analyzer for C++
  • ggcov -  GTK+ GUI for exploring test coverage data produced by C and C++ programs compiled with gcc --coverage.
  • lcov - graphical front-end for GCC's coverage testing tool gcov. Creates HTML pages containing the source code annotated with coverage information.
  • Trucov - open source program that works with the GCC compiler to display the control flow of a program and its test coverage information

STEPS:

1) add CXX, CFD + LINKER FLAGS

2) remove OBJS output dir and generate .o .gcov,... to root project directory

3)remove MOC directory output for Qt app

3)run gcov xx.cpp

--- generate html

sudo apt-get install lcov (http://ltp.sourceforge.net/coverage/lcov.php)

lcov --capture --directory ~/dev/Applications/AtomixApp/AtomixApp --output-file coverage.info

How to use articles

How to integrate with jenkins

StackOverflow questions

15 Oct 2013

Posted by: ludek.vodicka

Linux Windows Mac OS #code-coverage

Slow execution of application from Visual studio

Today my Visual Studio 2010 started to execute my application super slowly. When I tried to execute my application (without any changes in source-code) the delay between "Start Debugging" and application start was about one minute.

I know that too many breakpoints or breakpoints in templates could caused this, but I don't see any breakpoint in my Breakpoints window.

Breakpoint window

But as I have found that the problem was really caused by breakpoints. In some special cases - when you're using some external tools to modified your project file (.sln/.vcxproj) - breakpoints can disappear and begin to make a trouble (I'm using Qt qmake to update my project based on .pro files.)

The solution is pretty easy. Use **Delete All Breakpoins** from Debug menu:

Delete all breakpoints

And your problem will be solved ;-).

21 Sep 2013

ERROR 2006 (HY000) at line 1: MySQL server has gone away

Problem:

Getting error 2006 during database backup import. The problem is in short timeout and small packet size. It's necessary to **update my.cnf** and restart **MySql service.**

Solution:

</p>
<p>[mysqld]<br />
max_allowed_packet = 64M<br />
wait_timeout = 6000</p>
<p>[mysqldump]<br />
max_allowed_packet = 64M</p>
<p>

External links

02 Sep 2013

Posted by: ludek.vodicka

Windows #Windows #mysql #srevice

GetTickCount64 problem on WindowsXP

[caption id="" align="aligncenter" width="637"]
The procedure entry point GetTickCount64 could not be located in the dynamic link library KERNEL32.dll
The procedure entry point GetTickCount64 could not be located in the dynamic link library KERNEL32.dll[/caption]

Today we received report from one of our customers about problem with our ORM Designer on WindowsXP - 32bit. Our latest version returns following error:

The procedure entry point GetTickCount64 could not be located in the dynamic link library KERNEL32.dll

**The problem is that GetTickCount64 doesn't exists in XP system**.

**Solution:**

It's necessary to compile your application (and any library which uses GetTickCount64) with correct **WINVER** and **_WIN32_WINNT **defines value. List of WINVER values for all Windows version can be found here.

You can define these values in your resource.h file:

#define WINVER 0x0501
#define _WIN32_WINNT 0x0501

or add it to a project property -> C/C++ -> Preprocessor -> Preprocessor Definitions:

2013-08-29_15-45-10

**Qt Solution:**

If you want to define these values automatically in Qt project, add following lines to your .pro file:

#Windows XP compatability
DEFINES += "WINVER=0x0501"
DEFINES += "_WIN32_WINNT=0x0501"

External links:

29 Aug 2013

Problem with msdia80.dll

One of tool we're using requires **msdia80.dll** file. Unfortunately this DLL is available only inside the VS2005 installation / redistributable pack. When you execute **dump_syms.exe** without this file, you will receive following message:

CoCreateInstance CLSID_DiaSource failed (msdia80.dll unregistered?)<br />

One solution is to install Visual C++ 2005 Redistributable Package. Another way is download only msdia80.dll file and register it manually by using:

regsrv32 msdia80.dll<br />
17 Jul 2013

Posted by: ludek.vodicka

Windows #dll windows

SVN repository maintenance

To perform SVN repository maintenance use following commands

svnadmin verify REPO</p>
<p>
14 Jun 2013

Posted by: ludek.vodicka

Programming Linux Windows Mac OS #svn

Find out what wakes up your Windows 7/Vista from its sleep

@rem Get info about last wake<br />
powercfg -lastwake</p>
<p>@rem Which device caused the wake up<br />
powercfg -devicequery wake_armed</p>
<p>@rem More detailed info including time of sleep and wake<br />
cmd /k wevtutil qe System /q:&quot;*[System[Provider[@Name='Microsoft-Windows-Power-Troubleshooter']]]&quot; /rd:true /c:1 /f:text</p>
<p>

External Links

25 Nov 2012

Posted by: ludek.vodicka

Windows Hardware

List of C++ profilers for windows (commercial and non-commercial)

24 Oct 2012

Posted by: ludek.vodicka

Programming Windows #C++ #development

How to fix "The device, \Device\Ide\iaStor0, did not respond within the timeout period."

Link with detailed description of this problem.

Short how to fix:

regedit<br />
open HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\iaStor\Parameters\Port[0-n]\<br />
set LPM=0, LPMDSTATE=0, and DIPM = 0<br />

if your registry doesn't contain this key, you have to add them.

Add new key &quot;Port0&quot;.<br />
Add new &quot;DWORD&quot; value named &quot;LPM&quot; and value leave 0.<br />
Add next two &quot;DWORD&quot; values named &quot;LPMDSTATE&quot; and &quot;DIPM&quot;.<br />

Another advise how to fix this error

This method is originally referred in MS Technet forum:

Also the issue may be the result of Aggressive Link State Power Management (ALPM) on the PCI-Express bus negotiating a lower power state for the link between the controller and disk when there is no activity. When ALPM works, disk requests are queued, the serial link revived, and the queued requests are sent to the relevant disk; this requires a disk that supports ALPM.

1.       Click Start button, choose Control Panel.<br />
2.       Move to Control Panel\All Control Panel Items\Power Options. Click Change plan setting in your current power plan.<br />
3.       Click “Change advanced power settings”, move to PCI Express-&gt; Link State Power Management, turn off the option.<br />

External links

23 Sep 2012

Posted by: ludek.vodicka

Windows Hardware #Windows #ssd #hardware

Find and delete all directories on windows

Run follwing command

DIR /AD/B/S | SORT /R &gt; EMPTIES.BAT<br />

and add RD command before every line in empties.bat file

RD filepath ...<br />
...<br />

Ref: http://www.pcmag.com/article2/0,2817,803393,00.asp

20 Sep 2012

Posted by: ludek.vodicka

Windows #Windows #utilities

Problem with compiling Boost

Warning: &quot;using python&quot; expects a two part (major, minor) version number; got %d.%d\nplatform=%s\nprefix=%s\nexec_prefix=%s\nexecutable=%s' % (version_info[0],version_info[1],platform,prefix,exec_prefix,executable))&quot;  instead<br />
Q:/ExternalLibraries/boost_trunk/tools/build/v2/build\feature.jam:276: in implied-feature from module featureerror: &quot;version_info[1]&quot; is not an implicit feature value<br />
Q:/ExternalLibraries/boost_trunk/tools/build/v2/build\feature.jam:355: in expand-subfeatures-aux from module featureQ:/ExternalLibraries/boost_trunk/tools/build/v2/build\feature.jam:424: in feature.expand-subfeatures from module feature<br />
Q:/ExternalLibraries/boost_trunk/tools/build/v2/build\property.jam:186: in property.expand-subfeatures-in-conditions from module property<br />
Q:/ExternalLibraries/boost_trunk/tools/build/v2/build\property-set.jam:407: in property-set.create-from-user-input from module property-set<br />
Q:/ExternalLibraries/boost_trunk/tools/build/v2/build\property-set.jam:461: in property-set.refine-from-user-input from module property-set<br />
Q:/ExternalLibraries/boost_trunk/tools/build/v2/build\targets.jam:1580: in targets.main-target-requirements from module targets<br />
Q:/ExternalLibraries/boost_trunk/tools/build/v2/tools\builtin.jam:532: in lib from module builtin<br />
Q:/ExternalLibraries/boost_trunk/tools/build/v2/tools\python.jam:680: in declare-libpython-target from module python<br />
Q:/ExternalLibraries/boost_trunk/tools/build/v2/tools\python.jam:925: in configure from module python<br />
Q:/ExternalLibraries/boost_trunk/tools/build/v2/tools\python.jam:110: in python.init from module python<br />
Q:/ExternalLibraries/boost_trunk/tools/build/v2/build\toolset.jam:41: in using from module toolset libs\python\build\Jamfile.v2:16: in modules.load from module Jamfile&lt;Q:\External<br />
Libraries\boost_trunk\libs\python\build&gt;<br />
Q:/ExternalLibraries/boost_trunk/tools/build/v2/build\project.jam:311: in load-jamfile from module project<br />
Q:/ExternalLibraries/boost_trunk/tools/build/v2/build\project.jam:64: in load from module project<br />
Q:/ExternalLibraries/boost_trunk/tools/build/v2/build\project.jam:89: in load-used-projects from module project<br />
Q:/ExternalLibraries/boost_trunk/tools/build/v2/build\project.jam:75: in load from module project<br />
Q:/ExternalLibraries/boost_trunk/tools/build/v2/build\project.jam:145: in project.find from module project<br />
Q:/ExternalLibraries/boost_trunk/tools/build/v2\build-system.jam:552: in load from module build-system<br />
Q:\ExternalLibraries\boost_trunk\tools\build\v2/kernel\modules.jam:289: in import from module modules<br />
Q:\ExternalLibraries\boost_trunk\tools\build\v2/kernel/bootstrap.jam:139: in boost-build from module<br />
Q:\ExternalLibraries\boost_trunk\boost-build.jam:17: in module scope from module<br />

The problem was that boost build helper run my python.bat instead of correct python.exe from %PATH% directory.

To check which python is used enter following param:

b2 --debug-configuration:<br />
notice: [python-cfg] Configuring python...<br />
notice: [python-cfg] Registry indicates Python 2.7 installed at &quot;C:\Python27\&quot;<br />
notice: [python-cfg] Checking interpreter command &quot;python&quot;...<br />
notice: [python-cfg] running command 'python -c &quot;from sys import *; print('version=%d.%d\nplatform=%s\nprefix=%s\nexec_prefix=%s\nexecutable=%s' % (version_info[0],version_info[1],platform,prefix,exec_prefix,executable))&quot; 2&gt;&amp;1'<br />
notice: [python-cfg] ...does not invoke a working interpreter<br />
notice: [python-cfg] Checking interpreter command &quot;C:\Python27\python&quot;...</p>
<p>####HERE####<br />
notice: [python-cfg] running command 'DIR /-C /A:S &quot;C:\Python27\python.exe&quot; 2&gt;&amp;1'<br />
####HERE####</p>
<p>notice: [python-cfg] running command 'C:\Python27\python -c &quot;from sys import *;print('version=%d.%d\nplatform=%s\nprefix=%s\nexec_prefix=%s\nexecutable=%s' % (version_info[0],version_info[1],platform,prefix,exec_prefix,executable))&quot; 2&gt;&amp;1'<br />
notice: [python-cfg] ...requested configuration matched!<br />
notice: [python-cfg] Details of this Python configuration:<br />
notice: [python-cfg]   interpreter command: &quot;C:\Python27\python&quot;<br />
notice: [python-cfg]   include path: &quot;C:\Python27\Include&quot;<br />
notice: [python-cfg]   library path: &quot;C:\Python27\libs&quot;<br />
notice: [python-cfg]   DLL search path: &quot;C:\Python27&quot;<br />

08 Sep 2012

Posted by: ludek.vodicka

Windows #C++ #boost #extrnal libraries

Qt and Google breakpad Windows/Linux/MacOS

Integration of Google breakpad on any platform is really challenge. I didn't figure out how to do it by using recommended ways. So I did it my way ;-)

Create your own Qt project

As first thing I did when integrating Qt and Breakpad is creation of my own .pri file. I manually add all required files from Breakpad one-by-one, starting with src/platform/exception_handler continuing with all files included in previous ones. The complete .pri file you will find at end of this post.

After that I created simple CCrashHandler (inspired by qt-breakpad project) class which register exception handler. It's necessary to implement this handler for each platform separately because each platform have different parameters in google_breakpad::ExceptionHandler() constructor. CrashHandler source code you can find also at end of this post.

Using Breakpad on Linux:

Article about Linux integration.

Notes Linux

  • GCC 4.6.3
  • Ubuntu 12.04.1 32/64bit

Get and Compile Breakpad

#get breakpad latest version<br />
svn checkout http://google-breakpad.googlecode.com/svn/trunk/ google-breakpad-read-only</p>
<p>#compile all breakpad tools for extracting symbol files<br />
./configure<br />
make<br />
sudo make install</p>
<p>#when compilation is ready, you should have installed file dump_syms from original directory /src/tools/linux/dump_syms in your /usr/bin<br />
dump_syms<br />

Generate symbol file and test debug info

Now how to generate and use symbol file:

#generate .sym file<br />
dump_syms ./Application &gt; Application.sym</p>
<p>#store sym file in the correct location<br />
#this step is necessary. Without that minidump_stackwalk tool doesn't work</p>
<p>head -n1 Application.sym<br />
#Result: MODULE Linux x86_64 6EDC6ACDB282125843FD59DA9C81BD830 Application</p>
<p>mkdir -p ./symbols/Application/6EDC6ACDB282125843FD59DA9C81BD830<br />
mv Application.sym ./symbols/Application/6EDC6ACDB282125843FD59DA9C81BD830</p>
<p>#show stack with using minidump_stackwalk tool<br />
minidump_stackwalk ./crash.dmp ./symbols<br />

Result of minidump_stackwalk tool can look like this:

Use additional tools

There is script written by Mozzila corp which simplifies extracting and storing .sym file:
http://mxr.mozilla.org/mozilla-central/source/toolkit/crashreporter/tools/symbolstore.py?raw=1

Now with this script, you can do only one step instead of all described above.

python /path/to/script/symbolstore.py /usr/local/bin/dump_syms ./symbol-storage ./Application<br />

This command correctly creates folder Application/uuid in path symbol-storage and copy generated .sym file inside.

Using Breakpad on MacOS:

To integrate Breakpad and Qt on MacOS I used the same article as for Linux because I'm using gcc and linux-like development toolchain. For native XCode integration you have to probably use this article.

Notes MacOS

  • GCC 4.6.3
  • Qt creator toolchain
  • Mac OS 10.7.3 64bit
  • Don't using any of XCode tool chaing

Do almost all steps like on Linux integration. There is one exception, because you can't compile Breakpad tools using linux-like configure&make. You have to build these tools with XCode.

Compile google_breakpad/src/tools/mac/dump_syms/dump_syms.xcodeproj with XCode

Before I managed to successfully compile dump_syms in XCode, I have to update Architectures Debug/Release to 64-bit Intel and BaseSDK to "Latest Mac OS X". I also fix all issues displayed in the left part of XCode window.

Next step is change compilation type from Debug to Release. After a short searching I found a way in "Schema->Edit schema->Build configuration".

To be honest, I was not sure what I did, but it worked ;-). Maybe there is some easier way how to compile dump_syms in xcode, but I don't know how. This was my first contact with XCode ;-).

The application is compiled to path "/Users/User/Library/Developer/Xcode/DerivedData/dump_syms-bjvr/Build/Products/Release/dump_syms". Now copy dump_syms to safe location from where you will use it.

The rest steps are same like in the Linux.

Using Breakpad on Windows

Notes Windows

Article about Windows integration.

  • Compile with Visual Studio 2010
  • Post-mortem debugging is done also via VS2010
  • Google breakpad under windows generates common .dmp files which can by simply load directly to VS

Generate symbol files and test debug info

You have to choices for Windows. First option is use standard .PDB and .DMP files mechanism in VS. Second is use the same way how you can did it for Linux and Mac.

**First way**: Let compiler generate .PDB file. Store this files and use them later in VS together with your crash dump.

**Second way**: Use dump_sys.exe. This file is located in the google breakpad directory tree: google-breakpad\src\tools\windows\binaries\dump_syms.exe .

dump_syms.exe AtomixDevelopment.exe &gt;AtomixDevelopment.sym<br />

And also like under Linux, you can use Python script symbolstore.py to extract symbols to correct directory:

python.exe symbolstore.py binaries\dump_syms.exe .\Symbols AtomixDevelopment.exe<br />

Minidump stackwalk for windows:
http://code.google.com/p/pcxfirefox/source/browse/trunk/betterpgo/talos/talos/breakpad/win32/minidump_stackwalk.exe?r=19

The best thing at end

The most amazing thing I found about dump_syms is their platform independence. If you correctly extract symbol file on each platform and store it in one location, you can analyze any crashdump on one location. No matter what is source platform, you will analyze .dmp file by using **minidump_stackwalk ./crash.dmp ./symbols**.

How to include CrashHandler directly to your project

This is what I get when I follow all includes from **.h** and **.cpp** files starting with exception_handler.h for all platforms. With small modification you can include it to your project and your application will be fully breakpad-able ;-).

# ---------- HEADER -----------------------------------------------------------<br />
OTHERS   += $$PWD/axCrashHandler.pri<br />
HEADERS += $$PWD/CrashHandler.h<br />
SOURCES += $$PWD/CrashHandler.cpp</p>
<p>BREAKPAD_PATH=$$EXTERNAL_LIBRARIES_PATH/breakpad-qt<br />
INCLUDEPATH += $$BREAKPAD_PATH/src</p>
<p>OSMAC {<br />
  HEADERS += $$BREAKPAD_PATH/src/client/mac/handler/exception_handler.h<br />
  HEADERS += $$BREAKPAD_PATH/src/client/mac/crash_generation/crash_generation_client.h<br />
  HEADERS += $$BREAKPAD_PATH/src/client/mac/crash_generation/crash_generation_server.h<br />
  HEADERS += $$BREAKPAD_PATH/src/client/mac/crash_generation/client_info.h<br />
  HEADERS += $$BREAKPAD_PATH/src/client/mac/handler/minidump_generator.h<br />
  HEADERS += $$BREAKPAD_PATH/src/client/mac/handler/dynamic_images.h<br />
  HEADERS += $$BREAKPAD_PATH/src/client/mac/handler/breakpad_nlist_64.h<br />
  HEADERS += $$BREAKPAD_PATH/src/client/mac/handler/mach_vm_compat.h<br />
  HEADERS += $$BREAKPAD_PATH/src/client/minidump_file_writer.h<br />
  HEADERS += $$BREAKPAD_PATH/src/client/minidump_file_writer-inl.h<br />
  HEADERS += $$BREAKPAD_PATH/src/common/mac/macho_utilities.h<br />
  HEADERS += $$BREAKPAD_PATH/src/common/mac/byteswap.h<br />
  HEADERS += $$BREAKPAD_PATH/src/common/mac/MachIPC.h<br />
  HEADERS += $$BREAKPAD_PATH/src/common/mac/scoped_task_suspend-inl.h<br />
  HEADERS += $$BREAKPAD_PATH/src/common/mac/file_id.h<br />
  HEADERS += $$BREAKPAD_PATH/src/common/mac/macho_id.h<br />
  HEADERS += $$BREAKPAD_PATH/src/common/mac/macho_walker.h<br />
  HEADERS += $$BREAKPAD_PATH/src/common/mac/macho_utilities.h<br />
  HEADERS += $$BREAKPAD_PATH/src/common/mac/bootstrap_compat.h<br />
  HEADERS += $$BREAKPAD_PATH/src/common/mac/string_utilities.h<br />
  HEADERS += $$BREAKPAD_PATH/src/common/linux/linux_libc_support.h<br />
  HEADERS += $$BREAKPAD_PATH/src/common/string_conversion.h<br />
  HEADERS += $$BREAKPAD_PATH/src/common/md5.h<br />
  HEADERS += $$BREAKPAD_PATH/src/common/memory.h<br />
  HEADERS += $$BREAKPAD_PATH/src/common/using_std_string.h<br />
  HEADERS += $$BREAKPAD_PATH/src/common/convert_UTF.h<br />
  HEADERS += $$BREAKPAD_PATH/src/processor/scoped_ptr.h<br />
  HEADERS += $$BREAKPAD_PATH/src/google_breakpad/common/minidump_exception_mac.h<br />
  HEADERS += $$BREAKPAD_PATH/src/google_breakpad/common/breakpad_types.h<br />
  HEADERS += $$BREAKPAD_PATH/src/google_breakpad/common/minidump_format.h<br />
  HEADERS += $$BREAKPAD_PATH/src/google_breakpad/common/minidump_size.h<br />
  HEADERS += $$BREAKPAD_PATH/src/third_party/lss/linux_syscall_support.h</p>
<p>  SOURCES += $$BREAKPAD_PATH/src/client/mac/handler/exception_handler.cc<br />
  SOURCES += $$BREAKPAD_PATH/src/client/mac/crash_generation/crash_generation_client.cc<br />
  SOURCES += $$BREAKPAD_PATH/src/client/mac/crash_generation/crash_generation_server.cc<br />
  SOURCES += $$BREAKPAD_PATH/src/client/mac/handler/minidump_generator.cc<br />
  SOURCES += $$BREAKPAD_PATH/src/client/mac/handler/dynamic_images.cc<br />
  SOURCES += $$BREAKPAD_PATH/src/client/mac/handler/breakpad_nlist_64.cc<br />
  SOURCES += $$BREAKPAD_PATH/src/client/minidump_file_writer.cc<br />
  SOURCES += $$BREAKPAD_PATH/src/common/mac/macho_id.cc<br />
  SOURCES += $$BREAKPAD_PATH/src/common/mac/macho_walker.cc<br />
  SOURCES += $$BREAKPAD_PATH/src/common/mac/macho_utilities.cc<br />
  SOURCES += $$BREAKPAD_PATH/src/common/mac/string_utilities.cc<br />
  SOURCES += $$BREAKPAD_PATH/src/common/mac/file_id.cc<br />
  SOURCES += $$BREAKPAD_PATH/src/common/mac/MachIPC.mm<br />
  SOURCES += $$BREAKPAD_PATH/src/common/mac/bootstrap_compat.cc<br />
  SOURCES += $$BREAKPAD_PATH/src/common/md5.cc<br />
  SOURCES += $$BREAKPAD_PATH/src/common/string_conversion.cc<br />
  SOURCES += $$BREAKPAD_PATH/src/common/linux/linux_libc_support.cc<br />
  SOURCES += $$BREAKPAD_PATH/src/common/convert_UTF.c<br />
  LIBS += /System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation<br />
  LIBS += /System/Library/Frameworks/CoreServices.framework/Versions/A/CoreServices<br />
  #breakpad app need debug info inside binaries<br />
  QMAKE_CXXFLAGS+=-g<br />
}</p>
<p>OSLIN {<br />
  HEADERS += $$BREAKPAD_PATH/src/client/linux/handler/exception_handler.h<br />
  HEADERS += $$BREAKPAD_PATH/src/client/linux/crash_generation/crash_generation_client.h<br />
  HEADERS += $$BREAKPAD_PATH/src/client/linux/handler/minidump_descriptor.h<br />
  HEADERS += $$BREAKPAD_PATH/src/client/linux/minidump_writer/minidump_writer.h<br />
  HEADERS += $$BREAKPAD_PATH/src/client/linux/minidump_writer/line_reader.h<br />
  HEADERS += $$BREAKPAD_PATH/src/client/linux/minidump_writer/linux_dumper.h<br />
  HEADERS += $$BREAKPAD_PATH/src/client/linux/minidump_writer/linux_ptrace_dumper.h<br />
  HEADERS += $$BREAKPAD_PATH/src/client/linux/minidump_writer/directory_reader.h<br />
  HEADERS += $$BREAKPAD_PATH/src/client/linux/log/log.h<br />
  HEADERS += $$BREAKPAD_PATH/src/client/minidump_file_writer-inl.h<br />
  HEADERS += $$BREAKPAD_PATH/src/client/minidump_file_writer.h<br />
  HEADERS += $$BREAKPAD_PATH/src/common/linux/linux_libc_support.h<br />
  HEADERS += $$BREAKPAD_PATH/src/common/linux/eintr_wrapper.h<br />
  HEADERS += $$BREAKPAD_PATH/src/common/linux/ignore_ret.h<br />
  HEADERS += $$BREAKPAD_PATH/src/common/linux/file_id.h<br />
  HEADERS += $$BREAKPAD_PATH/src/common/linux/memory_mapped_file.h<br />
  HEADERS += $$BREAKPAD_PATH/src/common/linux/safe_readlink.h<br />
  HEADERS += $$BREAKPAD_PATH/src/common/linux/guid_creator.h<br />
  HEADERS += $$BREAKPAD_PATH/src/common/linux/elfutils.h<br />
  HEADERS += $$BREAKPAD_PATH/src/common/linux/elfutils-inl.h<br />
  HEADERS += $$BREAKPAD_PATH/src/common/using_std_string.h<br />
  HEADERS += $$BREAKPAD_PATH/src/common/memory.h<br />
  HEADERS += $$BREAKPAD_PATH/src/common/basictypes.h<br />
  HEADERS += $$BREAKPAD_PATH/src/common/memory_range.h<br />
  HEADERS += $$BREAKPAD_PATH/src/common/string_conversion.h<br />
  HEADERS += $$BREAKPAD_PATH/src/common/convert_UTF.h<br />
  HEADERS += $$BREAKPAD_PATH/src/google_breakpad/common/minidump_format.h<br />
  HEADERS += $$BREAKPAD_PATH/src/google_breakpad/common/minidump_size.h<br />
  HEADERS += $$BREAKPAD_PATH/src/google_breakpad/common/breakpad_types.h<br />
  HEADERS += $$BREAKPAD_PATH/src/processor/scoped_ptr.h<br />
  HEADERS += $$BREAKPAD_PATH/src/third_party/lss/linux_syscall_support.h<br />
  SOURCES += $$BREAKPAD_PATH/src/client/linux/crash_generation/crash_generation_client.cc<br />
  SOURCES += $$BREAKPAD_PATH/src/client/linux/handler/exception_handler.cc<br />
  SOURCES += $$BREAKPAD_PATH/src/client/linux/handler/minidump_descriptor.cc<br />
  SOURCES += $$BREAKPAD_PATH/src/client/linux/minidump_writer/minidump_writer.cc<br />
  SOURCES += $$BREAKPAD_PATH/src/client/linux/minidump_writer/linux_dumper.cc<br />
  SOURCES += $$BREAKPAD_PATH/src/client/linux/minidump_writer/linux_ptrace_dumper.cc<br />
  SOURCES += $$BREAKPAD_PATH/src/client/linux/log/log.cc<br />
  SOURCES += $$BREAKPAD_PATH/src/client/minidump_file_writer.cc<br />
  SOURCES += $$BREAKPAD_PATH/src/common/linux/linux_libc_support.cc<br />
  SOURCES += $$BREAKPAD_PATH/src/common/linux/file_id.cc<br />
  SOURCES += $$BREAKPAD_PATH/src/common/linux/memory_mapped_file.cc<br />
  SOURCES += $$BREAKPAD_PATH/src/common/linux/safe_readlink.cc<br />
  SOURCES += $$BREAKPAD_PATH/src/common/linux/guid_creator.cc<br />
  SOURCES += $$BREAKPAD_PATH/src/common/linux/elfutils.cc<br />
  SOURCES += $$BREAKPAD_PATH/src/common/string_conversion.cc<br />
  SOURCES += $$BREAKPAD_PATH/src/common/convert_UTF.c<br />
  #breakpad app need debug info inside binaries<br />
  QMAKE_CXXFLAGS+=-g<br />
}</p>
<p>OSWIN {<br />
  BREAKPAD_PATH=q:/Applications/breakpad-qt/third-party/latest-breakpad<br />
  INCLUDEPATH += $$BREAKPAD_PATH/src<br />
  HEADERS += $$BREAKPAD_PATH/src/common/windows/string_utils-inl.h<br />
  HEADERS += $$BREAKPAD_PATH/src/common/windows/guid_string.h<br />
  HEADERS += $$BREAKPAD_PATH/src/client/windows/handler/exception_handler.h<br />
  HEADERS += $$BREAKPAD_PATH/src/client/windows/common/ipc_protocol.h<br />
  HEADERS += $$BREAKPAD_PATH/src/google_breakpad/common/minidump_format.h<br />
  HEADERS += $$BREAKPAD_PATH/src/google_breakpad/common/breakpad_types.h<br />
  HEADERS += $$BREAKPAD_PATH/src/client/windows/crash_generation/crash_generation_client.h<br />
  HEADERS += $$BREAKPAD_PATH/src/processor/scoped_ptr.h </p>
<p>  SOURCES += $$BREAKPAD_PATH/src/client/windows/handler/exception_handler.cc<br />
  SOURCES += $$BREAKPAD_PATH/src/common/windows/string_utils.cc<br />
  SOURCES += $$BREAKPAD_PATH/src/common/windows/guid_string.cc<br />
  SOURCES += $$BREAKPAD_PATH/src/client/windows/crash_generation/crash_generation_client.cc<br />
}<br />

And this is the minimal implementation of your new CrashHandler. My ownd crash handler is much more sophisticate to perform reporting, sending crash dump etc. But for purposes of this article this is what you need (And also I don't want to share my whole know-how here ;-)))

CrashHandler.h

#pragma once<br />
#include &lt;QtCore/QString&gt;</p>
<p>namespace Atomix<br />
{<br />
	class CrashHandlerPrivate;<br />
	class CrashHandler<br />
	{<br />
	public:<br />
		static CrashHandler* instance();<br />
    void Init(const QString&amp;  reportPath);</p>
<p>		void setReportCrashesToSystem(bool report);<br />
		bool writeMinidump();</p>
<p>	private:<br />
		CrashHandler();<br />
		~CrashHandler();<br />
		Q_DISABLE_COPY(CrashHandler)<br />
		CrashHandlerPrivate* d;<br />
	};<br />
}<br />

CrashHandler.cpp

#include &quot;CrashHandler.h&quot;<br />
#include &lt;QtCore/QDir&gt;<br />
#include &lt;QtCore/QProcess&gt;<br />
#include &lt;QtCore/QCoreApplication&gt;<br />
#include &lt;QString&gt;</p>
<p>#if defined(Q_OS_MAC)<br />
#include &quot;client/mac/handler/exception_handler.h&quot;<br />
#elif defined(Q_OS_LINUX)<br />
#include &quot;client/linux/handler/exception_handler.h&quot;<br />
#elif defined(Q_OS_WIN32)<br />
#include &quot;client/windows/handler/exception_handler.h&quot;<br />
#endif</p>
<p>namespace Atomix<br />
{<br />
	/************************************************************************/<br />
	/* CrashHandlerPrivate                                                  */<br />
	/************************************************************************/<br />
	class CrashHandlerPrivate<br />
	{<br />
	public:<br />
		CrashHandlerPrivate()<br />
		{<br />
			pHandler = NULL;<br />
		}</p>
<p>		~CrashHandlerPrivate()<br />
		{<br />
			delete pHandler;<br />
		}</p>
<p>		void InitCrashHandler(const QString&amp; dumpPath);<br />
		static google_breakpad::ExceptionHandler* pHandler;<br />
		static bool bReportCrashesToSystem;<br />
	};</p>
<p>	google_breakpad::ExceptionHandler* CrashHandlerPrivate::pHandler = NULL;<br />
	bool CrashHandlerPrivate::bReportCrashesToSystem = false;</p>
<p>	/************************************************************************/<br />
	/* DumpCallback                                                         */<br />
	/************************************************************************/<br />
#if defined(Q_OS_WIN32)<br />
	bool DumpCallback(const wchar_t* _dump_dir,const wchar_t* _minidump_id,void* context,EXCEPTION_POINTERS* exinfo,MDRawAssertionInfo* assertion,bool success)<br />
#elif defined(Q_OS_LINUX)<br />
	bool DumpCallback(const google_breakpad::MinidumpDescriptor &amp;md,void *context, bool success)<br />
#elif defined(Q_OS_MAC)<br />
	bool DumpCallback(const char* _dump_dir,const char* _minidump_id,void *context, bool success)<br />
#endif<br />
	{<br />
		Q_UNUSED(context);<br />
#if defined(Q_OS_WIN32)<br />
		Q_UNUSED(_dump_dir);<br />
		Q_UNUSED(_minidump_id);<br />
		Q_UNUSED(assertion);<br />
		Q_UNUSED(exinfo);<br />
#endif<br />
		qDebug(&quot;BreakpadQt crash&quot;);</p>
<p>		/*<br />
		NO STACK USE, NO HEAP USE THERE !!!<br />
		Creating QString's, using qDebug, etc. - everything is crash-unfriendly.<br />
		*/<br />
		return CrashHandlerPrivate::bReportCrashesToSystem ? success : true;<br />
	}</p>
<p>	void CrashHandlerPrivate::InitCrashHandler(const QString&amp; dumpPath)<br />
	{<br />
		if ( pHandler != NULL )<br />
			return;</p>
<p>#if defined(Q_OS_WIN32)<br />
		std::wstring pathAsStr = (const wchar_t*)dumpPath.utf16();<br />
		pHandler = new google_breakpad::ExceptionHandler(<br />
			pathAsStr,<br />
			/*FilterCallback*/ 0,<br />
			DumpCallback,<br />
			/*context*/<br />
			0,<br />
			true<br />
			);<br />
#elif defined(Q_OS_LINUX)<br />
		std::string pathAsStr = dumpPath.toStdString();<br />
		google_breakpad::MinidumpDescriptor md(pathAsStr);<br />
		pHandler = new google_breakpad::ExceptionHandler(<br />
			md,<br />
			/*FilterCallback*/ 0,<br />
			DumpCallback,<br />
			/*context*/ 0,<br />
			true,<br />
			-1<br />
			);<br />
#elif defined(Q_OS_MAC)<br />
		std::string pathAsStr = dumpPath.toStdString();<br />
		pHandler = new google_breakpad::ExceptionHandler(<br />
			pathAsStr,<br />
			/*FilterCallback*/ 0,<br />
			DumpCallback,<br />
			/*context*/<br />
			0,<br />
			true,<br />
			NULL<br />
			);<br />
#endif<br />
	}</p>
<p>	/************************************************************************/<br />
	/* CrashHandler                                                         */<br />
	/************************************************************************/<br />
	CrashHandler* CrashHandler::instance()<br />
	{<br />
		static CrashHandler globalHandler;<br />
		return &amp;globalHandler;<br />
	}</p>
<p>	CrashHandler::CrashHandler()<br />
	{<br />
		d = new CrashHandlerPrivate();<br />
	}</p>
<p>	CrashHandler::~CrashHandler()<br />
	{<br />
		delete d;<br />
	}</p>
<p>	void CrashHandler::setReportCrashesToSystem(bool report)<br />
	{<br />
		d-&gt;bReportCrashesToSystem = report;<br />
	}</p>
<p>	bool CrashHandler::writeMinidump()<br />
	{<br />
		bool res = d-&gt;pHandler-&gt;WriteMinidump();<br />
		if (res) {<br />
			qDebug(&quot;BreakpadQt: writeMinidump() successed.&quot;);<br />
		} else {<br />
			qWarning(&quot;BreakpadQt: writeMinidump() failed.&quot;);<br />
		}<br />
		return res;<br />
	}</p>
<p>	void CrashHandler::Init( const QString&amp; reportPath )<br />
	{<br />
		d-&gt;InitCrashHandler(reportPath);<br />
	}<br />
}<br />

Main.cpp

And here is how to use it:

#include &quot;axCore/axCrashHandler/CrashHandler.h&quot;<br />
#include &lt;QDebug&gt;<br />
#include &lt;QCoreApplication&gt;<br />
#include &lt;iostream&gt;</p>
<p>int buggyFunc()<br />
{<br />
	delete reinterpret_cast&lt;QString*&gt;(0xFEE1DEAD);<br />
	return 0;<br />
}</p>
<p>int main(int argc, char * argv[])<br />
{<br />
	qDebug() &lt;&lt; &quot;App start&quot;;<br />
	QCoreApplication app(argc, argv);</p>
<p>#if defined(Q_OS_WIN32)<br />
	Atomix::CrashHandler::instance()-&gt;Init(&quot;c:\\dump&quot;);<br />
#elif defined(Q_OS_LINUX)<br />
	Atomix::CrashHandler::instance()-&gt;Init(&quot;/Users/dev/dump&quot;);<br />
#elif defined(Q_OS_MAC)<br />
	Atomix::CrashHandler::instance()-&gt;Init(&quot;/Users/User/dump&quot;);<br />
#endif</p>
<p>	qDebug() &lt;&lt; &quot;CrashHandlerSet&quot;;<br />
	buggyFunc();<br />
	return 0;<br />
}<br />

Very slow svn updates from Virtual Machines (VMWare)

I have a lot of virtual machines used for my everyday development. It's very frustrating the SVN update speed if you have several externals in your main SVN source.

Today when I wait for some compilation start searching if there is anything what could improve SVN speed. After searching a lot of articles about faster network, better server hdd,... I found article with mention how SVN client communicate with server (intensively ;-) ). But without any clue how to improve it.

So I start searching how SVN client communiacte from within VMWare machines to server. I noticed that VMWare default network settings is NAT: Used to share the host's IP address:

So I start trying other network methods and this is the result:

When I use "Custom: Specific virtual network" and choose "VMnet0 Bridged", my svn update is about ten times faster than on NAT settings!!. I also tried first option "Bridged:..." but this doesn't work for me.

30 Aug 2012

Posted by: ludek.vodicka

Linux Windows Mac OS #deploy #svn

Windows, Linux and MacOS 7za equivalent

**Windows:**
http://www.7-zip.org/

**Ubuntu:**

sudo apt-get install p7zip-full<br />

**MacOS:**

sudo port install p7zip<br />

21 Aug 2012

Posted by: ludek.vodicka

Linux Windows Mac OS

How to execute 32-bit command line from 64-bit application

20 Aug 2012

Posted by: ludek.vodicka

Windows

Qt application crash when compiled for 64-bit VS2010

Callstack

&gt;	QtGui4.dll!00000000652f071f()<br />
 	[Frames below may be incorrect and/or missing, no symbols loaded for QtGui4.dll]<br />
 	QtGui4.dll!00000000652f07ae()<br />
 	QtGui4.dll!0000000065326821()<br />
 	QtGui4.dll!0000000065327f30()<br />
 	QtGui4.dll!00000000653284ba()<br />
 	QtGui4.dll!000000006532a5f5()<br />
 	QtGui4.dll!00000000652f4792()<br />
 	QtGui4.dll!000000006532f701()<br />
 	QtGui4.dll!000000006535be71()<br />
 	QtCore4.dll!0000000059a0ab9f()<br />
 	QtGui4.dll!0000000065306eb9()<br />
 	QtCore4.dll!00000000599f7903()<br />
 	QtGui4.dll!0000000064eaffa2()<br />
 	QtGui4.dll!0000000064eb2e56()<br />
 	QtCore4.dll!00000000599f7792()<br />
 	QtGui4.dll!0000000064eec2a3()<br />
 	QtGui4.dll!0000000064eee85e()<br />
 	QtGui4.dll!0000000064eec265()<br />
 	QtGui4.dll!0000000064eee85e()<br />
 	QtGui4.dll!0000000064eec265()<br />
 	QtGui4.dll!0000000064eee85e()<br />
 	QtGui4.dll!0000000064efa870()<br />
 	QtGui4.dll!0000000065208727()<br />
 	QtGui4.dll!000000006527a082()<br />
 	QtGui4.dll!0000000064eaffb6()<br />
 	QtGui4.dll!0000000064eb2e56()<br />
 	QtCore4.dll!00000000599f7792()<br />
 	QtGui4.dll!0000000064ef264c()<br />
 	QtGui4.dll!0000000064ef26c7()<br />
 	QtGui4.dll!0000000064ef26c7()<br />
 	QtGui4.dll!0000000064ef26c7()<br />
 	QtGui4.dll!0000000064efe30c()<br />
 	OrmDesigner2.exe!000000013f95a2cf()<br />
 	OrmDesigner2.exe!000000013f95dce2()<br />
 	kernel32.dll!000000007794652d()<br />
 	ntdll.dll!0000000077c8c521()<br />

The bug is probably caused by wrong alignment or incorrect VS2010 compiler optimalization.

Found resources:
https://bugreports.qt.nokia.com//browse/QTBUG-11445
https://connect.microsoft.com/VisualStudio/feedback/details/573262/incorrect-alignment-with-x64-optimizer-and-movaps
http://support.microsoft.com/kb/2280741
https://connect.microsoft.com/VisualStudio/Downloads/DownloadDetails.aspx?DownloadID=31433

Workarounds:

First way - Update VS2010 mkspec for Qt

go to $QTDIR/mkspecs/win32-msvc2010/qmake.conf and replace -02 with -01 (ie. reducing the optimzation level).Also /Ob0 could be used.

Microsoft hotfix for VS

http://archive.msdn.microsoft.com/KB2280741
File patch name VS10-KB2268081-x86.exe

Install Visual Studio 2010 SP1

Service pack could also contains required fix.
http://www.microsoft.com/download/en/details.aspx?id=23691

22 Nov 2011

Windows 7 autologin

09 Sep 2011

Posted by: ludek.vodicka

Windows

How to enable Send As in Exchange 2010

When you have more than one email for each user in your exchange 2010, it's necessary to configure Exchange to support it.

How is steps necessary to do that:

**1) Create shared Mailbox.**

The simpliest way is use Exchange management shell(EMS) and execute following command:

New-Mailbox -Name:[email protected]' -UserPrincipalName:[email protected]' -Shared

**2) Assign permissions**

As next thing you have to assign permissions for users which will use this mailbox for sending emails.

Add-ADPermission "[email protected]" -User "UserWhoWillUseThisAccount" -Extendedrights "Send As"

**3) Use it**

Check "From" button in "Options" tab and enter shared address to "From" field in the mail header.

**Note:**

When mails will be forwarded back with error about "not enought permissions", simply remove exchange account from outlook and add it back again. This solution resolve my problem after 6 hours of debugging ;-(

**Usefull web links:**

04 Sep 2011

Posted by: ludek.vodicka

Windows #SBS2011 #Exchange #Outlook

MinGW and compilation 32/64bit libraries

Install MinGW-64

1) Download MinGW 64-bit and 32-bit

http://sourceforge.net/projects/mingw-w64/files/Toolchains%20targetting%20Win64/

http://sourceforge.net/projects/mingw-w64/files/Toolchains%20targetting%20Win32/

- Toolchains targetting Win64 / Toolchains targetting Win32
- Automated Builds
- mingw-w64-1.0-bin_i686-mingw_*.zip
- mingw-w32-1.0-bin_i686-mingw_*.zip

2) Download MSYS compatible with 64-bit MinGW

http://sourceforge.net/projects/mingw-w64/files/External%20binary%20packages%20(Win64%20hosted)/MSYS%20(32-bit)/

3) Extract MinGW32, mingw64 and MSYS to one folder

MinGW-32, MinGW-64 and MSYS to folder MinGW64 (Bin folder from MinGW will be merged with bin folder from MSYS, etc.)

**External links:**

MSYS wiki
MinGW-64 wiki

30 Jan 2011

Posted by: ludek.vodicka

Programming Linux Windows #Linux #C++ #Windows #cygwin

Problem with Qt compilation under Windows 64-bit

This short post will show you how to resolve following error during Qt compilation on 64-bit windows:

Creating library ..\..\..\..\lib\QtWebKitd4.lib and object ..\..\..\..\lib\Qt<br />
WebKitd4.exp<br />
PluginViewWin.obj : error LNK2019: unresolved external symbol _HBeginPaint refer<br />
enced in function &quot;private: static struct HDC__ * __cdecl WebCore::PluginView::h<br />
ookedBeginPaint(struct HWND__ *,struct tagPAINTSTRUCT *)&quot; ([email protected]<br />
[email protected]@@CAPEAUHDC__@@PEAUHWND__@@PEAUtagP AINTSTRUCT@@@Z)<br />
PluginViewWin.obj : error LNK2019: unresolved external symbol _HEndPaint referen<br />
ced in function &quot;private: static int __cdecl WebCore::PluginView::hookedEndPaint<br />
(struct HWND__ *,struct tagPAINTSTRUCT const *)&quot; ([email protected]@Web<br />
Core@@CAHPEAUHWND__@@PEBUtagPAINTSTRUCT@@@Z)<br />
..\..\..\..\lib\QtWebKitd4.dll : fatal error LNK1120: 2 unresolved externals<br />
NMAKE : fatal error U1077: '&quot;C:\Program Files (x86)\Microsoft Visual Studio 9.0\<br />
VC\BIN\x86_amd64\link.EXE&quot;' : return code '0x460'<br />
Stop.<br />
NMAKE : fatal error U1077: '&quot;C:\Program Files (x86)\Microsoft Visual Studio 9.0\<br />
VC\BIN\nmake.exe&quot;' : return code '0x2'<br />

This error is caused by bug in **QMAKE_HOST** variable used in WebCore.pro file. This variable is tested to determine destination platform (x86 or x64).
This variable contains x86 value also on 64-bit builds instead of x86_64 value. This value is tested on the following line in a WebCore.pro file:

win32:!win32-g++*:contains(QMAKE_HOST.arch, x86_64):{<br />

If you want to fix this error, simply replace **QMAKE_HOST** by **QMAKE_TARGET** variable. Updated line should look like this:

win32:!win32-g++*:contains(QMAKE_TARGET.arch, x86_64):{<br />

After this update all required asm defines are correctly included and build of WebKit will be successful.

Update for this error

In newer versions of Qt there is already applied fix the error with QMAKE_HOST / QMAKE_TARGET, but also there is a new problem ;-(.

The Problem is in the following "if" definition:

   if(win32-msvc2005|win32-msvc2008):equals(TEMPLATE_PREFIX, &quot;vc&quot;) {<br />
        SOURCES += \<br />
            plugins/win/PaintHooks.asm<br />
    }<br />

When you compile your project for MSVC 2010, .asm file isn't included. It's necessary to add win32-msvc2010 to this definition. So updated WebCore.pro for Qt 4.8 will look like this:

 if(win32-msvc2005|win32-msvc2008|win32-msvc2010):equals(TEMPLATE_PREFIX, &quot;vc&quot;) {<br />
        SOURCES += \<br />
            plugins/win/PaintHooks.asm<br />
    }<br />

Next problem solution

Next problem which I found during compilation is wrongly set QMAKE_TARGET.arg. For unspecified reason, when I compile 64bit library in 64bit system in 64bit VS command line, this variable has value x86 instead of x86_64.
The problem is in the qmake project.cpp file. QMAKE trying to determine 64/32 bit version based on the %PATH% configuration. Qmake search for VS-PATH\bin\amd64 of \bin\x86_amd64 string. Unfortunately there is a bug in concating searched string. This is how looks original project.cpp file at line 3177:

QString vcBin64 = qgetenv(&quot;VCINSTALLDIR&quot;).append(&quot;\\bin\\amd64&quot;);<br />
QString vcBinX86_64 = qgetenv(&quot;VCINSTALLDIR&quot;).append(&quot;\\bin\\x86_amd64&quot;);<br />

The problem is, that VCINSTALLDIR contains \ at the end of the string, and then we append \ again. So, result is:

QString vcBin64 = qgetenv(&quot;VCINSTALLDIR&quot;);<br />
if ( vcBin64.at( vcBin64.size()-1 ) != '\\' )<br />
  vcBin64.append(&quot;\\&quot;);<br />
vcBin64.append(&quot;bin\\amd64&quot;);</p>
<p>QString vcBinX86_64 = qgetenv(&quot;VCINSTALLDIR&quot;);<br />
if ( vcBinX86_64.at( vcBinX86_64.size()-1 ) != '\\' )<br />
  vcBinX86_64.append(&quot;\\&quot;);<br />
vcBinX86_64.append(&quot;bin\\x86_amd64&quot;);<br />

Now, QMake correctly determine 32/64 bit compilation and then correctly include PaintHooks.asm and your Qt WebCore will be sucesfully compiled.

28 Jan 2011

Mount error(12): Cannot allocate memory

Problem

When mounting some windows samba drives, "mount error(12)" error can occurred. Problem is in windows samba server settings. Full linux error message:

mount error(12): Cannot allocate memory<br />
Refer to the mount.cifs(8) manual page (e.g.man mount.cifs)<br />

and error message in windows event log:

Source: srv<br />
Event ID: 2017<br />
Level: Error<br />
The server was unable to allocate from the system nonpaged pool because the server reached the configured limit for nonpaged pool allocations.<br />

Solution

Update following registry:

HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Memory Management\LargeSystemCache = 1<br />
HKLM\SYSTEM\CurrentControlSet\Services\LanmanServer\Parameters\Size = 3<br />

After you update these values, restart your computer.

More about this issue:

http://alan.lamielle.net

13 Dec 2010

Posted by: ludek.vodicka

Linux Windows #Linux #Windows