[Mono-list] Re: Method signature modification
shankari82 at yahoo.com
Mon Oct 17 15:50:11 EDT 2005
Thanks for your time. I am restating the problem
My C function looks like : void func (param1,
param2). In fact I dont bother about how my C function
prototype looks like as it can choose not to use any
arguments passed to it.
My C# function does a Dll import like
static extern void func (param1, param2);
Under normal cases, I would call func(param1,param2)
But I want to set a flag during this. So, I thought of
doing it like this.
The C function implementation remains as it is. But
Dll import is changed to
static extern void func (flag, param1, param2);
C# invocation : func(flag,param1,param2)
Now C function : func(param1, param2...)
Hence param1 = flag, param2 = param1.
To avoid this, I want to be able to strip the flag off
before mono generates the native wrapper and use the
flag to set some mono variable.
So, I guess mono_marshal_emit_native_wrapper(
marshal.c) has to get the original sgnature to emit
the right wrapper.
--- Jonathan Pryor <jonpryor at vt.edu> wrote:
> On Fri, 2005-10-14 at 20:50 -0700, Shankari wrote:
> > I have some questions in unmanaged call internals.
> > From what I understood, an unmanaged code is a
> > function call.
> Unmanaged code can be anything (including Perl
> code), and can be an
> unmanaged *function*. A function call would invoke
> the function.
> > To figure out where exactly the switch from
> managed to
> > unmanaged code is happening, I set a breakpoint in
> > C program and tried a backtrace from it. Here is
> > info I got.
> > (gdb) backtrace
> > #0 printmsg () at cprog.c:13
> > #1 0x0045b6ac in ?? ()
> > #2 0x00000001 in ?? ()
> > #3 0x00e65710 in ?? ()
> > #4 0x00450ad7 in ?? ()
> > #5 0x093458e0 in ?? ()
> > #6 0x093458c8 in ?? ()
> > #7 0x09389398 in ?? ()
> > #8 0x0002be60 in ?? ()
> > #9 0x00000000 in ?? ()
> > (gdb) n
> > 0x0045b6ac in ?? ()
> > (gdb)
> Translation of all that: Mono created a new thread
> which contains JITed
> code, so no debug symbols exist (that GDB knows
> Consequently, you need the managed callstack, which
> you can get using
> mono_print_method_from_ip, which takes a stack
> pointer as an argument,
> (gdb) p mono_print_method_from_ip (0x0045b6ac)
> > I am not able to single step through the code from
> > point where unmanaged code is ending.
> That's because no source code exists for those
> functions, at least as
> far as GDB is concerned.
> > Since the backtrace addr are not resolved, it
> > like an unmanaged call is spawned in a new thread.
> Correct. Mono creates several threads during
> startup for myriad reasons
> (such as for the garbage collector, finalizer
> thread, etc.).
> - Jon
Yahoo! Mail - PC Magazine Editors' Choice 2005
More information about the Mono-list