Creating module with pybind11 and debugging it in python at runtime crash - boost-python

I'm re-posting my issue from https://github.com/pybind/pybind11/discussions/4477 to here as I'm not getting much luck there for now...
To summarize I have c++ application that has python in it via boost. I want to load a c++ dll in to it via pybind11 and debug my dlls at runtime via attaching myself to the process and breakpoints in the source.
Sadly when I hit breakpoint I get that crazy error that you can see there.
I think this is the relevant part >
00007FFAE47AEAA5 (ucrtbased): (filename not available): get_wide_winmain_command_line
00007FFAE47AE8C3 (ucrtbased): (filename not available): get_wide_winmain_command_line
00007FFAE47B158F (ucrtbased): (filename not available): wassert
00007FFACC14B3F0 (python37_d): (filename not available): PyAST_Validate
S:\vcpkg\installed\x64-windows\include\pybind11\detail\internals.h (414): `pybind11::detail::get_internals'::`2'::gil_scoped_acquire_local::gil_scoped_acquire_local
S:\vcpkg\installed\x64-windows\include\pybind11\detail\internals.h (417): pybind11::detail::get_internals
S:\RnD\DLL_python\c_DLL_Python_01\icLib\library.cpp (34): PyInit_mydll
I've tried setting up compiler flags/etc but sadly no luck.
Has any1 been able to compile pybind11 to pyd dll on windows & load it in python and then breakpoint into it?
To any1 wondering why I'm jumping over soo many hoops and not using python... I wrote a framework in c++ that works between 4 apps via c++ api, sadly 5th app is only python and thus I "can" use my framework via pybind11 but I need help debugging.

Related

Error: register 'sp' unsuitable for global register variables on this target

I am playing around with a project for a STM32 µC. I use the SW4STM32 workbench and CubeMX on a Mac OSX system. My project itself is fine, everything compiles accordingly and behaves on the device as expected.
For a further learning purpose, I would like to implement unit tests using the CppuUTest framework. I have set up everything, got my test directories and a makefile to configure the MakefileWorker variables in place.
However, when executing the Makefile, I keep getting the error:
error:
register 'sp' unsuitable for global register variables on this target
This error originates from the file syscalls.c (which is a file generated by CubeMX). The line causing the error is:
register char * stack_ptr asm("sp");
After doing my research, it seems like there is no easy workaround to solve the issue. The source code is generated by Cube and works fine when compiling with the sw4stm32 toolchain (which is using a mcu gcc compiler).
However, the CppUTest toolchain is using clang, which cannot cope with global register variables (as the error says aswell).
My question here ist:
Has anyone of you had the same error yet or more experience in setting up CppUTest for a sw4stm32 project on an OSx system? Does anyone have an idea how to solve this problem?
If you need more information / code snippets from me, I will gladly share it.
Thank you very much guys! Any help would be highly appreciated :-)
Cheers,
Tobi

Can't Compile Tesseract API example for WIndows using Tesseract 3.0.2.02 archive

I'm looking at using Tesseract to do some work with PDF files, and so I want to use the library rather than an external executable.
I started by downloading the full Tesseract source and looking at building that. Sadly the standard sources don't have any means to build on a non-Linux platform, in my case Windows. There are methods for doing so, and I looked at those.
Firstly the VS2008 build doesn't. I'm aware that it need Leptonica, but I figured I'd tackle that afterwards and just tried to build the existing code. Fails with "fatal error C1083: Cannot open include file: 'allheaders.h': No such file or directory". Nothing to do with Leptonica at this stage, it simply doesn't work.
Even if I were able to get past that, I'd have to build Leptonica, and that requires using GNU tools and therefore an installation of Cygwin, so I gave up. I Have a MingW instatllation, (I've never managed to get Cygwin to work in a usable fashion) but I'm not keen enough to mess with such a complicated and fragile build.
So I decided I'd just use the pre-built binaries which some kind soul creates. Downloaded that from code.google.com. Now I need to look into using the code, so the next obvious step is the Tesseract API example, which states it requires "tesseract-ocr-3.02.02-win32-lib-include-dirs.zip", no problem, because I already have that now.
No real clue as to where the API example wants the files to be placed, but a little messing about gets them in appropriate locations. Press build and "fatal error C1083: Cannot open include file: 'allheaders.h': No such file or directory", just like trying to build Tesseract from source.....
And indeed there is no such file.
So, where is this file ?
I also struggled some time ago to make it works under windows and then I found this git repository : https://github.com/charlesw/tesseract-vs2012
It includes all needed extern library (because Tesseract need Leptonica, but Leptonica also need extern library to handle the different image format) and is also working great with vs 2013.
OK so now I see that allheaders.h is part of Leptonica. Still leaves me wondering why the Tesseract pre-built library requires that I have Leptonica available, I would have expected that to be built-in, I guess it isn't.

Access LLDB / set breakpoints when running simple swift file from command line

I have a simple Swift script that I'd like to step into using LLDB but having a hard time making sense of the documentation. If I run the following inside the REPL:
:target create ./myswiftfile.swift
I get back
error: './test.swift' doesn't contain any 'host' platform architectures: x86_64h, x86_64, i386
Is it possible to either set the arch from inside the REPL or otherwise invoke myswiftfile in a way that gets me into the debugger? I realize I can debug inside Xcode using the Command Line Tool template but it's a shame given how lightweight a simple Swift script can be. Basically looking for pdb for Swift.
lldb does not currently support compiling swift files for you and then loading them into the debugger or the REPL. It wouldn't be all that hard to do. The best thing to do is to file an enhancement request with bugreporter.apple.com.

Modifying the Eclipse Debugger

I am attempting to modify the eclipse CDT debugger to allow my to step though my code on my FR family Fujitsu board. The board can only be communicated by the SOFTUNE IDE. Fujitsu provides a dll for communicating with with SOFTUNE's debugger.
Making a simple c++ program I was able to get this to work and control the SOFTUNE.
The supplied commands in the .dll are:
Initialize();
Openproject();
Build();
Go();
Stop();
TargetFile();
Reset();
ReadPC();
SetBreak();
GetDebuggerStatus();
GlobalSymbolToAdrress();
ExpressionToAdrress();
WriteMemory();
ReadMemory();
The issue I am having is making a plugin to the CDT debugger to pass commands using the dll. Searching the web i can only find making my own debugger, is there an easier way then starting from scratch?

How to package a PySide/Phonon app under Mac OSX?

I have a PySide/Phonon app (developed for and working flawlessly on Windows) that I need to "port" to Mac OSX - where I have no development experience whatsoever.
The app works as expected if I just run the Python file - the problems arise when I try to package it (which I need to do) with py2app.
If I leave the resulting .app as is, Phonon doesn't work, because it fails to load the required phonon_backend ; if I add the plugin path to qt.conf, as various sources suggest, Phonon seems to load (that is, I don't get the corresponding error message anymore), but I start getting the "so-and-so library is loaded twice, one will be used, which one is undefined" error, and the app crashes right away.
Finally, if I try to use the macdeploy_qt tool, I receive a message to the effect of "no external framework" and the results are functionally equivalent to what I get without using the tool, except there are a few more plugins in the relevant directory.
Any ideas/pointers/tutorials/etc? I'm using PySide1.1.1 for Qt4.7, by the way, and Python.org python binaries (otherwise py2app can't even start to build a standalone app, it seems).
I suggest you do it like in this tutorial.
Then you just have to add the following line somewhere at the top of your main module:
QApplication.setLibraryPaths([os.path.join(os.environ['_MEIPASS2'], 'qt4_plugins'), os.environ['_MEIPASS2'] ])
For PyInstaller >1.5 the following code should be used instead:
QApplication.setLibraryPaths([os.path.join(sys._MEIPASS, 'qt4_plugins'), sys._MEIPASS])