From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 13564 invoked by alias); 1 Aug 2009 21:38:27 -0000 Received: (qmail 13555 invoked by uid 22791); 1 Aug 2009 21:38:26 -0000 X-SWARE-Spam-Status: No, hits=0.1 required=5.0 tests=AWL,BAYES_00,SPF_PASS X-Spam-Check-By: sourceware.org Received: from qw-out-1920.google.com (HELO qw-out-1920.google.com) (74.125.92.148) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Sat, 01 Aug 2009 21:38:20 +0000 Received: by qw-out-1920.google.com with SMTP id 5so1750636qwf.24 for ; Sat, 01 Aug 2009 14:38:18 -0700 (PDT) Received: by 10.224.45.72 with SMTP id d8mr3339416qaf.124.1249162697976; Sat, 01 Aug 2009 14:38:17 -0700 (PDT) Received: from dyn-209-2-216-193.dyn.columbia.edu (dyn-209-2-216-193.dyn.columbia.edu [209.2.216.193]) by mx.google.com with ESMTPS id 2sm9203307qwi.43.2009.08.01.14.38.16 (version=TLSv1/SSLv3 cipher=RC4-MD5); Sat, 01 Aug 2009 14:38:17 -0700 (PDT) Message-Id: <97234C41-9CA5-4A2C-89BA-6B54256D8B81@gmail.com> From: kceiwH To: gdb@sourceware.org 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: errors in GDB reading symbols Date: Sat, 01 Aug 2009 21:38:00 -0000 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/msg00001.txt.bz2 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