[C++-sig] [Swig-user] A callback function with arguments causes error

Bruce Who bruce.who.hk at gmail.com
Tue May 15 16:49:24 CEST 2007


hi, Nitro

Thanks for your hint, and I tried a similar method, I add __asm {int
3} before the call, but the unassembld code are really hard to read
and I donnot think I can figure it out even it's translated into C++
source code.

I just wonder if this kind of usage is not supported by swig or maybe
I miss something very basic, since I just made a little modification
to the swig example.

On 5/15/07, Nitro <nitro at dr-code.org> wrote:
> Am 15.05.2007, 02:25 Uhr, schrieb Bruce Who <bruce.who.hk at gmail.com>:
>
> <snip>
>
> Why don't you compile a debug version and invoke the debugger when it
> crashes (or before it crashes)? My favourite trick for debugging an
> extension module is like this:
>
> test.py:
>
> import myModule
> doSomeNonCrashingPythonThingsHere()
> myModule.InvokeDebugger()  # Debugger gets involved here
> this_line_will_make_it_crash()
>
>
> myModule.i:
>
> ....
>
> %inline
> %{
> void InvokeDebugger()
> {
>      int* x = 0;
>      y = *x;
> }
> %}
>
>
> When it crashes on the invoke debugger line, windows gives me that error
> box where I can choose "Debug". When I do this I end up in the y = *x
> line, then set the "next instruction" to the end of the InvokeDebugger
> function, set all breakpoints I want to set (for example in the
> myModuke_wrap.cpp) and hit F5 to contiue debugging. The debugger will then
> either break on the next breakpoint or break when it crashes.
> This should give you enough pointers to see what you are doing wrong.
>
> -Matthias
>
> P.S.: I think this only works in debug mode and probably only on msvc. In
> release mode the InvokeDebugger function is sometimes either not executed
> or it doesn't care whether it dereferences a 0 pointer.
>

Bruce



More information about the Cplusplus-sig mailing list