public inbox for gdb-prs@sourceware.org
help / color / mirror / Atom feed
From: "konsolebox at gmail dot com" <sourceware-bugzilla@sourceware.org>
To: gdb-prs@sourceware.org
Subject: [Bug server/13984] gdb stops controlling a thread after "Remote 'g' packet reply is too long: ..." error message
Date: Tue, 12 Sep 2023 14:49:02 +0000	[thread overview]
Message-ID: <bug-13984-4717-zaN9qImD4J@http.sourceware.org/bugzilla/> (raw)
In-Reply-To: <bug-13984-4717@http.sourceware.org/bugzilla/>

https://sourceware.org/bugzilla/show_bug.cgi?id=13984

konsolebox <konsolebox at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |konsolebox at gmail dot com

--- Comment #16 from konsolebox <konsolebox at gmail dot com> ---
(In reply to Mehmet Ali SARIKAYA from comment #3)
> Comment on attachment 8506 [details]
> gdb/remote.c change set
> 
> 6064 /* Further sanity checks, with knowledge of the architecture. 
> 6065 //SunnyBeike
> 6066 
> 6067 // if (buf_len  > 2 * rsa->sizeof_g_packet) 
> 6068 // error (_("Remote 'g' packet reply is too long: %s"), rs->buf); 
> 6069 
> 6070    if(buf_len > 2 * rsa->sizeof_g_packet) {
> 6071         rsa->sizeof_g_packet = buf_len;
> 6072         for(i = 0; i < gdbarch_num_regs(gdbarch); i++){
> 6073             if(rsa->regs->pnum == -1)
> 6074                continue;
> 6075             if(rsa->regs->offset >= rsa->sizeof_g_packet)
> 6076                rsa->regs->in_g_packet = 0;
> 6077             else
> 6078                rsa->regs->in_g_packet = 1;
> 6079         } 
> 6080    }
> 6081

Hello Mehmet,

Thank you for sharing your patch.  It worked for me, at least by concept, but
did you miss adding index references to each rsa->regs element in the loop?

I modified it to make it work with 13.2 and also so that each loop refers to a
different rsa->regs element.  Kindly refer to it to see what I mean.

I also made it a bit simpler:

diff --git a/gdb/remote.c b/gdb/remote.c
index 218bca3..f715dec 100644
--- a/gdb/remote.c
+++ b/gdb/remote.c
@@ -8482,10 +8482,17 @@ remote_target::process_g_packet (struct regcache
*regcache)

   /* Further sanity checks, with knowledge of the architecture.  */
   if (buf_len > 2 * rsa->sizeof_g_packet)
-    error (_("Remote 'g' packet reply is too long (expected %ld bytes, got %d
"
-            "bytes): %s"),
-          rsa->sizeof_g_packet, buf_len / 2,
-          rs->buf.data ());
+    {
+      rsa->sizeof_g_packet = buf_len;
+
+      for (i = 0; i < gdbarch_num_regs (gdbarch); i++)
+       {
+         struct packet_reg *r = &rsa->regs[i];
+
+         if (r->pnum != -1)
+           r->in_g_packet = (r->offset >= rsa->sizeof_g_packet) ? 0 : 1;
+       }
+    }

   /* Save the size of the packet sent to us by the target.  It is used
      as a heuristic when determining the max size of packets that the

-- 
You are receiving this mail because:
You are on the CC list for the bug.

      parent reply	other threads:[~2023-09-12 14:49 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-04-16  2:34 [Bug server/13984] New: " curty at ieee dot org
2015-08-12 11:47 ` [Bug server/13984] " sarikayameh at gmail dot com
2015-08-12 11:49 ` sarikayameh at gmail dot com
2015-08-12 11:50 ` sarikayameh at gmail dot com
2015-08-12 12:55 ` ciro.santilli at gmail dot com
2015-08-12 12:57 ` ciro.santilli at gmail dot com
2015-08-12 13:07 ` ciro.santilli at gmail dot com
2015-08-12 17:08 ` sarikayameh at gmail dot com
2015-08-12 17:09 ` sarikayameh at gmail dot com
2015-08-12 21:01 ` ciro.santilli at gmail dot com
2015-08-13 10:37 ` sarikayameh at gmail dot com
2015-08-13 10:39 ` ciro.santilli at gmail dot com
2023-09-12 14:49 ` konsolebox at gmail dot com [this message]

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=bug-13984-4717-zaN9qImD4J@http.sourceware.org/bugzilla/ \
    --to=sourceware-bugzilla@sourceware.org \
    --cc=gdb-prs@sourceware.org \
    /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).