From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 17836 invoked by alias); 2 Aug 2009 23:45:59 -0000 Received: (qmail 17824 invoked by uid 22791); 2 Aug 2009 23:45:58 -0000 X-SWARE-Spam-Status: No, hits=-2.6 required=5.0 tests=BAYES_00,SPF_PASS X-Spam-Check-By: sourceware.org Received: from mail-qy0-f198.google.com (HELO mail-qy0-f198.google.com) (209.85.221.198) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Sun, 02 Aug 2009 23:45:51 +0000 Received: by qyk36 with SMTP id 36so3886532qyk.12 for ; Sun, 02 Aug 2009 16:45:49 -0700 (PDT) Received: by 10.224.89.15 with SMTP id c15mr4149864qam.116.1249256748250; Sun, 02 Aug 2009 16:45:48 -0700 (PDT) Received: from ?192.168.1.125? (cpe-69-201-134-242.nyc.res.rr.com [69.201.134.242]) by mx.google.com with ESMTPS id 8sm11192487qwj.46.2009.08.02.16.41.31 (version=TLSv1/SSLv3 cipher=RC4-MD5); Sun, 02 Aug 2009 16:45:47 -0700 (PDT) Message-Id: <8C1960DC-20AA-419C-AA4D-80500393842F@gmail.com> From: kceiwH To: gdb@sourceware.org In-Reply-To: <97234C41-9CA5-4A2C-89BA-6B54256D8B81@gmail.com> Content-Type: text/plain; charset=US-ASCII; format=flowed; delsp=yes Content-Transfer-Encoding: 7bit Mime-Version: 1.0 (Apple Message framework v935.3) Subject: Re: errors in GDB reading symbols Date: Sun, 02 Aug 2009 23:45:00 -0000 References: <97234C41-9CA5-4A2C-89BA-6B54256D8B81@gmail.com> X-IsSubscribed: yes Mailing-List: contact gdb-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-owner@sourceware.org X-SW-Source: 2009-08/txt/msg00002.txt.bz2 Forget it. I found the bug. I gave a different parameter to my program. Sorry to bother you. Regards, Mao On Aug 1, 2009, at 5:38 PM, kceiwH wrote: > Hi, > > I try to write a program to convert a line number of the source code > to the corresponding memory address. The program will link to > libgdb, libbfd, libiberty, libopcodes, which are generated when you > compile GDB. My problem is that the number of symbols (more than ten > thousand) of a given executable file that my program reads is quite > different from that (less than one hundred) GDB reads. > > All I did is mainly calling the interfaces to read an executable > file and its symbols. That is, I call exec_file_attach and > symbol_file_add_main. They should read the file's symbols. > My last try is copying the codes from functions main (in gdb/gdb.c), > gdb_main (in gdb/main.c), and captured_main (in gdb/main.c), without > the statement captured_command_loop, and putting them in a single > function in my program. I also changed the names of some local > variables, so I don't need to pass them as parameters. And the paths > such as BINDIR, DEBUGDIR, gdb_sysroot are set to the current > directory ".". Even though, the program still reads more than ten > thousand symbols of a given executable file. > > I compile my program with linking to libgdb, libbfd, libopcodes, > libiberty. And I also compiled GDB and run it to test whether my > program behaved correctly. They are based on the same codes. The > only differences are the path names. So my program should behave > like GDB. But my program reads much more symbols than the GDB does. > Is there anybody knows why that happen. I appreciate if you can give > a clue. > > Regards, > > Mao > >