1""" 2Test lldb data formatter subsystem. 3""" 4 5 6import lldb 7from lldbsuite.test.decorators import * 8from lldbsuite.test.lldbtest import * 9from lldbsuite.test import lldbutil 10 11 12class LibcxxChronoDataFormatterTestCase(TestBase): 13 @add_test_categories(["libc++"]) 14 @skipIf(compiler="clang", compiler_version=["<", "17.0"]) 15 def test_with_run_command(self): 16 """Test that that file and class static variables display correctly.""" 17 isNotWindowsHost = lldbplatformutil.getHostPlatform() != "windows" 18 self.build() 19 (self.target, process, thread, bkpt) = lldbutil.run_to_source_breakpoint( 20 self, "break here", lldb.SBFileSpec("main.cpp", False) 21 ) 22 23 lldbutil.continue_to_breakpoint(process, bkpt) 24 self.expect("frame variable ns", substrs=["ns = 1 ns"]) 25 self.expect("frame variable us", substrs=["us = 12 µs"]) 26 self.expect("frame variable ms", substrs=["ms = 123 ms"]) 27 self.expect("frame variable s", substrs=["s = 1234 s"]) 28 self.expect("frame variable min", substrs=["min = 12345 min"]) 29 self.expect("frame variable h", substrs=["h = 123456 h"]) 30 31 self.expect("frame variable d", substrs=["d = 654321 days"]) 32 self.expect("frame variable w", substrs=["w = 54321 weeks"]) 33 self.expect("frame variable m", substrs=["m = 4321 months"]) 34 self.expect("frame variable y", substrs=["y = 321 years"]) 35 36 self.expect( 37 "frame variable ss_tp", 38 substrs=["ss_tp = date/time=1970-01-01T00:00:00Z timestamp=0 s"], 39 ) 40 self.expect( 41 "frame variable ss_tp_d", 42 substrs=["ss_tp_d = date/time=1970-01-01T00:00:00Z timestamp=0 s"], 43 ) 44 self.expect( 45 "frame variable ss_tp_d_r", 46 substrs=["ss_tp_d_r = date/time=1970-01-01T00:00:00Z timestamp=0 s"], 47 ) 48 self.expect( 49 "frame variable ss_tp_d_r2", 50 substrs=["ss_tp_d_r2 = date/time=1970-01-01T00:00:00Z timestamp=0 s"], 51 ) 52 53 self.expect( 54 "frame variable ss_0", 55 substrs=["ss_0 = date/time=1970-01-01T00:00:00Z timestamp=0 s"], 56 ) 57 58 self.expect( 59 "frame variable ss_neg_date_time", 60 substrs=[ 61 ( 62 "ss_neg_date_time = date/time=-32767-01-01T00:00:00Z timestamp=-1096193779200 s" 63 if isNotWindowsHost 64 else "ss_neg_date_time = timestamp=-1096193779200 s" 65 ) 66 ], 67 ) 68 self.expect( 69 "frame variable ss_neg_seconds", 70 substrs=["ss_neg_seconds = timestamp=-1096193779201 s"], 71 ) 72 73 self.expect( 74 "frame variable ss_pos_date_time", 75 substrs=[ 76 ( 77 "ss_pos_date_time = date/time=32767-12-31T23:59:59Z timestamp=971890963199 s" 78 if isNotWindowsHost 79 else "ss_pos_date_time = timestamp=971890963199 s" 80 ) 81 ], 82 ) 83 self.expect( 84 "frame variable ss_pos_seconds", 85 substrs=["ss_pos_seconds = timestamp=971890963200 s"], 86 ) 87 88 self.expect( 89 "frame variable ss_min", 90 substrs=["ss_min = timestamp=-9223372036854775808 s"], 91 ) 92 self.expect( 93 "frame variable ss_max", 94 substrs=["ss_max = timestamp=9223372036854775807 s"], 95 ) 96 97 self.expect( 98 "frame variable sd_tp", 99 substrs=["sd_tp = date=1970-01-01Z timestamp=0 days"], 100 ) 101 self.expect( 102 "frame variable sd_tp_d_r", 103 substrs=["sd_tp_d_r = date=1970-01-01Z timestamp=0 days"], 104 ) 105 self.expect( 106 "frame variable sd_tp_d_r2", 107 substrs=["sd_tp_d_r2 = date=1970-01-01Z timestamp=0 days"], 108 ) 109 110 self.expect( 111 "frame variable sd_0", substrs=["sd_0 = date=1970-01-01Z timestamp=0 days"] 112 ) 113 self.expect( 114 "frame variable sd_neg_date", 115 substrs=[ 116 ( 117 "sd_neg_date = date=-32767-01-01Z timestamp=-12687428 days" 118 if isNotWindowsHost 119 else "sd_neg_date = timestamp=-12687428 days" 120 ) 121 ], 122 ) 123 self.expect( 124 "frame variable sd_neg_days", 125 substrs=["sd_neg_days = timestamp=-12687429 days"], 126 ) 127 128 self.expect( 129 "frame variable sd_pos_date", 130 substrs=[ 131 ( 132 "sd_pos_date = date=32767-12-31Z timestamp=11248737 days" 133 if isNotWindowsHost 134 else "sd_pos_date = timestamp=11248737 days" 135 ) 136 ], 137 ) 138 self.expect( 139 "frame variable sd_pos_days", 140 substrs=["sd_pos_days = timestamp=11248738 days"], 141 ) 142 143 self.expect( 144 "frame variable sd_min", 145 substrs=["sd_min = timestamp=-2147483648 days"], 146 ) 147 self.expect( 148 "frame variable sd_max", 149 substrs=["sd_max = timestamp=2147483647 days"], 150 ) 151 152 # local_seconds aliasses 153 154 self.expect( 155 "frame variable ls_tp", 156 substrs=["ls_tp = date/time=1970-01-01T00:00:00 timestamp=0 s"], 157 ) 158 self.expect( 159 "frame variable ls_tp_d", 160 substrs=["ls_tp_d = date/time=1970-01-01T00:00:00 timestamp=0 s"], 161 ) 162 self.expect( 163 "frame variable ls_tp_d_r", 164 substrs=["ls_tp_d_r = date/time=1970-01-01T00:00:00 timestamp=0 s"], 165 ) 166 self.expect( 167 "frame variable ls_tp_d_r2", 168 substrs=["ls_tp_d_r2 = date/time=1970-01-01T00:00:00 timestamp=0 s"], 169 ) 170 171 # local_seconds 172 173 self.expect( 174 "frame variable ls_0", 175 substrs=["ls_0 = date/time=1970-01-01T00:00:00 timestamp=0 s"], 176 ) 177 178 self.expect( 179 "frame variable ls_neg_date_time", 180 substrs=[ 181 ( 182 "ls_neg_date_time = date/time=-32767-01-01T00:00:00 timestamp=-1096193779200 s" 183 if isNotWindowsHost 184 else "ls_neg_date_time = timestamp=-1096193779200 s" 185 ) 186 ], 187 ) 188 self.expect( 189 "frame variable ls_neg_seconds", 190 substrs=["ls_neg_seconds = timestamp=-1096193779201 s"], 191 ) 192 193 self.expect( 194 "frame variable ls_pos_date_time", 195 substrs=[ 196 ( 197 "ls_pos_date_time = date/time=32767-12-31T23:59:59 timestamp=971890963199 s" 198 if isNotWindowsHost 199 else "ls_pos_date_time = timestamp=971890963199 s" 200 ) 201 ], 202 ) 203 self.expect( 204 "frame variable ls_pos_seconds", 205 substrs=["ls_pos_seconds = timestamp=971890963200 s"], 206 ) 207 208 self.expect( 209 "frame variable ls_min", 210 substrs=["ls_min = timestamp=-9223372036854775808 s"], 211 ) 212 self.expect( 213 "frame variable ls_max", 214 substrs=["ls_max = timestamp=9223372036854775807 s"], 215 ) 216 217 # local_days aliasses 218 219 self.expect( 220 "frame variable ld_tp", 221 substrs=["ld_tp = date=1970-01-01 timestamp=0 days"], 222 ) 223 self.expect( 224 "frame variable ld_tp_d_r", 225 substrs=["ld_tp_d_r = date=1970-01-01 timestamp=0 days"], 226 ) 227 self.expect( 228 "frame variable ld_tp_d_r2", 229 substrs=["ld_tp_d_r2 = date=1970-01-01 timestamp=0 days"], 230 ) 231 232 # local_days 233 234 self.expect( 235 "frame variable ld_0", substrs=["ld_0 = date=1970-01-01 timestamp=0 days"] 236 ) 237 self.expect( 238 "frame variable ld_neg_date", 239 substrs=[ 240 ( 241 "ld_neg_date = date=-32767-01-01 timestamp=-12687428 days" 242 if isNotWindowsHost 243 else "ld_neg_date = timestamp=-12687428 days" 244 ) 245 ], 246 ) 247 self.expect( 248 "frame variable ld_neg_days", 249 substrs=["ld_neg_days = timestamp=-12687429 days"], 250 ) 251 252 self.expect( 253 "frame variable ld_pos_date", 254 substrs=[ 255 ( 256 "ld_pos_date = date=32767-12-31 timestamp=11248737 days" 257 if isNotWindowsHost 258 else "ld_pos_date = timestamp=11248737 days" 259 ) 260 ], 261 ) 262 self.expect( 263 "frame variable ld_pos_days", 264 substrs=["ld_pos_days = timestamp=11248738 days"], 265 ) 266 267 self.expect( 268 "frame variable ld_min", 269 substrs=["ld_min = timestamp=-2147483648 days"], 270 ) 271 self.expect( 272 "frame variable ld_max", 273 substrs=["ld_max = timestamp=2147483647 days"], 274 ) 275 276 self.expect("frame variable d_0", substrs=["d_0 = day=0"]) 277 self.expect("frame variable d_1", substrs=["d_1 = day=1"]) 278 self.expect("frame variable d_31", substrs=["d_31 = day=31"]) 279 self.expect("frame variable d_255", substrs=["d_255 = day=255"]) 280 281 self.expect("frame variable jan", substrs=["jan = month=January"]) 282 self.expect("frame variable feb", substrs=["feb = month=February"]) 283 self.expect("frame variable mar", substrs=["mar = month=March"]) 284 self.expect("frame variable apr", substrs=["apr = month=April"]) 285 self.expect("frame variable may", substrs=["may = month=May"]) 286 self.expect("frame variable jun", substrs=["jun = month=June"]) 287 self.expect("frame variable jul", substrs=["jul = month=July"]) 288 self.expect("frame variable aug", substrs=["aug = month=August"]) 289 self.expect("frame variable sep", substrs=["sep = month=September"]) 290 self.expect("frame variable oct", substrs=["oct = month=October"]) 291 self.expect("frame variable nov", substrs=["nov = month=November"]) 292 self.expect("frame variable dec", substrs=["dec = month=December"]) 293 294 self.expect("frame variable month_0", substrs=["month_0 = month=0"]) 295 self.expect("frame variable month_1", substrs=["month_1 = month=January"]) 296 self.expect("frame variable month_2", substrs=["month_2 = month=February"]) 297 self.expect("frame variable month_3", substrs=["month_3 = month=March"]) 298 self.expect("frame variable month_4", substrs=["month_4 = month=April"]) 299 self.expect("frame variable month_5", substrs=["month_5 = month=May"]) 300 self.expect("frame variable month_6", substrs=["month_6 = month=June"]) 301 self.expect("frame variable month_7", substrs=["month_7 = month=July"]) 302 self.expect("frame variable month_8", substrs=["month_8 = month=August"]) 303 self.expect("frame variable month_9", substrs=["month_9 = month=September"]) 304 self.expect("frame variable month_10", substrs=["month_10 = month=October"]) 305 self.expect("frame variable month_11", substrs=["month_11 = month=November"]) 306 self.expect("frame variable month_12", substrs=["month_12 = month=December"]) 307 self.expect("frame variable month_13", substrs=["month_13 = month=13"]) 308 self.expect("frame variable month_255", substrs=["month_255 = month=255"]) 309 310 self.expect("frame variable sun", substrs=["sun = weekday=Sunday"]) 311 self.expect("frame variable mon", substrs=["mon = weekday=Monday"]) 312 self.expect("frame variable tue", substrs=["tue = weekday=Tuesday"]) 313 self.expect("frame variable wed", substrs=["wed = weekday=Wednesday"]) 314 self.expect("frame variable thu", substrs=["thu = weekday=Thursday"]) 315 self.expect("frame variable fri", substrs=["fri = weekday=Friday"]) 316 self.expect("frame variable sat", substrs=["sat = weekday=Saturday"]) 317 318 self.expect("frame variable weekday_0", substrs=["weekday_0 = weekday=Sunday"]) 319 self.expect("frame variable weekday_1", substrs=["weekday_1 = weekday=Monday"]) 320 self.expect("frame variable weekday_2", substrs=["weekday_2 = weekday=Tuesday"]) 321 self.expect( 322 "frame variable weekday_3", substrs=["weekday_3 = weekday=Wednesday"] 323 ) 324 self.expect( 325 "frame variable weekday_4", substrs=["weekday_4 = weekday=Thursday"] 326 ) 327 self.expect("frame variable weekday_5", substrs=["weekday_5 = weekday=Friday"]) 328 self.expect( 329 "frame variable weekday_6", substrs=["weekday_6 = weekday=Saturday"] 330 ) 331 self.expect("frame variable weekday_7", substrs=["weekday_7 = weekday=Sunday"]) 332 self.expect("frame variable weekday_8", substrs=["weekday_8 = weekday=8"]) 333 self.expect("frame variable weekday_255", substrs=["weekday_255 = weekday=255"]) 334 335 self.expect( 336 "frame variable wdi_saturday_0", 337 substrs=["wdi_saturday_0 = weekday=Saturday index=0"], 338 ) 339 self.expect( 340 "frame variable wdi_monday_1", 341 substrs=["wdi_monday_1 = weekday=Monday index=1"], 342 ) 343 self.expect( 344 "frame variable wdi_invalid", 345 substrs=["wdi_invalid = weekday=255 index=255"], 346 ) 347 348 self.expect( 349 "frame variable wdl_monday", 350 substrs=["wdl_monday = weekday=Monday index=last"], 351 ) 352 self.expect( 353 "frame variable wdl_invalid", 354 substrs=["wdl_invalid = weekday=255 index=last"], 355 ) 356 357 self.expect("frame variable y_min", substrs=["y_min = year=-32767"]) 358 self.expect("frame variable y_0", substrs=["y_0 = year=0"]) 359 self.expect("frame variable y_1970", substrs=["y_1970 = year=1970"]) 360 self.expect("frame variable y_2038", substrs=["y_2038 = year=2038"]) 361 self.expect("frame variable y_max", substrs=["y_max = year=32767"]) 362 363 self.expect( 364 "frame variable md_new_years_eve", 365 substrs=["md_new_years_eve = month=December day=31"], 366 ) 367 self.expect( 368 "frame variable md_new_year", substrs=["md_new_year = month=January day=1"] 369 ) 370 self.expect( 371 "frame variable md_invalid", substrs=["md_invalid = month=255 day=255"] 372 ) 373 374 self.expect( 375 "frame variable mdl_jan", substrs=["mdl_jan = month=January day=last"] 376 ) 377 self.expect( 378 "frame variable mdl_new_years_eve", 379 substrs=["mdl_new_years_eve = month=December day=last"], 380 ) 381 382 self.expect( 383 "frame variable mwd_first_thursday", 384 substrs=["mwd_first_thursday = month=January weekday=Thursday index=1"], 385 ) 386 387 self.expect( 388 "frame variable mwdl_last_saturday", 389 substrs=["mwdl_last_saturday = month=December weekday=Saturday index=last"], 390 ) 391 392 self.expect( 393 "frame variable ym_year_zero", 394 substrs=["ym_year_zero = year=0 month=January"], 395 ) 396 397 self.expect("frame variable ymd_bc", substrs=["ymd_bc = date=-0001-03-255"]) 398 self.expect( 399 "frame variable ymd_year_zero", substrs=["ymd_year_zero = date=0000-255-25"] 400 ) 401 self.expect( 402 "frame variable ymd_unix_epoch", 403 substrs=["ymd_unix_epoch = date=1970-01-01"], 404 ) 405 406 self.expect( 407 "frame variable ymdl_bc", 408 substrs=["ymdl_bc = year=-1 month=December day=last"], 409 ) 410 self.expect( 411 "frame variable ymdl_may_1970", 412 substrs=["ymdl_may_1970 = year=1970 month=May day=last"], 413 ) 414 415 self.expect( 416 "frame variable ymwd_bc", 417 substrs=["ymwd_bc = year=-1 month=June weekday=Wednesday index=2"], 418 ) 419 self.expect( 420 "frame variable ymwd_forth_tuesday_2024", 421 substrs=[ 422 "ymwd_forth_tuesday_2024 = year=2024 month=January weekday=Tuesday index=4" 423 ], 424 ) 425 426 self.expect( 427 "frame variable ymwdl_bc", 428 substrs=["ymwdl_bc = year=-1 month=April weekday=Friday index=last"], 429 ) 430 self.expect( 431 "frame variable ymwdl_2024_last_tuesday_january", 432 substrs=[ 433 "ymwdl_2024_last_tuesday_january = year=2024 month=January weekday=Tuesday index=last" 434 ], 435 ) 436