diff options
-rw-r--r-- | runtime/map.h | 8 | ||||
-rw-r--r-- | testsuite/systemtap.base/array_string.exp | 45 |
2 files changed, 50 insertions, 3 deletions
diff --git a/runtime/map.h b/runtime/map.h index 6c1c855b..09e46f85 100644 --- a/runtime/map.h +++ b/runtime/map.h @@ -49,10 +49,12 @@ amount of memory. Do not increase above 5. */ #define MAX_KEY_ARITY 5 #endif -/** Maximum length of strings in maps. This sets the amount of space reserved - for each string. */ +/** Maximum length of strings in maps. This sets the amount of space + reserved for each string. This should match MAXSTRINGLEN. If + MAP_STRING_LENGTH is less than MAXSTRINGLEN, a user could get + strings truncated that are stored in arrays. */ #ifndef MAP_STRING_LENGTH -#define MAP_STRING_LENGTH 256 +#define MAP_STRING_LENGTH MAXSTRINGLEN #endif /** @cond DONT_INCLUDE */ diff --git a/testsuite/systemtap.base/array_string.exp b/testsuite/systemtap.base/array_string.exp new file mode 100644 index 00000000..92df1149 --- /dev/null +++ b/testsuite/systemtap.base/array_string.exp @@ -0,0 +1,45 @@ +# PR 11220. Make sure we can store large strings in arrays. + +if {![installtest_p]} { untested $test; return } + +set test "ARRAY_STRING" + +set test_script { + global str + global str_array[1] + + probe begin { + str = " 0:123456789+123456789+123456789+123456789+123456789+123456789 1:123456789+123456789+123456789+123456789+123456789+123456789 2:123456789+123456789+123456789+123456789+123456789+123456789 3:123456789+123456789+123456789+123456789+123456789+123456789 4:123456789+123456789+123456789+123456789+123456789+123456789 5:123456789+123456789+123456789+123456789+123456789+123456789 6:123456789+123456789+123456789+123456789+123456789+123456789 7:123456789+123456789+123456789+123456789+123456789+123456789" + str_array[0] = str + printf("systemtap starting probe\n") + } + + probe end { + printf("systemtap ending probe\n") + if (strlen(str) < 500) { + printf("string str is too short: %d\n", strlen(str)) + printf("%s\n", str) + } + if (strlen(str) == strlen(str_array[0])) { + printf("string lengths match\n") + } + else { + printf("string lengths *don't* match\n") + printf("str: %d\n", strlen(str)) + printf("str_array[0]: %d\n", strlen(str_array[0])) + } + if (str_array[0] == str) { + printf("strings match\n") + } + else { + printf("strings *don't* match!\n") + printf("str: %s\n", str) + printf("str_array[0]: %s\n", str_array[0]) + } + } +} + +set output "string lengths match\r\nstrings match\r\n" + +# Set MAXSTRINGLEN to 512 to be sure we're testing what we intend. +stap_run $test no_load $output -DMAXSTRINGLEN=512 -e $test_script |