<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class="">Resending without attachments….<br class=""><div><br class=""><blockquote type="cite" class=""><div class="">On Jul 14, 2021, at 10:15 PM, Andrew Fish <<a href="mailto:afish@apple.com" class="">afish@apple.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><meta http-equiv="Content-Type" content="text/html; charset=utf-8" class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class="">I’ve been watching the Le Tour replays and playing around with gdb scripts. I was trying to figure out how to do stuff I know how to do in lldb. <div class=""><br class=""></div><div class="">For lldb I have Pretty Printer and for CHAR16 things like this:</div><div class=""><br class=""></div><div class=""><div class="">CHAR16 gChar    = L'X';</div></div><div class=""><div class="">CHAR16 gStr[]   = L"1234567890\x23f3"; </div><div class="">CHAR16 *gStrPtr = gStr;      </div></div><div class=""><br class=""></div><div class=""><div class=""><span style="font-variant-ligatures: no-common-ligatures;" class="">For lldb I get:</span></div><div class=""><span style="font-variant-ligatures: no-common-ligatures;" class="">L’X’</span></div><div class=""><span style="font-variant-ligatures: no-common-ligatures;" class="">L”</span><span style="font-family: Menlo; font-size: 11px;" class="">1234567890</span><span style="font-family: Menlo; font-size: 11px;" class="">⏳</span><font face="Menlo" class=""><span style="font-size: 11px;" class="">”</span></font></div><div class=""><span style="font-family: Menlo; font-size: 11px;" class="">(CHAR16 *)</span><span style="font-variant-ligatures: no-common-ligatures;" class="">L”</span><span style="font-family: Menlo; font-size: 11px;" class="">1234567890</span><span style="font-family: Menlo; font-size: 11px;" class="">⏳</span><font face="Menlo" class=""><span style="font-size: 11px;" class="">”</span></font></div></div><div class=""><br class=""></div><div class="">The default for gdb is:</div><div class=""><div style="margin: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">(gdb) p /r gChar</span></div><div style="margin: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">$8 = 88</span></div><div style="margin: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">(gdb) p /r gStr</span></div><div style="margin: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">$9 = {49, 50, 51, 52, 53, 54, 55, 56, 57, 48, 9203, 0}</span></div><div style="margin: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">(gdb) p /r gStrPtr</span></div><div style="margin: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">$10 = (CHAR16 *) </span><span style="font-variant-ligatures: no-common-ligatures; color: #400bd9" class="">0x100008030</span><span style="font-variant-ligatures: no-common-ligatures" class=""> <</span><span style="font-variant-ligatures: no-common-ligatures; color: #9fa01c" class="">gStr</span><span style="font-variant-ligatures: no-common-ligatures" class="">></span></div></div><div class=""><br class=""></div><div class="">I’ve figured out how to teach GDB to pretty print CHAR16, but I can’t figure out how to hook CHAR16 * or CHAR16 {}?</div><div class=""><br class=""></div><div class="">This is what I’ve got (vs what gdb does for char):</div><div class=""><div style="margin: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">$1 = 88 'X'</span></div><div style="margin: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">$2 = L'X'</span></div><div style="margin: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Menlo; min-height: 13px;" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""> </span><br class="webkit-block-placeholder"></div><div style="margin: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">$3 = "1234567890"</span></div><div style="margin: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">$4 = {L'1', L'2', L'3', L'4', L'5', L'6', L'7', L'8', L'9', L'0', L'⏳', L'\x00'}</span></div><div style="margin: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Menlo; min-height: 13px;" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""> </span><br class="webkit-block-placeholder"></div><div style="margin: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">$5 = </span><span style="font-variant-ligatures: no-common-ligatures; color: #400bd9" class="">0x100008058</span><span style="font-variant-ligatures: no-common-ligatures" class=""> <</span><span style="font-variant-ligatures: no-common-ligatures; color: #9fa01c" class="">Str</span><span style="font-variant-ligatures: no-common-ligatures" class="">> "1234567890"</span></div><div style="margin: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">$6 = (CHAR16 *) </span><span style="font-variant-ligatures: no-common-ligatures; color: #400bd9" class="">0x100008030</span><span style="font-variant-ligatures: no-common-ligatures" class=""> <</span><span style="font-variant-ligatures: no-common-ligatures; color: #9fa01c" class="">gStr</span><span style="font-variant-ligatures: no-common-ligatures" class="">></span></div></div><div class=""><span style="font-variant-ligatures: no-common-ligatures" class=""><br class=""></span></div><div class="">This is the script...</div><div class="">$ cat CHAR16.py</div><div class=""><div class="">import gdb</div><div class=""><br class=""></div><div class="">from gdb.printing import register_pretty_printer</div><div class="">from gdb.printing import RegexpCollectionPrettyPrinter</div><div class=""><br class=""></div><div class=""><br class=""></div><div class="">class CHAR16_PrettyPrinter(object):</div><div class=""><br class=""></div><div class="">    def __init__(self, val):</div><div class="">        self.val = val</div><div class=""><br class=""></div><div class="">    def to_string(self):</div><div class="">        if int(self.val) < 0x20:</div><div class="">            return f"L'\\x{int(self.val):02x}'"</div><div class="">        else:</div><div class="">            return f"L'{chr(self.val):s}'"</div><div class=""><br class=""></div><div class=""><br class=""></div><div class="">def build_pretty_printer():</div><div class="">    pp = RegexpCollectionPrettyPrinter("EFI")</div><div class="">    pp.add_printer('CHAR16', '^CHAR16$', CHAR16_PrettyPrinter)</div><div class="">    return pp</div><div class=""><br class=""></div><div class=""><br class=""></div><div class="">register_pretty_printer(None, build_pretty_printer(), replace=True)</div></div><div class=""><br class=""></div><div class="">$ cat CHAR16.c</div><div class=""><div class="">#include <stdio.h></div><div class=""><br class=""></div><div class="">///</div><div class="">/// 2-byte Character.  Unless otherwise specified all strings are stored in the</div><div class="">/// UTF-16 encoding format as defined by Unicode 2.1 and ISO/IEC 10646 standards.</div><div class="">///</div><div class="">typedef unsigned short      CHAR16;</div><div class=""><br class=""></div><div class="">CHAR16 gChar    = L'X';</div><div class="">CHAR16 gChar2   = L'\x23f3';</div><div class="">CHAR16 gStr[]   = L"1234567890\x23f3"; </div><div class="">CHAR16 *gStrPtr = gStr;      </div><div class=""><br class=""></div><div class="">char Char       = 'X';</div><div class="">char Str[]      = "1234567890";</div><div class="">char *StrPtr    = Str;</div><div class=""><br class=""></div><div class="">int</div><div class="">main(int argc, char **argv)</div><div class="">{</div><div class="">  printf ("hello world!\n");</div><div class="">  return 0;</div><div class="">}</div></div><div class=""><br class=""></div><div class="">$ cat CHAR16.sh</div><div class=""><div class="">gcc -fshort-wchar -g CHAR16.c</div><div class="">gdb  -ex "source CHAR16.py" -ex "p Char" -ex "p gChar" -ex "shell echo ' '" -ex "p Str" -ex "p gStr" -ex "shell echo ' '" -ex "p StrPtr" -ex "p gStrPtr”</div></div><div class=""><br class=""></div><div class="">Given the above example you should be able to experiment with just the code in this email to figure out how to get CHAR16 working. No edk2 or EFI knowledge required, in case you have a friend who is good with gdb pretty print?</div><div class=""><br class=""></div><div class="">If you have CHAR16.sh, CHAR16.c, and CHAR16.py you can just run ./CHAR16.sh and it will print out the results for char and CHAR16 if you modify the CHAR16.py gdb Python script it will show you the results. </div><div class=""><br class=""></div><div class="">Thanks,</div><div class=""><br class=""></div><div class="">Andrew Fish</div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""></div></div><span id="cid:88502EC4-8802-4031-96D1-39E27439BE59"><CHAR16.py></span><div style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><meta http-equiv="Content-Type" content="text/html; charset=us-ascii" class=""><div class=""></div></div><span id="cid:708F83E4-1321-45B4-B4F8-12CB023B2B4C"><CHAR16.c></span><div style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><meta http-equiv="Content-Type" content="text/html; charset=us-ascii" class=""><div class=""></div></div><span id="cid:740FA0E5-95BC-44EB-9B1D-3A2DC2ECF8E3"><CHAR16.sh></span><meta http-equiv="Content-Type" content="text/html; charset=us-ascii" class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><div class=""></div><div class=""><br class=""></div></div></div></blockquote></div><br class=""></body></html>

 <div width="1" style="color:white;clear:both">_._,_._,_</div> <hr>   Groups.io Links:<p>   You receive all messages sent to this group.    <p> <a target="_blank" href="https://edk2.groups.io/g/devel/message/77817">View/Reply Online (#77817)</a> |    |  <a target="_blank" href="https://groups.io/mt/84219086/1813853">Mute This Topic</a>  | <a href="https://edk2.groups.io/g/devel/post">New Topic</a><br>    <a href="https://edk2.groups.io/g/devel/editsub/1813853">Your Subscription</a> | <a href="mailto:devel+owner@edk2.groups.io">Contact Group Owner</a> |  <a href="https://edk2.groups.io/g/devel/unsub">Unsubscribe</a>  [edk2-devel-archive@redhat.com]<br> <div width="1" style="color:white;clear:both">_._,_._,_</div>