================
@@ -373,7 +373,6 @@ void yaml::MappingContextTraits<MemoryDescriptor, 
yaml::BinaryRef>::mapping(
 void yaml::MappingContextTraits<MemoryDescriptor_64, yaml::BinaryRef>::mapping(
     IO &IO, MemoryDescriptor_64 &Memory, BinaryRef &Content) {
   mapRequiredHex(IO, "Start of Memory Range", Memory.StartOfMemoryRange);
-  mapRequiredHex(IO, "Data Size", Memory.DataSize);
----------------
labath wrote:

> Content isn't initialized when the mapping is being configured, so 
> binary_size() always resolves to 0.

Are you sure about that? Did you put this line after the line that initializes 
the `Content` field?

This pattern really should work, as that's the same one used for 
RawContentStream. And now that I've looked into it more closely, I think it'd 
be best to do exactly the same thing as RawContentStream does, where a smaller 
DataSize field is an error, and a larger value just pads the output with zeroes 
(so if you just want a field of a certain size, and don't care about the 
contents, you can just put `DataSize: 47` and omit the Content entirely:

```
$ yaml2obj <<EOF | obj2yaml
--- !minidump
Streams:
  - Type:            LinuxAuxv
    Size:            100
    Content:         DEADBEEFBAADF00D
EOF
--- !minidump
Streams:
  - Type:            LinuxAuxv
    Content:         
DEADBEEFBAADF00D0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
...

$ yaml2obj <<EOF
--- !minidump
Streams:
  - Type:            LinuxAuxv
    Size:            7
    Content:         DEADBEEFBAADF00D
EOF                                  
YAML:3:5: error: Stream size must be greater or equal to the content size
  - Type:            LinuxAuxv
    ^
yaml2obj: error: failed to parse YAML input: Invalid argument

$ yaml2obj <<EOF | obj2yaml
--- !minidump
Streams:                      
  - Type:            LinuxAuxv
    Size:            10 
EOF                                  
--- !minidump
Streams:
  - Type:            LinuxAuxv
    Content:         '00000000000000000000'
...

```

https://github.com/llvm/llvm-project/pull/101272
_______________________________________________
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to