LinuxConsulting

- Nicu Pavel personal page

PaNiC Random Rant (or how we used to call it: .plan)


Monday, August 3, 2009

QMake with Visual Studio: Generating debug information (pdb) files


Working with multiple libraries on different subdirs in Visual Studio using QMake tools brings a problem when you try to debug code that is contained in those libraries: the debug files (pdb) are generated with same name (vc80.pdb or similar) in libraries dirs which results in visual studio being unable to get the right debug information. To fix this problem pdb files need to be renamed and placed in the location where the executable is run for debugging.
As an example we have a main .pro file which it's a subdirs template to compile code in multiple subdirs:

TEMPLATE = subdirs
CONFIG += ordered
SUBDIRS += mbl_utils \
mbl_usb \
mbl_encoder \
mbl_renderer \
nanoGUI


For each .pro file in the libraries subdirectory we will have to add on a debug:win32 entry the following code:


debug:win32 {
# Hack to get pdb files generated with proper name
QMAKE_CXXFLAGS += -Fd$${TARGET}.pdb
# Hack to get pdb files copied in Bin folder from where the binary is run
pdbtarget.files = $${TARGET}.pdb
pdbtarget.path = $${BINDIR}
pdbtarget.command = copy /y $${TARGET}.pdb $${BINDIR}
INSTALLS += pdbtarget
}


Where TARGET is defined as the library name and BINDIR is where the executable file is copied after compilation. This should create proper debug information files where the project executable is being run.

Labels: , , ,

posted by panic @ 12:44 PM 0 Comments


Thursday, June 18, 2009

Hijacking library calls


From time to time you might want to override a function call by a binary or library with your own supplied code. This might be useful for example binding a program to a certain address considering that the program doesn't have an option for that. It can also be used for debugging or other obscure tasks. The attached example it's pretty simple, it saves the real address of connect function from libc to a function pointer named real_connect, reads the address/port information from environment and issues the new parameters after the bind call has been performed to the real_connect function.

For your "library" to be preloaded it has to be added to /etc/ld.so.preload by simply doing:
echo "/path/to/libc-highjack.so" > /etc/ld.so.preload

To use it, before starting a program, export HIGHHACK_PORT and HIGHJACK_IP to the values that you need.

The compiling instructions are in the source code.


uploads-blog/libc-highjack.c

Labels: , ,

posted by panic @ 4:42 PM 0 Comments


Wednesday, August 8, 2007

Python Wrapper for picoLCD


Chris Jones has created a python wrapper for my picoLCD SDK which is available
for download here. You can read more about this at his blog and watch a nice video
of his python application and picoLCD in action here.

Labels: , ,

posted by panic @ 4:08 PM