Debugging the architecture-dependent AD file

Lindenmaier, Goetz goetz.lindenmaier at sap.com
Tue Oct 25 13:58:27 UTC 2016


Hi,

for the expand, you have to debug the generated files.
Set the breakpoint in 
build/... /hotspot/variant-server/gensrc/adfiles/ad_ppc_expand.cpp, loadB_indirect_ExNode::Expand()

If it's real C-code, you can set the breakpoint in the ad file, 
as for emit statements (in ad_ppc.cpp), see below. The #line statement makes
gdb step in the ad file for a while.

void convB2I_reg_2Node::emit(CodeBuffer& cbuf, PhaseRegAlloc* ra_) const {
  cbuf.set_insts_mark();
  // Start at oper_input_base() and count operands
  unsigned idx0 = 1;
  unsigned idx1 = 1; 	// src
  {
    MacroAssembler _masm(&cbuf);

#line 4999 "/sapmnt/home1/d045726/oJ/8168283-adlc_expand-hs/hotspot/src/cpu/ppc/vm/ppc.ad"

    // TODO: PPC port $archOpcode(ppc64Opcode_extsb);
    __ extsb(opnd_array(0)->as_Register(ra_,this)/* dst */, opnd_array(1)->as_Register(ra_,this,idx1)/* src */);
  
#line 7447 "ad_ppc.cpp"
  }
}

The expand declaration specifies a small graph transformation.

instruct loadB_indirect_Ex(iRegIdst dst, indirectMemory mem) %{
  match(Set dst (LoadB mem));
  predicate(n->as_Load()->is_unordered() || followed_by_acquire(n));
  ins_cost(MEMORY_REF_COST + DEFAULT_COST);
  expand %{
    iRegIdst tmp;
    loadUB_indirect(tmp, mem);
    convB2I_reg_2(dst, tmp);
  %}
%}

    ...
      |
      |  mem
      |
   loadB_indirect_Ex
      |
      | dst
      |
    ...
 
is transformed to 

    ...
      |
      |  mem
      |
  loadUB_indirect
      |
       | tmp
       |
   convB2I_reg_2
      |
      | dst
      |
    ...

The expand is applied after matching the node to refine the machine nodes.

Best regards,
 Goetz.



> -----Original Message-----
> From: hotspot-compiler-dev [mailto:hotspot-compiler-dev-
> bounces at openjdk.java.net] On Behalf Of Gustavo Serra Scalet
> Sent: Dienstag, 25. Oktober 2016 15:16
> To: hotspot-compiler-dev at openjdk.java.net
> Subject: Debugging the architecture-dependent AD file
> 
> Hi,
> 
> I'd like to know if there is any easier way to debug the architecture-
> dependent
> AD file. I see that some compilers include a set of gdb-python scripts in order
> to facilitate debugging.
> 
> On this example I wanted to closely check how loadB_indirect_Ex is behaving
> on
> ppc. I could manage to debug the hotspot overall, but I'm confused about
> what is
> happening when looking at the AD file:
> 
> ~/hs-comp $ ./build/linux-ppc64le-normal-server-slowdebug/jdk/bin/javac
> pidigits.java
> ~/hs-comp $ gdb ./build/linux-ppc64le-normal-server-
> slowdebug/jdk/bin/java
> GNU gdb (Ubuntu 7.9-1ubuntu1) 7.9
> Copyright (C) 2015 Free Software Foundation, Inc.
> License GPLv3+: GNU GPL version 3 or later
> <http://gnu.org/licenses/gpl.html>
> This is free software: you are free to change and redistribute it.
> There is NO WARRANTY, to the extent permitted by law.  Type "show
> copying"
> and "show warranty" for details.
> This GDB was configured as "powerpc64le-linux-gnu".
> Type "show configuration" for configuration details.
> For bug reporting instructions, please see:
> <http://www.gnu.org/software/gdb/bugs/>.
> Find the GDB manual and other documentation resources online at:
> <http://www.gnu.org/software/gdb/documentation/>.
> For help, type "help".
> Type "apropos word" to search for commands related to "word"...
> Reading symbols from java...done.
> (gdb 64) handle SIGILL nostop noprint pass
> Signal        Stop      Print   Pass to program Description
> SIGILL        No        No      Yes             Illegal instruction
> (gdb 64) handle SIGSEGV nostop noprint pass
> Signal        Stop      Print   Pass to program Description
> SIGSEGV       No        No      Yes             Segmentation fault
> (gdb 64) b ppc.ad:5030
> No source file named ppc.ad.
> Make breakpoint pending on future shared library load? (y or [n]) y
> Breakpoint 1 (ppc.ad:5030) pending.
> (gdb 64) r -Xcomp -XX:-UseSIGTRAP pidigits 10
> Starting program: /home/gut/hs-comp/java -Xcomp -XX:-UseSIGTRAP
> pidigits 10
> [Thread debugging using libthread_db enabled]
> Using host libthread_db library "/lib/powerpc64le-linux-
> gnu/libthread_db.so.1".
> [New Thread 0x3fffb61df1a0 (LWP 17208)]
> ... (removed for readability purposes)
> [New Thread 0x3fffb534f1a0 (LWP 17209)]
> [Switching to Thread 0x3ffe7944f1a0 (LWP 17292)]
> 
> Breakpoint 1, State::_sub_Op_LoadB (this=0x3ffe68044950,
> n=0x3ffe34326930) at /home/gut/hs-
> comp/hotspot/src/cpu/ppc/vm/ppc.ad:5031
> warning: Source file is more recent than executable.
> 5031      predicate(n->as_Load()->is_unordered() ||
> followed_by_acquire(n));
> (gdb 64) l
> 5026    %}
> 5027
> 5028    // Load Byte (8bit signed). LoadB = LoadUB + ConvUB2B.
> 5029    instruct loadB_indirect_Ex(iRegIdst dst, indirectMemory mem) %{
> 5030      match(Set dst (LoadB mem));
> 5031      predicate(n->as_Load()->is_unordered() ||
> followed_by_acquire(n));
> 5032      ins_cost(MEMORY_REF_COST + DEFAULT_COST);
> 5033      expand %{
> 5034        iRegIdst tmp;
> 5035        loadUB_indirect(tmp, mem);
> (gdb 64) n
> 7500    dfa_ppc.cpp: No such file or directory.
> (gdb 64) dir build/linux-ppc64le-normal-server-slowdebug/hotspot/variant-
> server/gensrc/adfiles/
> Source directories searched: /home/gut/hs-comp/build/linux-ppc64le-
> normal-server-slowdebug/hotspot/variant-server/gensrc/adfiles:$cdir:$cwd
> (gdb 64) l
> 7495            DFA_PRODUCTION__SET_VALID(RARG3REGI,
> loadB_indirect_ac_Ex_rule, c+1)
> 7496          }
> 7497          if (STATE__NOT_YET_VALID(RARG4REGI) || _cost[RARG4REGI] >
> c+1) {
> 7498            DFA_PRODUCTION__SET_VALID(RARG4REGI,
> loadB_indirect_ac_Ex_rule, c+1)
> 7499          }
> 7500        }
> 7501        if( STATE__VALID_CHILD(_kids[0], INDIRECTMEMORY) &&
> 7502            (
> 7503    #line 5031 "/home/gut/hs-comp/hotspot/src/cpu/ppc/vm/ppc.ad"
> 7504    n->as_Load()->is_unordered() || followed_by_acquire(n)
> (gdb 64) #WTH?!
> (gdb 64) fin
> Run till exit from #0  State::_sub_Op_LoadB (this=0x3ffe68044950,
> n=0x3ffe34326930) at dfa_ppc.cpp:7514
> State::DFA (this=0x3ffe68044950, opcode=156, n=0x3ffe34326930) at
> dfa_ppc.cpp:11395
> 11395     case Op_LoadB: { _sub_Op_LoadB(n);
> (gdb 64) n
> 11676     }
> (gdb 64)
> 11677     return true;
> (gdb 64)
> Matcher::Label_Root (this=0x3ffe7944b5d8, n=0x3ffe34326930,
> svec=0x3ffe68044950, control=0x3ffe34326748, mem=0x1)
>     at /home/gut/hs-comp/hotspot/src/share/vm/opto/matcher.cpp:1565
> 1565      for( x = 0; x < _LAST_MACH_OPER; x++ )
> 
> 
> I see that the wiki page dedicated to this topic is unfortunately empty:
> https://wiki.openjdk.java.net/display/HotSpot/UsingGDB
> 
> And I also didn't find any blog post about this (I'm considering doing one after
> I figure this out).
> 
> Thanks in advance


More information about the hotspot-compiler-dev mailing list