public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [patch]change dwarf2_start_subfile() to adapt inappropriate dir name
@ 2010-11-15  1:21 JuYoung Kim
  2010-11-15  4:09 ` Eli Zaretskii
  0 siblings, 1 reply; 4+ messages in thread
From: JuYoung Kim @ 2010-11-15  1:21 UTC (permalink / raw)
  To: gdb-patches; +Cc: 김주영


Hello, My name is Kim, Juyoung at TmaxCore co. in south korea.
I've sent this email last week but haven't receive any reply or inform.
Today I found the email was encoded in korean and maybe you could not read it.
So, I send this mail again, and I hope you reply me as possible as you can, please.

It is about subfile for DWARF.
When you see the function dwarf2_start_subfile() in the source, there is a comment about source's file name.
Some compiler ( like RCVT3.1 ) include '/' at the end of dir name.

For example,
in case, DW_AT_name: /srcdir/list0.c
you expect
     files.files[0].name: list0.h
     files.files[0].dir: /srcdir
but, the DWARF made by RVCT3.1 is like this.
    files.files[0].name: list0.h
    files.files[0].dir: /srcdir/

then the function dwarf2_start_subfile(); make the fullname "/srcdir//list0.c"
, which result in the gdb cannot find the source's debugging information.

The function dwarf2_start_subfile() is at gdb/dwarf2read.c:8650.

The original source code is

.........
  if (!IS_ABSOLUTE_PATH (filename) && dirname != NULL) {
    fullname = concat (dirname, SLASH_STRING, filename, (char *)NULL);
  }
  else
    fullname = filename;
........

I changed it as below.

........
  if (!IS_ABSOLUTE_PATH (filename) && dirname != NULL) {
     if (dirname[strlen(dirname)-1] == '/' || dirname[strlen(dirname)-1] == '')
        fullname = concat (dirname, filename, (char *)NULL);
     else fullname = concat (dirname, SLASH_STRING, filename, (char *)NULL);
  }
  else
     fullname = filename;
..........

This is my first time to report the patch.
So please, inform me if my way of reporting is not proper.

Thanks.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [patch]change dwarf2_start_subfile() to adapt inappropriate dir name
  2010-11-15  1:21 [patch]change dwarf2_start_subfile() to adapt inappropriate dir name JuYoung Kim
@ 2010-11-15  4:09 ` Eli Zaretskii
  0 siblings, 0 replies; 4+ messages in thread
From: Eli Zaretskii @ 2010-11-15  4:09 UTC (permalink / raw)
  To: j0.kim; +Cc: gdb-patches

> Date: Mon, 15 Nov 2010 01:21:14 +0000 (GMT)
> From: JuYoung Kim <j0.kim@samsung.com>
> Cc: 김주영 <j0.kim@samsung.com>
> 
>   if (!IS_ABSOLUTE_PATH (filename) && dirname != NULL) {
>      if (dirname[strlen(dirname)-1] == '/' || dirname[strlen(dirname)-1] == '')

Please use IS_DIR_SEPARATOR instead of testing for '/' literally.  And
the second part of the if clause cannot happen at all, so it should be
removed.

Also, the GNU coding standards say to put the braces like this:

   if (something)
    {
      do_something;
      do_something_else;
    }

>      else fullname = concat (dirname, SLASH_STRING, filename, (char *)NULL);

Make "else" have its own line, like this:

   else
     fullname = concat (dirname, SLASH_STRING, filename, NULL);

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [patch]change dwarf2_start_subfile() to adapt inappropriate dir name
  2010-11-15 18:05   ` Nathan Froyd
  2010-11-15 18:34     ` Eli Zaretskii
@ 2010-11-23 20:47     ` Tom Tromey
  1 sibling, 0 replies; 4+ messages in thread
From: Tom Tromey @ 2010-11-23 20:47 UTC (permalink / raw)
  To: Nathan Froyd; +Cc: Joel Brobecker, JuYoung Kim, Eli Zaretskii, gdb-patches

>>>>> "Nathan" == Nathan Froyd <froydnj@codesourcery.com> writes:

Nathan> FWIW, we encountered this problem as well.  This is the patch we used to
Nathan> fix it.  It's very similar to the proposed patch, but slightly more
Nathan> complete.

Thanks.

Nathan> +      if (dirname[dir_len-1] == SLASH_STRING[0])

Noting Eli's note...

Nathan> +	memmove (concat_name+dir_len-1, concat_name+dir_len,

Spaces around the operators.

Nathan> +		 /* SLASH_STRING and trailing NULL */
Nathan> +		 strlen (filename) + 1 + 1);

I think it is mildly better to use strlen (SLASH_STRING) rather than 1.
Or just call concat two different ways instead of memmove.

This is ok with these nits fixed.

Tom

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [patch]change dwarf2_start_subfile() to adapt inappropriate dir name
  2010-11-15 18:05   ` Nathan Froyd
@ 2010-11-15 18:34     ` Eli Zaretskii
  2010-11-23 20:47     ` Tom Tromey
  1 sibling, 0 replies; 4+ messages in thread
From: Eli Zaretskii @ 2010-11-15 18:34 UTC (permalink / raw)
  To: Nathan Froyd; +Cc: brobecker, j0.kim, gdb-patches

> Date: Mon, 15 Nov 2010 10:05:14 -0800
> From: Nathan Froyd <froydnj@codesourcery.com>
> Cc: JuYoung Kim <j0.kim@samsung.com>, Eli Zaretskii <eliz@gnu.org>,
> 	"gdb-patches@sourceware.org" <gdb-patches@sourceware.org>
> 
> +      if (dirname[dir_len-1] == SLASH_STRING[0])

Sorry, but comparing with SLASH_STRING[0] is as bad as comparing with
a literal '/' or '\\'.  The issue here is that DOS/Windows filesystems
can use both / and \, and even mix them freely in the same file name.
IS_DIR_SEPARATOR takes this into account, while comparing against a
single character will miss the other alternative.

SLASH_STRING is for _constructing_ file names (with `concat' or
equivalent code), not for taking file names apart or examining them.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2010-11-23 20:47 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-11-15  1:21 [patch]change dwarf2_start_subfile() to adapt inappropriate dir name JuYoung Kim
2010-11-15  4:09 ` Eli Zaretskii
2010-11-15  6:25 JuYoung Kim
2010-11-15 16:58 ` Joel Brobecker
2010-11-15 18:05   ` Nathan Froyd
2010-11-15 18:34     ` Eli Zaretskii
2010-11-23 20:47     ` Tom Tromey

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).