This is the mail archive of the
java@gcc.gnu.org
mailing list for the Java project.
Re: addr2line and the name of the executable
Ranjit Mathew writes:
> > > > Andrew> gnu.gcj.prognamegnu.gcj.progname should probably be argv[0],
> unmangled by anuything.
> > > >
> > > > That would mean that my patch would have _Jv_ThisExecutable()
> potentially
> > > > return something different than gnu.gcj.progname.
> > >
> > >Yes. Definitely. We shouldn't intermix the implementation of
> > >gnu.gcj.progname and argv[0]; they have completely different purposes.
>
> I was a bit confused by this statement from Andrew,
I'm not surprised.
I meant we shouldn't intermix the implementation of gnu.gcj.progname
and _Jv_ThisExecutable(). I'm sorry for the confustion.
> but still, here's what (IMHO) we should do based on my
> understanding of the discussion so far:
>
> a. "gnu.gcj.progname" should be set to whatever is argv[0]. Note that
> apparently on Mac OS Classic, argv[0] can actually be equal to NULL,
> though this might be irrelevant since there is no port of GCJ on Mac
> OS Classic.
>
> b. _Jv_ThisExecutable( ) should return the actual executable file that
> was used to create the current process, if possible.
>
> c. NameFinder should use _Jv_ThisExecutable( ) to construct the argument
> passed to "addr2line -e".
Exactly right.
> For both (a) and (b), we would need to preserve argv[0] for a while.
> (Already defined through the global variable _Jv_argv in prims.cc and
> used, for example, by gnu/gcj/runtime/natNameFinder.cc.)
>
> Note that for gnu.gcj.progname (==argv[0]), it is not *necessarily* the
> command used to invoke the program, merely a (desirable, IMHO) convention,
> especially on UNIX and WinNT/2K/XP - on Win9x for example, it is
> expanded to the full path to the current executable.
Yes. We should, where practical, make gnu.gcj.progname the command
used to invoke the program. For POSIX, that means not doing anything
to the string in argv[0].
> For (b), we could define a _Jv_platform_getThisExecutable( ) (or some
> such function) that:
>
> i. for POSIX, uses whatever we have right now in prims.cc (_Jv_RunMain)
> between (and including) "#ifdef DISABLE_MAIN_ARGS" and its counter
> "#endif".
>
> ii. for Win32, uses the Win32 GetModuleFileName( ) function.
>
> The current code in (i) could then be replaced by something like
> "_Jv_ThisExecutable( _Jv_platform_getThisExecutable( ))".
>
> Comments?
Simpler just to move _Jv_ThisExecutable() into a platform dependent
file, no?
Andrew.