This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [Patch] Add mips*-linux* catch syscall support.
- From: Mark Kettenis <mark dot kettenis at xs4all dot nl>
- To: ddaney at caviumnetworks dot com
- Cc: froydnj at codesourcery dot com, gdb-patches at sourceware dot org
- Date: Sat, 12 Feb 2011 23:29:52 +0100 (CET)
- Subject: Re: [Patch] Add mips*-linux* catch syscall support.
- References: <4D39E2DC.6060907@caviumnetworks.com> <20110122150559.GY6247@codesourcery.com> <4D3DC1CC.6020906@caviumnetworks.com>
> Date: Mon, 24 Jan 2011 10:15:40 -0800
> From: David Daney <ddaney@caviumnetworks.com>
>
> On 01/22/2011 07:06 AM, Nathan Froyd wrote:
> > On Fri, Jan 21, 2011 at 11:47:40AM -0800, David Daney wrote:
> >> Index: gdb/mips-linux-tdep.c
> >> ===================================================================
> >> @@ -1206,6 +1207,40 @@ mips_linux_syscall_next_pc (struct frame
> >>
> >> return pc + 4;
> >> }
> >> +/* Return the current system call's number present in the
> >> + v0 register. When the function fails, it returns -1. */
> >> +static LONGEST
> >> +mips_linux_get_syscall_number (struct gdbarch *gdbarch,
> >> + ptid_t ptid)
> >> +{
> >> + buf = (gdb_byte *) xmalloc (regsize * sizeof (gdb_byte));
> >
> > Why not just use alloca or XALLOCAVEC here?
> >
>
> Because I copied the code from PPC, and that is what was done there.
>
> Since we know that the maximum size is 8 bytes, I could just allocate a
> fixed size array on the stack. That would simplify things quite a bit.
That's typically what I do for code that supports both 32-bit and
64-bit registers in the GDB targets I (sort of) maintain (i386/amd64,
sparc/sparc64).