From owner-freebsd-hackers Wed May 29 16:03:56 1996 Return-Path: owner-hackers Received: (from root@localhost) by freefall.freebsd.org (8.7.5/8.7.3) id QAA19512 for hackers-outgoing; Wed, 29 May 1996 16:03:56 -0700 (PDT) Received: from palmer.demon.co.uk (palmer.demon.co.uk [158.152.50.150]) by freefall.freebsd.org (8.7.5/8.7.3) with ESMTP id QAA19490 for ; Wed, 29 May 1996 16:03:50 -0700 (PDT) Received: from palmer.demon.co.uk (localhost [127.0.0.1]) by palmer.demon.co.uk (sendmail/PALMER-1) with ESMTP id AAA02953; Thu, 30 May 1996 00:00:15 +0100 (BST) To: grog@lemis.de (Greg Lehey) cc: scrappy@ki.net (Marc G. Fournier), hackers@FreeBSD.ORG (FreeBSD Hackers) From: "Gary Palmer" Subject: Re: I HATE OPTIMISING COMPILERS In-reply-to: Your message of "Wed, 29 May 1996 18:52:09 +0200." <199605291652.SAA24396@allegro.lemis.de> Date: Thu, 30 May 1996 00:00:14 +0100 Message-ID: <2951.833410814@palmer.demon.co.uk> Sender: owner-hackers@FreeBSD.ORG X-Loop: FreeBSD.org Precedence: bulk Greg Lehey wrote in message ID <199605291652.SAA24396@allegro.lemis.de>: > At this point, of course, our mileage varies. Here, you would get the > result: > + (gdb) p pdu->version > + $3 = -1 Sorry, BZZZZZZZT The actual program, producing the actual results: gdb apps/snmpwalk GDB is free software and you are welcome to distribute copies of it under certain conditions; type "show copying" to see the conditions. There is absolutely no warranty for GDB; type "show warranty" for details. GDB 4.13 (i386-unknown-freebsd), Copyright 1994 Free Software Foundation, Inc... (gdb) break snmp_api.c:1006 Breakpoint 1 at 0x96df: file snmp_api.c, line 1006. (gdb) run -v 1 localhost public Starting program: /mnt/root/usr/home/gary/ftp/ucd-snmp-3.1/apps/snmpwalk -v 1 localhost public Breakpoint 1, snmp_send (session=0x65100, pdu=0x65180) at snmp_api.c:1007 1007 if (pdu->version == SNMP_DEFAULT_VERSION){ (gdb) print pdu->version $1 = -1 (gdb) print session->version $2 = 0 (gdb) break 1009 Breakpoint 2 at 0x96ef: file snmp_api.c, line 1009. (gdb) cont Continuing. Breakpoint 2, snmp_send (session=0x65100, pdu=0x65180) at snmp_api.c:1010 1010 if (pdu->version == SNMP_DEFAULT_VERSION){ (gdb) print pdu->version $3 = 0 (gdb) print session->version $4 = 0 (gdb) s 1011 fprintf(stderr, "No version specified\n"); (gdb) 1013 return 0; (gdb) No version specified 1068 snmp_errno = SNMPERR_BAD_ADDRESS; So, you see, GDB says that pdu->version does NOT equal SNMP_DEFAULT_VERSION. I guess it would have tracked down the problem quicker, but I STILL don't like gdb :-) I guess it comes from a time when I tried (and NEARLY suceeded) in porting the FreeBSD kernel to another machine ... printf was all I had :-) > I'd do this differently in gdb. Personally, I'd look at the code that > was generated. Your code won't look like this, of course, because > this code works. But you can see a few things: Only if you read 80x86, which I don't, and probably never will. I've been corrupted by a RISC processor, and hope never to have to touch a CISC assembler ever again :-) I know (or used to) 6502 and 68000, and that's plenty CISC to last enough a lifetime :-) [SNIP] > Reading assembler is tough, of course, but there are other ways. In > any case, you save a lot by doing it this way rather than going and > editing and recompiling possibly dozens of times. Hmm. Maybe. Call me stoopid, but I still like my printf's thankyou :-) Gary -- Gary Palmer FreeBSD Core Team Member FreeBSD: Turning PC's into workstations. See http://www.FreeBSD.ORG/ for info