[Mono-list] Re: Method signature modification
Shankari
shankari82 at yahoo.com
Mon Oct 17 15:50:11 EDT 2005
Hi Robert,
Thanks for your time. I am restating the problem
below.
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
[DllImport(...)]
static extern void func (param1, param2);
Under normal cases, I would call func(param1,param2)
from C#.
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
[DllImport(...)]
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.
Thanks,
--- 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.
>
> <pedantic>
> Unmanaged code can be anything (including Perl
> code), and can be an
> unmanaged *function*. A function call would invoke
> the function.
> </pedantic>
>
> > To figure out where exactly the switch from
> managed to
> > unmanaged code is happening, I set a breakpoint in
> my
> > C program and tried a backtrace from it. Here is
> the
> > 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
> about).
>
> Consequently, you need the managed callstack, which
> you can get using
> mono_print_method_from_ip, which takes a stack
> pointer as an argument,
> e.g.:
>
> (gdb) p mono_print_method_from_ip (0x0045b6ac)
>
> > I am not able to single step through the code from
> the
> > 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
> looks
> > 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
http://mail.yahoo.com
More information about the Mono-list
mailing list