From: Hui Li <lihui@loongson.cn>
To: gdb-patches@sourceware.org
Cc: Tiezhu Yang <yangtiezhu@loongson.cn>
Subject: [PATCH] gdb: LoongArch: Optimize fetch register process
Date: Thu, 6 Jul 2023 11:44:06 +0800 [thread overview]
Message-ID: <20230706034406.17525-1-lihui@loongson.cn> (raw)
For the current code, when a register is fetched, the entire regset
are fetched via ptrace, but only this register status is updated in
regcache. If another register in this regset to be fetched at this
point, it need to fetch the same regset through ptrace again. This
is obviously unnecessary.
This change is to update the status of entire regset in regcache after
fetching a register via ptrace. Since the status of the entire regset
in regcache is up to date, If another register in this regset to be
fetched at this point. It will be fetched directly from the regcache,
there is no need to fetch the same regset again via ptrace.
This is just an optimization patch for LoongArch. the following are
test results on LoongArch.
before this patch:
make check-gdb -j4
=== gdb Summary ===
# of expected passes 83662
# of unexpected failures 1530
after this patch:
make check-gdb -j4
=== gdb Summary ===
# of expected passes 83662
# of unexpected failures 1528
Signed-off-by: Hui Li <lihui@loongson.cn>
---
gdb/loongarch-linux-nat.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/gdb/loongarch-linux-nat.c b/gdb/loongarch-linux-nat.c
index 5eb32b0a52a..40231d5d753 100644
--- a/gdb/loongarch-linux-nat.c
+++ b/gdb/loongarch-linux-nat.c
@@ -65,7 +65,7 @@ fetch_gregs_from_thread (struct regcache *regcache, int regnum, pid_t tid)
if (ptrace (PTRACE_GETREGSET, tid, NT_PRSTATUS, (long) &iov) < 0)
perror_with_name (_("Couldn't get NT_PRSTATUS registers"));
else
- loongarch_gregset.supply_regset (nullptr, regcache, regnum,
+ loongarch_gregset.supply_regset (nullptr, regcache, -1,
®set, sizeof (regset));
}
}
@@ -116,7 +116,7 @@ fetch_fpregs_from_thread (struct regcache *regcache, int regnum, pid_t tid)
if (ptrace (PTRACE_GETREGSET, tid, NT_FPREGSET, (long) &iovec) < 0)
perror_with_name (_("Couldn't get NT_FPREGSET registers"));
else
- loongarch_fpregset.supply_regset (nullptr, regcache, regnum,
+ loongarch_fpregset.supply_regset (nullptr, regcache, -1,
®set, sizeof (regset));
}
}
--
2.38.1
next reply other threads:[~2023-07-06 3:44 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-07-06 3:44 Hui Li [this message]
2023-07-06 15:36 ` Tom Tromey
2023-07-19 14:19 ` Tiezhu Yang
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=20230706034406.17525-1-lihui@loongson.cn \
--to=lihui@loongson.cn \
--cc=gdb-patches@sourceware.org \
--cc=yangtiezhu@loongson.cn \
/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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).