From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 1173 invoked by alias); 6 Feb 2003 22:55:53 -0000 Mailing-List: contact gdb-patches-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sources.redhat.com Received: (qmail 1154 invoked from network); 6 Feb 2003 22:55:52 -0000 Received: from unknown (HELO main.gmane.org) (80.91.224.249) by 172.16.49.205 with SMTP; 6 Feb 2003 22:55:52 -0000 Received: from list by main.gmane.org with local (Exim 3.35 #1 (Debian)) id 18gutv-00056K-00 for ; Thu, 06 Feb 2003 23:53:47 +0100 X-Injected-Via-Gmane: http://gmane.org/ To: gdb-patches@sources.redhat.com Received: from news by main.gmane.org with local (Exim 3.35 #1 (Debian)) id 18gutt-000561-00 for ; Thu, 06 Feb 2003 23:53:45 +0100 From: "Raoul Gough" Subject: [RFA] DLLs without debugging symbols (repost) Date: Thu, 06 Feb 2003 22:55:00 -0000 Message-ID: Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="----=_NextPart_000_0015_01C2CE33.01058C70" X-Complaints-To: usenet@main.gmane.org X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2600.0000 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2600.0000 X-SW-Source: 2003-02/txt/msg00224.txt.bz2 This is a multi-part message in MIME format. ------=_NextPart_000_0015_01C2CE33.01058C70 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-length: 461 Apparently my copyright assignment forms have now been processed, so my patches for extracting minimal symbols from DLLs could now be entered into CVS. This message includes up-to-date diffs with the latest versions of the relevant files, as well as some documentation that I've added to gdb.texinfo (basically, there's a new node under the Cygwin Native node entitled "Non-debug DLL symbols" which explains some of the tricks involved). Regards, Raoul Gough. ------=_NextPart_000_0015_01C2CE33.01058C70 Content-Type: text/plain; name="coffread.diff.txt" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="coffread.diff.txt" Content-length: 880 Index: coffread.c =================================================================== RCS file: /cvs/src/src/gdb/coffread.c,v retrieving revision 1.33 diff -c -p -r1.33 coffread.c *** coffread.c 4 Feb 2003 18:07:00 -0000 1.33 --- coffread.c 6 Feb 2003 19:39:27 -0000 *************** *** 45,50 **** --- 45,52 ---- #include "target.h" #include "gdb_assert.h" + #include "coff-pe-read.h" + extern void _initialize_coffread (void); struct coff_symfile_info *************** coff_symtab_read (long symtab_offset, un *** 1084,1089 **** --- 1086,1098 ---- process_coff_symbol (cs, &main_aux, objfile); break; } + } + + if ((nsyms == 0) && (pe_file)) + { + /* We've got no debugging symbols, but it's is a portable + executable, so try to read the export table */ + read_pe_exported_syms (objfile); } if (last_source_file) ------=_NextPart_000_0015_01C2CE33.01058C70 Content-Type: text/plain; name="Makefile.in.diff.txt" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="Makefile.in.diff.txt" Content-length: 3163 Index: Makefile.in =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D RCS file: /cvs/src/src/gdb/Makefile.in,v retrieving revision 1.325 diff -c -p -r1.325 Makefile.in *** Makefile.in 6 Feb 2003 05:30:16 -0000 1.325 --- Makefile.in 6 Feb 2003 19:39:49 -0000 *************** SFILES =3D ada-exp.y ada-lang.c ada-typepr *** 511,517 **** ax-general.c ax-gdb.c \ bcache.c blockframe.c breakpoint.c buildsym.c builtin-regs.c \ c-exp.y c-lang.c c-typeprint.c c-valprint.c \ ! charset.c cli-out.c coffread.c complaints.c completer.c corefile.c \ cp-abi.c cp-support.c cp-valprint.c \ dbxread.c demangle.c disasm.c doublest.c \ dummy-frame.c dwarfread.c dwarf2read.c \ --- 511,518 ---- ax-general.c ax-gdb.c \ bcache.c blockframe.c breakpoint.c buildsym.c builtin-regs.c \ c-exp.y c-lang.c c-typeprint.c c-valprint.c \ ! charset.c cli-out.c coffread.c coff-pe-read.c \ ! complaints.c completer.c corefile.c \ cp-abi.c cp-support.c cp-valprint.c \ dbxread.c demangle.c disasm.c doublest.c \ dummy-frame.c dwarfread.c dwarf2read.c \ *************** call_cmds_h =3D call-cmds.h *** 612,617 **** --- 613,619 ---- ch_lang_h =3D ch-lang.h cli_out_h =3D cli-out.h coff_solib_h =3D coff-solib.h + coff_pe_read_h =3D coff-pe-read.h command_h =3D command.h complaints_h =3D complaints.h completer_h =3D completer.h *************** COMMON_OBS =3D version.o blockframe.o brea *** 833,839 **** kod.o kod-cisco.o \ gdb-events.o \ exec.o bcache.o objfiles.o minsyms.o maint.o demangle.o \ ! dbxread.o coffread.o elfread.o \ dwarfread.o dwarf2read.o mipsread.o stabsread.o corefile.o \ c-lang.o f-lang.o \ ui-out.o cli-out.o \ --- 835,841 ---- kod.o kod-cisco.o \ gdb-events.o \ exec.o bcache.o objfiles.o minsyms.o maint.o demangle.o \ ! dbxread.o coffread.o coff-pe-read.o elfread.o \ dwarfread.o dwarf2read.o mipsread.o stabsread.o corefile.o \ c-lang.o f-lang.o \ ui-out.o cli-out.o \ *************** coffread.o: coffread.c $(defs_h) $(symta *** 1564,1570 **** $(breakpoint_h) $(bfd_h) $(gdb_obstack_h) $(gdb_string_h) \ $(coff_internal_h) $(libcoff_h) $(symfile_h) $(objfiles_h) \ $(buildsym_h) $(gdb_stabs_h) $(stabsread_h) $(complaints_h) \ ! $(target_h) $(gdb_assert_h) complaints.o: complaints.c $(defs_h) $(complaints_h) $(gdb_assert_h) \ $(command_h) $(gdbcmd_h) completer.o: completer.c $(defs_h) $(symtab_h) $(gdbtypes_h) $(expression= _h) \ --- 1566,1574 ---- $(breakpoint_h) $(bfd_h) $(gdb_obstack_h) $(gdb_string_h) \ $(coff_internal_h) $(libcoff_h) $(symfile_h) $(objfiles_h) \ $(buildsym_h) $(gdb_stabs_h) $(stabsread_h) $(complaints_h) \ ! $(target_h) $(gdb_assert_h) $(coff_pe_read_h) ! coff-pe-read.o: coff-pe-read.c $(bfd_h) $(defs_h) $(symtab_h) \ ! $(gdbtypes_h) $(symfile_h) $(objfiles_h) $(coff_pe_read_h) complaints.o: complaints.c $(defs_h) $(complaints_h) $(gdb_assert_h) \ $(command_h) $(gdbcmd_h) completer.o: completer.c $(defs_h) $(symtab_h) $(gdbtypes_h) $(expression= _h) \ ------=_NextPart_000_0015_01C2CE33.01058C70 Content-Type: application/octet-stream; name="coff-pe-read.h" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="coff-pe-read.h" Content-length: 1307 /* Interface to coff-pe-read.c (portable-executable-specific symbol reader)= .=0A= =0A= Copyright 2003 Free Software Foundation, Inc.=0A= =0A= This file is part of GDB.=0A= =0A= This program is free software; you can redistribute it and/or modify=0A= it under the terms of the GNU General Public License as published by=0A= the Free Software Foundation; either version 2 of the License, or=0A= (at your option) any later version.=0A= =0A= This program is distributed in the hope that it will be useful,=0A= but WITHOUT ANY WARRANTY; without even the implied warranty of=0A= MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the=0A= GNU General Public License for more details.=0A= =0A= You should have received a copy of the GNU General Public License=0A= along with this program; if not, write to the Free Software=0A= Foundation, Inc., 59 Temple Place - Suite 330,=0A= Boston, MA 02111-1307, USA.=0A= =0A= Contributed by Raoul M. Gough (RaoulGough@yahoo.co.uk). */=0A= =0A= #if !defined (COFF_PE_READ_H)=0A= #define COFF_PE_READ_H=0A= =0A= struct objfile;=0A= =0A= /* Read the export table and convert it to minimal symbol table entries */= =0A= void read_pe_exported_syms (struct objfile *objfile);=0A= =0A= #endif /* !defined (COFF_PE_READ_H) */=0A= ------=_NextPart_000_0015_01C2CE33.01058C70 Content-Type: application/octet-stream; name="coff-pe-read.c" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="coff-pe-read.c" Content-length: 11640 /* Read the export table symbols from a portable executable and=0A= convert to internal format, for GDB. Used as a last resort if no=0A= debugging symbols recognized.=0A= =0A= Copyright 2003 Free Software Foundation, Inc.=0A= =0A= This file is part of GDB.=0A= =0A= This program is free software; you can redistribute it and/or modify=0A= it under the terms of the GNU General Public License as published by=0A= the Free Software Foundation; either version 2 of the License, or=0A= (at your option) any later version.=0A= =0A= This program is distributed in the hope that it will be useful,=0A= but WITHOUT ANY WARRANTY; without even the implied warranty of=0A= MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the=0A= GNU General Public License for more details.=0A= =0A= You should have received a copy of the GNU General Public License=0A= along with this program; if not, write to the Free Software=0A= Foundation, Inc., 59 Temple Place - Suite 330,=0A= Boston, MA 02111-1307, USA.=0A= =0A= Contributed by Raoul M. Gough (RaoulGough@yahoo.co.uk). */=0A= =0A= #include "coff-pe-read.h"=0A= =0A= #include "bfd.h"=0A= =0A= #include "defs.h"=0A= #include "gdbtypes.h"=0A= =0A= #include "symtab.h"=0A= #include "symfile.h"=0A= #include "objfiles.h"=0A= =0A= /* Internal section information */=0A= =0A= struct read_pe_section_data=0A= {=0A= CORE_ADDR vma_offset; /* Offset to loaded address of sectio= n.*/=0A= unsigned long rva_start; /* Start offset within the pe. */=0A= unsigned long rva_end; /* End offset within the pe. */=0A= enum minimal_symbol_type ms_type; /* Type to assign symbols in section.= */=0A= };=0A= =0A= #define PE_SECTION_INDEX_TEXT 0=0A= #define PE_SECTION_INDEX_DATA 1=0A= #define PE_SECTION_INDEX_BSS 2=0A= #define PE_SECTION_TABLE_SIZE 3=0A= #define PE_SECTION_INDEX_INVALID -1=0A= =0C=0A= /* Get the index of the named section in our own array, which contains=0A= text, data and bss in that order. Return PE_SECTION_INDEX_INVALID=0A= if passed an unrecognised section name. */=0A= =0A= static int=0A= read_pe_section_index (const char *section_name)=0A= {=0A= if (strcmp (section_name, ".text") =3D=3D 0)=0A= {=0A= return PE_SECTION_INDEX_TEXT;=0A= }=0A= =0A= else if (strcmp (section_name, ".data") =3D=3D 0)=0A= {=0A= return PE_SECTION_INDEX_DATA;=0A= }=0A= =0A= else if (strcmp (section_name, ".bss") =3D=3D 0)=0A= {=0A= return PE_SECTION_INDEX_BSS;=0A= }=0A= =0A= else=0A= {=0A= return PE_SECTION_INDEX_INVALID;=0A= }=0A= }=0A= =0A= /* Record the virtual memory address of a section. */=0A= =0A= static void=0A= get_section_vmas (bfd *abfd, asection *sectp, void *context)=0A= {=0A= struct read_pe_section_data *sections =3D context;=0A= int sectix =3D read_pe_section_index (sectp->name);=0A= =0A= if (sectix !=3D PE_SECTION_INDEX_INVALID)=0A= {=0A= /* Data within the section start at rva_start in the pe and at=0A= bfd_get_section_vma() within memory. Store the offset. */=0A= =0A= sections[sectix].vma_offset=0A= =3D bfd_get_section_vma (abfd, sectp) - sections[sectix].rva_start;=0A= }=0A= }=0A= =0C=0A= /* Create a minimal symbol entry for an exported symbol. */=0A= =0A= static void=0A= add_pe_exported_sym (char *sym_name,=0A= unsigned long func_rva,=0A= const struct read_pe_section_data *section_data,=0A= const char *dll_name,=0A= struct objfile *objfile)=0A= {=0A= /* Add the stored offset to get the loaded address of the symbol. */=0A= =0A= CORE_ADDR vma =3D func_rva + section_data->vma_offset;=0A= =0A= char *qualified_name =3D 0;=0A= int dll_name_len =3D strlen (dll_name);=0A= int count;=0A= =0A= /* Generate a (hopefully unique) qualified name using the first part=0A= of the dll name, e.g. KERNEL32!AddAtomA. This matches the style=0A= used by windbg from the "Microsoft Debugging Tools for Windows". */=0A= =0A= qualified_name =3D xmalloc (dll_name_len + strlen (sym_name) + 2);=0A= =0A= strncpy (qualified_name, dll_name, dll_name_len);=0A= qualified_name[dll_name_len] =3D '!';=0A= strcpy (qualified_name + dll_name_len + 1, sym_name);=0A= =0A= prim_record_minimal_symbol (qualified_name,=0A= vma,=0A= section_data->ms_type,=0A= objfile);=0A= =0A= xfree (qualified_name);=0A= =0A= /* Enter the plain name as well, which might not be unique. */=0A= prim_record_minimal_symbol (sym_name,=0A= vma,=0A= section_data->ms_type,=0A= objfile);=0A= }=0A= =0A= /* Truncate a dll_name at the first dot character. */=0A= =0A= static void=0A= read_pe_truncate_name (char *dll_name)=0A= {=0A= while (*dll_name)=0A= {=0A= if ((*dll_name) =3D=3D '.')=0A= {=0A= *dll_name =3D '\0'; /* truncates and causes loop exit. */=0A= }=0A= =0A= else=0A= {=0A= ++dll_name;=0A= }=0A= }=0A= }=0A= =0C=0A= /* Low-level support functions, direct from the ld module pe-dll.c. */=0A= static unsigned int=0A= pe_get16 (bfd *abfd, int where)=0A= {=0A= unsigned char b[2];=0A= =0A= bfd_seek (abfd, (file_ptr) where, SEEK_SET);=0A= bfd_bread (b, (bfd_size_type) 2, abfd);=0A= return b[0] + (b[1] << 8);=0A= }=0A= =0A= static unsigned int=0A= pe_get32 (bfd *abfd, int where)=0A= {=0A= unsigned char b[4];=0A= =0A= bfd_seek (abfd, (file_ptr) where, SEEK_SET);=0A= bfd_bread (b, (bfd_size_type) 4, abfd);=0A= return b[0] + (b[1] << 8) + (b[2] << 16) + (b[3] << 24);=0A= }=0A= =0A= static unsigned int=0A= pe_as32 (void *ptr)=0A= {=0A= unsigned char *b =3D ptr;=0A= =0A= return b[0] + (b[1] << 8) + (b[2] << 16) + (b[3] << 24);=0A= }=0A= =0C=0A= /* Read the (non-debug) export symbol table from a portable=0A= executable. Code originally lifted from the ld function=0A= pe_implied_import_dll in pe-dll.c. */=0A= =0A= void=0A= read_pe_exported_syms (struct objfile *objfile)=0A= {=0A= bfd *dll =3D objfile->obfd;=0A= unsigned long pe_header_offset, opthdr_ofs, num_entries, i;=0A= unsigned long export_rva, export_size, nsections, secptr, expptr;=0A= unsigned long exp_funcbase;=0A= unsigned char *expdata, *erva;=0A= unsigned long name_rvas, ordinals, nexp, ordbase;=0A= char *dll_name;=0A= =0A= /* Array elements are for text, data and bss in that order=0A= Initialization with start_rva > end_rva guarantees that=0A= unused sections won't be matched. */=0A= struct read_pe_section_data section_data[PE_SECTION_TABLE_SIZE]=0A= =3D { {0, 1, 0, mst_text},=0A= {0, 1, 0, mst_data},=0A= {0, 1, 0, mst_bss} };=0A= =0A= struct cleanup *back_to =3D 0;=0A= =0A= char const *target =3D bfd_get_target (objfile->obfd);=0A= =0A= if ((strcmp (target, "pe-i386") !=3D 0) && (strcmp (target, "pei-i386") != =3D 0))=0A= {=0A= /* This is not an i386 format file. Abort now, because the code=0A= is untested on anything else. *FIXME* test on further=0A= architectures and loosen or remove this test. */=0A= return;=0A= }=0A= =0A= /* Get pe_header, optional header and numbers of export entries. */=0A= pe_header_offset =3D pe_get32 (dll, 0x3c);=0A= opthdr_ofs =3D pe_header_offset + 4 + 20;=0A= num_entries =3D pe_get32 (dll, opthdr_ofs + 92);=0A= =0A= if (num_entries < 1) /* No exports. */=0A= {=0A= return;=0A= }=0A= =0A= export_rva =3D pe_get32 (dll, opthdr_ofs + 96);=0A= export_size =3D pe_get32 (dll, opthdr_ofs + 100);=0A= nsections =3D pe_get16 (dll, pe_header_offset + 4 + 2);=0A= secptr =3D (pe_header_offset + 4 + 20 +=0A= pe_get16 (dll, pe_header_offset + 4 + 16));=0A= expptr =3D 0;=0A= =0A= /* Get the rva and size of the export section. */=20=0A= for (i =3D 0; i < nsections; i++)=0A= {=0A= char sname[8];=0A= unsigned long secptr1 =3D secptr + 40 * i;=0A= unsigned long vaddr =3D pe_get32 (dll, secptr1 + 12);=0A= unsigned long vsize =3D pe_get32 (dll, secptr1 + 16);=0A= unsigned long fptr =3D pe_get32 (dll, secptr1 + 20);=0A= =0A= bfd_seek (dll, (file_ptr) secptr1, SEEK_SET);=0A= bfd_bread (sname, (bfd_size_type) 8, dll);=0A= =0A= if (vaddr <=3D export_rva && vaddr + vsize > export_rva)=0A= {=0A= expptr =3D fptr + (export_rva - vaddr);=0A= if (export_rva + export_size > vaddr + vsize)=0A= export_size =3D vsize - (export_rva - vaddr);=0A= break;=0A= }=0A= }=0A= =0A= if (export_size =3D=3D 0)=0A= {=0A= /* Empty export table. */=0A= return;=0A= }=0A= =0A= /* Scan sections and store the base and size of the relevant sections. */= =0A= for (i =3D 0; i < nsections; i++)=0A= {=0A= unsigned long secptr1 =3D secptr + 40 * i;=0A= unsigned long vsize =3D pe_get32 (dll, secptr1 + 8);=0A= unsigned long vaddr =3D pe_get32 (dll, secptr1 + 12);=0A= unsigned long flags =3D pe_get32 (dll, secptr1 + 36);=0A= char sec_name[9];=0A= int sectix;=0A= =0A= sec_name[8] =3D '\0';=0A= bfd_seek (dll, (file_ptr) secptr1 + 0, SEEK_SET);=0A= bfd_bread (sec_name, (bfd_size_type) 8, dll);=0A= =0A= sectix =3D read_pe_section_index (sec_name);=0A= =0A= if (sectix !=3D PE_SECTION_INDEX_INVALID)=0A= {=0A= section_data[sectix].rva_start =3D vaddr;=0A= section_data[sectix].rva_end =3D vaddr + vsize;=0A= }=0A= }=0A= =0A= expdata =3D (unsigned char *) xmalloc (export_size);=0A= back_to =3D make_cleanup (xfree, expdata);=0A= =0A= bfd_seek (dll, (file_ptr) expptr, SEEK_SET);=0A= bfd_bread (expdata, (bfd_size_type) export_size, dll);=0A= erva =3D expdata - export_rva;=0A= =0A= nexp =3D pe_as32 (expdata + 24);=0A= name_rvas =3D pe_as32 (expdata + 32);=0A= ordinals =3D pe_as32 (expdata + 36);=0A= ordbase =3D pe_as32 (expdata + 16);=0A= exp_funcbase =3D pe_as32 (expdata + 28);=0A= =0A= /* Use internal dll name instead of full pathname. */=0A= dll_name =3D pe_as32 (expdata + 12) + erva;=0A= =0A= bfd_map_over_sections (dll, get_section_vmas, section_data);=0A= =0A= /* Adjust the vma_offsets in case this PE got relocated. This=0A= assumes that *all* sections share the same relocation offset=0A= as the text section. */=0A= for (i =3D 0; i < PE_SECTION_TABLE_SIZE; i++)=0A= {=0A= section_data[i].vma_offset=0A= +=3D ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT (objfile));=0A= }=0A= =0A= printf_filtered ("Minimal symbols from %s...", dll_name);=0A= wrap_here ("");=0A= =0A= /* Truncate name at first dot. Should maybe also convert to all=0A= lower case for convenience on Windows. */=0A= read_pe_truncate_name (dll_name);=0A= =0A= /* Iterate through the list of symbols. */=0A= for (i =3D 0; i < nexp; i++)=0A= {=0A= /* Pointer to the names vector. */=0A= unsigned long name_rva =3D pe_as32 (erva + name_rvas + i * 4);=0A= =0A= /* Pointer to the function address vector. */=20=0A= unsigned long func_rva =3D pe_as32 (erva + exp_funcbase + i * 4);=0A= =0A= /* Find this symbol's section in our own array. */=0A= int sectix =3D 0;=0A= =0A= for (sectix =3D 0; sectix < PE_SECTION_TABLE_SIZE; ++sectix)=0A= {=0A= if ((func_rva >=3D section_data[sectix].rva_start)=0A= && (func_rva < section_data[sectix].rva_end))=0A= {=0A= add_pe_exported_sym (erva + name_rva,=0A= func_rva,=0A= section_data + sectix,=0A= dll_name,=0A= objfile);=0A= break;=0A= }=0A= }=0A= }=0A= =0A= /* discard expdata. */=0A= do_cleanups (back_to);=0A= }=0A= =0A= =0A= =0A= ------=_NextPart_000_0015_01C2CE33.01058C70 Content-Type: text/plain; name="ChangeLog_entry.txt" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="ChangeLog_entry.txt" Content-length: 506 2003-02-06 Raoul Gough * coff-pe-read.c: New file - support reading of minimal symbols from a portable executable using the export table. * coff-pe-read.h: New file * coffread.c: #include coff-pe-read.h (coff_symtab_read): call read_pe_exported_syms iff no recognized debugging symbols found. * Makefile.in (SFILES): add coff-pe-read.o (coff_pe_read_h): define (COMMON_OBS): add coff-pe-read.o (coffread.o): add coff_pe_read_h dependency (coff-pe-read.o): New target ------=_NextPart_000_0015_01C2CE33.01058C70 Content-Type: text/plain; name="doc_changelog_entry.txt" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="doc_changelog_entry.txt" Content-length: 232 2003-02-06 Raoul Gough * gdb.texinfo (Cygwin Native): Links to Non-debug DLL symbols. (Non-debug DLL symbols): New node, describing the minimal symbols loaded from DLLs without real debugging symbols. ------=_NextPart_000_0015_01C2CE33.01058C70 Content-Type: text/plain; name="gdb.texinfo.diff.txt" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="gdb.texinfo.diff.txt" Content-length: 6432 Index: gdb.texinfo =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D RCS file: /cvs/src/src/gdb/doc/gdb.texinfo,v retrieving revision 1.147 diff -c -p -r1.147 gdb.texinfo *** gdb.texinfo 4 Feb 2003 22:52:51 -0000 1.147 --- gdb.texinfo 6 Feb 2003 22:54:28 -0000 *************** This command is supported only with some *** 11142,11150 **** @cindex native Cygwin debugging @cindex Cygwin-specific commands =20=20 ! @value{GDBN} supports native debugging of MS Windows programs, and ! defines a few commands specific to the Cygwin port. This ! subsection describes those commands. =20=20 @table @code @kindex info w32 --- 11142,11153 ---- @cindex native Cygwin debugging @cindex Cygwin-specific commands =20=20 ! @value{GDBN} supports native debugging of MS Windows programs, including ! DLLs with and without symbolic debugging information. There are various ! additional Cygwin-specific commands, described in this subsection. The ! subsubsection @ref{Non-debug DLL symbols} describes working with DLLs ! that have no debugging symbols. !=20 =20=20 @table @code @kindex info w32 *************** via a shell or directly (default value i *** 11221,11226 **** --- 11224,11350 ---- Displays if the debuggee will be started with a shell. =20=20 @end table +=20 + @menu + * Non-debug DLL symbols:: Support for DLLs without debugging symbols + @end menu +=20 + @node Non-debug DLL symbols + @subsubsection Support for DLLs without debugging symbols + @cindex DLLs with no debugging symbols +=20 + Very often on windows, some of the DLLs that your program relies on do + not include symbolic debugging information (for example, + kernel32.dll). When @value{GDBN} doesn't recognize any debugging symbols + in a DLL, it relies on the minimal amount of symbolic information + contained in the DLL's export table. This subsubsection describes + working with such symbols, known internally to @value{GDBN} as ``minimal + symbols''. +=20 + Note that before the debugged program has started execution, no DLLs + will have been loaded. The easiest way around this problem is simply to + start the program - either by setting a breakpoint or letting the + program run once to completion. It is also possible to force + @value{GDBN} to load a particular DLL before starting the executable - + see the shared library information in @ref{Files} or the + @code{dll-symbols} command in @ref{Cygwin Native}. Currently, explicitly + loading symbols from a DLL with no debugging information will cause the + same symbols to be duplicated in @value{GDBN}'s symbol table, which may + adversely affect symbol lookup performance. +=20 + @subsubsection DLL name prefixes +=20 + In keeping with the naming conventions used by the Microsoft debugging + tools, DLL export symbols are made available with a prefix based on the + DLL name, for instance ``KERNEL32!CreateFileA''. The plain name is also + entered into the symbol table, so ``CreateFileA'' is often + sufficient. In some cases there will be name clashes within a program + (particularly if the executable itself includes full debugging symbols) + necessitating the use of the fully qualified name. Use single-quotes + around the name to avoid the exclamation mark (``!'') being interpreted + as a language operator. +=20 + Note that the internal name of the DLL may be all upper-case, even + though the file name of the DLL is lower-case, or vice-versa. Since + symbols within @value{GDBN} are @emph{case-sensitive} this may cause + some confusion. If in doubt, try the @code{info functions} and + @code{info variables} commands or even @code{maint print msymbols} (see + @ref{Symbols}). Here's an example: +=20 + @smallexample + (gdb) info function CreateFileA + All functions matching regular expression "CreateFileA": +=20 + Non-debugging symbols: + 0x77e885f4 CreateFileA + 0x77e885f4 KERNEL32!CreateFileA + @end smallexample +=20 + @smallexample + (gdb) info function ! + All functions matching regular expression "!": +=20 + Non-debugging symbols: + 0x6100114c cygwin1!__assert + 0x61004034 cygwin1!_dll_crt0@@0 + 0x61004240 cygwin1!dll_crt0(per_process *) + [etc...] + @end smallexample +=20 + @subsubsection Working with minimal symbols +=20 + Symbols extracted from a DLL's export table do not contain very much + type information. All that @value{GDBN} can do is guess whether a symbol + refers to a function or variable depending on the linker section that + contains the symbol. Also note that the actual contents of the memory + contained in a DLL are not available unless the program is running. This + means that you cannot examine the contents of a variable or disassemble + a function within a DLL without a running program. +=20 + Variables are generally treated as pointers and dereferenced + automatically. For this reason, it is often necessary to prefix a + variable name with an ampersand (``&'') and provide explicit type + information in the command. Here's an example of the type of problem: +=20 + @smallexample + (gdb) print 'cygwin1!__argv' + $1 =3D 268572168 + @end smallexample +=20 + @smallexample + (gdb) x 'cygwin1!__argv' + 0x10021610: "\230y\"" + @end smallexample +=20 + And two possible solutions: +=20 + @smallexample + (gdb) print ((char **)'cygwin1!__argv')[0] + $2 =3D 0x22fd98 "/cygdrive/c/mydirectory/myprogram" + @end smallexample +=20 + @smallexample + (gdb) x/2x &'cygwin1!__argv' + 0x610c0aa8 : 0x10021608 0x00000000 + (gdb) x/x 0x10021608 + 0x10021608: 0x0022fd98 + (gdb) x/s 0x0022fd98 + 0x22fd98: "/cygdrive/c/mydirectory/myprogram" + @end smallexample +=20 + Setting a break point within a DLL is possible even before the program + starts execution. However, under these circumstances, @value{GDBN} can't + examine the initial instructions of the function in order to skip the + function's frame set-up code. You can work around this by using ``*&'' + to set the breakpoint at a raw memory address: +=20 + @smallexample + (gdb) break *&'python22!PyOS_Readline' + Breakpoint 1 at 0x1e04eff0 + @end smallexample +=20 + The author of these extensions is not entirely convinced that setting a + break point within a shared DLL like kernel32.dll is completely safe. =20=20 @node Embedded OS @section Embedded Operating Systems ------=_NextPart_000_0015_01C2CE33.01058C70--