From owner-freebsd-current Wed Apr 19 12:48:48 1995 Return-Path: current-owner Received: (from majordom@localhost) by freefall.cdrom.com (8.6.10/8.6.6) id MAA27014 for current-outgoing; Wed, 19 Apr 1995 12:48:48 -0700 Received: from inet-gw-1.pa.dec.com (inet-gw-1.pa.dec.com [16.1.0.22]) by freefall.cdrom.com (8.6.10/8.6.6) with SMTP id MAA27008 for ; Wed, 19 Apr 1995 12:48:39 -0700 Received: from rks32.pcs.dec.com by inet-gw-1.pa.dec.com (5.65/24Feb95) id AA08002; Wed, 19 Apr 95 12:43:16 -0700 Received: by rks32.pcs.dec.com (Smail3.1.27.1 #16) id m0s1fbi-0005OqC; Wed, 19 Apr 95 21:40 MSZ Message-Id: Date: Wed, 19 Apr 95 21:40 MSZ From: garyj@rks32.pcs.dec.com (Gary Jennejohn) To: current%freebsd.org@inet-gw-1.pa.dec.com Subject: patch to gdb Sender: current-owner@FreeBSD.org Precedence: bulk Reply-to: gj@freebsd.org [ had to add the Reply-to by hand, damned mailx ! ] The appended patch fixes the "when I do gdb -k /none_existent_file /dev/mem, gdb core dumps" bug which was recently reported. Can some kind soul apply it ? Maybe it's time for me to get commit privileges, Jordan ? Gary J. ------------------------------- SNIP ------------------------------ *** kcorelow.c~ Wed Apr 19 19:52:52 1995 --- kcorelow.c Wed Apr 19 20:42:48 1995 *************** *** 170,177 **** old_chain = make_cleanup (free, filename); core_kd = kvm_open (exec_bfd->filename, filename, NULL, ! write_files? O_RDWR: O_RDONLY, 0); if (core_kd < 0) perror_with_name (filename); --- 170,187 ---- old_chain = make_cleanup (free, filename); + /* + * gdb doesn't really do anything if the exec-file couldn't + * be opened (in that case exec_bfd is NULL). Usually that's + * no big deal, but kvm_open needs the exec-file's name, + * which results in dereferencing a NULL pointer, a real NO-NO ! + * So, check here if the open of the exec-file succeeded. + */ + if (exec_bfd == NULL) /* the open failed */ + error ("kgdb could not open the exec-file, please check the name you used !"); + core_kd = kvm_open (exec_bfd->filename, filename, NULL, ! write_files? O_RDWR: O_RDONLY, "kgdb: "); if (core_kd < 0) perror_with_name (filename);