debuggingwindbgsos

How to output partial of the result !da address with windbg?


If the array contains 100000000 item , it is too long to output all of the itemsm so may I know if I want to just output ten items of the array with windbg, such as !da top 10 address, how to deal with it ?


Solution

  • The !da command takes -start and -length parameter:

     -start <startIndex>: optional, only supported for single dimension array. 
                          Specify from which index the command shows the elements.
     -length <length>:    optional, only supported for single dimension array. 
                          Specify how many elements to show.
    

    In you can use !mdt with the -start: and -count: parameters:

    !sosex.mdt [typename | paramname | localname | MT] [ADDR] 
               [-r[:level]] [-e[:level]] [-start:index] [-count:n]
    

    Or you can use NetExt. The !wdo command works for arrays and has /start and /end parameters to limit the indices:

    !wdo [/forcearray] [/shownull] [/noheader] [/noindex] [/mt <expr>]
         [/start <expr>] [/end <expr>] <expr>
      /mt <expr> - mt,Method table for value objects (space-delimited)
      <expr> - Address,Object Address
      /start <expr> - Starting index to show in an array (space-delimited)
      /end <expr> - Ending index to show in an array (space-delimited)
      /forcearray - For Byte[] and Char[] arrays show items not the string
      /shownull - For arrays will show items that are null
      /noheader - Display only object address and field and values
      /noindex - For arrays it will show values without the index
      /tokens - show class and type tokens for fields