File: utf_kernel_trunc.stp

package info (click to toggle)
systemtap 5.3-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 47,556 kB
  • sloc: cpp: 81,117; ansic: 54,933; xml: 49,795; exp: 43,595; sh: 11,526; python: 5,003; perl: 2,252; tcl: 1,312; makefile: 1,006; javascript: 149; lisp: 105; awk: 101; asm: 91; java: 70; sed: 16
file content (86 lines) | stat: -rw-r--r-- 2,590 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
%{
#if MAXSTRINGLEN != 41
#error This test is hard-coded for MAXSTRINGLEN==41
#endif

#define UPTO5  '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '0', '1', '2', '3', '4', '5'
#define UPTO6  UPTO5, '6'
#define UPTO7  UPTO6, '7'
#define UPTO8  UPTO7, '8'
#define UPTO9  UPTO8, '9'


static u16 s16_len1_0[] = {UPTO8, 0x5A, 0}; // Z
static u16 s16_len1_1[] = {UPTO9, 0x5A, 0};

static u16 s16_len2_0[] = {UPTO7, 0x3A9, 0}; // Ω
static u16 s16_len2_1[] = {UPTO8, 0x3A9, 0};
static u16 s16_len2_2[] = {UPTO9, 0x3A9, 0};

static u16 s16_len3_0[] = {UPTO6, 0x263A, 0}; // ☺
static u16 s16_len3_1[] = {UPTO7, 0x263A, 0};
static u16 s16_len3_2[] = {UPTO8, 0x263A, 0};
static u16 s16_len3_3[] = {UPTO9, 0x263A, 0};

static u16 s16_len4_0[] = {UPTO5, 0xD83D, 0xDE08, 0}; // 😈
static u16 s16_len4_1[] = {UPTO6, 0xD83D, 0xDE08, 0};
static u16 s16_len4_2[] = {UPTO7, 0xD83D, 0xDE08, 0};
static u16 s16_len4_3[] = {UPTO8, 0xD83D, 0xDE08, 0};
static u16 s16_len4_4[] = {UPTO9, 0xD83D, 0xDE08, 0};

static u16 *utf16_strings[] = {
  s16_len1_0, s16_len1_1,
  s16_len2_0, s16_len2_1, s16_len2_2,
  s16_len3_0, s16_len3_1, s16_len3_2, s16_len3_3,
  s16_len4_0, s16_len4_1, s16_len4_2, s16_len4_3, s16_len4_4,
  0
};


static u32 s32_len1_0[] = {UPTO8, 0x5A, 0}; // Z
static u32 s32_len1_1[] = {UPTO9, 0x5A, 0};

static u32 s32_len2_0[] = {UPTO7, 0x3A9, 0}; // Ω
static u32 s32_len2_1[] = {UPTO8, 0x3A9, 0};
static u32 s32_len2_2[] = {UPTO9, 0x3A9, 0};

static u32 s32_len3_0[] = {UPTO6, 0x263A, 0}; // ☺
static u32 s32_len3_1[] = {UPTO7, 0x263A, 0};
static u32 s32_len3_2[] = {UPTO8, 0x263A, 0};
static u32 s32_len3_3[] = {UPTO9, 0x263A, 0};

static u32 s32_len4_0[] = {UPTO5, 0x1F608, 0}; // 😈
static u32 s32_len4_1[] = {UPTO6, 0x1F608, 0};
static u32 s32_len4_2[] = {UPTO7, 0x1F608, 0};
static u32 s32_len4_3[] = {UPTO8, 0x1F608, 0};
static u32 s32_len4_4[] = {UPTO9, 0x1F608, 0};

static u32 *utf32_strings[] = {
  s32_len1_0, s32_len1_1,
  s32_len2_0, s32_len2_1, s32_len2_2,
  s32_len3_0, s32_len3_1, s32_len3_2, s32_len3_3,
  s32_len4_0, s32_len4_1, s32_len4_2, s32_len4_3, s32_len4_4,
  0
};

%}

function utf16_addr:long(i:long) %{
  STAP_RETVALUE = (intptr_t)utf16_strings[STAP_ARG_i];
%}

function utf32_addr:long(i:long) %{
  STAP_RETVALUE = (intptr_t)utf32_strings[STAP_ARG_i];
%}

probe begin
{
  for (i = 0; s = utf16_addr(i); ++i)
    println("utf-16:", kernel_string_utf16(s))

  for (i = 0; s = utf32_addr(i); ++i)
    println("utf-32:", kernel_string_utf32(s))

  exit()
}