"\[0x[0-9A-Fa-f]+f0, 0x[0-9A-Fa-f]+00\): 0xf \(mismatch\)\n"
"\[0x[0-9A-Fa-f]+00, 0x[0-9A-Fa-f]+10\): 0x0 \(mismatch\)$"])
- # Tags in start/end are ignored when creating the range.
- # So this is not an error despite start/end having different tags
- self.expect("memory tag read mte_buf mte_buf_alt_tag+16",
- patterns=["Logical tag: 0x9\n"
+ # Top byte is ignored when creating the range, not just the 4 tag bits.
+ # So even though these two pointers have different top bytes
+ # and the start's is > the end's, this is not an error.
+ self.expect("memory tag read mte_buf_alt_tag mte_buf+16",
+ patterns=["Logical tag: 0xa\n"
"Allocation tags:\n"
"\[0x[0-9A-Fa-f]+00, 0x[0-9A-Fa-f]+10\): 0x0 \(mismatch\)$"])
// Tag the original pointer with 9
mte_buf = __arm_mte_create_random_tag(mte_buf, ~(1 << 9));
- // A different tag so that buf_alt_tag > buf if you don't handle the tag
+ // A different tag so that mte_buf_alt_tag > mte_buf if you don't handle the
+ // tag
char *mte_buf_alt_tag = __arm_mte_create_random_tag(mte_buf, ~(1 << 10));
// lldb should be removing the whole top byte, not just the tags.
// So fill 63-60 with something non zero so we'll fail if we only remove tags.
-#define SET_TOP_NIBBLE(ptr) (char *)((size_t)(ptr) | (0xA << 60))
- mte_buf = SET_TOP_NIBBLE(mte_buf);
- mte_buf_alt_tag = SET_TOP_NIBBLE(mte_buf_alt_tag);
- mte_buf_2 = SET_TOP_NIBBLE(mte_buf_2);
- mte_read_only = SET_TOP_NIBBLE(mte_read_only);
+#define SET_TOP_NIBBLE(ptr, value) \
+ (char *)((size_t)(ptr) | ((size_t)((value)&0xf) << 60))
+ // mte_buf_alt_tag's nibble > mte_buf to check that lldb isn't just removing
+ // tag bits but the whole top byte when making ranges.
+ mte_buf = SET_TOP_NIBBLE(mte_buf, 0xA);
+ mte_buf_alt_tag = SET_TOP_NIBBLE(mte_buf_alt_tag, 0xB);
+ mte_buf_2 = SET_TOP_NIBBLE(mte_buf_2, 0xC);
+ mte_read_only = SET_TOP_NIBBLE(mte_read_only, 0xD);
// Breakpoint here
return 0;