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

Alexander Angriawan angriawan at hotmail.com
Wed Aug 8 14:27:02 PDT 2012


Attached. But this doesn't work with global variables and I haven't had chance to look at it.

Subject: Re: [lldb-dev] Formatter for std::shared_ptr<std::wstring>
From: egranata at apple.com
Date: Wed, 8 Aug 2012 09:48:34 -0700
CC: nino.kettlitz at googlemail.com; lldb-dev at cs.uiuc.edu
To: angriawan at hotmail.com

Alexander,feel free to share your script if you desire.I can work on integrating it into mainline LLDB.
Thanks!

Enrico Granata✉ egranata@.com✆ (408) 972-7683


On Aug 7, 2012, at 8:41 PM, Alexander Angriawan <angriawan at hotmail.com> wrote:





Hi,
 
I got it working.  
I follow example from the following to navigate and Nino's script to read the char.
http://llvm.org/svn/llvm-project/lldb/trunk/examples/synthetic/libcxx.py
I can post the script if needed.
thanks,PA

 
Subject: Re: [lldb-dev] Formatter for std::shared_ptr<std::wstring>
From: egranata at apple.com
Date: Mon, 6 Aug 2012 11:54:51 -0700
CC: angriawan at hotmail.com; lldb-dev at cs.uiuc.edu
To: nino.kettlitz at googlemail.com

Alexander is using libcpp, part of the LLVM project, whereas you are using libstdcpp (a GNU project).They both implement the C++ Standard Library but with different internals!Luckily they are easy to differentiate because libcpp classes lived in a std::__1 namespace


Enrico Granata egranata@.com✆ (408) 972-7683


On Aug 6, 2012, at 11:52 AM, Nino Kettlitz <nino.kettlitz at googlemail.com> wrote:
  
    
  
  
    Hi Alexander,

      

      your string implementation looks very complicated.

      

      Also the type of the string looks strange. I would expect that
      "std::wstring" is a typedef

      for "std::basic_string<wchar_t,
      std::char_traits<wchar_t>, std::allocator<wchar_t>"

      

      You are using "std::__1::wstring" and the real type also contains
      this "__1" stuff

      "std::__1::basic_string<wchar_t,
      std::__1::char_traits<wchar_t>,
      std::__1::allocator<wchar_t>>"

      and it is additionally wrapped by a std::pair or sth similar. 

      

      I've never seen this before. Maybe somebody else in the mailing
      list did?!

      

      So the wstring.py data formater works only for std::wstring with a
      "_M_dataplus" and a "_M_p" member

      

      Cheers,

      Nino

      

      

      

      

      Am 06.08.2012 19:47, schrieb Alexander Angriawan:

    
    
      
      I am using Mac OS X Version 10.7.4
        The 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

                      
                      

                    
                  
                
              
            
            

          
        
      
    
    

  

_______________________________________________
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/20120808/934aba6b/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: formatter.bin
Type: application/octet-stream
Size: 3547 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-dev/attachments/20120808/934aba6b/attachment.bin>


More information about the lldb-dev mailing list