1 #include <string> 2 #include <cstring> 3 4 struct A { 5 char data[4]; 6 char overflow[4]; 7 }; 8 9 #define MAKE_VARS3(c, v, s) \ 10 c v s char c##v##s##chararray[] = #c #v #s "char"; \ 11 c v s char *c##v##s##charstar = c##v##s##chararray 12 #define MAKE_VARS2(c, v) \ 13 MAKE_VARS3(c, v, ); \ 14 MAKE_VARS3(c, v, signed); \ 15 MAKE_VARS3(c, v, unsigned) 16 #define MAKE_VARS(c) \ 17 MAKE_VARS2(c, ); \ 18 MAKE_VARS2(c, volatile) 19 20 MAKE_VARS(); 21 MAKE_VARS(const); 22 23 template<typename T> 24 struct S { 25 int x = 0; 26 }; 27 S<char[5]> Schar5; 28 S<char *> Scharstar; 29 30 int main (int argc, char const *argv[]) 31 { 32 A a, b, c; 33 // Deliberately write past the end of data to test that the formatter stops 34 // at the end of array. 35 memcpy(a.data, "FOOBAR", 7); 36 memcpy(b.data, "FO\0BAR", 7); 37 memcpy(c.data, "F\0O\0AR", 7); 38 std::string stdstring("Hello\t\tWorld\nI am here\t\tto say hello\n"); //%self.addTearDownHook(lambda x: x.runCmd("setting set escape-non-printables true")) 39 const char *charwithtabs = stdstring.c_str(); 40 std::string longstring( 41 "I am a very long string; in fact I am longer than any reasonable length that a string should be; quite long indeed; oh my, so many words; so many letters; this is kind of like writing a poem; except in real life all that is happening" 42 " is just me producing a very very long set of words; there is text here, text there, text everywhere; it fills me with glee to see so much text; all around me it's just letters, and symbols, and other pleasant drawings that cause me" 43 " a large amount of joy upon visually seeing them with my eyes; well, this is now a lot of letters, but it is still not enough for the purpose of the test I want to test, so maybe I should copy and paste this a few times, you know.." 44 " for science, or something" 45 "I am a very long string; in fact I am longer than any reasonable length that a string should be; quite long indeed; oh my, so many words; so many letters; this is kind of like writing a poem; except in real life all that is happening" 46 " is just me producing a very very long set of words; there is text here, text there, text everywhere; it fills me with glee to see so much text; all around me it's just letters, and symbols, and other pleasant drawings that cause me" 47 " a large amount of joy upon visually seeing them with my eyes; well, this is now a lot of letters, but it is still not enough for the purpose of the test I want to test, so maybe I should copy and paste this a few times, you know.." 48 " for science, or something" 49 "I am a very long string; in fact I am longer than any reasonable length that a string should be; quite long indeed; oh my, so many words; so many letters; this is kind of like writing a poem; except in real life all that is happening" 50 " is just me producing a very very long set of words; there is text here, text there, text everywhere; it fills me with glee to see so much text; all around me it's just letters, and symbols, and other pleasant drawings that cause me" 51 " a large amount of joy upon visually seeing them with my eyes; well, this is now a lot of letters, but it is still not enough for the purpose of the test I want to test, so maybe I should copy and paste this a few times, you know.." 52 " for science, or something" 53 ); 54 const char* longconstcharstar = longstring.c_str(); 55 return 0; //% if self.TraceOn(): self.runCmd('frame variable') 56 //% 57 //% self.expect_var_path('stdstring', summary='"Hello\\t\\tWorld\\nI am here\\t\\tto say hello\\n"') 58 //% self.expect_var_path('charwithtabs', summary='"Hello\\t\\tWorld\\nI am here\\t\\tto say hello\\n"') 59 //% self.expect_var_path("a.data", summary='"FOOB"') 60 //% self.expect_var_path("b.data", summary=r'"FO\0B"') 61 //% self.expect_var_path("c.data", summary=r'"F\0O"') 62 //% 63 //% for c in ["", "const"]: 64 //% for v in ["", "volatile"]: 65 //% for s in ["", "unsigned"]: 66 //% summary = '"'+c+v+s+'char"' 67 //% self.expect_var_path(c+v+s+"chararray", summary=summary) 68 //% # These should be printed normally 69 //% self.expect_var_path(c+v+s+"charstar", summary=summary) 70 //% Schar5 = self.expect_var_path("Schar5", 71 //% children=[ValueCheck(name="x", value="0")]) 72 //% self.assertIsNone(Schar5.GetSummary()) 73 //% Scharstar = self.expect_var_path("Scharstar", 74 //% children=[ValueCheck(name="x", value="0")]) 75 //% self.assertIsNone(Scharstar.GetSummary()) 76 //% 77 //% self.runCmd("setting set escape-non-printables false") 78 //% self.expect_var_path('stdstring', summary='"Hello\t\tWorld\nI am here\t\tto say hello\n"') 79 //% self.expect_var_path('charwithtabs', summary='"Hello\t\tWorld\nI am here\t\tto say hello\n"') 80 //% self.assertTrue(self.frame().FindVariable('longstring').GetSummary().endswith('"...')) 81 //% self.assertTrue(self.frame().FindVariable('longconstcharstar').GetSummary().endswith('"...')) 82 // FIXME: make "b.data" and "c.data" work sanely 83 } 84 85