Hi Aaron,

On Sun, Jan 19, 2025 at 10:20:32PM -0500, Aaron Merey wrote:
>       * libdw/dwarf_getsrclines.c (read_srcfiles): Initialize dbg
>       member.
>       * libdw/libdwP.h (struct Dwarf_Files_s): Add Dwarf member.
>       (struct Dwarf_Lines_s): Ditto.

Right, this is what you use in earlier patches to get back at the
Dwarf (dwarf_lock).

A Dwarf_Line_s already has a pointer to a Dwarf_Files, so might it be
able to use that instead of adding a Dwarf dbg to both?

> Signed-off-by: Aaron Merey <ame...@redhat.com>
> ---
>  libdw/dwarf_getsrclines.c | 4 ++++
>  libdw/libdwP.h            | 2 ++
>  2 files changed, 6 insertions(+)
> 
> diff --git a/libdw/dwarf_getsrclines.c b/libdw/dwarf_getsrclines.c
> index fb2c431b..6ae5abc7 100644
> --- a/libdw/dwarf_getsrclines.c
> +++ b/libdw/dwarf_getsrclines.c
> @@ -717,6 +717,7 @@ read_srcfiles (Dwarf *dbg,
>    if (unlikely (files == NULL))
>      goto no_mem;
>  
> +  files->dbg = dbg;
>    const char **dirs = (void *) &files->info[nfilelist];
>  
>    struct filelist *fileslist = filelist;
> @@ -1197,6 +1198,8 @@ read_srclines (Dwarf *dbg,
>                         + nnewfiles * sizeof (Dwarf_Fileinfo)
>                         + (ndirs + 1) * sizeof (char *),
>                         1);
> +      newfiles->dbg = dbg;
> +
>        /* Copy prevfiles to newfiles.  */
>        for (size_t n = 0; n < nprevfiles; n++)
>       newfiles->info[n] = prevfiles->info[n];
> @@ -1254,6 +1257,7 @@ read_srclines (Dwarf *dbg,
>       The buffers overlap, so we've clobbered the early elements
>       of SORTLINES by the time we're reading the later ones.  */
>    Dwarf_Lines *lines = buf;
> +  lines->dbg = dbg;
>    lines->nlines = state.nlinelist;
>    for (size_t i = 0; i < state.nlinelist; ++i)
>      {
> diff --git a/libdw/libdwP.h b/libdw/libdwP.h
> index db5abeec..7655e3ec 100644
> --- a/libdw/libdwP.h
> +++ b/libdw/libdwP.h
> @@ -304,6 +304,7 @@ struct Dwarf_Abbrev
>  /* Files in line information records.  */
>  struct Dwarf_Files_s
>    {
> +    Dwarf *dbg;
>      unsigned int ndirs;
>      unsigned int nfiles;
>      struct Dwarf_Fileinfo_s
> @@ -345,6 +346,7 @@ struct Dwarf_Line_s
>  
>  struct Dwarf_Lines_s
>  {
> +  Dwarf *dbg;
>    size_t nlines;
>    struct Dwarf_Line_s info[0];
>  };
> -- 
> 2.47.1
> 

Reply via email to