From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 32467 invoked by alias); 20 Jun 2006 18:37:16 -0000 Received: (qmail 32457 invoked by uid 22791); 20 Jun 2006 18:37:15 -0000 X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (66.187.233.31) by sourceware.org (qpsmtpd/0.31) with ESMTP; Tue, 20 Jun 2006 18:37:12 +0000 Received: from int-mx1.corp.redhat.com (int-mx1.corp.redhat.com [172.16.52.254]) by mx1.redhat.com (8.12.11.20060308/8.12.11) with ESMTP id k5KIbBBg022078 for ; Tue, 20 Jun 2006 14:37:11 -0400 Received: from pobox.toronto.redhat.com (pobox.toronto.redhat.com [172.16.14.4]) by int-mx1.corp.redhat.com (8.12.11.20060308/8.12.11) with ESMTP id k5KIbBtB012559 for ; Tue, 20 Jun 2006 14:37:11 -0400 Received: from [172.16.14.227] (IDENT:B3bCMYtRJiP29i9ht6j3ksvr5DMYwjqE@topaz.toronto.redhat.com [172.16.14.227]) by pobox.toronto.redhat.com (8.12.8/8.12.8) with ESMTP id k5KIbAve026522 for ; Tue, 20 Jun 2006 14:37:10 -0400 Message-ID: <44984056.2040901@redhat.com> Date: Tue, 20 Jun 2006 18:37:00 -0000 From: Dave Brolley User-Agent: Mozilla Thunderbird 1.0.2 (X11/20050317) MIME-Version: 1.0 To: sid@sources.redhat.com Subject: [patch][commit] cgen_symbol_at_address and cgen_print_address Content-Type: multipart/mixed; boundary="------------080700070604040700030301" X-IsSubscribed: yes Mailing-List: contact sid-help@sourceware.org; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: sid-owner@sourceware.org X-SW-Source: 2006-q2/txt/msg00045.txt.bz2 This is a multi-part message in MIME format. --------------080700070604040700030301 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-length: 507 Hi, I've committed the attached patch which implements cgen_symbol_at_address and cgen_print_address (in cgen_bi_endian_cpu). The implementation uses the loader's function? pin and current-function attribute (added previously for dynamic configuration) to determine which symbol is associated with the given address. Previously, cgen_symbol_at_address simply wrote a message to cerr. The disassembly for ports which use these functions now looks more like the disassembly produced by objdump. Dave --------------080700070604040700030301 Content-Type: text/plain; name="sid-disassemble.ChangeLog" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="sid-disassemble.ChangeLog" Content-length: 621 2006-06-20 Dave Brolley * commonCfg.cxx (BoardCfg::write_config): If there is a loader, then relate it to the cpu and connect the cpu's disassembly-symbol-address pin to the loader's function? pin. 2006-06-20 Dave Brolley * compCGEN.cxx (cgen_bi_endian_cpu): Initialize loader. Add "loader" relation and "disassembly-symbol-address" pin. (cgen_print_address): Call cgen_symbol_at_address and print the symbol name. (cgen_symbol_at_address): Implemented. * cgen-cpu.h (class cgen_bi_endian_cpu): Add symbol_at_address, loader and disassembly_symbol_address_pin. --------------080700070604040700030301 Content-Type: text/plain; name="sid-disassemble.patch.txt" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="sid-disassemble.patch.txt" Content-length: 5189 Index: sid/component/cgen-cpu/cgen-cpu.h =================================================================== RCS file: /cvs/src/src/sid/component/cgen-cpu/cgen-cpu.h,v retrieving revision 1.17 diff -c -p -r1.17 cgen-cpu.h *** sid/component/cgen-cpu/cgen-cpu.h 10 May 2006 20:58:29 -0000 1.17 --- sid/component/cgen-cpu/cgen-cpu.h 20 Jun 2006 18:25:18 -0000 *************** public: *** 70,76 **** --- 70,80 ---- void disassemble (PCADDR pc, disassembler_ftype printfn, enum bfd_flavour flavour, enum bfd_architecture arch, enum bfd_endian endian, const char *name, CGEN_BITSET *isas = 0, int machine = 0); + string symbol_at_address; struct disassemble_info info; + component *loader; + output_pin disassembly_symbol_address_pin; + protected: static int cgen_read_memory (bfd_vma memaddr, bfd_byte *myaddr, unsigned int length, Index: sid/component/cgen-cpu/compCGEN.cxx =================================================================== RCS file: /cvs/src/src/sid/component/cgen-cpu/compCGEN.cxx,v retrieving revision 1.18 diff -c -p -r1.18 compCGEN.cxx *** sid/component/cgen-cpu/compCGEN.cxx 11 May 2006 14:33:40 -0000 1.18 --- sid/component/cgen-cpu/compCGEN.cxx 20 Jun 2006 18:25:18 -0000 *************** using namespace cgen; *** 42,47 **** --- 42,48 ---- // ---------------------------------------------------------------------------- cgen_bi_endian_cpu::cgen_bi_endian_cpu () { + loader = 0; branch_was_return = false; warnings_enabled = false; add_attribute ("enable-warnings?", & warnings_enabled, "setting"); *************** cgen_bi_endian_cpu::cgen_bi_endian_cpu ( *** 50,55 **** --- 51,58 ---- & cgen_bi_endian_cpu::set_engine_type, & cgen_bi_endian_cpu::get_engine_type, "setting"); + add_uni_relation("loader", &loader); + add_pin ("disassembly-symbol-address", & disassembly_symbol_address_pin); } *************** cgen_bi_endian_cpu::cgen_print_address(b *** 230,245 **** { cgen_bi_endian_cpu *thisp = static_cast(info->application_data); ! thisp->trace_stream ! << "0x" << hex << addr << dec; } int cgen_bi_endian_cpu::cgen_symbol_at_address(bfd_vma addr, struct disassemble_info * info) { ! cerr << "cgen_bi_endian_cpu::symbol_at_address!?" << endl; ! return 0; } --- 233,265 ---- { cgen_bi_endian_cpu *thisp = static_cast(info->application_data); ! thisp->trace_stream << hex << addr << dec; ! ! if (cgen_symbol_at_address (addr, info)) ! if (! thisp->symbol_at_address.empty ()) ! thisp->trace_stream << " <" << thisp->symbol_at_address << '>'; } int cgen_bi_endian_cpu::cgen_symbol_at_address(bfd_vma addr, struct disassemble_info * info) { ! cgen_bi_endian_cpu *thisp = static_cast(info->application_data); ! if (thisp->loader) ! { ! thisp->disassembly_symbol_address_pin.drive (addr); ! thisp->symbol_at_address = thisp->loader->attribute_value("current-function"); ! } ! else ! thisp->symbol_at_address = ""; ! ! if (thisp->symbol_at_address.empty ()) ! { ! cerr << "cgen_bi_endian_cpu::symbol_at_address!?" << endl; ! return 0; // failed ! } ! ! return 1; // success } Index: sid/main/dynamic/commonCfg.cxx =================================================================== RCS file: /cvs/src/src/sid/main/dynamic/commonCfg.cxx,v retrieving revision 1.13 diff -c -p -r1.13 commonCfg.cxx *** sid/main/dynamic/commonCfg.cxx 14 Jun 2006 20:41:28 -0000 1.13 --- sid/main/dynamic/commonCfg.cxx 20 Jun 2006 18:25:18 -0000 *************** void BoardCfg::write_config (Writer &w) *** 1256,1261 **** --- 1256,1269 ---- { AggregateCfg::write_config (w); + // Make the connection which allows the cpu to query the loader regarding + // addresses. + if (loader) + { + Relation (cpu, "loader", loader).write_to (w); + PinConnection (cpu, "disassembly-symbol-address", loader, "function?").write_to (w); + } + if (gloss) { if (gdb) Index: sid/component/loader/compLoader.cxx =================================================================== RCS file: /cvs/src/src/sid/component/loader/compLoader.cxx,v retrieving revision 1.12 diff -c -p -r1.12 compLoader.cxx *** sid/component/loader/compLoader.cxx 1 Mar 2006 21:07:01 -0000 1.12 --- sid/component/loader/compLoader.cxx 20 Jun 2006 18:25:18 -0000 *************** void *** 420,426 **** elf_loader::check_function_pin_handler (host_int_4 addr) { // Find the function corresponding to the given address in the symbol ! // table, if any, and set current_function to that name. If no function is // found, set current_function to a string representing the address. if (symbol_table) { --- 420,426 ---- elf_loader::check_function_pin_handler (host_int_4 addr) { // Find the function corresponding to the given address in the symbol ! // table, if any, and set current_function to that name. If a function is // found, set current_function to a string representing the address. if (symbol_table) { --------------080700070604040700030301--