From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 17907 invoked by alias); 19 Jul 2009 08:21:17 -0000 Received: (qmail 17887 invoked by uid 22791); 19 Jul 2009 08:21:15 -0000 X-SWARE-Spam-Status: No, hits=-1.7 required=5.0 tests=AWL,BAYES_00,SARE_MSGID_LONG40,SPF_PASS X-Spam-Check-By: sourceware.org Received: from mail-pz0-f203.google.com (HELO mail-pz0-f203.google.com) (209.85.222.203) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Sun, 19 Jul 2009 08:21:08 +0000 Received: by pzk41 with SMTP id 41so1324415pzk.12 for ; Sun, 19 Jul 2009 01:21:07 -0700 (PDT) MIME-Version: 1.0 Received: by 10.142.193.13 with SMTP id q13mr678641wff.293.1247991667121; Sun, 19 Jul 2009 01:21:07 -0700 (PDT) In-Reply-To: <4A6121FC.3030205@vmware.com> References: <4A5A8438.6030005@vmware.com> <4A6121FC.3030205@vmware.com> From: Hui Zhu Date: Sun, 19 Jul 2009 17:19:00 -0000 Message-ID: Subject: Re: [RFA/RFC Prec] Add Linux AMD64 process record support second version, (AMD64 Linux system call support) 3/3 To: Michael Snyder Cc: gdb-patches ml , mark.kettenis@xs4all.nl Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-IsSubscribed: yes Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2009-07/txt/msg00453.txt.bz2 On Sat, Jul 18, 2009 at 09:14, Michael Snyder wrote: > Hui Zhu wrote: > > >> + =A0/* Convert tmpulongest to number in record_linux_system_call. =A0*/ >> + =A0switch (tmpulongest) >> + =A0 =A0{ >> + =A0 =A0 =A0/* sys_read */ >> + =A0 =A0case 0: >> + =A0 =A0 =A0num =3D 3; >> + =A0 =A0 =A0break; >> + =A0 =A0 =A0/* sys_write */ >> + =A0 =A0case 1: >> + =A0 =A0 =A0num =3D 4; >> + =A0 =A0 =A0break; > > Hey Hui, > > This switch statement is over 1000 lines long! =A0;-) > > It's OK, there's no real rule against that, but it just > makes me think about whether shortening it might make it > any easier to read and maintain... > > I thought of suggesting a look-up table, but that would > actually make it harder to read and maintain, I think... > > What about this? =A0If you wrote it this way... > > =A0 =A0 =A0 =A0case 1: =A0 =A0 =A0 =A0 /* sys_write */ > > you'd save over 250 lines, and I think it would be more readable. > > And then, if you abstracted the switch statement out > into a separate function, you could code it like this... > > =A0 =A0 =A0 =A0case 1: =A0 =A0 =A0 =A0 /* sys_write */ > =A0 =A0 =A0 =A0 =A0return 4; > =A0 =A0 =A0 =A0case 2: =A0 =A0 =A0 =A0 /* sys_open */ > > and save another 250 lines, cutting the whole thing by half. > You'd have to special-case number 158, of course. > > I leave it up to you, you can decide. > > Other than that it looks fine. =A0Mark? > > > That is really a big work. Please let me post a special patch for it later. Thanks, Hui