diff options
Diffstat (limited to 'erts/etc/unix/etp-commands.in')
| -rw-r--r-- | erts/etc/unix/etp-commands.in | 214 | 
1 files changed, 213 insertions, 1 deletions
| diff --git a/erts/etc/unix/etp-commands.in b/erts/etc/unix/etp-commands.in index 19c92681d0..141d51824f 100644 --- a/erts/etc/unix/etp-commands.in +++ b/erts/etc/unix/etp-commands.in @@ -1130,6 +1130,39 @@ document etp-cp  %---------------------------------------------------------------------------  end +define etp-check-beam-ranges +  set $etp_ci = 0 +  while $etp_ci < 3 +    printf "Checking code index %i...\n", $etp_ci +    set $etp_j = 0 +    while $etp_j < r[$etp_ci].n +      set $etp_p = &r[$etp_ci].modules[$etp_j] +      if $etp_j > 0 && $etp_p->start < (Range*)$etp_p[-1].end.counter +        printf "r[%i].modules[%i]: ERROR start < previous\n", $etp_ci, $etp_j +      end +      if $etp_p->start > (Range*)$etp_p->end.counter +        printf "r[%i].modules[%i]: ERROR start > end\n", $etp_ci, $etp_j +      else +        if $etp_p->start == (Range*)$etp_p->end.counter +          printf "r[%i].modules[%i]: Purged\n", $etp_ci, $etp_j +        end +      end +      set $etp_j = $etp_j + 1 +    end +    set $etp_ci = $etp_ci + 1 +  end +end + +document etp-check-beam-ranges +%--------------------------------------------------------------------------- +% etp-check-beam-ranges +% +% Do consistency check of beam_ranges data structure +% and print errors and empty slots from purged modules. +%--------------------------------------------------------------------------- +end + +  ############################################################################  # Commands for special term bunches.  # @@ -2401,7 +2434,7 @@ define etp-system-info    printf "ERTS version: %s\n", etp_erts_version    printf "Compile date: %s\n", etp_compile_date    printf "Arch: %s\n", etp_arch -  printf "Endianess: " +  printf "Endianness: "    if (etp_big_endian)      printf "Big\n"    else @@ -2842,6 +2875,152 @@ document etp-search-alloc  end +define etp-alloc-stats +  printf "\nIx Name    Inst.   Blocks        Bytes    Carriers    Crr.bytes  Util\n" +  set $etp_tot_block_no = 0 +  set $etp_tot_block_sz = 0 +  set $etp_tot_crr_no = 0 +  set $etp_tot_crr_sz = 0 +  set $etp_ERTS_ALC_A_MIN = 1 +  set $etp_ERTS_ALC_A_MAX = (sizeof(erts_allctrs) / sizeof(*erts_allctrs)) - 1 + +  set $etp_ix = $etp_ERTS_ALC_A_MIN +  while $etp_ix <= $etp_ERTS_ALC_A_MAX +    set $etp_allctr = 0 +    set $etp_alloc = erts_allctrs[$etp_ix].alloc +    if $etp_alloc != erts_sys_alloc +      if $etp_alloc == erts_alcu_alloc_thr_spec || \ +         $etp_alloc == erts_alcu_alloc_thr_pref +        set $etp_instance = 0 +        set $etp_block_no = 0 +        set $etp_block_sz = 0 +        set $etp_crr_no = 0 +        set $etp_crr_sz = 0 +        set $etp_tspec = (ErtsAllocatorThrSpec_t *) erts_allctrs[$etp_ix].extra +	if $etp_tspec->enabled +          while $etp_instance < $etp_tspec->size +            set $etp_allctr = $etp_tspec->allctr[$etp_instance] +            set $etp_block_no = $etp_block_no + $etp_allctr->mbcs.blocks.curr.no \ +					      + $etp_allctr->sbcs.blocks.curr.no +            set $etp_block_sz = $etp_block_sz + $etp_allctr->mbcs.blocks.curr.size \ +					      + $etp_allctr->sbcs.blocks.curr.size +            set $etp_crr_no = $etp_crr_no + $etp_allctr->mbcs.curr.norm.mseg.no \ +					  + $etp_allctr->sbcs.curr.norm.mseg.no \ +					  + $etp_allctr->mbcs.curr.norm.sys_alloc.no \ +					  + $etp_allctr->sbcs.curr.norm.sys_alloc.no +            set $etp_crr_sz = $etp_crr_sz + $etp_allctr->mbcs.curr.norm.mseg.size \ +					  + $etp_allctr->sbcs.curr.norm.mseg.size \ +					  + $etp_allctr->mbcs.curr.norm.sys_alloc.size \ +					  + $etp_allctr->sbcs.curr.norm.sys_alloc.size +            set $etp_instance = $etp_instance + 1 +          end +	else +          printf "erts_allctr[%d]: Disabled (thread specific)\n", $etp_ix +	end +      else +        if $etp_alloc == erts_alcu_alloc_ts || $etp_alloc == erts_alcu_alloc +          set $etp_allctr = (Allctr_t*) erts_allctrs[$etp_ix].extra +          set $etp_block_no = $etp_allctr->mbcs.blocks.curr.no \ +			    + $etp_allctr->sbcs.blocks.curr.no +          set $etp_block_sz = $etp_allctr->mbcs.blocks.curr.size \ +			    + $etp_allctr->sbcs.blocks.curr.size +          set $etp_crr_no = $etp_allctr->mbcs.curr.norm.mseg.no \ +			  + $etp_allctr->sbcs.curr.norm.mseg.no \ +			  + $etp_allctr->mbcs.curr.norm.sys_alloc.no \ +			  + $etp_allctr->sbcs.curr.norm.sys_alloc.no +          set $etp_crr_sz = $etp_allctr->mbcs.curr.norm.mseg.size \ +			  + $etp_allctr->sbcs.curr.norm.mseg.size \ +			  + $etp_allctr->mbcs.curr.norm.sys_alloc.size \ +			  + $etp_allctr->sbcs.curr.norm.sys_alloc.size +	  set $etp_instance = 1 +        else +          printf "erts_allctr[%d]: Unknown allocation function: ", $etp_ix +          p $etp_alloc +        end +      end +    end +    if $etp_allctr != 0 +      printf "%2d %-8s%2d%12lu%13lu%12lu%13lu", $etp_ix, $etp_allctr->name_prefix, \ +	     $etp_instance, \ +	     $etp_block_no, $etp_block_sz, $etp_crr_no, $etp_crr_sz +      if $etp_crr_sz != 0 +        printf "%5lu%%", ($etp_block_sz * 100) / $etp_crr_sz +      end +      printf "\n" +      set $etp_tot_block_no = $etp_tot_block_no + $etp_block_no +      set $etp_tot_block_sz = $etp_tot_block_sz + $etp_block_sz +      set $etp_tot_crr_no = $etp_tot_crr_no + $etp_crr_no +      set $etp_tot_crr_sz = $etp_tot_crr_sz + $etp_crr_sz +    end +    set $etp_ix = $etp_ix + 1 +  end +  printf "\nTotal:       %12lu%13lu%12lu%13lu", $etp_tot_block_no, $etp_tot_block_sz, \ +				     $etp_tot_crr_no, $etp_tot_crr_sz +  if $etp_tot_crr_sz != 0 +    printf "%5lu%%", ($etp_tot_block_sz * 100) / $etp_tot_crr_sz +  end +  printf "\n" +end + +document etp-alloc-stats +%--------------------------------------------------------------------------- +% etp-alloc-stats +% +% Combine and print allocator statistics +%--------------------------------------------------------------------------- +end + + +define etp-alloc-instances +  set $etp_ERTS_ALC_A_MIN = 1 +  set $etp_ERTS_ALC_A_MAX = (sizeof(erts_allctrs) / sizeof(*erts_allctrs)) - 1 + +  set $etp_ix = $arg0 +  if $etp_ix >= $etp_ERTS_ALC_A_MIN && $etp_ix <= $etp_ERTS_ALC_A_MAX +    set $etp_allctr = 0 +    set $etp_alloc = erts_allctrs[$etp_ix].alloc +    if $etp_alloc == erts_sys_alloc +      printf "Allocator %d is sys_alloc\n", $etp_ix +    else +      if $etp_alloc == erts_alcu_alloc_thr_spec || \ +         $etp_alloc == erts_alcu_alloc_thr_pref +        set $etp_instance = 0 +        set $etp_tspec = (ErtsAllocatorThrSpec_t *) erts_allctrs[$etp_ix].extra +	if $etp_tspec->enabled +          printf "All instances for allocator '%s'\n", $etp_tspec->allctr[0]->name_prefix +          while $etp_instance < $etp_tspec->size +	    p $etp_tspec->allctr[$etp_instance] +            set $etp_instance = $etp_instance + 1 +          end +	else +          printf "erts_allctr[%d]: Disabled (thread specific)\n", $etp_ix +	end +      else +        if $etp_alloc == erts_alcu_alloc_ts || $etp_alloc == erts_alcu_alloc +          set $etp_allctr = (Allctr_t*) erts_allctrs[$etp_ix].extra +          printf "Single instances for allocator '%s'\n", $etp_allctr->name_prefix +	  p $etp_allctr +        else +          printf "erts_allctr[%d]: Unknown allocation function: ", $etp_ix +          p $etp_alloc +        end +      end +    end +  else +    printf "Allocator type not between %d and %d\n", $etp_ERTS_ALC_A_MIN, $etp_ERTS_ALC_A_MAX +  end +end + +document etp-alloc-instances +%--------------------------------------------------------------------------- +% etp-alloc-instances +% +% Print pointers to all allocator instances for a specific type (Ix) +%--------------------------------------------------------------------------- +end + + +  define etp-overlapped-heaps  # Args:  @@ -3406,6 +3585,39 @@ document etp-carrier-blocks  %---------------------------------------------------------------------------  end +define etp-address-to-beam-opcode +  set $etp_i = 0 +  set $etp_min_diff = ((UWord)1 << (sizeof(UWord)*8 - 1)) +  set $etp_min_opcode = -1 +  set $etp_addr = (UWord) ($arg0) + +  while $etp_i < num_instructions && $etp_min_diff > 0 +    if ($etp_addr - (UWord)beam_ops[$etp_i]) < $etp_min_diff +      set $etp_min_diff = $etp_addr - (UWord)beam_ops[$etp_i] +      set $etp_min_opcode = $etp_i +    end +    set $etp_i = $etp_i + 1 +  end +  if $etp_min_diff == 0 +    printf "Address %p is start of '%s'\n", $etp_addr, opc[$etp_min_opcode].name +  else +    if $etp_min_opcode >= 0 +      printf "Address is %ld bytes into opcode '%s' at %p\n", $etp_min_diff, opc[$etp_min_opcode].name, beam_ops[$etp_min_opcode] +    else +      printf "Invalid opcode address\n" +    end +  end +end + +document etp-address-to-beam-opcode +%--------------------------------------------------------------------------- +% Get beam opcode from a native instruction address (within process_main()) +% Arg: Instructon pointer value +% +% Does not work with NO_JUMP_TABLE +%--------------------------------------------------------------------------- +end +  ############################################################################  # Toolbox parameter handling | 
