jarin added a comment.

In D72133#1806822 <https://reviews.llvm.org/D72133#1806822>, @clayborg wrote:

> So as long as the following are true from this patch I am ok:
>
> - if I ask for the array element type of "str" in the test that was added, it 
> should return "MCHAR". We shouldn't be removing any typedefs from the type. 
> The user can call SBType::GetCanonicalType() if they need to (or equivalent 
> with internal APIs)


As discussed before, this works exactly the same way without my patch.

> - If there are no formatters for "MCHAR[]" we can fall back to "char[]".

This works. If there is formatter for MCHAR[], we use that formatter.

Note that if there is formatter for the element type (MCHAR), the command 
interpreter will not use that one because of the logic in 
ValueObjectPrinter::ShouldPrintChildren (which only expands children if the 
summary formatter says it has children or if there is no summary formatter). 
This might be a CLI usability regression.

> - If there are no formatters for "MMCHAR[]" from my example we fall back to 
> the _first_ array formatter that supports the array of typedefs, or back to 
> the the array of canonical types. Only the first array based formatter should 
> be returned as the desired formatter

This also works. Here is an example:

  (lldb) b df.cc:7
  Breakpoint 1: where = df.out`main + 61 at df.cc:7:3, address = 
0x000000000040114d
  (lldb) r
  ...
  (lldb) p m
  (MCHAR [10]) $0 = "m1"
  (lldb) p mm
  (MMCHAR [10]) $1 = "m2"
  (lldb) type summary add --summary-string "-- mchar --" -x "MCHAR \[[0-9]+]"
  (lldb) p m
  (MCHAR [10]) $2 = -- mchar --
  (lldb) p mm
  (MMCHAR [10]) $3 = -- mchar --
  (lldb) type summary add --summary-string "-- mmchar --" -x "MMCHAR \[[0-9]+]"
  (lldb) p m
  (MCHAR [10]) $6 = -- mchar --
  (lldb) p mm
  (MMCHAR [10]) $7 = -- mmchar --

Here is the program:

  typedef char MCHAR;
  typedef MCHAR MMCHAR;
  
  int main() {
    MMCHAR mm[10] = "m2";
    MCHAR m[10] = "m1";
    return 0;  // break here
  }




CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D72133/new/

https://reviews.llvm.org/D72133



_______________________________________________
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to