From: Arnaldo Carvalho de Melo <acme@kernel.org>
To: Daniel Xu <dxu@dxuuu.xyz>
Cc: jolsa@kernel.org, quentin@isovalent.com, alan.maguire@oracle.com,
eddyz87@gmail.com, andrii.nakryiko@gmail.com, ast@kernel.org,
daniel@iogearbox.net, bpf@vger.kernel.org
Subject: Re: [PATCH dwarves v9 1/3] pahole: Save input filename separate from output
Date: Tue, 30 Apr 2024 15:41:01 -0300 [thread overview]
Message-ID: <ZjE7PUSvpHRJGNgK@x1> (raw)
In-Reply-To: <1728b8d941d2658b310457b6c59d97f102aaf66d.1714430735.git.dxu@dxuuu.xyz>
On Mon, Apr 29, 2024 at 04:45:58PM -0600, Daniel Xu wrote:
> During detached BTF encoding, the input file is not necessarily the same
> as the output file. So save them separately. This matters when we need
> to look at the input file again, such as for kfunc tagging.
You forgot to check a strdup(), I added this on top of this patch:
diff --git a/btf_encoder.c b/btf_encoder.c
index 5ffaf5d969c9bc49..8aa2a7709dc1555f 100644
--- a/btf_encoder.c
+++ b/btf_encoder.c
@@ -1651,7 +1651,7 @@ struct btf_encoder *btf_encoder__new(struct cu *cu, const char *detached_filenam
encoder->raw_output = detached_filename != NULL;
encoder->source_filename = strdup(cu->filename);
encoder->filename = strdup(encoder->raw_output ? detached_filename : cu->filename);
- if (encoder->filename == NULL)
+ if (encoder->source_filename == NULL || encoder->filename == NULL)
goto out_delete;
encoder->btf = btf__new_empty_split(base_btf);
> Signed-off-by: Daniel Xu <dxu@dxuuu.xyz>
> ---
> btf_encoder.c | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/btf_encoder.c b/btf_encoder.c
> index 19e9d90..5ffaf5d 100644
> --- a/btf_encoder.c
> +++ b/btf_encoder.c
> @@ -64,6 +64,7 @@ struct btf_encoder {
> struct btf *btf;
> struct cu *cu;
> struct gobuffer percpu_secinfo;
> + const char *source_filename;
> const char *filename;
> struct elf_symtab *symtab;
> uint32_t type_id_off;
> @@ -1648,6 +1649,7 @@ struct btf_encoder *btf_encoder__new(struct cu *cu, const char *detached_filenam
>
> if (encoder) {
> encoder->raw_output = detached_filename != NULL;
> + encoder->source_filename = strdup(cu->filename);
> encoder->filename = strdup(encoder->raw_output ? detached_filename : cu->filename);
> if (encoder->filename == NULL)
> goto out_delete;
> @@ -1730,6 +1732,7 @@ void btf_encoder__delete(struct btf_encoder *encoder)
> btf_encoders__delete(encoder);
> __gobuffer__delete(&encoder->percpu_secinfo);
> zfree(&encoder->filename);
> + zfree(&encoder->source_filename);
> btf__free(encoder->btf);
> encoder->btf = NULL;
> elf_symtab__delete(encoder->symtab);
> --
> 2.44.0
next prev parent reply other threads:[~2024-04-30 18:41 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-04-29 22:45 [PATCH dwarves v9 0/3] pahole: Inject kfunc decl tags into BTF Daniel Xu
2024-04-29 22:45 ` [PATCH dwarves v9 1/3] pahole: Save input filename separate from output Daniel Xu
2024-04-30 18:41 ` Arnaldo Carvalho de Melo [this message]
2024-04-29 22:45 ` [PATCH dwarves v9 2/3] pahole: Add --btf_feature=decl_tag_kfuncs feature Daniel Xu
2024-04-30 18:48 ` Arnaldo Carvalho de Melo
2024-04-30 23:00 ` Daniel Xu
2024-05-02 11:49 ` Alan Maguire
2024-05-02 13:35 ` Arnaldo Carvalho de Melo
2024-05-02 13:43 ` Alan Maguire
2024-04-29 22:46 ` [PATCH dwarves v9 3/3] pahole: Inject kfunc decl tags into BTF Daniel Xu
2024-04-30 19:57 ` Arnaldo Carvalho de Melo
2024-04-30 23:29 ` Daniel Xu
2024-04-30 20:42 ` Arnaldo Carvalho de Melo
2024-04-30 23:27 ` Daniel Xu
2024-05-06 20:07 ` Arnaldo Carvalho de Melo
2024-05-07 2:18 ` Daniel Xu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=ZjE7PUSvpHRJGNgK@x1 \
--to=acme@kernel.org \
--cc=alan.maguire@oracle.com \
--cc=andrii.nakryiko@gmail.com \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=dxu@dxuuu.xyz \
--cc=eddyz87@gmail.com \
--cc=jolsa@kernel.org \
--cc=quentin@isovalent.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox