|
50 | 50 | _type_unsigned_char_ptr = gdb.lookup_type('unsigned char').pointer() # unsigned char* |
51 | 51 | _type_void_ptr = gdb.lookup_type('void').pointer() # void* |
52 | 52 | _type_size_t = gdb.lookup_type('size_t') |
| 53 | +_type_unsigned_short_ptr = gdb.lookup_type('unsigned short').pointer() |
| 54 | +_type_unsigned_int_ptr = gdb.lookup_type('unsigned int').pointer() |
53 | 55 |
|
54 | 56 | _is_pep393 = 'data' in [f.name for f in gdb.lookup_type('PyUnicodeObject').target().fields()] |
55 | 57 |
|
@@ -1124,25 +1126,36 @@ def proxyval(self, visited): |
1124 | 1126 | # From unicodeobject.h: |
1125 | 1127 | # Py_ssize_t length; /* Length of raw Unicode data in buffer */ |
1126 | 1128 | # Py_UNICODE *str; /* Raw Unicode buffer */ |
1127 | | - field_length = long(self.field('length')) |
1128 | 1129 | if _is_pep393: |
1129 | 1130 | # Python 3.3 and newer |
1130 | 1131 | may_have_surrogates = False |
1131 | | - field_state = long(self.field('state')) |
1132 | | - repr_kind = (field_state & 0xC) >> 2 |
1133 | | - if repr_kind == 0: |
| 1132 | + compact = self.field('_base') |
| 1133 | + ascii = compact['_base'] |
| 1134 | + state = ascii['state'] |
| 1135 | + field_length = long(ascii['length']) |
| 1136 | + if not int(state['ready']): |
1134 | 1137 | # string is not ready |
1135 | 1138 | may_have_surrogates = True |
1136 | | - field_str = self.field('wstr') |
1137 | | - field_length = self.field('wstr_length') |
1138 | | - elif repr_kind == 1: |
1139 | | - field_str = self.field('data')['latin1'] |
1140 | | - elif repr_kind == 2: |
1141 | | - field_str = self.field('data')['ucs2'] |
1142 | | - elif repr_kind == 3: |
1143 | | - field_str = self.field('data')['ucs4'] |
| 1139 | + field_str = ascii['wstr'] |
| 1140 | + if not int(state['ascii']): |
| 1141 | + field_length = compact('wstr_length') |
| 1142 | + else: |
| 1143 | + if int(state['ascii']): |
| 1144 | + field_str = ascii.address + 1 |
| 1145 | + elif int(state['compact']): |
| 1146 | + field_str = compact.address + 1 |
| 1147 | + else: |
| 1148 | + field_str = self.field('data')['any'] |
| 1149 | + repr_kind = int(state['kind']) |
| 1150 | + if repr_kind == 1: |
| 1151 | + field_str = field_str.cast(_type_unsigned_char_ptr) |
| 1152 | + elif repr_kind == 2: |
| 1153 | + field_str = field_str.cast(_type_unsigned_short_ptr) |
| 1154 | + elif repr_kind == 3: |
| 1155 | + field_str = field_str.cast(_type_unsigned_int_ptr) |
1144 | 1156 | else: |
1145 | 1157 | # Python 3.2 and earlier |
| 1158 | + field_length = long(self.field('length')) |
1146 | 1159 | field_str = self.field('str') |
1147 | 1160 | may_have_surrogates = self.char_width() == 2 |
1148 | 1161 |
|
|
0 commit comments