From: Eli Zaretskii <eliz@gnu.org>
To: teawater <teawater@gmail.com>
Cc: gdb-patches@sourceware.org
Subject: Re: [RFA] Process record and replay, 5/10
Date: Sun, 09 Nov 2008 19:58:00 -0000 [thread overview]
Message-ID: <uabc8r7s9.fsf@gnu.org> (raw)
In-Reply-To: <daef60380811081953g7d5fcc9bh22e39b323fd32271@mail.gmail.com>
> Date: Sun, 9 Nov 2008 11:53:54 +0800
> From: teawater <teawater@gmail.com>
> Cc: gdb-patches@sourceware.org
>
> >> +/* These macros are the values of the first argument of system call
> >> + "sys_ptrace". The values of these macros are gotten from Linux Kernel
> >> + source. */
> >> +
> >> +#define RECORD_PTRACE_PEEKTEXT 1
> >> +#define RECORD_PTRACE_PEEKDATA 2
> >> +#define RECORD_PTRACE_PEEKUSR 3
> >
> > Again, shouldn't this kind of data be taken from the syscall database,
> > rather than being spread over a few source files? I think having them
> > in one place will make the code more maintainable.
>
> What about I make a special .h file for each of them?
I was referring to the syscall database that is part of the "catch
syscalls" patch discussed elsewhere in this list. I think we should
have all the data about Linux system calls in the same place.
> >> + /* sys_ni_syscall */
> >> + case 56:
> >> + /* sys_setpgid */
> >> + case 57:
> >> + /* sys_ni_syscall */
> >> + case 58:
> >> + break;
> >> +
> >> + /* sys_olduname */
> >> + case 59:
> >> + regcache_raw_read (record_regcache, tdep->arg1, (gdb_byte *) & tmpu32);
> >> + if (record_arch_list_add_mem (tmpu32, tdep->size_oldold_utsname))
> >> + {
> >> + return (-1);
> >> + }
> >> + break;
> >> +
> >> + /* sys_umask */
> >> + case 60:
> >> + /* sys_chroot */
> >> + case 61:
> >> + break;
> >> +
> >> + /* sys_ustat */
> >> + case 62:
> >> + regcache_raw_read (record_regcache, tdep->arg2, (gdb_byte *) & tmpu32);
> >> + if (record_arch_list_add_mem (tmpu32, tdep->size_ustat))
> >> + {
> >> + return (-1);
> >> + }
> >> + break;
> >
> > It's a matter of style, I guess, but wouldn't it be better, instead of
> > endless repetition of almost identical code fragments like the two
> > above, to put the differing chunks in some data structure and then
> > just have one instance of the call to regcache_raw_read and
> > record_arch_list_add_mem, using the data in the data structure?
> >
>
> Sorry, I am not very clear your mean. I am not native speaker. :(
>
> Do you mean is put this code to a function that has a argv is tdep?
No, I mean to define a data structure, like this:
struct syscall_entry {
int num;
size_t size;
} syscall_data[] = {
...
{ 56, 0 },
{ 57, 0 },
{ 58, 0 },
{ 59, tdep->size_oldold_utsname },
...
};
and then use it like this:
if (syscall_data[i].size)
{
regcache_raw_read (record_regcache, tdep->arg1, (gdb_byte *) & tmpu32);
if (record_arch_list_add_mem (tmpu32, syscall_data[i].size))
{
return (-1);
}
}
break;
You can then have only one (or maybe few different) code fragments,
and the rest will be recorded in the data structure.
> >> + case RECORD_SYS_GETPEERNAME:
> >> + {
> >> + uint32_t a[3];
> >> + regcache_raw_read (record_regcache, tdep->arg2,
> >> + (gdb_byte *) & tmpu32);
> >> + if (tmpu32)
> >> + {
> >> + if (target_read_memory (tmpu32, (gdb_byte *) a, sizeof (a)))
> >> + {
> >> + fprintf_unfiltered (gdb_stdlog,
> >> + "Record: read memory addr = 0x%s len = %d error.\n",
> >
> > Is this a left-over from debugging stage? If not, why is it needed in
> > GDB? (There are few more fprintf_unfiltered's like this one.)
> >
> I want let user know what happen when got a error. What do you think about it?
I think we should at least have a user option to turn it on and off.
next prev parent reply other threads:[~2008-11-09 19:58 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-11-06 7:50 teawater
2008-11-07 15:10 ` Eli Zaretskii
2008-11-09 3:54 ` teawater
2008-11-09 19:58 ` Eli Zaretskii [this message]
2008-11-11 18:54 ` teawater
2008-11-13 23:00 ` Thiago Jung Bauermann
2008-11-14 13:53 ` teawater
2008-12-03 1:34 ` Thiago Jung Bauermann
2008-12-03 2:57 ` teawater
2008-12-04 3:22 ` teawater
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=uabc8r7s9.fsf@gnu.org \
--to=eliz@gnu.org \
--cc=gdb-patches@sourceware.org \
--cc=teawater@gmail.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