public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] Search .dwo in the binary directory.
@ 2020-02-13  6:19 Ali Tamur via gdb-patches
  2020-02-18  2:33 ` Luis Machado
  2020-03-13 13:43 ` Tom Tromey
  0 siblings, 2 replies; 3+ messages in thread
From: Ali Tamur via gdb-patches @ 2020-02-13  6:19 UTC (permalink / raw)
  To: gdb-patches; +Cc: Nitika.Achra, JiniSusan.George, Ali Tamur

.dwo files generated by the compiler usually resides in the same directory as
the generated binary itself. Add that binary to the list of directories to
search when searching for the .dwo file.

gdb/ChangeLog:

	* dwarf2/read.c (try_open_dwop_file): Include binary directory to
	the list of directories to search.  Search the path also when looking
	for a .dwo file.
---
 gdb/dwarf2/read.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c
index 7edbd9d7df..39f583e758 100644
--- a/gdb/dwarf2/read.c
+++ b/gdb/dwarf2/read.c
@@ -12012,9 +12012,14 @@ try_open_dwop_file (struct dwarf2_per_objfile *dwarf2_per_objfile,
   else
     search_path = debug_file_directory;
 
+  /* Add the directory of the binary to the search list.  */
+  search_path_holder.reset(
+     concat (ldirname (dwarf2_per_objfile->objfile->original_name).c_str (),
+             dirname_separator_string, search_path, (char *) NULL));
+  search_path = search_path_holder.get ();
+
   openp_flags flags = OPF_RETURN_REALPATH;
-  if (is_dwp)
-    flags |= OPF_SEARCH_IN_PATH;
+  flags |= OPF_SEARCH_IN_PATH;
 
   gdb::unique_xmalloc_ptr<char> absolute_name;
   desc = openp (search_path, flags, file_name,
-- 
2.25.0.265.gbab2e86ba0-goog

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

* Re: [PATCH] Search .dwo in the binary directory.
  2020-02-13  6:19 [PATCH] Search .dwo in the binary directory Ali Tamur via gdb-patches
@ 2020-02-18  2:33 ` Luis Machado
  2020-03-13 13:43 ` Tom Tromey
  1 sibling, 0 replies; 3+ messages in thread
From: Luis Machado @ 2020-02-18  2:33 UTC (permalink / raw)
  To: Ali Tamur, gdb-patches; +Cc: Nitika.Achra, JiniSusan.George

Hi,

On 2/13/20 3:19 AM, Ali Tamur via gdb-patches wrote:
> .dwo files generated by the compiler usually resides in the same directory as
> the generated binary itself. Add that binary to the list of directories to
> search when searching for the .dwo file.

Thanks. This seems to be aligned with what find_separate_debug_file does:

   /* First try in the same directory as the original file.  */
   std::string debugfile = dir;
   debugfile += debuglink;

I guess you meant "Add that binary's path to the list ...".

> 
> gdb/ChangeLog:
> 
> 	* dwarf2/read.c (try_open_dwop_file): Include binary directory to
> 	the list of directories to search.  Search the path also when looking
> 	for a .dwo file.
> ---
>   gdb/dwarf2/read.c | 9 +++++++--
>   1 file changed, 7 insertions(+), 2 deletions(-)
> 
> diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c
> index 7edbd9d7df..39f583e758 100644
> --- a/gdb/dwarf2/read.c
> +++ b/gdb/dwarf2/read.c
> @@ -12012,9 +12012,14 @@ try_open_dwop_file (struct dwarf2_per_objfile *dwarf2_per_objfile,
>     else
>       search_path = debug_file_directory;
>   
> +  /* Add the directory of the binary to the search list.  */
> +  search_path_holder.reset(
> +     concat (ldirname (dwarf2_per_objfile->objfile->original_name).c_str (),
> +             dirname_separator_string, search_path, (char *) NULL));
> +  search_path = search_path_holder.get ();
> +
>     openp_flags flags = OPF_RETURN_REALPATH;
> -  if (is_dwp)
> -    flags |= OPF_SEARCH_IN_PATH;
> +  flags |= OPF_SEARCH_IN_PATH;

This was the only use of is_dwp. Now the parameter is unused in 
try_open_dwop_file and this and other functions should be updated. Do 
you know what is_dwp is originally for? Other than telling the function 
we're interested in reading a dwp file?

I see it was added back in 2012 by commit 
80626a55b99a0cb91546f334fc683f7a9f351101.

>   
>     gdb::unique_xmalloc_ptr<char> absolute_name;
>     desc = openp (search_path, flags, file_name,
> 

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

* Re: [PATCH] Search .dwo in the binary directory.
  2020-02-13  6:19 [PATCH] Search .dwo in the binary directory Ali Tamur via gdb-patches
  2020-02-18  2:33 ` Luis Machado
@ 2020-03-13 13:43 ` Tom Tromey
  1 sibling, 0 replies; 3+ messages in thread
From: Tom Tromey @ 2020-03-13 13:43 UTC (permalink / raw)
  To: Ali Tamur via gdb-patches; +Cc: Ali Tamur, Nitika.Achra, JiniSusan.George

>>>>> "Ali" == Ali Tamur via gdb-patches <gdb-patches@sourceware.org> writes:

Ali> .dwo files generated by the compiler usually resides in the same directory as
Ali> the generated binary itself. Add that binary to the list of directories to
Ali> search when searching for the .dwo file.

Thanks for the patch.
I didn't see a review of this, apologies if it's a duplicate.

Ali> +  /* Add the directory of the binary to the search list.  */
Ali> +  search_path_holder.reset(
Ali> +     concat (ldirname (dwarf2_per_objfile->objfile->original_name).c_str (),
Ali> +             dirname_separator_string, search_path, (char *) NULL));

If search_path_holder was already set, then I think this will leak the
old value.

Maybe changing search_path_holder to std::string would be better, since
it would make it simpler to avoid leaks.

Ali> +  search_path = search_path_holder.get ();
Ali> +
Ali>    openp_flags flags = OPF_RETURN_REALPATH;
Ali> -  if (is_dwp)
Ali> -    flags |= OPF_SEARCH_IN_PATH;
Ali> +  flags |= OPF_SEARCH_IN_PATH;
 
This line can be merged into the declaration of flags.

How did you test this patch?

Tom

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

end of thread, other threads:[~2020-03-13 13:43 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-02-13  6:19 [PATCH] Search .dwo in the binary directory Ali Tamur via gdb-patches
2020-02-18  2:33 ` Luis Machado
2020-03-13 13:43 ` 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).