May 05 2010

Install GDB cross debugger for i386 ELF on Mac OS X

Category: Uncategorizedwuxicn @ 9:31 AM

1. Download and install gettext: http://www.gnu.org/software/gettext/

2. Install i386-elf-gcc from MacPorts:

sudo port install i386-elf-gcc
sudo port -f activate i386-elf-gcc

You may need to create some symbolic links:

cd /opt/local/bin
sudo ln -s i386-elf-gcc-4.3.2 i386-elf-gcc
sudo ln -s i386-elf-g++-4.3.2 i386-elf-g++

3. Download GDB: http://www.gnu.org/software/gdb/download/

4. Configure and install GDB for i386-ELF:

./configure --prefix=/opt/local \
            --program-prefix=i386-elf- \
            --target=i386-elf \
            --with-gmp=/opt/local \
            --with-libelf=/opt/local \
            --with-build-libsubdir=/opt/local
make
sudo make install

Then the i386-ELF GDB will be installed in /opt/local with program name i386-elf-gdb.

Note: option ‘–target=i386-elf’ specifies guest(target) type ‘i386 ELF’.

Tags: , , , , ,


Mar 26 2010

VC下几个有用的DEBUG函数

Category: Uncategorizedwuxicn @ 1:21 PM

Output Window 是 Visual Studio 提供的一个非常有用的Debug窗口,程序在Debug版下可以通过VC提供的函数向Output窗口输出东西(如一些变量的值,一些测试点等)而不用考虑影响程序的正常输出或者中断程序。下面这些就是VC为之提供的函数:

1. MFC中: TRACEn() 宏, 其中n=0,1,2,3. 用法类似printf,n表示可以有几个附加参数。如:TRACE2(“width=%d, height=%d”, w, h); 详见:MSDN: http://msdn.microsoft.com/en-US/library/w6xa1ayx(v=VS.80).aspx

2. CRT中: _RPTn() 宏, 类似MFC的TRACEn() 宏。#include <crtdbg.h> 见: MSDN: http://msdn.microsoft.com/en-us/library/yt0c3wdh(v=VS.80).aspx

3. Win32中: OutputDebugString() 函数,类似上面两个,注意有一点不同:这个函数在Release也会输出!所以最好自己再封装一遍。见:MSDN: http://msdn.microsoft.com/en-us/library/aa363362(VS.85).aspx

Tags: , , ,


Jul 30 2009

调试Python程序 python -m pdb <your_script> <args…>

Category: Uncategorizedwuxicn @ 10:32 AM

用pdb来调试python程序,用法:

python -m pdb <your_script> <args…>

Tags: , ,