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]

Re: setting a breakpoint on a dll, relative path or absolute path issue


On 2011-6-14 0:59, Eli Zaretskii wrote:
Date: Mon, 13 Jun 2011 14:29:28 +0800
>  From: Asm warrior<asmwarrior@gmail.com>
>  CC: "John E. / TDM"<tdragon@tdragon.net>, Eli Zaretskii<eliz@gnu.org>,
>    jan.kratochvil@redhat.com,keiths@redhat.com
>
>  When loop on the symbols. I found that at one loop, I get
>
>  s->filename = "../../src/common/string.cpp"
>  s->dirname  = "D:\code\wxWidgets-2.8.12\build\msw"
>
>  But too badly, the result
>  s->fullname =
>  "D:\code\wxWidgets-2.8.12\build\msw/../../src/common/string.cpp"
>
>  This is the reason about the issue, if the result is:
>  "D:\code\wxWidgets-2.8.12/src/common/string.cpp"
>  Then, this problem can be fixed.
>
>  I'm not sure why gdb does not give a cannical filename, but still leaves
>  the "../../" in the result.
Because the function that canonicalizes the file name does not support
backslashes correctly?


By reading the gdb source, mostly in file: source.c and symtab.c


I found that in the function:

char *
symtab_to_fullname (struct symtab *s)
{
  int r;

  if (!s)
    return NULL;

  /* Don't check s->fullname here, the file could have been
     deleted/moved/..., look for it again.  */
  r = find_and_open_source (s->filename, s->dirname, &s->fullname);

  if (r >= 0)
    {
      close (r);
      return s->fullname;
    }

  return NULL;
}

This function try to check if the file exists.

The lucky thing is: The function call:

open("D:\code\wxWidgets-2.8.12\build\msw/../../src/common/string.cpp") ;

works OK.

Though the file path is not satisfied by me, but it just satisfied by open() function, Yeah, the open() function can internally do a path canonization on its parameter, and gdb knows that this file exists and can be opened.

As I know, GDB does not do a canonization on any returned file names. (I can't find any code snippet doing this kind of work).

Well, the proposed method can be: (see below)
char *
symtab_to_fullname (struct symtab *s)
{
  int r;

  if (!s)
    return NULL;

  /* Don't check s->fullname here, the file could have been
     deleted/moved/..., look for it again.  */
  r = find_and_open_source (s->filename, s->dirname, &s->fullname);

  if (r >= 0)
    {
      close (r);
      *******
      DoSomePathCanonization(&s->fullname);
      *******
      return s->fullname;
    }

  return NULL;
}

This way, the returned string can be:
"D:/code/wxWidgets-2.8.12/src/common/string.cpp"

BTW:Did you thing that Any one would like to set a breakpoint by using name containing many "../../"?

I can hardly think one would like to set a break point by entering this command:

b "D:\code\wxWidgets-2.8.12\build\msw/../../src/common/string.cpp:165"

I personally think this is too ugly.

Any ideas?

Asmwarrior
ollydbg from codeblocks' forum







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