@@ -1150,6 +1150,16 @@ void kdb_set_current_task(struct task_struct *p)
1150
1150
kdb_current_regs = NULL ;
1151
1151
}
1152
1152
1153
+ static void drop_newline (char * buf )
1154
+ {
1155
+ size_t len = strlen (buf );
1156
+
1157
+ if (len == 0 )
1158
+ return ;
1159
+ if (* (buf + len - 1 ) == '\n' )
1160
+ * (buf + len - 1 ) = '\0' ;
1161
+ }
1162
+
1153
1163
/*
1154
1164
* kdb_local - The main code for kdb. This routine is invoked on a
1155
1165
* specific processor, it is not global. The main kdb() routine
@@ -1327,6 +1337,7 @@ static int kdb_local(kdb_reason_t reason, int error, struct pt_regs *regs,
1327
1337
cmdptr = cmd_head ;
1328
1338
diag = kdb_parse (cmdbuf );
1329
1339
if (diag == KDB_NOTFOUND ) {
1340
+ drop_newline (cmdbuf );
1330
1341
kdb_printf ("Unknown kdb command: '%s'\n" , cmdbuf );
1331
1342
diag = 0 ;
1332
1343
}
@@ -1566,6 +1577,7 @@ static int kdb_md(int argc, const char **argv)
1566
1577
int symbolic = 0 ;
1567
1578
int valid = 0 ;
1568
1579
int phys = 0 ;
1580
+ int raw = 0 ;
1569
1581
1570
1582
kdbgetintenv ("MDCOUNT" , & mdcount );
1571
1583
kdbgetintenv ("RADIX" , & radix );
@@ -1575,9 +1587,10 @@ static int kdb_md(int argc, const char **argv)
1575
1587
repeat = mdcount * 16 / bytesperword ;
1576
1588
1577
1589
if (strcmp (argv [0 ], "mdr" ) == 0 ) {
1578
- if (argc != 2 )
1590
+ if (argc == 2 || (argc == 0 && last_addr != 0 ))
1591
+ valid = raw = 1 ;
1592
+ else
1579
1593
return KDB_ARGCOUNT ;
1580
- valid = 1 ;
1581
1594
} else if (isdigit (argv [0 ][2 ])) {
1582
1595
bytesperword = (int )(argv [0 ][2 ] - '0' );
1583
1596
if (bytesperword == 0 ) {
@@ -1613,7 +1626,10 @@ static int kdb_md(int argc, const char **argv)
1613
1626
radix = last_radix ;
1614
1627
bytesperword = last_bytesperword ;
1615
1628
repeat = last_repeat ;
1616
- mdcount = ((repeat * bytesperword ) + 15 ) / 16 ;
1629
+ if (raw )
1630
+ mdcount = repeat ;
1631
+ else
1632
+ mdcount = ((repeat * bytesperword ) + 15 ) / 16 ;
1617
1633
}
1618
1634
1619
1635
if (argc ) {
@@ -1630,7 +1646,10 @@ static int kdb_md(int argc, const char **argv)
1630
1646
diag = kdbgetularg (argv [nextarg ], & val );
1631
1647
if (!diag ) {
1632
1648
mdcount = (int ) val ;
1633
- repeat = mdcount * 16 / bytesperword ;
1649
+ if (raw )
1650
+ repeat = mdcount ;
1651
+ else
1652
+ repeat = mdcount * 16 / bytesperword ;
1634
1653
}
1635
1654
}
1636
1655
if (argc >= nextarg + 1 ) {
@@ -1640,8 +1659,15 @@ static int kdb_md(int argc, const char **argv)
1640
1659
}
1641
1660
}
1642
1661
1643
- if (strcmp (argv [0 ], "mdr" ) == 0 )
1644
- return kdb_mdr (addr , mdcount );
1662
+ if (strcmp (argv [0 ], "mdr" ) == 0 ) {
1663
+ int ret ;
1664
+ last_addr = addr ;
1665
+ ret = kdb_mdr (addr , mdcount );
1666
+ last_addr += mdcount ;
1667
+ last_repeat = mdcount ;
1668
+ last_bytesperword = bytesperword ; // to make REPEAT happy
1669
+ return ret ;
1670
+ }
1645
1671
1646
1672
switch (radix ) {
1647
1673
case 10 :
@@ -2473,52 +2499,17 @@ static int kdb_kill(int argc, const char **argv)
2473
2499
return 0 ;
2474
2500
}
2475
2501
2476
- struct kdb_tm {
2477
- int tm_sec ; /* seconds */
2478
- int tm_min ; /* minutes */
2479
- int tm_hour ; /* hours */
2480
- int tm_mday ; /* day of the month */
2481
- int tm_mon ; /* month */
2482
- int tm_year ; /* year */
2483
- };
2484
-
2485
- static void kdb_gmtime (struct timespec * tv , struct kdb_tm * tm )
2486
- {
2487
- /* This will work from 1970-2099, 2100 is not a leap year */
2488
- static int mon_day [] = { 31 , 29 , 31 , 30 , 31 , 30 , 31 ,
2489
- 31 , 30 , 31 , 30 , 31 };
2490
- memset (tm , 0 , sizeof (* tm ));
2491
- tm -> tm_sec = tv -> tv_sec % (24 * 60 * 60 );
2492
- tm -> tm_mday = tv -> tv_sec / (24 * 60 * 60 ) +
2493
- (2 * 365 + 1 ); /* shift base from 1970 to 1968 */
2494
- tm -> tm_min = tm -> tm_sec / 60 % 60 ;
2495
- tm -> tm_hour = tm -> tm_sec / 60 / 60 ;
2496
- tm -> tm_sec = tm -> tm_sec % 60 ;
2497
- tm -> tm_year = 68 + 4 * (tm -> tm_mday / (4 * 365 + 1 ));
2498
- tm -> tm_mday %= (4 * 365 + 1 );
2499
- mon_day [1 ] = 29 ;
2500
- while (tm -> tm_mday >= mon_day [tm -> tm_mon ]) {
2501
- tm -> tm_mday -= mon_day [tm -> tm_mon ];
2502
- if (++ tm -> tm_mon == 12 ) {
2503
- tm -> tm_mon = 0 ;
2504
- ++ tm -> tm_year ;
2505
- mon_day [1 ] = 28 ;
2506
- }
2507
- }
2508
- ++ tm -> tm_mday ;
2509
- }
2510
-
2511
2502
/*
2512
2503
* Most of this code has been lifted from kernel/timer.c::sys_sysinfo().
2513
2504
* I cannot call that code directly from kdb, it has an unconditional
2514
2505
* cli()/sti() and calls routines that take locks which can stop the debugger.
2515
2506
*/
2516
2507
static void kdb_sysinfo (struct sysinfo * val )
2517
2508
{
2518
- struct timespec uptime ;
2519
- ktime_get_ts ( & uptime );
2509
+ u64 uptime = ktime_get_mono_fast_ns () ;
2510
+
2520
2511
memset (val , 0 , sizeof (* val ));
2521
- val -> uptime = uptime . tv_sec ;
2512
+ val -> uptime = div_u64 ( uptime , NSEC_PER_SEC ) ;
2522
2513
val -> loads [0 ] = avenrun [0 ];
2523
2514
val -> loads [1 ] = avenrun [1 ];
2524
2515
val -> loads [2 ] = avenrun [2 ];
@@ -2533,8 +2524,8 @@ static void kdb_sysinfo(struct sysinfo *val)
2533
2524
*/
2534
2525
static int kdb_summary (int argc , const char * * argv )
2535
2526
{
2536
- struct timespec now ;
2537
- struct kdb_tm tm ;
2527
+ time64_t now ;
2528
+ struct tm tm ;
2538
2529
struct sysinfo val ;
2539
2530
2540
2531
if (argc )
@@ -2548,9 +2539,9 @@ static int kdb_summary(int argc, const char **argv)
2548
2539
kdb_printf ("domainname %s\n" , init_uts_ns .name .domainname );
2549
2540
kdb_printf ("ccversion %s\n" , __stringify (CCVERSION ));
2550
2541
2551
- now = __current_kernel_time ();
2552
- kdb_gmtime ( & now , & tm );
2553
- kdb_printf ("date %04d -%02d-%02d %02d:%02d:%02d "
2542
+ now = __ktime_get_real_seconds ();
2543
+ time64_to_tm ( now , 0 , & tm );
2544
+ kdb_printf ("date %04ld -%02d-%02d %02d:%02d:%02d "
2554
2545
"tz_minuteswest %d\n" ,
2555
2546
1900 + tm .tm_year , tm .tm_mon + 1 , tm .tm_mday ,
2556
2547
tm .tm_hour , tm .tm_min , tm .tm_sec ,
0 commit comments