From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 7587 invoked by alias); 11 Sep 2009 08:09:31 -0000 Received: (qmail 7567 invoked by uid 22791); 11 Sep 2009 08:09:29 -0000 X-SWARE-Spam-Status: No, hits=-1.6 required=5.0 tests=AWL,BAYES_00,SPF_SOFTFAIL X-Spam-Check-By: sourceware.org Received: from mtaout4.012.net.il (HELO mtaout3.012.net.il) (84.95.2.10) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 11 Sep 2009 08:09:22 +0000 Received: from conversion-daemon.i_mtaout3.012.net.il by i_mtaout3.012.net.il (HyperSendmail v2004.12) id <0KPS00G00RS50D00@i_mtaout3.012.net.il> for gdb-patches@sourceware.org; Fri, 11 Sep 2009 11:09:20 +0300 (IDT) Received: from HOME-C4E4A596F7 ([84.228.50.163]) by i_mtaout3.012.net.il (HyperSendmail v2004.12) with ESMTPA id <0KPS0044BRZJ5WB0@i_mtaout3.012.net.il>; Fri, 11 Sep 2009 11:09:20 +0300 (IDT) Date: Fri, 11 Sep 2009 08:09:00 -0000 From: Eli Zaretskii Subject: Re: [RFC 1/3] catch syscall -- try 6 -- Source-code modifications In-reply-to: <200909101942.26646.sergiodj@linux.vnet.ibm.com> To: =?iso-8859-1?q?S=E9rgio_Durigan_J=FAnior?= Cc: gdb-patches@sourceware.org Reply-to: Eli Zaretskii Message-id: <83tyz929bz.fsf@gnu.org> MIME-version: 1.0 Content-type: text/plain; charset=iso-8859-1 Content-transfer-encoding: 8BIT References: <200909041600.47670.sergiodj@linux.vnet.ibm.com> <83ocpp501z.fsf@gnu.org> <200909101942.26646.sergiodj@linux.vnet.ibm.com> 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-09/txt/msg00310.txt.bz2 > From: Sérgio_Durigan_Júnior > Date: Thu, 10 Sep 2009 19:42:26 -0300 > Cc: gdb-patches@sourceware.org > > > Could you perhaps expand the comment a bit more? For example, what > > should the target do if NEEDED is zero? Also, I understand that > > ANY_COUNT nonzero means TABLE should be ignored, is that right? > > > > IOW, imagine that someone is to implement this method, and try to give > > any information necessary to write the code. > > I tried to be more descriptive about this piece of code. I also addressed > your other message, fixing some wrong comments. What do you think now? It's fine, now the API is clear. Thanks. I have one more small request: > + /* Check if the user provided a syscall name or a number. */ > + syscall_number = (int) strtol (cur_name, &endptr, 10); This forces the user to specify the system call numbers in decimal. However, sometimes it might be more convenient to use hex. For example, I'm planning to add support for this to the DJGPP port, where the various software interrupts and their functions are known to people by their hex numbers, e.g. Interrupt 0x21 function 0x2a is the DOS system call to get the system clock date. Asking the users to translate those into decimal would be a nuisance. So can we use zero instead of 10 for the last argument of this call to strtol? Finally, a minor nit: > + while (*arg != '\0') > + { > + int i, syscall_number; > + char *endptr; > + char cur_name[128]; > + struct syscall s; > + > + /* Skip whitespace. */ > + while (isspace (*arg)) > + arg++; > + > + for (i = 0; arg[i] && !isspace (arg[i]); ++i) > + cur_name[i] = arg[i]; > + cur_name[i] = '\0'; > + arg += i; The last loop does not take care not to overrun the 128-character limit that cur_name[] imposes on the length of syscall names, and will happily smash the stack if GDB is fed a very long string.