UnicodeDecodeError for serialize SBValue description

Hi Enrico,

Instead of trying function-evaluation c_str(), I decided to decode the information from fbstring_core fields. I got it working but have two questions for it.

type summary add -F data_formatter.folly_string_formatter -x “std::fbstring_core”

Here is the output:

fr v -T small
(std::string) small = “small”

fr v -T small.store_
(std::fbstring_core) small.store_ = None

fr v -T small.store_.ml_
(std::fbstring_core::MediumLarge) small.store_.ml_ = None

Questions:

  1. Even I only added formatter for std::fbstring_core why does it work for std::string?
  2. Why the later small.store_ and small.store_.ml_ will show summary None now? I would not expect the data formatter will happen to them.

Btw: here is the implementation of fbstring_core
https://github.com/facebook/folly/blob/master/folly/FBString.h

Thanks
Jeffrey

Hi Enrico,

Instead of trying function-evaluation c_str(), I decided to decode the information from fbstring_core fields. I got it working but have two questions for it.

type summary add -F data_formatter.folly_string_formatter -x “std::fbstring_core”

Here is the output:

fr v -T small
(std::string) small = “small”

fr v -T small.store_
(std::fbstring_core) small.store_ = None

fr v -T small.store_.ml_
(std::fbstring_core::MediumLarge) small.store_.ml_ = None

Questions:

  1. Even I only added formatter for std::fbstring_core why does it work for std::string?
  2. Why the later small.store_ and small.store_.ml_ will show summary None now? I would not expect the data formatter will happen to them.

Using “-x” means you added a summary for every type that matches the regular expression “std::fbstring_core”
If you seriously only want to match “std::fbstring_core”, you should leave out the “-x” argument
That should solve the third problem you are running into

As for the first issue - I am not sure - I’d need to look at the data_formatter.py file

Btw: here is the implementation of fbstring_core
https://github.com/facebook/folly/blob/master/folly/FBString.h

Thanks
Jeffrey

Thanks,
- Enrico
:envelope_with_arrow: egranata@.com :phone: 27683

After removing the “-x” and apply the formatter to “std::string” instead of fbstring_core, it works fine now. Thanks!

Hi Enrico/Greg,

Can you help me to understand what is the difference between “p” and “fr v” command to print local variables? My data formatter works fine in all cases of “fr v”, and will fail for “p” command in some case(implementation at the end). In the debug log output below, you can see, when I use “fr v” command the “char[24]” object is summarized correctly, while “p” command fail to recognize it. I suspect “char32_t [] summary provider” may have failed in “p” case, but could not understand why.

(lldb) p small

folly_stl_string_formatter: $2 $2
folly_fbstring_core: store_ $2.store_ [115L, 109L, 97L, 108L, 108L, 0L, 0L, 0L, 235L, 46L, 64L, 0L, 0L, 0L, 0L, 0L, 80L, 213L, 255L, 255L, 255L, 127L, 0L, 18L]
category: 0
obj: (char [24]) small_ = {
[0] = ‘s’
[1] = ‘m’
[2] = ‘a’
[3] = ‘l’
[4] = ‘l’
[5] = ‘\0’
[6] = ‘\0’
[7] = ‘\0’
[8] = ‘\xeb’
[9] = ‘.’
[10] = ‘@’
[11] = ‘\0’
[12] = ‘\0’
[13] = ‘\0’
[14] = ‘\0’
[15] = ‘\0’
[16] = ‘P’
[17] = ‘\xd5’
[18] = ‘\xff’
[19] = ‘\xff’
[20] = ‘\xff’
[21] = ‘\x7f’
[22] = ‘\0’
[23] = ‘\x12’
}, None, None
(std::string) $2 = None
(lldb) fr v small
folly_stl_string_formatter: small small
folly_fbstring_core: store_ small.store_ [115L, 109L, 97L, 108L, 108L, 0L, 0L, 0L, 235L, 46L, 64L, 0L, 0L, 0L, 0L, 0L, 80L, 213L, 255L, 255L, 255L, 127L, 0L, 18L]
category: 0
obj: (char [24]) small_ = “small”, “small”, None
(std::string) small = “small”

"p" uses the expression parser and might cause code to be jitted and run in the program being debugged. If the expression is simple enough, the expression parser will emulate the IR. With "frame variable", it doesn't use the expression parser. "frame variable" can display children: "pt.x" or "pt->y", and can treat pointers as arrays: "my_ptr[12]", and can do address of "&argc" and deref pointers "*this". And the text given to "frame variable" can do all of them "&m->a.b[12].c->q".

"p" will return a ValueObject subclass that is ValueObjectConstResult. Any children will be of type ValueObjectConstResultChild. This has a copy of the expression result stored in a buffer up in LLDB itself and also down in the process itself. Each one of these result objects has a unique name like "$0", "$1", etc. Since the value is also stored in the program memory, it can be accessed by a subsequent expression.

"frame variable" will use a fully modifiable version of the ValueObject, usually a ValueObjectVariable. And any children will be ValueObjectChild.

So there might be some bugs in the ValueObjectConstResult/ValueObjectConstResultChild classes.

Let us know what you find.

Greg