From: Daniel Jacobowitz <drow@mvista.com>
To: gdb@sources.redhat.com
Subject: Re: G packet format ...
Date: Thu, 01 Nov 2001 10:18:00 -0000 [thread overview]
Message-ID: <20011112004001.A11764@nevyn.them.org> (raw)
In-Reply-To: <3BEF5CF4.4010201@cygnus.com>
On Mon, Nov 12, 2001 at 12:24:04AM -0500, Andrew Cagney wrote:
> Hello,
>
> For those that don't know, GDB's remote protocol G packet currently
> determins the layout of GDB's internal register cache. Doh!
Indeed.
> NB: Why do this?
>
> The objective is to decouple the remote protocol's G packet from the
> rest of GDB. That way, GDB has greater flexability in how it implements
> its regcache. For instance, with the MIPS, it will be possible to have
> a single internal register layout while still being able to connect to
> all the remote MIPS targets.
I guess I posted my gdbserver register cache patch before I converted
it to generate them from a shell script. Here's what I've been using.
I didn't consider the issue of only-transferable-in-P-packet registers
(and I still don't see a good reason... well, maybe I can come up with
one, actually. Things that react when read.).
Here's an example and a shell script; ideally these would be built into
an archive and then linked to both gdb and gdbserver. Possibly
autogenerate a manual chapter from them? Should not be hard.
--
Daniel Jacobowitz Carnegie Mellon University
MontaVista Software Debian GNU/Linux Developer
/* *INDENT-OFF* */ /* THIS FILE IS GENERATED */
/* A register protocol for GDB, the GNU debugger.
Copyright 2001 Free Software Foundation, Inc.
This file is part of GDB.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
/* This file was created with the aid of ``regdat.sh'' and ``dat/reg-i386.dat''. */
struct reg regs_i386[] = {
{ "eax", 0, 4 },
{ "ecx", 4, 4 },
{ "edx", 8, 4 },
{ "ebx", 12, 4 },
{ "esp", 16, 4 },
{ "ebp", 20, 4 },
{ "esi", 24, 4 },
{ "edi", 28, 4 },
{ "eip", 32, 4 },
{ "eflags", 36, 4 },
{ "cs", 40, 4 },
{ "ss", 44, 4 },
{ "ds", 48, 4 },
{ "es", 52, 4 },
{ "fs", 56, 4 },
{ "gs", 60, 4 },
{ "st0", 64, 10 },
{ "st1", 74, 10 },
{ "st2", 84, 10 },
{ "st3", 94, 10 },
{ "st4", 104, 10 },
{ "st5", 114, 10 },
{ "st6", 124, 10 },
{ "st7", 134, 10 },
{ "fctrl", 144, 4 },
{ "fstat", 148, 4 },
{ "ftag", 152, 4 },
{ "fiseg", 156, 4 },
{ "fioff", 160, 4 },
{ "foseg", 164, 4 },
{ "fooff", 168, 4 },
{ "fop", 172, 4 },
{ "xmm0", 176, 16 },
{ "xmm1", 192, 16 },
{ "xmm2", 208, 16 },
{ "xmm3", 224, 16 },
{ "xmm4", 240, 16 },
{ "xmm5", 256, 16 },
{ "xmm6", 272, 16 },
{ "xmm7", 288, 16 },
{ "mxcsr", 304, 4 },
};
const char *resume_regs_i386 = { "ebp", "esp", "eip", 0 };
<snip here>
#!/bin/sh -u
# Register protocol definitions for GDB, the GNU debugger.
# Copyright 2001 Free Software Foundation, Inc.
#
# This file is part of GDB.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
move_if_change ()
{
file=$1
if test -r ${file} && cmp -s "${file}" new-"${file}"
then
echo "${file} unchanged." 1>&2
else
mv new-"${file}" "${file}"
echo "${file} updated." 1>&2
fi
}
# Format of the input files
read="type entry"
do_read ()
{
type=""
entry=""
while read line
do
if test "${line}" = ""
then
continue
elif test "${line}" = "#" -a "${comment}" = ""
then
continue
elif expr "${line}" : "#" > /dev/null
then
comment="${comment}
${line}"
else
# The semantics of IFS varies between different SH's. Some
# treat ``::' as three fields while some treat it as just too.
# Work around this by eliminating ``::'' ....
line="`echo "${line}" | sed -e 's/::/: :/g' -e 's/::/: :/g'`"
OFS="${IFS}" ; IFS="[:]"
eval read ${read} <<EOF
${line}
EOF
IFS="${OFS}"
# .... and then going back through each field and strip out those
# that ended up with just that space character.
for r in ${read}
do
if eval test \"\${${r}}\" = \"\ \"
then
eval ${r}=""
fi
done
break
fi
done
if [ -n "${type}" ]
then
true
else
false
fi
}
if test ! -r $1; then
echo "$0: Could not open $1." 1>&2
exit 1
fi
copyright ()
{
cat <<EOF
/* *INDENT-OFF* */ /* THIS FILE IS GENERATED */
/* A register protocol for GDB, the GNU debugger.
Copyright 2001 Free Software Foundation, Inc.
This file is part of GDB.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
/* This file was created with the aid of \`\`regdat.sh'' and \`\`$1''. */
EOF
}
exec > new-$2
copyright
offset=0
i=0
name=x
resume=x
exec < $1
while do_read
do
if test "${type}" = "name"; then
name="${entry}"
echo "struct reg regs_${name}[] = {"
continue
elif test "${type}" = "resume"; then
resume="${entry}"
continue
elif test "${name}" = x; then
echo "$0: $1 does not specify \`\`name''." 1>&2
exit 1
else
echo " { \"${entry}\", ${offset}, ${type} },"
offset=`expr ${offset} + ${type}`
i=`expr $i + 1`
fi
done
echo "};"
echo
echo "const char *resume_regs_${name} = { \"`echo ${resume} | sed 's/,/", "/g'`\", 0 };"
# close things off
exec 1>&2
move_if_change $2
next prev parent reply other threads:[~2001-11-12 5:40 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2001-11-01 9:37 Andrew Cagney
2001-11-01 10:18 ` Daniel Jacobowitz [this message]
2001-11-01 10:30 ` Andrew Cagney
2001-11-01 10:58 ` Daniel Jacobowitz
2001-11-05 8:04 ` Andrew Cagney
2001-11-01 12:30 ` Fernando Nasser
2001-11-01 12:51 ` Andrew Cagney
2001-11-01 16:51 ` Frank Ch. Eigler
2001-11-02 0:37 ` Andrew Cagney
2001-11-05 8:19 ` Andrew Cagney
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=20011112004001.A11764@nevyn.them.org \
--to=drow@mvista.com \
--cc=gdb@sources.redhat.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