[v2,1/3] abg-dwarf-reader: create new corpus unconditionally

Message ID 20210527085305.1400592-2-gprocida@google.com
State Under Review
Headers
Series always create fresh corpus objects |

Commit Message

Giuliano Procida May 27, 2021, 8:53 a.m. UTC
  The DWARF reader appears to create a new corpus object only if one is
not already present. However, the only case where there can be
multiple corpora is when build_corpus_group_from_kernel_dist_under is
called and this function clears down the reader context, including the
current corpus, between reading ELF objects.

So it's clearer to just create a fresh corpus object unconditionally
in the DWARF reader.

	* src/abg-dwarf-reader.cc (read_debug_info_into_corpus):
	Create new corpus object unconditionally.

Signed-off-by: Giuliano Procida <gprocida@google.com>
---
 src/abg-dwarf-reader.cc | 9 +--------
 1 file changed, 1 insertion(+), 8 deletions(-)
  

Comments

Giuliano Procida June 1, 2021, 7:38 a.m. UTC | #1
I forgot to add: this addresses bug 27769.

On Thu, 27 May 2021, 09:53 Giuliano Procida, <gprocida@google.com> wrote:

> The DWARF reader appears to create a new corpus object only if one is
> not already present. However, the only case where there can be
> multiple corpora is when build_corpus_group_from_kernel_dist_under is
> called and this function clears down the reader context, including the
> current corpus, between reading ELF objects.
>
> So it's clearer to just create a fresh corpus object unconditionally
> in the DWARF reader.
>
>         * src/abg-dwarf-reader.cc (read_debug_info_into_corpus):
>         Create new corpus object unconditionally.
>
> Signed-off-by: Giuliano Procida <gprocida@google.com>
> ---
>  src/abg-dwarf-reader.cc | 9 +--------
>  1 file changed, 1 insertion(+), 8 deletions(-)
>
> diff --git a/src/abg-dwarf-reader.cc b/src/abg-dwarf-reader.cc
> index a06ca88f..135d33c3 100644
> --- a/src/abg-dwarf-reader.cc
> +++ b/src/abg-dwarf-reader.cc
> @@ -14243,14 +14243,7 @@ static corpus_sptr
>  read_debug_info_into_corpus(read_context& ctxt)
>  {
>    ctxt.clear_per_corpus_data();
> -
> -  if (!ctxt.current_corpus())
> -    {
> -      corpus_sptr corp (new corpus(ctxt.env(), ctxt.elf_path()));
> -      ctxt.current_corpus(corp);
> -      if (!ctxt.env())
> -       ctxt.env(corp->get_environment());
> -    }
> +  ctxt.current_corpus(std::make_shared<corpus>(ctxt.env(),
> ctxt.elf_path()));
>
>    // First set some mundane properties of the corpus gathered from
>    // ELF.
> --
> 2.31.1.818.g46aad6cb9e-goog
>
>
  
Dodji Seketeli June 10, 2021, 3:58 p.m. UTC | #2
Giuliano Procida <gprocida@google.com> a écrit:

> The DWARF reader appears to create a new corpus object only if one is
> not already present. However, the only case where there can be
> multiple corpora is when build_corpus_group_from_kernel_dist_under is
> called and this function clears down the reader context, including the
> current corpus, between reading ELF objects.
>
> So it's clearer to just create a fresh corpus object unconditionally
> in the DWARF reader.
>
> 	* src/abg-dwarf-reader.cc (read_debug_info_into_corpus):
> 	Create new corpus object unconditionally.
>
> Signed-off-by: Giuliano Procida <gprocida@google.com>

Applied to master, thanks!

[...]

Cheers,
  
Dodji Seketeli June 10, 2021, 4:52 p.m. UTC | #3
Giuliano Procida <gprocida@google.com> a écrit:

> The DWARF reader appears to create a new corpus object only if one is
> not already present. However, the only case where there can be
> multiple corpora is when build_corpus_group_from_kernel_dist_under is
> called and this function clears down the reader context, including the
> current corpus, between reading ELF objects.
>
> So it's clearer to just create a fresh corpus object unconditionally
> in the DWARF reader.
>
> 	* src/abg-dwarf-reader.cc (read_debug_info_into_corpus):
> 	Create new corpus object unconditionally.
>
> Signed-off-by: Giuliano Procida <gprocida@google.com>

Applied to master.

Thanks!

[...]

Cheers,
  

Patch

diff --git a/src/abg-dwarf-reader.cc b/src/abg-dwarf-reader.cc
index a06ca88f..135d33c3 100644
--- a/src/abg-dwarf-reader.cc
+++ b/src/abg-dwarf-reader.cc
@@ -14243,14 +14243,7 @@  static corpus_sptr
 read_debug_info_into_corpus(read_context& ctxt)
 {
   ctxt.clear_per_corpus_data();
-
-  if (!ctxt.current_corpus())
-    {
-      corpus_sptr corp (new corpus(ctxt.env(), ctxt.elf_path()));
-      ctxt.current_corpus(corp);
-      if (!ctxt.env())
-	ctxt.env(corp->get_environment());
-    }
+  ctxt.current_corpus(std::make_shared<corpus>(ctxt.env(), ctxt.elf_path()));
 
   // First set some mundane properties of the corpus gathered from
   // ELF.