Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Yang Liu <liuyang22@iscas.ac.cn>
To: gdb-patches@sourceware.org
Cc: tom@tromey.com, simon.marchi@polymtl.ca,
	Yang Liu <liuyang22@iscas.ac.cn>
Subject: [PATCH] gdb/jit: fix jit-reader linetable integrity
Date: Sat, 21 Dec 2024 16:30:35 +0800	[thread overview]
Message-ID: <20241221083035.80249-1-liuyang22@iscas.ac.cn> (raw)

The custom linetable functionality in GDB's JIT Interface has been broken
since commit 1acc9dca423f78e44553928f0de839b618c13766.

In that commit, linetables were made independent from the objfile, which
requires objfile->section_offsets to be initialized. However, section_offsets
were never initialized in objfiles generated by GDB's JIT Interface
with custom jit-readers, leading to GDB crashes when stepping into JITed code
blocks with the following command already executed:

  jit-reader-load libmygdbjitreader.so

This patch fixes the issue by initializing the minimum section_offsets required
for linetable parsing procedures.
---
 gdb/jit.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/gdb/jit.c b/gdb/jit.c
index 77d41bf86ba..7027c84b5bf 100644
--- a/gdb/jit.c
+++ b/gdb/jit.c
@@ -665,6 +665,8 @@ jit_object_close_impl (struct gdb_symbol_callbacks *cb,
 
   objfile *objfile = objfile::make (nullptr, current_program_space,
 				    objfile_name.c_str (), OBJF_NOT_FILENAME);
+  objfile->section_offsets.assign (1, 0);
+  objfile->sect_index_text = 0;
   objfile->per_bfd->gdbarch = priv_data->gdbarch;
 
   for (gdb_symtab &symtab : obj->symtabs)
-- 
2.42.0


             reply	other threads:[~2024-12-21  8:31 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-12-21  8:30 Yang Liu [this message]
2024-12-22  2:12 ` Simon Marchi
2024-12-22 11:46 liuyang22
2024-12-22 14:22 ` Simon Marchi
2024-12-22 16:38   ` Yang Liu
2024-12-22 16:31 Yang Liu
2024-12-22 16:34 ` Yang Liu

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=20241221083035.80249-1-liuyang22@iscas.ac.cn \
    --to=liuyang22@iscas.ac.cn \
    --cc=gdb-patches@sourceware.org \
    --cc=simon.marchi@polymtl.ca \
    --cc=tom@tromey.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