public inbox for sid@sourceware.org
 help / color / mirror / Atom feed
* [patch][commit] cgen_symbol_at_address and cgen_print_address
@ 2006-06-20 18:37 Dave Brolley
  0 siblings, 0 replies; only message in thread
From: Dave Brolley @ 2006-06-20 18:37 UTC (permalink / raw)
  To: sid

[-- Attachment #1: Type: text/plain, Size: 507 bytes --]

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

[-- Attachment #2: sid-disassemble.ChangeLog --]
[-- Type: text/plain, Size: 621 bytes --]

2006-06-20  Dave Brolley  <brolley@redhat.com>

	* 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  <brolley@redhat.com>

	* 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.


[-- Attachment #3: sid-disassemble.patch.txt --]
[-- Type: text/plain, Size: 5189 bytes --]

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<cgen_bi_endian_cpu *>(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;
  }
  
  \f
--- 233,265 ----
  {
    cgen_bi_endian_cpu *thisp = static_cast<cgen_bi_endian_cpu *>(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<cgen_bi_endian_cpu *>(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
  }
  
  \f
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)
      {

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2006-06-20 18:37 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-06-20 18:37 [patch][commit] cgen_symbol_at_address and cgen_print_address Dave Brolley

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).