@@ -1150,6 +1150,16 @@ void kdb_set_current_task(struct task_struct *p)
11501150 kdb_current_regs = NULL ;
11511151}
11521152
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+
11531163/*
11541164 * kdb_local - The main code for kdb. This routine is invoked on a
11551165 * 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,
13271337 cmdptr = cmd_head ;
13281338 diag = kdb_parse (cmdbuf );
13291339 if (diag == KDB_NOTFOUND ) {
1340+ drop_newline (cmdbuf );
13301341 kdb_printf ("Unknown kdb command: '%s'\n" , cmdbuf );
13311342 diag = 0 ;
13321343 }
@@ -1566,6 +1577,7 @@ static int kdb_md(int argc, const char **argv)
15661577 int symbolic = 0 ;
15671578 int valid = 0 ;
15681579 int phys = 0 ;
1580+ int raw = 0 ;
15691581
15701582 kdbgetintenv ("MDCOUNT" , & mdcount );
15711583 kdbgetintenv ("RADIX" , & radix );
@@ -1575,9 +1587,10 @@ static int kdb_md(int argc, const char **argv)
15751587 repeat = mdcount * 16 / bytesperword ;
15761588
15771589 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
15791593 return KDB_ARGCOUNT ;
1580- valid = 1 ;
15811594 } else if (isdigit (argv [0 ][2 ])) {
15821595 bytesperword = (int )(argv [0 ][2 ] - '0' );
15831596 if (bytesperword == 0 ) {
@@ -1613,7 +1626,10 @@ static int kdb_md(int argc, const char **argv)
16131626 radix = last_radix ;
16141627 bytesperword = last_bytesperword ;
16151628 repeat = last_repeat ;
1616- mdcount = ((repeat * bytesperword ) + 15 ) / 16 ;
1629+ if (raw )
1630+ mdcount = repeat ;
1631+ else
1632+ mdcount = ((repeat * bytesperword ) + 15 ) / 16 ;
16171633 }
16181634
16191635 if (argc ) {
@@ -1630,7 +1646,10 @@ static int kdb_md(int argc, const char **argv)
16301646 diag = kdbgetularg (argv [nextarg ], & val );
16311647 if (!diag ) {
16321648 mdcount = (int ) val ;
1633- repeat = mdcount * 16 / bytesperword ;
1649+ if (raw )
1650+ repeat = mdcount ;
1651+ else
1652+ repeat = mdcount * 16 / bytesperword ;
16341653 }
16351654 }
16361655 if (argc >= nextarg + 1 ) {
@@ -1640,8 +1659,15 @@ static int kdb_md(int argc, const char **argv)
16401659 }
16411660 }
16421661
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+ }
16451671
16461672 switch (radix ) {
16471673 case 10 :
@@ -2473,52 +2499,17 @@ static int kdb_kill(int argc, const char **argv)
24732499 return 0 ;
24742500}
24752501
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-
25112502/*
25122503 * Most of this code has been lifted from kernel/timer.c::sys_sysinfo().
25132504 * I cannot call that code directly from kdb, it has an unconditional
25142505 * cli()/sti() and calls routines that take locks which can stop the debugger.
25152506 */
25162507static void kdb_sysinfo (struct sysinfo * val )
25172508{
2518- struct timespec uptime ;
2519- ktime_get_ts ( & uptime );
2509+ u64 uptime = ktime_get_mono_fast_ns () ;
2510+
25202511 memset (val , 0 , sizeof (* val ));
2521- val -> uptime = uptime . tv_sec ;
2512+ val -> uptime = div_u64 ( uptime , NSEC_PER_SEC ) ;
25222513 val -> loads [0 ] = avenrun [0 ];
25232514 val -> loads [1 ] = avenrun [1 ];
25242515 val -> loads [2 ] = avenrun [2 ];
@@ -2533,8 +2524,8 @@ static void kdb_sysinfo(struct sysinfo *val)
25332524 */
25342525static int kdb_summary (int argc , const char * * argv )
25352526{
2536- struct timespec now ;
2537- struct kdb_tm tm ;
2527+ time64_t now ;
2528+ struct tm tm ;
25382529 struct sysinfo val ;
25392530
25402531 if (argc )
@@ -2548,9 +2539,9 @@ static int kdb_summary(int argc, const char **argv)
25482539 kdb_printf ("domainname %s\n" , init_uts_ns .name .domainname );
25492540 kdb_printf ("ccversion %s\n" , __stringify (CCVERSION ));
25502541
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 "
25542545 "tz_minuteswest %d\n" ,
25552546 1900 + tm .tm_year , tm .tm_mon + 1 , tm .tm_mday ,
25562547 tm .tm_hour , tm .tm_min , tm .tm_sec ,
0 commit comments