Date: Thu, 30 May 1996 00:00:14 +0100 From: "Gary Palmer" <gpalmer@FreeBSD.ORG> To: grog@lemis.de (Greg Lehey) Cc: scrappy@ki.net (Marc G. Fournier), hackers@FreeBSD.ORG (FreeBSD Hackers) Subject: Re: I HATE OPTIMISING COMPILERS Message-ID: <2951.833410814@palmer.demon.co.uk> In-Reply-To: Your message of "Wed, 29 May 1996 18:52:09 %2B0200." <199605291652.SAA24396@allegro.lemis.de>
next in thread | previous in thread | raw e-mail | index | archive | help
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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?2951.833410814>