addr2line and the name of the executable

Ranjit Mathew rmathew4lists@hotmail.com
Wed Feb 26 05:04:00 GMT 2003


> > > 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, 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".

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.

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?


> case of Win32. Semantically, argv[0] and the full path to the executable
> are the same in the case of Win32, and given that gnu.gcj.progname is

Only in the case of Win9x and not on WinNT/2K/XP:

    http://article.gmane.org/gmane.comp.gnu.mingw.user/6198

Ranjit.



More information about the Java mailing list