This is the mail archive of the gdb@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

find_and_open_source bug?


If find_and_open_source opens the file via rewrite_source_path,
should xfullname get called?
Grep for XXX below.

Seems so, otherwise the caller can't really assume what's
stored in *fullname is a "fullpath" (as defined by xfullpath).
[Maybe rewritten source paths shouldn't get passed through xfullpath
but then why does the rest of the function do that?]

[I'm trying to understand what invariants callers of find_and_open_source
can expect.]

int
find_and_open_source (const char *filename,
		      const char *dirname,
		      char **fullname)
{
  char *path = source_path;
  const char *p;
  int result;

  /* Quick way out if we already know its full name.  */

  if (*fullname)
    {
      /* The user may have requested that source paths be rewritten
         according to substitution rules he provided.  If a substitution
         rule applies to this path, then apply it.  */
      char *rewritten_fullname = rewrite_source_path (*fullname);

      if (rewritten_fullname != NULL)
        {
          xfree (*fullname);
          *fullname = rewritten_fullname;
        }

      result = open (*fullname, OPEN_MODE);
      if (result >= 0)
        XXX shouldn't we pass *fullname through xfullpath here?
	return result;
      /* Didn't work -- free old one, try again.  */
      xfree (*fullname);
      *fullname = NULL;
    }
[...]


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]