Debian Codegraph @

doc/SystemTap_Beginners_Guide/testsuite/systemtap.base/utf_kernel.stp

raw
1 function utf16_addr:long() %{
2 static u16 utf16_string[] = {
3 0x73, 0x74, 0x61, 0x70, // "stap" (one-byte UTF-8 each)
4 0x7F, 0x80, // last one-byte, first two-byte
5 0x391, 0x3A9, // "ΑΩ" (two-byte UTF-8 each)
6 0x7FF, 0x800, // last two-byte, first three-byte
7 0x263A, // "☺" (three-byte UTF-8)
8 0xFFFF, 0xD800, 0xDC00, // last three-byte, first four-byte
9 0xD83D, 0xDE08, // U+1F608 "😈" (four-byte UTF-8)
10 0xDBFF, 0xDFFF, // last supported four-byte
11 0
12 };
13 STAP_RETVALUE = (intptr_t)utf16_string;
14 %}
15
16 function utf32_addr:long() %{
17 static u32 utf32_string[] = {
18 0x73, 0x74, 0x61, 0x70, // "stap" (one-byte UTF-8 each)
19 0x7F, 0x80, // last one-byte, first two-byte
20 0x391, 0x3A9, // "ΑΩ" (two-byte UTF-8 each)
21 0x7FF, 0x800, // last two-byte, first three-byte
22 0x263A, // "☺" (three-byte UTF-8)
23 0xFFFF, 0x10000, // last three-byte, first four-byte
24 0x1F608, // "😈" (four-byte UTF-8)
25 0x10FFFF, // last supported four-byte
26 0
27 };
28 STAP_RETVALUE = (intptr_t)utf32_string;
29 %}
30
31 probe begin
32 {
33 s = utf16_addr();
34 for (p = s; i = kernel_short(p) & 0xffff; p += 2)
35 printf("%X ", i)
36 println(":")
37 println(kernel_string_utf16(s))
38 println(kernel_string_quoted_utf16(s))
39
40 s = utf32_addr();
41 for (p = s; i = kernel_int(p) & 0xffffffff; p += 4)
42 printf("%X ", i)
43 println(":")
44 println(kernel_string_utf32(s))
45 println(kernel_string_quoted_utf32(s))
46
47 exit()
48 }
49