[lldb-dev] Formatter for std::shared_ptr<std::wstring>

Alexander Angriawan angriawan at hotmail.com
Mon Aug 6 10:47:23 PDT 2012


I am using Mac OS X Version 10.7.4The following is the lldb output:







(lldb) frame variable x
(std::__1::wstring) x = {
  __r_ = {
    std::__1::__libcpp_compressed_pair_imp<std::__1::basic_string<wchar_t, std::__1::char_traits<wchar_t>, std::__1::allocator<wchar_t> >::__rep, std::__1::allocator<wchar_t> > = {
      __first_ = {
         = {
          __l = {
            __cap_ = 17
            __size_ = 12
            __data_ = 0x00000001001009c0
          }
          __s = {
             = {
              __size_ = '\x11'
              _ = \x11\0\0\0
            }
            __data_ = {
              [0] = \0\0\0\0
              [1] = \f\0\0\0
              [2] = \0\0\0\0
              [3] = \xc0\t\x10\0
              [4] = \x01\0\0\0
            }
          }
          __r = {
            __words = {
              [0] = 17
              [1] = 12
              [2] = 4296018368
            }
          }
        }
      }
    }
  }
}
(lldb) 
Thanks,PA
Date: Mon, 6 Aug 2012 11:24:48 +0200
From: nino.kettlitz at googlemail.com
To: angriawan at hotmail.com
Subject: Re: [lldb-dev] Formatter for std::shared_ptr<std::wstring>


  
    
  
  
    Hmm, thats strange.

      

      I'm currently using not the latest lldb, so maybe something
      changed.

      

      What platform are you developing on? The script is written for
      osx.

      

      Maybe you can just send me the output of "frame variable x"
      without having the script installed. Maybe the structure of your
      strings differ.

      

      

      N. 

      

      Am 06.08.12 10:54, schrieb Alexander Angriawan:

    
    
      
      Thank you Nino.
        

          
          Unfortunately the script doesn't
              work in my environment.
          GetByteSize() always return 0 in
              my case.
          

            
          ....
          
                        if _M_p_data.GetByteSize() == 1:
                            _M_p_deref =
                _M_p_data.GetUnsignedInt8(e, 0)    # utf-8
                        elif
                _M_p_data.GetByteSize() == 2:
                            _M_p_deref =
                _M_p_data.GetUnsignedInt16(e, 0)   # utf-16
                        elif
                _M_p_data.GetByteSize() == 4:
                            _M_p_deref =
                _M_p_data.GetSignedInt32(e, 0)     # utf-32
                        else:
                            _M_p_deref = -1
                        
                        if _M_p_deref <= 0:
                         break
          
          ----
          

          
          My simple
            test code:
          

          
          
            int main(int argc, const
              char * argv[])
            {
                std::wstring x = L"fooo";
                return 0;
            }
          
          

          
          ---
          JA
          

          
          

          
          

          
          

          
          

            
              Date: Mon, 6 Aug 2012 09:54:09 +0200

              From: nino.kettlitz at googlemail.com

              To: angriawan at hotmail.com

              CC: lldb-dev at cs.uiuc.edu

              Subject: Re: [lldb-dev] Formatter for
              std::shared_ptr<std::wstring>

              

              Oh,

                

                I've seen, that the script attached to the mail is not
                on the server, so I attached it again, although it would
                be better to have it in the lldb svn.

                

                Yust copy the script to your hom directory and ad the
                folowing line to your .lldbinit

                

                script sys.path[:0] = [os.path.expanduser('~')]

                command alias pwd script print os.getcwd()

                script import wstring

                type summary add --python-function
                wstring.wstring_summary "std::wstring"

                type summary add --python-function
                wstring.wstring_summary "std::basic_string<int, class
                std::char_traits<int>, class
                std::allocator<int> >"

                type summary add --python-function
                wstring.wstring_summary "std::basic_string<unsigned
                short, class std::char_traits<unsigned short>,
                class std::allocator<unsigned short> >"

                type summary add --python-function
                wstring.wstring_summary "std::basic_string<wchar_t,
                class std::char_traits<wchar_t>, class
                std::allocator<wchar_t> >"

                

                

                Cheers, Nino

                

                Am 06.08.12 09:19, schrieb Alexander Angriawan:

              
              
                
                
                  Hello,
                  

                    
                  I am looking to write data
                      formatter for std::shared_ptr<std::wstring>.
                  

                    
                  I found the following old
                      article but this doesn't seem to work.
                  I have ver 159 installed.
                  http://lists.cs.uiuc.edu/pipermail/lldb-dev/2012-February/000825.html
                  

                    
                  Any idea?
                  

                  
                  Thank you much,
                  PA
                
                

                
                

                _______________________________________________
lldb-dev mailing list
lldb-dev at cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/lldb-dev

              
              

            
          
        
      
    
    
 		 	   		  
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/lldb-dev/attachments/20120806/830e1837/attachment.html>


More information about the lldb-dev mailing list