1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 2380 2381 2382 2383 2384 2385 2386 2387 2388 2389 2390 2391 2392 2393 2394 2395 2396 2397 2398 2399 2400 2401 2402 2403 2404 2405 2406 2407 2408 2409 2410 2411 2412 2413 2414 2415 2416 2417 2418 2419 2420 2421 2422 2423 2424 2425 2426 2427 2428 2429 2430 2431 2432 2433 2434 2435 2436 2437 2438 2439 2440 2441 2442 2443 2444 2445 2446 2447 2448 2449 2450 2451 2452 2453 2454 2455 2456 2457 2458 2459 2460 2461 2462 2463 2464 2465 2466 2467 2468 2469 2470 2471 2472 2473 2474 2475 2476 2477 2478 2479 2480 2481 2482 2483 2484 2485 2486 2487 2488 2489 2490 2491 2492 2493 2494 2495 2496 2497 2498 2499 2500 2501 2502 2503 2504 2505 2506 2507 2508 2509 2510 2511 2512 2513 2514 2515 2516 2517 2518 2519 2520 2521 2522 2523 2524 2525 2526 2527 2528 2529 2530 2531 2532 2533 2534 2535 2536 2537 2538 2539 2540 2541 2542 2543 2544 2545 2546 2547 2548 2549 2550 2551 2552 2553 2554 2555 2556 2557 2558 2559 2560 2561 2562 2563 2564 2565 2566 2567 2568 2569 2570 2571 2572 2573 2574 2575 2576 2577 2578 2579 2580 2581 2582 2583 2584 2585 2586 2587 2588 2589 2590 2591 2592 2593 2594 2595 2596 2597 2598 2599 2600 2601 2602 2603 2604 2605 2606 2607 2608 2609 2610 2611 2612 2613 2614 2615 2616 2617 2618 2619 2620 2621 2622 2623 2624 2625 2626 2627 2628 2629 2630 2631 2632 2633 2634 2635 2636 2637 2638 2639 2640 2641 2642 2643 2644 2645 2646 2647 2648 2649 2650 2651 2652 2653 2654 2655 2656 2657 2658 2659 2660 2661 2662 2663 2664 2665 2666 2667 2668 2669 2670 2671 2672 2673 2674 2675 2676 2677 2678 2679 2680 2681 2682 2683 2684 2685 2686 2687 2688 2689 2690 2691 2692 2693 2694 2695 2696 2697 2698 2699 2700 2701 2702 2703 2704 2705 2706 2707 2708 2709 2710 2711 2712 2713 2714 2715 2716 2717 2718 2719 2720 2721 2722 2723 2724 2725 2726 2727 2728 2729 2730 2731 2732 2733 2734 2735 2736 2737 2738 2739 2740 2741 2742 2743 2744 2745 2746 2747 2748 2749 2750 2751 2752 2753 2754 2755 2756 2757 2758 2759 2760 2761 2762 2763 2764 2765 2766 2767 2768 2769 2770 2771 2772 2773 2774 2775 2776 2777 2778 2779 2780 2781 2782 2783 2784 2785 2786 2787 2788 2789 2790 2791 2792 2793 2794 2795 2796 2797 2798 2799 2800 2801 2802 2803 2804 2805 2806 2807 2808 2809 2810 2811 2812 2813 2814 2815 2816 2817 2818 2819 2820 2821 2822 2823 2824 2825 2826 2827 2828 2829 2830 2831 2832 2833 2834 2835 2836 2837 2838 2839 2840 2841 2842 2843 2844 2845 2846 2847 2848 2849 2850 2851 2852 2853 2854 2855 2856 2857 2858 2859 2860 2861 2862 2863 2864 2865 2866 2867 2868 2869 2870 2871 2872 2873 2874 2875 2876 2877 2878 2879 2880 2881 2882 2883 2884 2885 2886 2887 2888 2889 2890 2891 2892 2893 2894 2895 2896 2897 2898 2899 2900 2901 2902 2903 2904 2905 2906 2907 2908 2909 2910 2911 2912 2913 2914 2915 2916 2917 2918 2919 2920 2921 2922 2923 2924 2925 2926 2927 2928 2929 2930 2931 2932 2933 2934 2935 2936 2937 2938 2939 2940 2941 2942 2943 2944 2945 2946 2947 2948 2949 2950 2951 2952 2953 2954 2955 2956 2957 2958 2959 2960 2961 2962 2963 2964 2965 2966 2967 2968 2969 2970 2971 2972 2973 2974 2975 2976 2977 2978 2979 2980 2981 2982 2983 2984 2985 2986 2987 2988 2989 2990 2991 2992 2993 2994 2995 2996 2997 2998 2999 3000 3001 3002 3003 3004 3005 3006 3007 3008 3009 3010 3011 3012 3013 3014 3015 3016 3017 3018 3019 3020 3021 3022 3023 3024 3025 3026 3027 3028 3029 3030 3031 3032 3033 3034 3035 3036 3037 3038 3039 3040 3041 3042 3043 3044 3045 3046 3047 3048 3049 3050 3051 3052 3053 3054 3055 3056 3057 3058 3059 3060 3061 3062 3063 3064 3065 3066 3067 3068 3069 3070 3071 3072 3073 3074 3075 3076 3077 3078 3079 3080 3081 3082 3083 3084 3085 3086 3087 3088 3089 3090 3091 3092 3093 3094 3095 3096 3097 3098 3099 3100 3101 3102 3103 3104 3105 3106 3107 3108 3109 3110 3111 3112 3113 3114 3115 3116 3117 3118 3119 3120 3121 3122 3123 3124 3125 3126 3127 3128 3129 3130 3131 3132 3133 3134 3135 3136 3137 3138 3139 3140 3141 3142 3143 3144 3145 3146 3147 3148 3149 3150 3151 3152 3153 3154 3155 3156 3157 3158 3159 3160 3161 3162 3163 3164 3165 3166 3167 3168 3169 3170 3171 3172 3173 3174 3175 3176 3177 3178 3179 3180 3181 3182 3183 3184 3185 3186 3187 3188 3189 3190 3191 3192 3193 3194 3195 3196 3197 3198 3199 3200 3201 3202 3203 3204 3205 3206 3207 3208 3209 3210 3211 3212 3213 3214 3215 3216 3217 3218 3219 3220 3221 3222 3223 3224 3225 3226 3227 3228 3229 3230 3231 3232 3233 3234 3235 3236 3237 3238 3239 3240 3241 3242 3243 3244 3245 3246 3247 3248 3249 3250 3251 3252 3253 3254 3255 3256 3257 3258 3259 3260 3261 3262 3263 3264 3265 3266 3267 3268 3269 3270 3271 3272 3273 3274 3275 3276 3277 3278 3279 3280 3281 3282 3283 3284 3285 3286 3287 3288 3289 3290 3291 3292 3293 3294 3295 3296 3297 3298 3299 3300 3301 3302 3303 3304 3305 3306 3307 3308 3309 3310 3311 3312 3313 3314 3315 3316 3317 3318 3319 3320 3321 3322 3323 3324 3325 3326 3327 3328 3329 3330 3331 3332 3333 3334 3335 3336 3337 3338 3339 3340 3341 3342 3343 3344 3345 3346 3347 3348 3349 3350 3351 3352 3353 3354 3355 3356 3357 3358 3359 3360 3361 3362 3363 3364 3365 3366 3367 3368 3369 3370 3371 3372 3373 3374 3375 3376 3377 3378 3379 3380 3381 3382 3383 3384 3385 3386 3387 3388 3389 3390 3391 3392 3393 3394 3395 3396 3397 3398 3399 3400 3401 3402 3403 3404 3405 3406 3407 3408 3409 3410 3411 3412 3413 3414 3415 3416 3417 3418 3419 3420 3421 3422 3423 3424 3425 3426 3427 3428 3429 3430 3431 3432 3433 3434 3435 3436 3437 3438 3439 3440 3441 3442 3443 3444 3445 3446 3447 3448 3449 3450 3451 3452 3453 3454 3455 3456 3457 3458 3459 3460 3461 3462 3463 3464 3465 3466 3467 3468 3469 3470 3471 3472 3473 3474 3475 3476 3477 3478 3479 3480 3481 3482 3483 3484 3485 3486 3487 3488 3489 3490 3491 3492 3493 3494 3495 3496 3497 3498 3499 3500 3501 3502 3503 3504 3505 3506 3507 3508 3509 3510 3511 3512 3513 3514 3515 3516 3517 3518 3519 3520 3521 3522 3523 3524 3525 3526 3527 3528 3529 3530 3531 3532 3533 3534 3535 3536 3537 3538 3539 3540 3541 3542 3543 3544 3545 3546 3547 3548 3549 3550 3551 3552 3553 3554 3555 3556 3557 3558 3559 3560 3561 3562 3563 3564 3565 3566 3567 3568 3569 3570 3571 3572 3573 3574 3575 3576 3577 3578 3579 3580 3581 3582 3583 3584 3585 3586 3587 3588 3589 3590 3591 3592 3593 3594 3595 3596 3597 3598 3599 3600 3601 3602 3603 3604 3605 3606 3607 3608 3609 3610 3611 3612 3613 3614 3615 3616 3617 3618 3619 3620 3621 3622 3623 3624 3625 3626 3627 3628 3629 3630 3631 3632 3633 3634 3635 3636 3637 3638 3639 3640 3641 3642 3643 3644 3645 3646 3647 3648 3649 3650 3651 3652 3653 3654 3655 3656 3657 3658 3659 3660 3661 3662 3663 3664 3665 3666 3667 3668 3669 3670 3671 3672 3673 3674 3675 3676 3677 3678 3679 3680 3681 3682 3683 3684 3685 3686 3687 3688 3689 3690 3691 3692 3693 3694 3695 3696 3697 3698 3699 3700 3701 3702 3703 3704 3705 3706 3707 3708 3709 3710 3711 3712 3713 3714 3715 3716 3717 3718 3719 3720 3721 3722 3723 3724 3725 3726 3727 3728 3729 3730 3731 3732 3733 3734 3735 3736 3737 3738 3739 3740 3741 3742 3743 3744 3745 3746 3747 3748 3749 3750 3751 3752 3753 3754 3755 3756 3757 3758 3759 3760 3761 3762 3763 3764 3765 3766 3767 3768 3769 3770 3771 3772 3773 3774 3775 3776 3777 3778 3779 3780 3781 3782 3783 3784 3785 3786 3787 3788 3789 3790 3791 3792 3793 3794 3795 3796 3797 3798 3799 3800 3801 3802 3803 3804 3805 3806 3807 3808 3809 3810 3811 3812 3813 3814 3815 3816 3817 3818 3819 3820 3821 3822 3823 3824 3825 3826 3827 3828 3829 3830 3831 3832 3833 3834 3835 3836 3837 3838 3839 3840 3841 3842 3843 3844 3845 3846 3847 3848 3849 3850 3851 3852 3853 3854 3855 3856 3857 3858 3859 3860 3861 3862 3863 3864 3865 3866 3867 3868 3869 3870 3871 3872 3873 3874 3875 3876 3877 3878 3879 3880 3881 3882 3883 3884 3885 3886 3887 3888 3889 3890 3891 3892 3893 3894 3895 3896 3897 3898 3899 3900 3901 3902 3903 3904 3905 3906 3907 3908 3909 3910 3911 3912 3913 3914 3915 3916 3917 3918 3919 3920 3921 3922 3923 3924 3925 3926 3927 3928 3929 3930 3931 3932 3933 3934 3935 3936 3937 3938 3939 3940 3941 3942 3943 3944 3945 3946 3947 3948 3949 3950 3951 3952 3953 3954 3955 3956 3957 3958 3959 3960 3961 3962 3963 3964 3965 3966 3967 3968 3969 3970 3971 3972 3973 3974 3975 3976 3977 3978 3979 3980 3981 3982 3983 3984 3985 3986 3987 3988 3989 3990 3991 3992 3993 3994 3995 3996 3997 3998 3999 4000 4001 4002 4003 4004 4005 4006 4007 4008 4009 4010 4011 4012 4013 4014 4015 4016 4017 4018 4019 4020 4021 4022 4023 4024 4025 4026 4027 4028 4029 4030 4031 4032 4033 4034 4035 4036 4037 4038 4039 4040 4041 4042 4043 4044 4045 4046 4047 4048 4049 4050 4051 4052 4053 4054 4055 4056 4057 4058 4059 4060 4061 4062 4063 4064 4065 4066 4067 4068 4069 4070 4071 4072 4073 4074 4075 4076 4077 4078 4079 4080 4081 4082 4083 4084 4085 4086 4087 4088 4089 4090 4091 4092 4093 4094 4095 4096 4097 4098 4099 4100 4101 4102 4103 4104 4105 4106 4107 4108 4109 4110 4111 4112 4113 4114 4115 4116 4117 4118 4119 4120 4121 4122 4123 4124 4125 4126 4127 4128 4129 4130 4131 4132 4133 4134 4135 4136 4137 4138 4139 4140 4141 4142 4143 4144 4145 4146 4147 4148 4149 4150 4151 4152 4153 4154 4155 4156 4157 4158 4159 4160 4161 4162 4163 4164 4165 4166 4167 4168 4169 4170 4171 4172 4173 4174 4175 4176 4177 4178 4179 4180 4181 4182 4183 4184 4185 4186 4187 4188 4189 4190 4191 4192 4193 4194 4195 4196 4197 4198 4199 4200 4201 4202 4203 4204 4205 4206 4207 4208 4209 4210 4211 4212 4213 4214 4215 4216 4217 4218 4219 4220 4221 4222 4223 4224 4225 4226 4227 4228 4229 4230 4231 4232 4233 4234 4235 4236 4237 4238 4239 4240 4241 4242 4243 4244 4245 4246 4247 4248 4249 4250 4251 4252 4253 4254 4255 4256 4257 4258 4259 4260 4261 4262 4263 4264 4265 4266 4267 4268 4269 4270 4271 4272 4273 4274 4275 4276 4277 4278 4279 4280 4281 4282 4283 4284 4285 4286 4287 4288 4289 4290 4291 4292 4293 4294 4295 4296 4297 4298 4299 4300 4301 4302 4303 4304 4305 4306 4307 4308 4309 4310 4311 4312 4313 4314 4315 4316 4317 4318 4319 4320 4321 4322 4323 4324 4325 4326 4327 4328 4329 4330 4331 4332 4333 4334 4335 4336 4337 4338 4339 4340 4341 4342 4343 4344 4345 4346 4347 4348 4349 4350 4351 4352 4353 4354 4355 4356 4357 4358 4359 4360 4361 4362 4363 4364 4365 4366 4367 4368 4369 4370 4371 4372 4373 4374 4375 4376 4377 4378 4379 4380 4381 4382 4383 4384 4385 4386 4387 4388 4389 4390 4391 4392 4393 4394 4395 4396 4397 4398 4399 4400 4401 4402 4403 4404 4405 4406 4407 4408 4409 4410 4411 4412 4413 4414 4415 4416 4417 4418 4419 4420 4421 4422 4423 4424 4425 4426 4427 4428 4429 4430 4431 4432 4433 4434 4435 4436 4437 4438 4439 4440 4441 4442 4443 4444 4445 4446 4447 4448 4449 4450 4451 4452 4453 4454 4455 4456 4457 4458 4459 4460 4461 4462 4463 4464 4465 4466 4467 4468 4469 4470 4471 4472 4473 4474 4475 4476 4477 4478 4479 4480 4481 4482 4483 4484 4485 4486 4487 4488 4489 4490 4491 4492 4493 4494 4495 4496 4497 4498 4499 4500 4501 4502 4503 4504 4505 4506 4507 4508 4509 4510 4511 4512 4513 4514 4515 4516 4517 4518 4519 4520 4521 4522 4523 4524 4525 4526 4527 4528 4529 4530 4531 4532 4533 4534 4535 4536 4537 4538 4539 4540 4541 4542 4543 4544 4545 4546 4547 4548 4549 4550 4551 4552 4553 4554 4555 4556 4557 4558 4559 4560 4561 4562 4563 4564 4565 4566 4567 4568 4569 4570 4571 4572 4573 4574 4575 4576 4577 4578 4579 4580 4581 4582 4583 4584 4585 4586 4587 4588 4589 4590 4591 4592 4593 4594 4595 4596 4597 4598 4599 4600 4601 4602 4603 4604 4605 4606 4607 4608 4609 4610 4611 4612 4613 4614 4615 4616 4617 4618 4619 4620 4621 4622 4623 4624 4625 4626 4627 4628 4629 4630 4631 4632 4633 4634 4635 4636 4637 4638 4639 4640 4641 4642 4643 4644 4645 4646 4647 4648 4649 4650 4651 4652 4653 4654 4655 4656 4657 4658 4659 4660 4661 4662 4663 4664 4665 4666 4667 4668 4669 4670 4671 4672 4673 4674 4675 4676 4677 4678 4679 4680 4681 4682 4683 4684 4685 4686 4687 4688 4689 4690 4691 4692 4693 4694 4695 4696 4697 4698 4699 4700 4701 4702 4703 4704 4705 4706 4707 4708 4709 4710 4711 4712 4713 4714 4715 4716 4717 4718 4719 4720 4721 4722 4723 4724 4725 4726 4727 4728 4729 4730 4731 4732 4733 4734 4735 4736 4737 4738 4739 4740 4741 4742 4743 4744 4745 4746 4747 4748 4749 4750 4751 4752 4753 4754 4755 4756 4757 4758 4759 4760 4761 4762 4763 4764 4765 4766 4767 4768 4769 4770 4771 4772 4773 4774 4775 4776 4777 4778 4779 4780 4781 4782 4783 4784 4785 4786 4787 4788 4789 4790 4791 4792 4793 4794 4795 4796 4797 4798 4799 4800 4801 4802 4803 4804 4805 4806 4807 4808 4809 4810 4811 4812 4813 4814 4815 4816 4817 4818 4819 4820 4821 4822 4823 4824 4825 4826 4827 4828 4829 4830 4831 4832 4833 4834 4835 4836 4837 4838 4839 4840 4841 4842 4843 4844 4845 4846 4847 4848 4849 4850 4851 4852 4853 4854 4855 4856 4857 4858 4859 4860 4861 4862 4863 4864 4865 4866 4867 4868 4869 4870 4871 4872 4873 4874 4875 4876 4877 4878 4879 4880 4881 4882 4883 4884 4885 4886 4887 4888 4889 4890 4891 4892 4893 4894 4895 4896 4897 4898 4899 4900 4901 4902 4903 4904 4905 4906 4907 4908 4909 4910 4911 4912 4913 4914 4915 4916 4917 4918 4919 4920 4921 4922 4923 4924 4925 4926 4927 4928 4929 4930 4931 4932 4933 4934 4935 4936 4937 4938 4939 4940 4941 4942 4943 4944 4945 4946 4947 4948 4949 4950 4951 4952 4953 4954 4955 4956 4957 4958 4959 4960 4961 4962 4963 4964 4965 4966 4967 4968 4969 4970 4971 4972 4973 4974 4975 4976 4977 4978 4979 4980 4981 4982 4983 4984 4985 4986 4987 4988 4989 4990 4991 4992 4993 4994 4995 4996 4997 4998 4999 5000 5001 5002 5003 5004 5005 5006 5007 5008 5009 5010 5011 5012 5013 5014 5015 5016 5017 5018 5019 5020 5021 5022 5023 5024 5025 5026 5027 5028 5029 5030 5031 5032 5033 5034 5035 5036 5037 5038 5039 5040 5041 5042 5043 5044 5045 5046 5047 5048 5049 5050 5051 5052 5053 5054 5055 5056 5057 5058 5059 5060 5061 5062 5063 5064 5065 5066 5067 5068 5069 5070 5071 5072 5073 5074 5075 5076 5077 5078 5079 5080 5081 5082 5083 5084 5085 5086 5087 5088 5089 5090 5091 5092 5093 5094 5095 5096 5097 5098 5099 5100 5101 5102 5103 5104 5105 5106 5107 5108 5109 5110 5111 5112 5113 5114 5115 5116 5117 5118 5119 5120 5121 5122 5123 5124 5125 5126 5127 5128 5129 5130 5131 5132 5133 5134 5135 5136 5137 5138 5139 5140 5141 5142 5143 5144 5145 5146 5147 5148 5149 5150 5151 5152 5153 5154 5155 5156 5157 5158 5159 5160 5161 5162 5163 5164 5165 5166 5167 5168 5169 5170 5171 5172 5173 5174 5175 5176 5177 5178 5179 5180 5181 5182 5183 5184 5185 5186 5187 5188 5189 5190 5191 5192 5193 5194 5195 5196 5197 5198 5199 5200 5201 5202 5203 5204 5205 5206 5207 5208 5209 5210 5211 5212 5213 5214 5215 5216 5217 5218 5219 5220 5221 5222 5223 5224 5225 5226 5227 5228 5229 5230 5231 5232 5233 5234 5235 5236 5237 5238 5239 5240 5241 5242 5243 5244 5245 5246 5247 5248 5249 5250 5251 5252 5253 5254 5255 5256 5257 5258 5259 5260 5261 5262 5263 5264 5265 5266 5267 5268 5269 5270 5271 5272 5273 5274 5275 5276 5277 5278 5279 5280 5281 5282 5283 5284 5285 5286 5287 5288 5289 5290 5291 5292 5293 5294 5295 5296 5297 5298 5299 5300 5301 5302 5303 5304 5305 5306 5307 5308 5309 5310 5311 5312 5313 5314 5315 5316 5317 5318 5319 5320 5321 5322 5323 5324 5325 5326 5327 5328 5329 5330 5331 5332 5333 5334 5335 5336 5337 5338 5339 5340 5341 5342 5343 5344 5345 5346 5347 5348 5349 5350 5351 5352 5353 5354 5355 5356 5357 5358 5359 5360 5361 5362 5363 5364 5365 5366 5367 5368 5369 5370 5371 5372 5373 5374 5375 5376 5377 5378 5379 5380 5381 5382 5383 5384 5385 5386 5387 5388 5389 5390 5391 5392 5393 5394 5395 5396 5397 5398 5399 5400 5401 5402 5403 5404 5405 5406 5407 5408 5409 5410 5411 5412 5413 5414 5415 5416 5417 5418 5419 5420 5421 5422 5423 5424 5425 5426 5427 5428 5429 5430 5431 5432 5433 5434 5435 5436 5437 5438 5439 5440 5441 5442 5443 5444 5445 5446 5447 5448 5449 5450 5451 5452 5453 5454 5455 5456 5457 5458 5459 5460 5461 5462 5463 5464 5465 5466 5467 5468 5469 5470 5471 5472 5473 5474 5475 5476 5477 5478 5479 5480 5481 5482 5483 5484 5485 5486 5487 5488 5489 5490 5491 5492 5493 5494 5495 5496 5497 5498 5499 5500 5501 5502 5503 5504 5505 5506 5507 5508 5509 5510 5511 5512 5513 5514 5515 5516 5517 5518 5519 5520 5521 5522 5523 5524 5525 5526 5527 5528 5529 5530 5531 5532 5533 5534 5535 5536 5537 5538 5539 5540 5541 5542 5543 5544 5545 5546 5547 5548 5549 5550 5551 5552 5553 5554 5555 5556 5557 5558 5559 5560 5561 5562 5563 5564 5565 5566 5567 5568 5569 5570 5571 5572 5573 5574 5575 5576 5577 5578 5579 5580 5581 5582 5583 5584 5585 5586 5587 5588 5589 5590 5591 5592 5593 5594 5595 5596 5597 5598 5599 5600 5601 5602 5603 5604 5605 5606 5607 5608 5609 5610 5611 5612 5613 5614 5615 5616 5617 5618 5619 5620 5621 5622 5623 5624 5625 5626 5627 5628 5629 5630 5631 5632 5633 5634 5635 5636 5637 5638 5639 5640 5641 5642 5643 5644 5645 5646 5647 5648 5649 5650 5651 5652 5653 5654 5655 5656 5657 5658 5659 5660 5661 5662 5663 5664 5665 5666 5667 5668 5669 5670 5671 5672 5673 5674 5675 5676 5677 5678 5679 5680 5681 5682 5683 5684 5685 5686 5687 5688 5689 5690 5691 5692 5693 5694 5695 5696 5697 5698 5699 5700 5701 5702 5703 5704 5705 5706 5707 5708 5709 5710 5711 5712 5713 5714 5715 5716 5717 5718 5719 5720 5721 5722 5723 5724 5725 5726 5727 5728 5729 5730 5731 5732 5733 5734 5735 5736 5737 5738 5739 5740 5741 5742 5743 5744 5745 5746 5747 5748 5749 5750 5751 5752 5753 5754 5755 5756 5757 5758 5759 5760 5761 5762 5763 5764 5765 5766 5767 5768 5769 5770 5771 5772 5773 5774 5775 5776 5777 5778 5779 5780 5781 5782 5783 5784 5785 5786 5787 5788 5789 5790 5791 5792 5793 5794 5795 5796 5797 5798 5799 5800 5801 5802 5803 5804 5805 5806 5807 5808 5809 5810 5811 5812 5813 5814 5815 5816 5817 5818 5819 5820 5821 5822 5823 5824 5825 5826 5827 5828 5829 5830 5831 5832 5833 5834 5835 5836 5837 5838 5839 5840 5841 5842 5843 5844 5845 5846 5847 5848 5849 5850 5851 5852 5853 5854 5855 5856 5857 5858 5859 5860 5861 5862 5863 5864 5865 5866 5867 5868 5869 5870 5871 5872 5873 5874 5875 5876 5877 5878 5879 5880 5881 5882 5883 5884 5885 5886 5887 5888 5889 5890 5891 5892 5893 5894 5895 5896 5897 5898 5899 5900 5901 5902 5903 5904 5905 5906 5907 5908 5909 5910 5911 5912 5913 5914 5915 5916 5917 5918 5919 5920 5921 5922 5923 5924 5925 5926 5927 5928 5929 5930 5931 5932 5933 5934 5935 5936 5937 5938 5939 5940 5941 5942 5943 5944 5945 5946 5947 5948 5949 5950 5951 5952 5953 5954 5955 5956 5957 5958 5959 5960 5961 5962 5963 5964 5965 5966 5967 5968 5969 5970 5971 5972 5973 5974 5975 5976 5977 5978 5979 5980 5981 5982 5983 5984 5985 5986 5987 5988 5989 5990 5991 5992 5993 5994 5995 5996 5997 5998 5999 6000 6001 6002 6003 6004 6005 6006 6007 6008 6009 6010 6011 6012 6013 6014 6015 6016 6017 6018 6019 6020 6021 6022 6023 6024 6025 6026 6027 6028 6029 6030 6031 6032 6033 6034 6035 6036 6037 6038 6039 6040 6041 6042 6043 6044 6045 6046 6047 6048 6049 6050 6051 6052 6053 6054 6055 6056 6057 6058 6059 6060 6061 6062 6063 6064 6065 6066 6067 6068 6069 6070 6071 6072 6073 6074 6075 6076 6077 6078 6079 6080 6081 6082 6083 6084 6085 6086 6087 6088 6089 6090 6091 6092 6093 6094 6095 6096 6097 6098 6099 6100 6101 6102 6103 6104 6105 6106 6107 6108 6109 6110 6111 6112 6113 6114 6115 6116 6117 6118 6119 6120 6121 6122 6123 6124 6125 6126 6127 6128 6129 6130 6131 6132 6133 6134 6135 6136 6137 6138 6139 6140 6141 6142 6143 6144 6145 6146 6147 6148 6149 6150 6151 6152 6153 6154 6155 6156 6157 6158 6159 6160 6161 6162 6163 6164 6165 6166 6167 6168 6169 6170 6171 6172 6173 6174 6175 6176 6177 6178 6179 6180 6181 6182 6183 6184 6185 6186 6187 6188 6189 6190 6191 6192 6193 6194 6195 6196 6197 6198 6199 6200 6201 6202 6203 6204 6205 6206 6207 6208 6209 6210 6211 6212 6213 6214 6215 6216 6217 6218 6219 6220 6221 6222 6223 6224 6225 6226 6227 6228 6229 6230 6231 6232 6233 6234 6235 6236 6237 6238 6239 6240 6241 6242 6243 6244 6245 6246 6247 6248 6249 6250 6251 6252 6253 6254 6255 6256 6257 6258 6259 6260 6261 6262 6263 6264 6265 6266 6267 6268 6269 6270 6271 6272 6273 6274 6275 6276 6277 6278 6279 6280 6281 6282 6283 6284 6285 6286 6287 6288 6289 6290 6291 6292 6293 6294 6295 6296 6297 6298 6299 6300 6301 6302 6303 6304 6305 6306 6307 6308 6309 6310 6311 6312 6313 6314 6315 6316 6317 6318 6319 6320 6321 6322 6323 6324 6325 6326 6327 6328 6329 6330 6331 6332 6333 6334 6335 6336 6337 6338 6339 6340 6341 6342 6343 6344 6345 6346 6347 6348 6349 6350 6351 6352 6353 6354 6355 6356 6357 6358 6359 6360 6361 6362 6363 6364 6365 6366 6367 6368 6369 6370 6371 6372 6373 6374 6375 6376 6377 6378 6379 6380 6381 6382 6383 6384 6385 6386 6387 6388 6389 6390 6391 6392 6393 6394 6395 6396 6397 6398 6399 6400 6401 6402 6403 6404 6405 6406 6407 6408 6409 6410 6411 6412 6413 6414 6415 6416 6417 6418 6419 6420 6421 6422 6423 6424 6425 6426 6427 6428 6429 6430 6431 6432 6433 6434 6435 6436 6437 6438 6439 6440 6441 6442 6443 6444 6445 6446 6447 6448 6449 6450 6451 6452 6453 6454 6455 6456 6457 6458 6459 6460 6461 6462 6463 6464 6465 6466 6467 6468 6469 6470 6471 6472 6473 6474 6475 6476 6477 6478 6479 6480 6481 6482 6483 6484 6485 6486 6487 6488 6489 6490 6491 6492 6493 6494 6495 6496 6497 6498 6499 6500 6501 6502 6503 6504 6505 6506 6507 6508 6509 6510 6511 6512 6513 6514 6515 6516 6517 6518 6519 6520 6521 6522 6523 6524 6525 6526 6527 6528 6529 6530 6531 6532 6533 6534 6535 6536 6537 6538 6539 6540 6541 6542 6543 6544 6545 6546 6547 6548 6549 6550 6551 6552 6553 6554 6555 6556 6557 6558 6559 6560 6561 6562 6563 6564 6565 6566 6567 6568 6569 6570 6571 6572 6573 6574 6575 6576 6577 6578 6579 6580 6581 6582 6583 6584 6585 6586 6587 6588 6589 6590 6591 6592 6593 6594 6595 6596 6597 6598 6599 6600 6601 6602 6603 6604 6605 6606 6607 6608 6609 6610 6611 6612 6613 6614 6615 6616 6617 6618 6619 6620 6621 6622 6623 6624 6625 6626 6627 6628 6629 6630 6631 6632 6633 6634 6635 6636 6637 6638 6639 6640 6641 6642 6643 6644 6645 6646 6647 6648 6649 6650 6651 6652 6653 6654 6655 6656 6657 6658 6659 6660 6661 6662 6663 6664 6665 6666 6667 6668 6669 6670 6671 6672 6673 6674 6675 6676 6677 6678 6679 6680 6681 6682 6683 6684 6685 6686 6687 6688 6689 6690 6691 6692 6693 6694 6695 6696 6697 6698 6699 6700 6701 6702 6703 6704 6705 6706 6707 6708 6709 6710 6711 6712 6713 6714 6715 6716 6717 6718 6719 6720 6721 6722 6723 6724 6725 6726 6727 6728 6729 6730 6731 6732 6733 6734 6735 6736 6737 6738 6739 6740 6741 6742 6743 6744 6745 6746 6747 6748 6749 6750 6751 6752 6753 6754 6755 6756 6757 6758 6759 6760 6761 6762 6763 6764 6765 6766 6767 6768 6769 6770 6771 6772 6773 6774 6775 6776 6777 6778 6779 6780 6781 6782 6783 6784 6785 6786 6787 6788 6789 6790 6791 6792 6793 6794 6795 6796 6797 6798 6799 6800 6801 6802 6803 6804 6805 6806 6807 6808 6809 6810 6811 6812 6813 6814 6815 6816 6817 6818 6819 6820 6821 6822 6823 6824 6825 6826 6827 6828 6829 6830 6831 6832 6833 6834 6835 6836 6837 6838 6839 6840 6841 6842 6843 6844 6845 6846 6847 6848 6849 6850 6851 6852 6853 6854 6855 6856 6857 6858 6859 6860 6861 6862 6863 6864 6865 6866 6867 6868 6869 6870 6871 6872 6873 6874 6875 6876 6877 6878 6879 6880 6881 6882 6883 6884 6885 6886 6887 6888 6889 6890 6891 6892 6893 6894 6895 6896 6897 6898 6899 6900 6901 6902 6903 6904 6905 6906 6907 6908 6909 6910 6911 6912 6913 6914 6915 6916 6917 6918 6919 6920 6921 6922 6923 6924 6925 6926 6927 6928 6929 6930 6931 6932 6933 6934 6935 6936 6937 6938 6939 6940 6941 6942 6943 6944 6945 6946 6947 6948 6949 6950 6951 6952 6953 6954 6955 6956 6957 6958 6959 6960 6961 6962 6963 6964 6965 6966 6967 6968 6969 6970 6971 6972 6973 6974 6975 6976 6977 6978 6979 6980 6981 6982 6983 6984 6985 6986 6987 6988 6989 6990 6991 6992 6993 6994 6995 6996 6997 6998 6999 7000 7001 7002 7003 7004 7005 7006 7007 7008 7009 7010 7011 7012 7013 7014 7015 7016 7017 7018 7019 7020 7021 7022 7023 7024 7025 7026 7027 7028 7029 7030 7031 7032 7033 7034 7035 7036 7037 7038 7039 7040 7041 7042 7043 7044 7045 7046 7047 7048 7049 7050 7051 7052 7053 7054 7055 7056 7057 7058 7059 7060 7061 7062 7063 7064 7065 7066 7067 7068 7069 7070 7071 7072 7073 7074 7075 7076 7077 7078 7079 7080 7081 7082 7083 7084 7085 7086 7087 7088 7089 7090 7091 7092 7093 7094 7095 7096 7097 7098 7099 7100 7101 7102 7103 7104 7105 7106 7107 7108 7109 7110 7111 7112 7113 7114 7115 7116 7117 7118 7119 7120 7121 7122 7123 7124 7125 7126 7127 7128 7129 7130 7131 7132 7133 7134 7135 7136 7137 7138 7139 7140 7141 7142 7143 7144 7145 7146 7147 7148 7149 7150 7151 7152 7153 7154 7155 7156 7157 7158 7159 7160 7161 7162 7163 7164 7165 7166 7167 7168 7169 7170 7171 7172 7173 7174 7175 7176 7177 7178 7179 7180 7181 7182 7183 7184 7185 7186 7187 7188 7189 7190 7191 7192 7193 7194 7195 7196 7197 7198 7199 7200 7201 7202 7203 7204 7205 7206 7207 7208 7209 7210 7211 7212 7213 7214 7215 7216 7217 7218 7219 7220 7221 7222 7223 7224 7225 7226 7227 7228 7229 7230 7231 7232 7233 7234 7235 7236 7237 7238 7239 7240 7241 7242 7243 7244 7245 7246 7247 7248 7249 7250 7251 7252 7253 7254 7255 7256 7257 7258 7259 7260 7261 7262 7263 7264 7265 7266 7267 7268 7269 7270 7271 7272 7273 7274 7275 7276 7277 7278 7279 7280 7281 7282 7283 7284 7285 7286 7287 7288 7289 7290 7291 7292 7293 7294 7295 7296 7297 7298 7299 7300 7301 7302 7303 7304 7305 7306 7307 7308 7309 7310 7311 7312 7313 7314 7315 7316 7317 7318 7319 7320 7321 7322 7323 7324 7325 7326 7327 7328 7329 7330 7331 7332 7333 7334 7335 7336 7337 7338 7339 7340 7341 7342 7343 7344 7345 7346 7347 7348 7349 7350 7351 7352 7353 7354 7355 7356 7357 7358 7359 7360 7361 7362 7363 7364 7365 7366 7367 7368 7369 7370 7371 7372 7373 7374 7375 7376 7377 7378 7379 7380 7381 7382 7383 7384 7385 7386 7387 7388 7389 7390 7391 7392 7393 7394 7395 7396 7397 7398 7399 7400 7401 7402 7403 7404 7405 7406 7407 7408 7409 7410 7411 7412 7413 7414 7415 7416 7417 7418 7419 7420 7421 7422 7423 7424 7425 7426 7427 7428 7429 7430 7431 7432 7433 7434 7435 7436 7437 7438 7439 7440 7441 7442 7443 7444 7445 7446 7447 7448 7449 7450 7451 7452 7453 7454 7455 7456 7457 7458 7459 7460 7461 7462 7463 7464 7465 7466 7467 7468 7469 7470 7471 7472 7473 7474 7475 7476 7477 7478 7479 7480 7481 7482 7483 7484 7485 7486 7487 7488 7489 7490 7491 7492 7493 7494 7495 7496 7497 7498 7499 7500 7501 7502 7503 7504 7505 7506 7507 7508 7509 7510 7511 7512 7513 7514 7515 7516 7517 7518 7519 7520 7521 7522 7523 7524 7525 7526 7527 7528 7529 7530 7531 7532 7533 7534 7535 7536 7537 7538 7539 7540 7541 7542 7543 7544 7545 7546 7547 7548 7549 7550 7551 7552 7553 7554 7555 7556 7557 7558 7559 7560 7561 7562 7563 7564 7565 7566 7567 7568 7569 7570 7571 7572 7573 7574 7575 7576 7577 7578 7579 7580 7581 7582 7583 7584 7585 7586 7587 7588 7589 7590 7591 7592 7593 7594 7595 7596 7597 7598 7599 7600 7601 7602 7603 7604 7605 7606 7607 7608 7609 7610 7611 7612 7613 7614 7615 7616 7617 7618 7619 7620 7621 7622 7623 7624 7625 7626 7627 7628 7629 7630 7631 7632 7633 7634 7635 7636 7637 7638 7639 7640 7641 7642 7643 7644 7645 7646 7647 7648 7649 7650 7651 7652 7653 7654 7655 7656 7657 7658 7659 7660 7661 7662 7663 7664 7665 7666 7667 7668 7669 7670 7671 7672 7673 7674 7675 7676 7677 7678 7679 7680 7681 7682 7683 7684 7685 7686 7687 7688 7689 7690 7691 7692 7693 7694 7695 7696 7697 7698 7699 7700 7701 7702 7703 7704 7705 7706 7707 7708 7709 7710 7711 7712 7713 7714 7715 7716 7717 7718 7719 7720 7721 7722 7723 7724 7725 7726 7727 7728 7729 7730 7731 7732 7733 7734 7735 7736 7737 7738 7739 7740 7741 7742 7743 7744 7745 7746 7747 7748 7749 7750 7751 7752 7753 7754 7755 7756 7757 7758 7759 7760 7761 7762 7763 7764 7765 7766 7767 7768 7769 7770 7771 7772 7773 7774 7775 7776 7777 7778 7779 7780 7781 7782 7783 7784 7785 7786 7787 7788 7789 7790 7791 7792 7793 7794 7795 7796 7797 7798 7799 7800 7801 7802 7803 7804 7805 7806 7807 7808 7809 7810 7811 7812 7813 7814 7815 7816 7817 7818 7819 7820 7821 7822 7823 7824 7825 7826 7827 7828 7829 7830 7831 7832 7833 7834 7835 7836 7837 7838 7839 7840 7841 7842 7843 7844 7845 7846 7847 7848 7849 7850 7851 7852 7853 7854 7855 7856 7857 7858 7859 7860 7861 7862 7863 7864 7865 7866 7867 7868 7869 7870 7871 7872 7873 7874 7875 7876 7877 7878 7879 7880 7881 7882 7883 7884 7885 7886 7887 7888 7889 7890 7891 7892 7893 7894 7895 7896 7897 7898 7899 7900 7901 7902 7903 7904 7905 7906 7907 7908 7909 7910 7911 7912 7913 7914 7915 7916 7917 7918 7919 7920 7921 7922 7923 7924 7925 7926 7927 7928 7929 7930 7931 7932 7933 7934 7935 7936 7937 7938 7939 7940 7941 7942 7943 7944 7945 7946 7947 7948 7949 7950 7951 7952 7953 7954 7955 7956 7957 7958 7959 7960 7961 7962 7963 7964 7965 7966 7967 7968 7969 7970 7971 7972 7973 7974 7975 7976 7977 7978 7979 7980 7981 7982 7983 7984 7985 7986 7987 7988 7989 7990 7991 7992 7993 7994 7995 7996 7997 7998 7999 8000 8001 8002 8003 8004 8005 8006 8007 8008 8009 8010 8011 8012 8013 8014 8015 8016 8017 8018 8019 8020 8021 8022 8023 8024 8025 8026 8027 8028 8029 8030 8031 8032 8033 8034 8035 8036 8037 8038 8039 8040 8041 8042 8043 8044 8045 8046 8047 8048 8049 8050 8051 8052 8053 8054 8055 8056 8057 8058 8059 8060 8061 8062 8063 8064 8065 8066 8067 8068 8069 8070 8071 8072 8073 8074 8075 8076 8077 8078 8079 8080 8081 8082 8083 8084 8085 8086 8087 8088 8089 8090 8091 8092 8093 8094 8095 8096 8097 8098 8099 8100 8101 8102 8103 8104 8105 8106 8107 8108 8109 8110 8111 8112 8113 8114 8115 8116 8117 8118 8119 8120 8121 8122 8123 8124 8125 8126 8127 8128 8129 8130 8131 8132 8133 8134 8135 8136 8137 8138 8139 8140 8141 8142 8143 8144 8145 8146 8147 8148 8149 8150 8151 8152 8153 8154 8155 8156 8157 8158 8159 8160 8161 8162 8163 8164 8165 8166 8167 8168 8169 8170 8171 8172 8173 8174 8175 8176 8177 8178 8179 8180 8181 8182 8183 8184 8185 8186 8187 8188 8189 8190 8191 8192 8193 8194 8195 8196 8197 8198 8199 8200 8201 8202 8203 8204 8205 8206 8207 8208 8209 8210 8211 8212 8213 8214 8215 8216 8217 8218 8219 8220 8221 8222 8223 8224 8225 8226 8227 8228 8229 8230 8231 8232 8233 8234 8235 8236 8237 8238 8239 8240 8241 8242 8243 8244 8245 8246 8247 8248 8249 8250 8251 8252 8253 8254 8255 8256 8257 8258 8259 8260 8261 8262 8263 8264 8265 8266 8267 8268 8269 8270 8271 8272 8273 8274 8275 8276 8277 8278 8279 8280 8281 8282 8283 8284 8285 8286 8287 8288 8289 8290 8291 8292 8293 8294 8295 8296 8297 8298 8299 8300 8301 8302 8303 8304 8305 8306 8307 8308 8309 8310 8311 8312 8313 8314 8315 8316 8317 8318 8319 8320 8321 8322 8323 8324 8325 8326 8327 8328 8329 8330 8331 8332 8333 8334 8335 8336 8337 8338 8339 8340 8341 8342 8343 8344 8345 8346 8347 8348 8349 8350 8351 8352 8353 8354 8355 8356 8357 8358 8359 8360 8361 8362 8363 8364 8365 8366 8367 8368 8369 8370 8371 8372 8373 8374 8375 8376 8377 8378 8379 8380 8381 8382 8383 8384 8385 8386 8387 8388 8389 8390 8391 8392 8393 8394 8395 8396 8397 8398 8399 8400 8401 8402 8403 8404 8405 8406 8407 8408 8409 8410 8411 8412 8413 8414 8415 8416 8417 8418 8419 8420 8421 8422 8423 8424 8425 8426 8427 8428 8429 8430 8431 8432 8433 8434 8435 8436 8437 8438 8439 8440 8441 8442 8443 8444 8445 8446 8447 8448 8449 8450 8451 8452 8453 8454 8455 8456 8457 8458 8459 8460 8461 8462 8463 8464 8465 8466 8467 8468 8469 8470 8471 8472 8473 8474 8475 8476 8477 8478 8479 8480 8481 8482 8483 8484 8485 8486 8487 8488 8489 8490 8491 8492 8493 8494 8495 8496 8497 8498 8499 8500 8501 8502 8503 8504 8505 8506 8507 8508 8509 8510 8511 8512 8513 8514 8515 8516 8517 8518 8519 8520 8521 8522 8523 8524 8525 8526 8527 8528 8529 8530 8531 8532 8533 8534 8535 8536 8537 8538 8539 8540 8541 8542 8543 8544 8545 8546 8547 8548 8549 8550 8551 8552 8553 8554 8555 8556 8557 8558 8559 8560 8561 8562 8563 8564 8565 8566 8567 8568 8569 8570 8571 8572 8573 8574 8575 8576 8577 8578 8579 8580 8581 8582 8583 8584 8585 8586 8587 8588 8589 8590 8591 8592 8593 8594 8595 8596 8597 8598 8599 8600 8601 8602 8603 8604 8605 8606 8607 8608 8609 8610 8611 8612 8613 8614 8615 8616 8617 8618 8619 8620 8621 8622 8623 8624 8625 8626 8627 8628 8629 8630 8631 8632 8633 8634 8635 8636 8637 8638 8639 8640 8641 8642 8643 8644 8645 8646 8647 8648 8649 8650 8651 8652 8653 8654 8655 8656 8657 8658 8659 8660 8661 8662 8663 8664 8665 8666 8667 8668 8669 8670 8671 8672 8673 8674 8675 8676 8677 8678 8679 8680 8681 8682 8683 8684 8685 8686 8687 8688 8689 8690 8691 8692 8693 8694 8695 8696 8697 8698 8699 8700 8701 8702 8703 8704 8705 8706 8707 8708 8709 8710 8711 8712 8713 8714 8715 8716 8717 8718 8719 8720 8721 8722 8723 8724 8725 8726 8727 8728 8729 8730 8731 8732 8733 8734 8735 8736 8737 8738 8739 8740 8741 8742 8743 8744 8745 8746 8747 8748 8749 8750 8751 8752 8753 8754 8755 8756 8757 8758 8759 8760 8761 8762 8763 8764 8765 8766 8767 8768 8769 8770 8771 8772 8773 8774 8775 8776 8777 8778 8779 8780 8781 8782 8783 8784 8785 8786 8787 8788 8789 8790 8791 8792 8793 8794 8795 8796 8797 8798 8799 8800 8801 8802 8803 8804 8805 8806 8807 8808 8809 8810 8811 8812 8813 8814 8815 8816 8817 8818 8819 8820 8821 8822 8823 8824 8825 8826 8827 8828 8829 8830 8831 8832 8833 8834 8835 8836 8837 8838 8839 8840 8841 8842 8843 8844 8845 8846 8847 8848 8849 8850 8851 8852 8853 8854 8855 8856 8857 8858 8859 8860 8861 8862 8863 8864 8865 8866 8867 8868 8869 8870 8871 8872 8873 8874 8875 8876 8877 8878 8879 8880 8881 8882 8883 8884 8885 8886 8887 8888 8889 8890 8891 8892 8893 8894 8895 8896 8897 8898 8899 8900 8901 8902 8903 8904 8905 8906 8907 8908 8909 8910 8911 8912 8913 8914 8915 8916 8917 8918 8919 8920 8921 8922 8923 8924 8925 8926 8927 8928 8929 8930 8931 8932 8933 8934 8935 8936 8937 8938 8939 8940 8941 8942 8943 8944 8945 8946 8947 8948 8949 8950 8951 8952 8953 8954 8955 8956 8957 8958 8959 8960 8961 8962 8963 8964 8965 8966 8967 8968 8969 8970 8971 8972 8973 8974 8975 8976 8977 8978 8979 8980 8981 8982 8983 8984 8985 8986 8987 8988 8989 8990 8991 8992 8993 8994 8995 8996 8997 8998 8999 9000 9001 9002 9003 9004 9005 9006 9007 9008 9009 9010 9011 9012 9013 9014 9015 9016 9017 9018 9019 9020 9021 9022 9023 9024 9025 9026 9027 9028 9029 9030 9031 9032 9033 9034 9035 9036 9037 9038 9039 9040 9041 9042 9043 9044 9045 9046 9047 9048 9049 9050 9051 9052 9053 9054 9055 9056 9057 9058 9059 9060 9061 9062 9063 9064 9065 9066 9067 9068 9069 9070 9071 9072 9073 9074 9075 9076 9077 9078 9079 9080 9081 9082 9083 9084 9085 9086 9087 9088 9089 9090 9091 9092 9093 9094 9095 9096 9097 9098 9099 9100 9101 9102 9103 9104 9105 9106 9107 9108 9109 9110 9111 9112 9113 9114 9115 9116 9117 9118 9119 9120 9121 9122 9123 9124 9125 9126 9127 9128 9129 9130 9131 9132 9133 9134 9135 9136 9137 9138 9139 9140 9141 9142 9143 9144 9145 9146 9147 9148 9149 9150 9151 9152 9153 9154 9155 9156 9157 9158 9159 9160 9161 9162 9163 9164 9165 9166 9167 9168 9169 9170 9171 9172 9173 9174 9175 9176 9177 9178 9179 9180 9181 9182 9183 9184 9185 9186 9187 9188 9189 9190 9191 9192 9193 9194 9195 9196 9197 9198 9199 9200 9201 9202 9203 9204 9205 9206 9207 9208 9209 9210 9211 9212 9213 9214 9215 9216 9217 9218 9219 9220 9221 9222 9223 9224 9225 9226 9227 9228 9229 9230 9231 9232 9233 9234 9235 9236 9237 9238 9239 9240 9241 9242 9243 9244 9245 9246 9247 9248 9249 9250 9251 9252 9253 9254 9255 9256 9257 9258 9259 9260 9261 9262 9263 9264 9265 9266 9267 9268 9269 9270 9271 9272 9273 9274 9275 9276 9277 9278 9279 9280 9281 9282 9283 9284 9285 9286 9287 9288 9289 9290 9291 9292 9293 9294 9295 9296 9297 9298 9299 9300 9301 9302 9303 9304 9305 9306 9307 9308 9309 9310 9311 9312 9313 9314 9315 9316 9317 9318 9319 9320 9321 9322 9323 9324 9325 9326 9327 9328 9329 9330 9331 9332 9333 9334 9335 9336 9337 9338 9339 9340 9341 9342 9343 9344 9345 9346 9347 9348 9349 9350 9351 9352 9353 9354 9355 9356 9357 9358 9359 9360 9361 9362 9363 9364 9365 9366 9367 9368 9369 9370 9371 9372 9373 9374 9375 9376 9377 9378 9379 9380 9381 9382 9383 9384 9385 9386 9387 9388 9389 9390 9391 9392 9393 9394 9395 9396 9397 9398 9399 9400 9401 9402 9403 9404 9405 9406 9407 9408 9409 9410 9411 9412 9413 9414 9415 9416 9417 9418 9419 9420 9421 9422 9423 9424 9425 9426 9427 9428 9429 9430 9431 9432 9433 9434 9435 9436 9437 9438 9439 9440 9441 9442 9443 9444 9445 9446 9447 9448 9449 9450 9451 9452 9453 9454 9455 9456 9457 9458 9459 9460 9461 9462 9463 9464 9465 9466 9467 9468 9469 9470 9471 9472 9473 9474 9475 9476 9477 9478 9479 9480 9481 9482 9483 9484 9485 9486 9487 9488 9489 9490 9491 9492 9493 9494 9495 9496 9497 9498 9499 9500 9501 9502 9503 9504 9505 9506 9507 9508 9509 9510 9511 9512 9513 9514 9515 9516 9517 9518 9519 9520 9521 9522 9523 9524 9525 9526 9527 9528 9529 9530 9531 9532 9533 9534 9535 9536 9537 9538 9539 9540 9541 9542 9543 9544 9545 9546 9547 9548 9549 9550 9551 9552 9553 9554 9555 9556 9557 9558 9559 9560 9561 9562 9563 9564 9565 9566 9567 9568 9569 9570 9571 9572 9573 9574 9575 9576 9577 9578 9579 9580 9581 9582 9583 9584 9585 9586 9587 9588 9589 9590 9591 9592 9593 9594 9595 9596 9597 9598 9599 9600 9601 9602 9603 9604 9605 9606 9607 9608 9609 9610 9611 9612 9613 9614 9615 9616 9617 9618 9619 9620 9621 9622 9623 9624 9625 9626 9627 9628 9629 9630 9631 9632 9633 9634 9635 9636 9637 9638 9639 9640 9641 9642 9643 9644 9645 9646 9647 9648 9649 9650 9651 9652 9653 9654 9655 9656 9657 9658 9659 9660 9661 9662 9663 9664 9665 9666 9667 9668 9669 9670 9671 9672 9673 9674 9675 9676 9677 9678 9679 9680 9681 9682 9683 9684 9685 9686 9687 9688 9689 9690 9691 9692 9693 9694 9695 9696 9697 9698 9699 9700 9701 9702 9703 9704 9705 9706 9707 9708 9709 9710 9711 9712 9713 9714 9715 9716 9717 9718 9719 9720 9721 9722 9723 9724 9725 9726 9727 9728 9729 9730 9731 9732 9733 9734 9735 9736 9737 9738 9739 9740 9741 9742 9743 9744 9745 9746 9747 9748 9749 9750 9751 9752 9753 9754 9755 9756 9757 9758 9759 9760 9761 9762 9763 9764 9765 9766 9767 9768 9769 9770 9771 9772 9773 9774 9775 9776 9777 9778 9779 9780 9781 9782 9783 9784 9785 9786 9787 9788 9789 9790 9791 9792 9793 9794 9795 9796 9797 9798 9799 9800 9801 9802 9803 9804 9805 9806 9807 9808 9809 9810 9811 9812 9813 9814 9815 9816 9817 9818 9819 9820 9821 9822 9823 9824 9825 9826 9827 9828 9829 9830 9831 9832 9833 9834 9835 9836 9837 9838 9839 9840 9841 9842 9843 9844 9845 9846 9847 9848 9849 9850 9851 9852 9853 9854 9855 9856 9857 9858 9859 9860 9861 9862 9863 9864 9865 9866 9867 9868 9869 9870 9871 9872 9873 9874 9875 9876 9877 9878 9879 9880 9881 9882 9883 9884 9885 9886 9887 9888 9889 9890 9891 9892 9893 9894 9895 9896 9897 9898 9899 9900 9901 9902 9903 9904 9905 9906 9907 9908 9909 9910 9911 9912 9913 9914 9915 9916 9917 9918 9919 9920 9921 9922 9923 9924 9925 9926 9927 9928 9929 9930 9931 9932 9933 9934 9935 9936 9937 9938 9939 9940 9941 9942 9943 9944 9945 9946 9947 9948 9949 9950 9951 9952 9953 9954 9955 9956 9957 9958 9959 9960 9961 9962 9963 9964 9965 9966 9967 9968 9969 9970 9971 9972 9973 9974 9975 9976 9977 9978 9979 9980 9981 9982 9983 9984 9985 9986 9987 9988 9989 9990 9991 9992 9993 9994 9995 9996 9997 9998 9999 10000 10001 10002 10003 10004 10005 10006 10007 10008 10009 10010 10011 10012 10013 10014 10015 10016 10017 10018 10019 10020 10021 10022 10023 10024 10025 10026 10027 10028 10029 10030 10031 10032 10033 10034 10035 10036 10037 10038 10039 10040 10041 10042 10043 10044 10045 10046 10047 10048 10049 10050 10051 10052 10053 10054 10055 10056 10057 10058 10059 10060 10061 10062 10063 10064 10065 10066 10067 10068 10069 10070 10071 10072 10073 10074 10075 10076 10077 10078 10079 10080 10081 10082 10083 10084 10085 10086 10087 10088 10089 10090 10091 10092 10093 10094 10095 10096 10097 10098 10099 10100 10101 10102 10103 10104 10105 10106 10107 10108 10109 10110 10111 10112 10113 10114 10115 10116 10117 10118 10119 10120 10121 10122 10123 10124 10125 10126 10127 10128 10129 10130 10131 10132 10133 10134 10135 10136 10137 10138 10139 10140 10141 10142 10143 10144 10145 10146 10147 10148 10149 10150 10151 10152 10153 10154 10155 10156 10157 10158 10159 10160 10161 10162 10163 10164 10165 10166 10167 10168 10169 10170 10171 10172 10173 10174 10175 10176 10177 10178 10179 10180 10181 10182 10183 10184 10185 10186 10187 10188 10189 10190 10191 10192 10193 10194 10195 10196 10197 10198 10199 10200 10201 10202 10203 10204 10205 10206 10207 10208 10209 10210 10211 10212 10213 10214 10215 10216 10217 10218 10219 10220 10221 10222 10223 10224 10225 10226 10227 10228 10229 10230 10231 10232 10233 10234 10235 10236 10237 10238 10239 10240 10241 10242 10243 10244 10245 10246 10247 10248 10249 10250 10251 10252 10253 10254 10255 10256 10257 10258 10259 10260 10261 10262 10263 10264 10265 10266 10267 10268 10269 10270 10271 10272 10273 10274 10275 10276 10277 10278 10279 10280 10281 10282 10283 10284 10285 10286 10287 10288 10289 10290 10291 10292 10293 10294 10295 10296 10297 10298 10299 10300 10301 10302 10303 10304 10305 10306 10307 10308 10309 10310 10311 10312 10313 10314 10315 10316 10317 10318 10319 10320 10321 10322 10323 10324 10325 10326 10327 10328 10329 10330 10331 10332 10333 10334 10335 10336 10337 10338 10339 10340 10341 10342 10343 10344 10345 10346 10347 10348 10349 10350 10351 10352 10353 10354 10355 10356 10357 10358 10359 10360 10361 10362 10363 10364 10365 10366 10367 10368 10369 10370 10371 10372 10373 10374 10375 10376 10377 10378 10379 10380 10381 10382 10383 10384 10385 10386 10387 10388 10389 10390 10391 10392 10393 10394 10395 10396 10397 10398 10399 10400 10401 10402 10403 10404 10405 10406 10407 10408 10409 10410 10411 10412 10413 10414 10415 10416 10417 10418 10419 10420 10421 10422 10423 10424 10425 10426 10427 10428 10429 10430 10431 10432 10433 10434 10435 10436 10437 10438 10439 10440 10441 10442 10443 10444 10445 10446 10447 10448 10449 10450 10451 10452 10453 10454 10455 10456 10457 10458 10459 10460 10461 10462 10463 10464 10465 10466 10467 10468 10469 10470 10471 10472 10473 10474 10475 10476 10477 10478 10479 10480 10481 10482 10483 10484 10485 10486 10487 10488 10489 10490 10491 10492 10493 10494 10495 10496 10497 10498 10499 10500 10501 10502 10503 10504 10505 10506 10507 10508 10509 10510 10511 10512 10513 10514 10515 10516 10517 10518 10519 10520 10521 10522 10523 10524 10525 10526 10527 10528 10529 10530 10531 10532 10533 10534 10535 10536 10537 10538 10539 10540 10541 10542 10543 10544 10545 10546 10547 10548 10549 10550 10551 10552 10553 10554 10555 10556 10557 10558 10559 10560 10561 10562 10563 10564 10565 10566 10567 10568 10569 10570 10571 10572 10573 10574 10575 10576 10577 10578 10579 10580 10581 10582 10583 10584 10585 10586 10587 10588 10589 10590 10591 10592 10593 10594 10595 10596 10597 10598 10599 10600 10601 10602 10603 10604 10605 10606 10607 10608 10609 10610 10611 10612 10613 10614 10615 10616 10617 10618 10619 10620 10621 10622 10623 10624 10625 10626 10627 10628 10629 10630 10631 10632 10633 10634 10635 10636 10637 10638 10639 10640 10641 10642 10643 10644 10645 10646 10647 10648 10649 10650 10651 10652 10653 10654 10655 10656 10657 10658 10659 10660 10661 10662 10663 10664 10665 10666 10667 10668 10669 10670 10671 10672 10673 10674 10675 10676 10677 10678 10679 10680 10681 10682 10683 10684 10685 10686 10687 10688 10689 10690 10691 10692 10693 10694 10695 10696 10697 10698 10699 10700 10701 10702 10703 10704 10705 10706 10707 10708 10709 10710 10711 10712 10713 10714 10715 10716 10717 10718 10719 10720 10721 10722 10723 10724 10725 10726 10727 10728 10729 10730 10731 10732 10733 10734 10735 10736 10737 10738 10739 10740 10741 10742 10743 10744 10745 10746 10747 10748 10749 10750 10751 10752 10753 10754 10755 10756 10757 10758 10759 10760 10761 10762 10763 10764 10765 10766 10767 10768 10769 10770 10771 10772 10773 10774 10775 10776 10777 10778 10779 10780 10781 10782 10783 10784 10785 10786 10787 10788 10789 10790 10791 10792 10793 10794 10795 10796 10797 10798 10799 10800 10801 10802 10803 10804 10805 10806 10807 10808 10809 10810 10811 10812 10813 10814 10815 10816 10817 10818 10819 10820 10821 10822 10823 10824 10825 10826 10827 10828 10829 10830 10831 10832 10833 10834 10835 10836 10837 10838 10839 10840 10841 10842 10843 10844 10845 10846 10847 10848 10849 10850 10851 10852 10853 10854 10855 10856 10857 10858 10859 10860 10861 10862 10863 10864 10865 10866 10867 10868 10869 10870 10871 10872 10873 10874 10875 10876 10877 10878 10879 10880 10881 10882 10883 10884 10885 10886 10887 10888 10889 10890 10891 10892 10893 10894 10895 10896 10897 10898 10899 10900 10901 10902 10903 10904 10905 10906 10907 10908 10909 10910 10911 10912 10913 10914 10915 10916 10917 10918 10919 10920 10921 10922 10923 10924 10925 10926 10927 10928 10929 10930 10931 10932 10933 10934 10935 10936 10937 10938 10939 10940 10941 10942 10943 10944 10945 10946 10947 10948 10949 10950 10951 10952 10953 10954 10955 10956 10957 10958 10959 10960 10961 10962 10963 10964 10965 10966 10967 10968 10969 10970 10971 10972 10973 10974 10975 10976 10977 10978 10979 10980 10981 10982 10983 10984 10985 10986 10987 10988 10989 10990 10991 10992 10993 10994 10995 10996 10997 10998 10999 11000 11001 11002 11003 11004 11005 11006 11007 11008 11009 11010 11011 11012 11013 11014 11015 11016 11017 11018 11019 11020 11021 11022 11023 11024 11025 11026 11027 11028 11029 11030 11031 11032 11033 11034 11035 11036 11037 11038 11039 11040 11041 11042 11043 11044 11045 11046 11047 11048 11049 11050 11051 11052 11053 11054 11055 11056 11057 11058 11059 11060 11061 11062 11063 11064 11065 11066 11067 11068 11069 11070 11071 11072 11073 11074 11075 11076 11077 11078 11079 11080 11081 11082 11083 11084 11085 11086 11087 11088 11089 11090 11091 11092 11093 11094 11095 11096 11097 11098 11099 11100 11101 11102 11103 11104 11105 11106 11107 11108 11109 11110 11111 11112 11113 11114 11115 11116 11117 11118 11119 11120 11121 11122 11123 11124 11125 11126 11127 11128 11129 11130 11131 11132 11133 11134 11135 11136 11137 11138 11139 11140 11141 11142 11143 11144 11145 11146 11147 11148 11149 11150 11151 11152 11153 11154 11155 11156 11157 11158 11159 11160 11161 11162 11163 11164 11165 11166 11167 11168 11169 11170 11171 11172 11173 11174 11175 11176 11177 11178 11179 11180 11181 11182 11183 11184 11185 11186 11187 11188 11189 11190 11191 11192 11193 11194 11195 11196 11197 11198 11199 11200 11201 11202 11203 11204 11205 11206 11207 11208 11209 11210 11211 11212 11213 11214 11215 11216 11217 11218 11219 11220 11221 11222 11223 11224 11225 11226 11227 11228 11229 11230 11231 11232 11233 11234 11235 11236 11237 11238 11239 11240 11241 11242 11243 11244 11245 11246 11247 11248 11249 11250 11251 11252 11253 11254 11255 11256 11257 11258 11259 11260 11261 11262 11263 11264 11265 11266 11267 11268 11269 11270 11271 11272 11273 11274 11275 11276 11277 11278 11279 11280 11281 11282 11283 11284 11285 11286 11287 11288 11289 11290 11291 11292 11293 11294 11295 11296 11297 11298 11299 11300 11301 11302 11303 11304 11305 11306 11307 11308 11309 11310 11311 11312 11313 11314 11315 11316 11317 11318 11319 11320 11321 11322 11323 11324 11325 11326 11327 11328 11329 11330 11331 11332 11333 11334 11335 11336 11337 11338 11339 11340 11341 11342 11343 11344 11345 11346 11347 11348 11349 11350 11351 11352 11353 11354 11355 11356 11357 11358 11359 11360 11361 11362 11363 11364 11365 11366 11367 11368 11369 11370 11371 11372 11373 11374 11375 11376 11377 11378 11379 11380 11381 11382 11383 11384 11385 11386 11387 11388 11389 11390 11391 11392 11393 11394 11395 11396 11397 11398 11399 11400 11401 11402 11403 11404 11405 11406 11407 11408 11409 11410 11411 11412 11413 11414 11415 11416 11417 11418 11419 11420 11421 11422 11423 11424 11425 11426 11427 11428 11429 11430 11431 11432 11433 11434 11435 11436 11437 11438 11439 11440 11441 11442 11443 11444 11445 11446 11447 11448 11449 11450 11451 11452 11453 11454 11455 11456 11457 11458 11459 11460 11461 11462 11463 11464 11465 11466 11467 11468 11469 11470 11471 11472 11473 11474 11475 11476 11477 11478 11479 11480 11481 11482 11483 11484 11485 11486 11487 11488 11489 11490 11491 11492 11493 11494 11495 11496 11497 11498 11499 11500 11501 11502 11503 11504 11505 11506 11507 11508 11509 11510 11511 11512 11513 11514 11515 11516 11517 11518 11519 11520 11521 11522 11523 11524 11525 11526 11527 11528 11529 11530 11531 11532 11533 11534 11535 11536 11537 11538 11539 11540 11541 11542 11543 11544 11545 11546 11547 11548 11549 11550 11551 11552 11553 11554 11555 11556 11557 11558 11559 11560 11561 11562 11563 11564 11565 11566 11567 11568 11569 11570 11571 11572 11573 11574 11575 11576 11577 11578 11579 11580 11581 11582 11583 11584 11585 11586 11587 11588 11589 11590 11591 11592 11593 11594 11595 11596 11597 11598 11599 11600 11601 11602 11603 11604 11605 11606 11607 11608 11609 11610 11611 11612 11613 11614 11615 11616 11617 11618 11619 11620 11621 11622 11623 11624 11625 11626 11627 11628 11629 11630 11631 11632 11633 11634 11635 11636 11637 11638 11639 11640 11641 11642 11643 11644 11645 11646 11647 11648 11649 11650 11651 11652 11653 11654 11655 11656 11657 11658 11659 11660 11661 11662 11663 11664 11665 11666 11667 11668 11669 11670 11671 11672 11673 11674 11675 11676 11677 11678 11679 11680 11681 11682 11683 11684 11685 11686 11687 11688 11689 11690 11691 11692 11693 11694 11695 11696 11697 11698 11699 11700 11701 11702 11703 11704 11705 11706 11707 11708 11709 11710 11711 11712 11713 11714 11715 11716 11717 11718 11719 11720 11721 11722 11723 11724 11725 11726 11727 11728 11729 11730 11731 11732 11733 11734 11735 11736 11737 11738 11739 11740 11741 11742 11743 11744 11745 11746 11747 11748 11749 11750 11751 11752 11753 11754 11755 11756 11757 11758 11759 11760 11761 11762 11763 11764 11765 11766 11767 11768 11769 11770 11771 11772 11773 11774 11775 11776 11777 11778 11779 11780 11781 11782 11783 11784 11785 11786 11787 11788 11789 11790 11791 11792 11793 11794 11795 11796 11797 11798 11799 11800 11801 11802 11803 11804 11805 11806 11807 11808 11809 11810 11811 11812 11813 11814 11815 11816 11817 11818 11819 11820 11821 11822 11823 11824 11825 11826 11827 11828 11829 11830 11831 11832 11833 11834 11835 11836 11837 11838 11839 11840 11841 11842 11843 11844 11845 11846 11847 11848 11849 11850 11851 11852 11853 11854 11855 11856 11857 11858 11859 11860 11861 11862 11863 11864 11865 11866 11867 11868 11869 11870 11871 11872 11873 11874 11875 11876 11877 11878 11879 11880 11881 11882 11883 11884 11885 11886 11887 11888 11889 11890 11891 11892 11893 11894 11895 11896 11897 11898 11899 11900 11901 11902 11903 11904 11905 11906 11907 11908 11909 11910 11911 11912 11913 11914 11915 11916 11917 11918 11919 11920 11921 11922 11923 11924 11925 11926 11927 11928 11929 11930 11931 11932 11933 11934 11935 11936 11937 11938 11939 11940 11941 11942 11943 11944 11945 11946 11947 11948 11949 11950 11951 11952 11953 11954 11955 11956 11957 11958 11959 11960 11961 11962 11963 11964 11965 11966 11967 11968 11969 11970 11971 11972 11973 11974 11975 11976 11977 11978 11979 11980 11981 11982 11983 11984 11985 11986 11987 11988 11989 11990 11991 11992 11993 11994 11995 11996 11997 11998 11999 12000 12001 12002 12003 12004 12005 12006 12007 12008 12009 12010 12011 12012 12013 12014 12015 12016 12017 12018 12019 12020 12021 12022 12023 12024 12025 12026 12027 12028 12029 12030 12031 12032 12033 12034 12035 12036 12037 12038 12039 12040 12041 12042 12043 12044 12045 12046 12047 12048 12049 12050 12051 12052 12053 12054 12055 12056 12057 12058 12059 12060 12061 12062 12063 12064 12065 12066 12067 12068 12069 12070 12071 12072 12073 12074 12075 12076 12077 12078 12079 12080 12081 12082 12083 12084 12085 12086 12087 12088 12089 12090 12091 12092 12093 12094 12095 12096 12097 12098 12099 12100 12101 12102 12103 12104 12105 12106 12107 12108 12109 12110 12111 12112 12113 12114 12115 12116 12117 12118 12119 12120 12121 12122 12123 12124 12125 12126 12127 12128 12129 12130 12131 12132 12133 12134 12135 12136 12137 12138 12139 12140 12141 12142 12143 12144 12145 12146 12147 12148 12149 12150 12151 12152 12153 12154 12155 12156 12157 12158 12159 12160 12161 12162 12163 12164 12165 12166 12167 12168 12169 12170 12171 12172 12173 12174 12175 12176 12177 12178 12179 12180 12181 12182 12183 12184 12185 12186 12187 12188 12189 12190 12191 12192 12193 12194 12195 12196 12197 12198 12199 12200 12201 12202 12203 12204 12205 12206 12207 12208 12209 12210 12211 12212 12213 12214 12215 12216 12217 12218 12219 12220 12221 12222 12223 12224 12225 12226 12227 12228 12229 12230 12231 12232 12233 12234 12235 12236 12237 12238 12239 12240 12241 12242 12243 12244 12245 12246 12247 12248 12249 12250 12251 12252 12253 12254 12255 12256 12257 12258 12259 12260 12261 12262 12263 12264 12265 12266 12267 12268 12269 12270 12271 12272 12273 12274 12275 12276 12277 12278 12279 12280 12281 12282 12283 12284 12285 12286 12287 12288 12289 12290 12291 12292 12293 12294 12295 12296 12297 12298 12299 12300 12301 12302 12303 12304 12305 12306 12307 12308 12309 12310 12311 12312 12313 12314 12315 12316 12317 12318 12319 12320 12321 12322 12323 12324 12325 12326 12327 12328 12329 12330 12331 12332 12333 12334 12335 12336 12337 12338 12339 12340 12341 12342 12343 12344 12345 12346 12347 12348 12349 12350 12351 12352 12353 12354 12355 12356 12357 12358 12359 12360 12361 12362 12363 12364 12365 12366 12367 12368 12369 12370 12371 12372 12373 12374 12375 12376 12377 12378 12379 12380 12381 12382 12383 12384 12385 12386 12387 12388 12389 12390 12391 12392 12393 12394 12395 12396 12397 12398 12399 12400 12401 12402 12403 12404 12405 12406 12407 12408 12409 12410 12411 12412 12413 12414 12415 12416 12417 12418 12419 12420 12421 12422 12423 12424 12425 12426 12427 12428 12429 12430 12431 12432 12433 12434 12435 12436 12437 12438 12439 12440 12441 12442 12443 12444 12445 12446 12447 12448 12449 12450 12451 12452 12453 12454 12455 12456 12457 12458 12459 12460 12461 12462 12463 12464 12465 12466 12467 12468 12469 12470 12471 12472 12473 12474 12475 12476 12477 12478 12479 12480 12481 12482 12483 12484 12485 12486 12487 12488 12489 12490 12491 12492 12493 12494 12495 12496 12497 12498 12499 12500 12501 12502 12503 12504 12505 12506 12507 12508 12509 12510 12511 12512 12513 12514 12515 12516 12517 12518 12519 12520 12521 12522 12523 12524 12525 12526 12527 12528 12529 12530 12531 12532 12533 12534 12535 12536 12537 12538 12539 12540 12541 12542 12543 12544 12545 12546 12547 12548 12549 12550 12551 12552 12553 12554 12555 12556 12557 12558 12559 12560 12561 12562 12563 12564 12565 12566 12567 12568 12569 12570 12571 12572 12573 12574 12575 12576 12577 12578 12579 12580 12581 12582 12583 12584 12585 12586 12587 12588 12589 12590 12591 12592 12593 12594 12595 12596 12597 12598 12599 12600 12601 12602 12603 12604 12605 12606 12607 12608 12609 12610 12611 12612 12613 12614 12615 12616 12617 12618 12619 12620 12621 12622 12623 12624 12625 12626 12627 12628 12629 12630 12631 12632 12633 12634 12635 12636 12637 12638 12639 12640 12641 12642 12643 12644 12645 12646 12647 12648 12649 12650 12651 12652 12653 12654 12655 12656 12657 12658 12659 12660 12661 12662 12663 12664 12665 12666 12667 12668 12669 12670 12671 12672 12673 12674 12675 12676 12677 12678 12679 12680 12681 12682 12683 12684 12685 12686 12687 12688 12689 12690 12691 12692 12693 12694 12695 12696 12697 12698 12699 12700 12701 12702 12703 12704 12705 12706 12707 12708 12709 12710 12711 12712 12713 12714 12715 12716 12717 12718 12719 12720 12721 12722 12723 12724 12725 12726 12727 12728 12729 12730 12731 12732 12733 12734 12735 12736 12737 12738 12739 12740 12741 12742 12743 12744 12745 12746 12747 12748 12749 12750 12751 12752 12753 12754 12755 12756 12757 12758 12759 12760 12761 12762 12763 12764 12765 12766 12767 12768 12769 12770 12771 12772 12773 12774 12775 12776 12777 12778 12779 12780 12781 12782 12783 12784 12785 12786 12787 12788 12789 12790 12791 12792 12793 12794 12795 12796 12797 12798 12799 12800 12801 12802 12803 12804 12805 12806 12807 12808 12809 12810 12811 12812 12813 12814 12815 12816 12817 12818 12819 12820 12821 12822 12823 12824 12825 12826 12827 12828 12829 12830 12831 12832 12833 12834 12835 12836 12837 12838 12839 12840 12841 12842 12843 12844 12845 12846 12847 12848 12849 12850 12851 12852 12853 12854 12855 12856 12857 12858 12859 12860 12861 12862 12863 12864 12865 12866 12867 12868 12869 12870 12871 12872 12873 12874 12875 12876 12877 12878 12879 12880 12881 12882 12883 12884 12885 12886 12887 12888 12889 12890 12891 12892 12893 12894 12895 12896 12897 12898 12899 12900 12901 12902 12903 12904 12905 12906 12907 12908 12909 12910 12911 12912 12913 12914 12915 12916 12917 12918 12919 12920 12921 12922 12923 12924 12925 12926 12927 12928 12929 12930 12931 12932 12933 12934 12935 12936 12937 12938 12939 12940 12941 12942 12943 12944 12945 12946 12947 12948 12949 12950 12951 12952 12953 12954 12955 12956 12957 12958 12959 12960 12961 12962 12963 12964 12965 12966 12967 12968 12969 12970 12971 12972 12973 12974 12975 12976 12977 12978 12979 12980 12981 12982 12983 12984 12985 12986 12987 12988 12989 12990 12991 12992 12993 12994 12995 12996 12997 12998 12999 13000 13001 13002 13003 13004 13005 13006 13007 13008 13009 13010 13011 13012 13013 13014 13015 13016 13017 13018 13019 13020 13021 13022 13023 13024 13025 13026 13027 13028 13029 13030 13031 13032 13033 13034 13035 13036 13037 13038 13039 13040 13041 13042 13043 13044 13045 13046 13047 13048 13049 13050 13051 13052 13053 13054 13055 13056 13057 13058 13059 13060 13061 13062 13063 13064 13065 13066 13067 13068 13069 13070 13071 13072 13073 13074 13075 13076 13077 13078 13079 13080 13081 13082 13083 13084 13085 13086 13087 13088 13089 13090 13091 13092 13093 13094 13095 13096 13097 13098 13099 13100 13101 13102 13103 13104 13105 13106 13107 13108 13109 13110 13111 13112 13113 13114 13115 13116 13117 13118 13119 13120 13121 13122 13123 13124 13125 13126 13127 13128 13129 13130 13131 13132 13133 13134 13135 13136 13137 13138 13139 13140 13141 13142 13143 13144 13145 13146 13147 13148 13149 13150 13151 13152 13153 13154 13155 13156 13157 13158 13159 13160 13161 13162 13163 13164 13165 13166 13167 13168 13169 13170 13171 13172 13173 13174 13175 13176 13177 13178 13179 13180 13181 13182 13183 13184 13185 13186 13187 13188 13189 13190 13191 13192 13193 13194 13195 13196 13197 13198 13199 13200 13201 13202 13203 13204 13205 13206 13207 13208 13209 13210 13211 13212 13213 13214 13215 13216 13217 13218 13219 13220 13221 13222 13223 13224 13225 13226 13227 13228 13229 13230 13231 13232 13233 13234 13235 13236 13237 13238 13239 13240 13241 13242 13243 13244 13245 13246 13247 13248 13249 13250 13251 13252 13253 13254 13255 13256 13257 13258 13259 13260 13261 13262 13263 13264 13265 13266 13267 13268 13269 13270 13271 13272 13273 13274 13275 13276 13277 13278 13279 13280 13281 13282 13283 13284 13285 13286 13287 13288 13289 13290 13291 13292 13293 13294 13295 13296 13297 13298 13299 13300 13301 13302 13303 13304 13305 13306 13307 13308 13309 13310 13311 13312 13313 13314 13315 13316 13317 13318 13319 13320 13321 13322 13323 13324 13325 13326 13327 13328 13329 13330 13331 13332 13333 13334 13335 13336 13337 13338 13339 13340 13341 13342 13343 13344 13345 13346 13347 13348 13349 13350 13351 13352 13353 13354 13355 13356 13357 13358 13359 13360 13361 13362 13363 13364 13365 13366 13367 13368 13369 13370 13371 13372 13373 13374 13375 13376 13377 13378 13379 13380 13381 13382 13383 13384 13385 13386 13387 13388 13389 13390 13391 13392 13393 13394 13395 13396 13397 13398 13399 13400 13401 13402 13403 13404 13405 13406 13407 13408 13409 13410 13411 13412 13413 13414 13415 13416 13417 13418 13419 13420 13421 13422 13423 13424 13425 13426 13427 13428 13429 13430 13431 13432 13433 13434 13435 13436 13437 13438 13439 13440 13441 13442 13443 13444 13445 13446 13447 13448 13449 13450 13451 13452 13453 13454 13455 13456 13457 13458 13459 13460 13461 13462 13463 13464 13465 13466 13467 13468 13469 13470 13471 13472 13473 13474 13475 13476 13477 13478 13479 13480 13481 13482 13483 13484 13485 13486 13487 13488 13489 13490 13491 13492 13493 13494 13495 13496 13497 13498 13499 13500 13501 13502 13503 13504 13505 13506 13507 13508 13509 13510 13511 13512 13513 13514 13515 13516 13517 13518 13519 13520 13521 13522 13523 13524 13525 13526 13527 13528 13529 13530 13531 13532 13533 13534 13535 13536 13537 13538 13539 13540 13541 13542 13543 13544 13545 13546 13547 13548 13549 13550 13551 13552 13553 13554 13555 13556 13557 13558 13559 13560 13561 13562 13563 13564 13565 13566 13567 13568 13569 13570 13571 13572 13573 13574 13575 13576 13577 13578 13579 13580 13581 13582 13583 13584 13585 13586 13587 13588 13589 13590 13591 13592 13593 13594 13595 13596 13597 13598 13599 13600 13601 13602 13603 13604 13605 13606 13607 13608 13609 13610 13611 13612 13613 13614 13615 13616 13617 13618 13619 13620 13621 13622 13623 13624 13625 13626 13627 13628 13629 13630 13631 13632 13633 13634 13635 13636 13637 13638 13639 13640 13641 13642 13643 13644 13645 13646 13647 13648 13649 13650 13651 13652 13653 13654 13655 13656 13657 13658 13659 13660 13661 13662 13663 13664 13665 13666 13667 13668 13669 13670 13671 13672 13673 13674 13675 13676 13677 13678 13679 13680 13681 13682 13683 13684 13685 13686 13687 13688 13689 13690 13691 13692 13693 13694 13695 13696 13697 13698 13699 13700 13701 13702 13703 13704 13705 13706 13707 13708 13709 13710 13711 13712 13713 13714 13715 13716 13717 13718 13719 13720 13721 13722 13723 13724 13725 13726 13727 13728 13729 13730 13731 13732 13733 13734 13735 13736 13737 13738 13739 13740 13741 13742 13743 13744 13745 13746 13747 13748 13749 13750 13751 13752 13753 13754 13755 13756 13757 13758 13759 13760 13761 13762 13763 13764 13765 13766 13767 13768 13769 13770 13771 13772 13773 13774 13775 13776 13777 13778 13779 13780 13781 13782 13783 13784 13785 13786 13787 13788 13789 13790 13791 13792 13793 13794 13795 13796 13797 13798 13799 13800 13801 13802 13803 13804 13805 13806 13807 13808 13809 13810 13811 13812 13813 13814 13815 13816 13817 13818 13819 13820 13821 13822 13823 13824 13825 13826 13827 13828 13829 13830 13831 13832 13833 13834 13835 13836 13837 13838 13839 13840 13841 13842 13843 13844 13845 13846 13847 13848 13849 13850 13851 13852 13853 13854 13855 13856 13857 13858 13859 13860 13861 13862 13863 13864 13865 13866 13867 13868 13869 13870 13871 13872 13873 13874 13875 13876 13877 13878 13879 13880 13881 13882 13883 13884 13885 13886 13887 13888 13889 13890 13891 13892 13893 13894 13895 13896 13897 13898 13899 13900 13901 13902 13903 13904 13905 13906 13907 13908 13909 13910 13911 13912 13913 13914 13915 13916 13917 13918 13919 13920 13921 13922 13923 13924 13925 13926 13927 13928 13929 13930 13931 13932 13933 13934 13935 13936 13937 13938 13939 13940 13941 13942 13943 13944 13945 13946 13947 13948 13949 13950 13951 13952 13953 13954 13955 13956 13957 13958 13959 13960 13961 13962 13963 13964 13965 13966 13967 13968 13969 13970 13971 13972 13973 13974 13975 13976 13977 13978 13979 13980 13981 13982 13983 13984 13985 13986 13987 13988 13989 13990 13991 13992 13993 13994 13995 13996 13997 13998 13999 14000 14001 14002 14003 14004 14005 14006 14007 14008 14009 14010 14011 14012 14013 14014 14015 14016 14017 14018 14019 14020 14021 14022 14023 14024 14025 14026 14027 14028 14029 14030 14031 14032 14033 14034 14035 14036 14037 14038 14039 14040 14041 14042 14043 14044 14045 14046 14047 14048 14049 14050 14051 14052 14053 14054 14055 14056 14057 14058 14059 14060 14061 14062 14063 14064 14065 14066 14067 14068 14069 14070 14071 14072 14073 14074 14075 14076 14077 14078 14079 14080 14081 14082 14083 14084 14085 14086 14087 14088 14089 14090 14091 14092 14093 14094 14095 14096 14097 14098 14099 14100 14101 14102 14103 14104 14105 14106 14107 14108 14109 14110 14111 14112 14113 14114 14115 14116 14117 14118 14119 14120 14121 14122 14123 14124 14125 14126 14127 14128 14129 14130 14131 14132 14133 14134 14135 14136 14137 14138 14139 14140 14141 14142 14143 14144 14145 14146 14147 14148 14149 14150 14151 14152 14153 14154 14155 14156 14157 14158 14159 14160 14161 14162 14163 14164 14165 14166 14167 14168 14169 14170 14171 14172 14173 14174 14175 14176 14177 14178 14179 14180 14181 14182 14183 14184 14185 14186 14187 14188 14189 14190 14191 14192 14193 14194 14195 14196 14197 14198 14199 14200 14201 14202 14203 14204 14205 14206 14207 14208 14209 14210 14211 14212 14213 14214 14215 14216 14217 14218 14219 14220 14221 14222 14223 14224 14225 14226 14227 14228 14229 14230 14231 14232 14233 14234 14235 14236 14237 14238 14239 14240 14241 14242 14243 14244 14245 14246 14247 14248 14249 14250 14251 14252 14253 14254 14255 14256 14257 14258 14259 14260 14261 14262 14263 14264 14265 14266 14267 14268 14269 14270 14271 14272 14273 14274 14275 14276 14277 14278 14279 14280 14281 14282 14283 14284 14285 14286 14287 14288 14289 14290 14291 14292 14293 14294 14295 14296 14297 14298 14299 14300 14301 14302 14303 14304 14305 14306 14307 14308 14309 14310 14311 14312 14313 14314 14315 14316 14317 14318 14319 14320 14321 14322 14323 14324 14325 14326 14327 14328 14329 14330 14331 14332 14333 14334 14335 14336 14337 14338 14339 14340 14341 14342 14343 14344 14345 14346 14347 14348 14349 14350 14351 14352 14353 14354 14355 14356 14357 14358 14359 14360 14361 14362 14363 14364 14365 14366 14367 14368 14369 14370 14371 14372 14373 14374 14375 14376 14377 14378 14379 14380 14381 14382 14383 14384 14385 14386 14387 14388 14389 14390 14391 14392 14393 14394 14395 14396 14397 14398 14399 14400 14401 14402 14403 14404 14405 14406 14407 14408 14409 14410 14411 14412 14413 14414 14415 14416 14417 14418 14419 14420 14421 14422 14423 14424 14425 14426 14427 14428 14429 14430 14431 14432 14433 14434 14435 14436 14437 14438 14439 14440 14441 14442 14443 14444 14445 14446 14447 14448 14449 14450 14451 14452 14453 14454 14455 14456 14457 14458 14459 14460 14461 14462 14463 14464 14465 14466 14467 14468 14469 14470 14471 14472 14473 14474 14475 14476 14477 14478 14479 14480 14481 14482 14483 14484 14485 14486 14487 14488 14489 14490 14491 14492 14493 14494 14495 14496 14497 14498 14499 14500 14501 14502 14503 14504 14505 14506 14507 14508 14509 14510 14511 14512 14513 14514 14515 14516 14517 14518 14519 14520 14521 14522 14523 14524 14525 14526 14527 14528 14529 14530 14531 14532 14533 14534 14535 14536 14537 14538 14539 14540 14541 14542 14543 14544 14545 14546 14547 14548 14549 14550 14551 14552 14553 14554 14555 14556 14557 14558 14559 14560 14561 14562 14563 14564 14565 14566 14567 14568 14569 14570 14571 14572 14573 14574 14575 14576 14577 14578 14579 14580 14581 14582 14583 14584 14585 14586 14587 14588 14589 14590 14591 14592 14593 14594 14595 14596 14597 14598 14599 14600 14601 14602 14603 14604 14605 14606 14607 14608 14609 14610 14611 14612 14613 14614 14615 14616 14617 14618 14619 14620 14621 14622 14623 14624 14625 14626 14627 14628 14629 14630 14631 14632 14633 14634 14635 14636 14637 14638 14639 14640 14641 14642 14643 14644 14645 14646 14647 14648 14649 14650 14651 14652 14653 14654 14655 14656 14657 14658 14659 14660 14661 14662 14663 14664 14665 14666 14667 14668 14669 14670 14671 14672 14673 14674 14675 14676 14677 14678 14679 14680 14681 14682 14683 14684 14685 14686 14687 14688 14689 14690 14691 14692 14693 14694 14695 14696 14697 14698 14699 14700 14701 14702 14703 14704 14705 14706 14707 14708 14709 14710 14711 14712 14713 14714 14715 14716 14717 14718 14719 14720 14721 14722 14723 14724 14725 14726 14727 14728 14729 14730 14731 14732 14733 14734 14735 14736 14737 14738 14739 14740 14741 14742 14743 14744 14745 14746 14747 14748 14749 14750 14751 14752 14753 14754 14755 14756 14757 14758 14759 14760 14761 14762 14763 14764 14765 14766 14767 14768 14769 14770 14771 14772 14773 14774 14775 14776 14777 14778 14779 14780 14781 14782 14783 14784 14785 14786 14787 14788 14789 14790 14791 14792 14793 14794 14795 14796 14797 14798 14799 14800 14801 14802 14803 14804 14805 14806 14807 14808 14809 14810 14811 14812 14813 14814 14815 14816 14817 14818 14819 14820 14821 14822 14823 14824 14825 14826 14827 14828 14829 14830 14831 14832 14833 14834 14835 14836 14837 14838 14839 14840 14841 14842 14843 14844 14845 14846 14847 14848 14849 14850 14851 14852 14853 14854 14855 14856 14857 14858 14859 14860 14861 14862 14863 14864 14865 14866 14867 14868 14869 14870 14871 14872 14873 14874 14875 14876 14877 14878 14879 14880 14881 14882 14883 14884 14885 14886 14887 14888 14889 14890 14891 14892 14893 14894 14895 14896 14897 14898 14899 14900 14901 14902 14903 14904 14905 14906 14907 14908 14909 14910 14911 14912 14913 14914 14915 14916 14917 14918 14919 14920 14921 14922 14923 14924 14925 14926 14927 14928 14929 14930 14931 14932 14933 14934 14935 14936 14937 14938 14939 14940 14941 14942 14943 14944 14945 14946 14947 14948 14949 14950 14951 14952 14953 14954 14955 14956 14957 14958 14959 14960 14961 14962 14963 14964 14965 14966 14967 14968 14969 14970 14971 14972 14973 14974 14975 14976 14977 14978 14979 14980 14981 14982 14983 14984 14985 14986 14987 14988 14989 14990 14991 14992 14993 14994 14995 14996 14997 14998 14999 15000 15001 15002 15003 15004 15005 15006 15007 15008 15009 15010 15011 15012 15013 15014 15015 15016 15017 15018 15019 15020 15021 15022 15023 15024 15025 15026 15027 15028 15029 15030 15031 15032 15033 15034 15035 15036 15037 15038 15039 15040 15041 15042 15043 15044 15045 15046 15047 15048 15049 15050 15051 15052 15053 15054 15055 15056 15057 15058 15059 15060 15061 15062 15063 15064 15065 15066 15067 15068 15069 15070 15071 15072 15073 15074 15075 15076 15077 15078 15079 15080 15081 15082 15083 15084 15085 15086 15087 15088 15089 15090 15091 15092 15093 15094 15095 15096 15097 15098 15099 15100 15101 15102 15103 15104 15105 15106 15107 15108 15109 15110 15111 15112 15113 15114 15115 15116 15117 15118 15119 15120 15121 15122 15123 15124 15125 15126 15127 15128 15129 15130 15131 15132 15133 15134 15135 15136 15137 15138 15139 15140 15141 15142 15143 15144 15145 15146 15147 15148 15149 15150 15151 15152 15153 15154 15155 15156 15157 15158 15159 15160 15161 15162 15163 15164 15165 15166 15167 15168 15169 15170 15171 15172 15173 15174 15175 15176 15177 15178 15179 15180 15181 15182 15183 15184 15185 15186 15187 15188 15189 15190 15191 15192 15193 15194 15195 15196 15197 15198 15199 15200 15201 15202 15203 15204 15205 15206 15207 15208 15209 15210 15211 15212 15213 15214 15215 15216 15217 15218 15219 15220 15221 15222 15223 15224 15225 15226 15227 15228 15229 15230 15231 15232 15233 15234 15235 15236 15237 15238 15239 15240 15241 15242 15243 15244 15245 15246 15247 15248 15249 15250 15251 15252 15253 15254 15255 15256 15257 15258 15259 15260 15261 15262 15263 15264 15265 15266 15267 15268 15269 15270 15271 15272 15273 15274 15275 15276 15277 15278 15279 15280 15281 15282 15283 15284 15285 15286 15287 15288 15289 15290 15291 15292 15293 15294 15295 15296 15297 15298 15299 15300 15301 15302 15303 15304 15305 15306 15307 15308 15309 15310 15311 15312 15313 15314 15315 15316 15317 15318 15319 15320 15321 15322 15323 15324 15325 15326 15327 15328 15329 15330 15331 15332 15333 15334 15335 15336 15337 15338 15339 15340 15341 15342 15343 15344 15345 15346 15347 15348 15349 15350 15351 15352 15353 15354 15355 15356 15357 15358 15359 15360 15361 15362 15363 15364 15365 15366 15367 15368 15369 15370 15371 15372 15373 15374 15375 15376 15377 15378 15379 15380 15381 15382 15383 15384 15385 15386 15387 15388 15389 15390 15391 15392 15393 15394 15395 15396 15397 15398 15399 15400 15401 15402 15403 15404 15405 15406 15407 15408 15409 15410 15411 15412 15413 15414 15415 15416 15417 15418 15419 15420 15421 15422 15423 15424 15425 15426 15427 15428 15429 15430 15431 15432 15433 15434 15435 15436 15437 15438 15439 15440 15441 15442 15443 15444 15445 15446 15447 15448 15449 15450 15451 15452 15453 15454 15455 15456 15457 15458 15459 15460 15461 15462 15463 15464 15465 15466 15467 15468 15469 15470 15471 15472 15473 15474 15475 15476 15477 15478 15479 15480 15481 15482 15483 15484 15485 15486 15487 15488 15489 15490 15491 15492 15493 15494 15495 15496 15497 15498 15499 15500 15501 15502 15503 15504 15505 15506 15507 15508 15509 15510 15511 15512 15513 15514 15515 15516 15517 15518 15519 15520 15521 15522 15523 15524 15525 15526 15527 15528 15529 15530 15531 15532 15533 15534 15535 15536 15537 15538 15539 15540 15541 15542 15543 15544 15545 15546 15547 15548 15549 15550 15551 15552 15553 15554 15555 15556 15557 15558 15559 15560 15561 15562 15563 15564 15565 15566 15567 15568 15569 15570 15571 15572 15573 15574 15575 15576 15577 15578 15579 15580 15581 15582 15583 15584 15585 15586 15587 15588 15589 15590 15591 15592 15593 15594 15595 15596 15597 15598 15599 15600 15601 15602 15603 15604 15605 15606 15607 15608 15609 15610 15611 15612 15613 15614 15615 15616 15617 15618 15619 15620 15621 15622 15623 15624 15625 15626 15627 15628 15629 15630 15631 15632 15633 15634 15635 15636 15637 15638 15639 15640 15641 15642 15643 15644 15645 15646 15647 15648 15649 15650 15651 15652 15653 15654 15655 15656 15657 15658 15659 15660 15661 15662 15663 15664 15665 15666 15667 15668 15669 15670 15671 15672 15673 15674 15675 15676 15677 15678 15679 15680 15681 15682 15683 15684 15685 15686 15687 15688 15689 15690 15691 15692 15693 15694 15695 15696 15697 15698 15699 15700 15701 15702 15703 15704 15705 15706 15707 15708 15709 15710 15711 15712 15713 15714 15715 15716 15717 15718 15719 15720 15721 15722 15723 15724 15725 15726 15727 15728 15729 15730 15731 15732 15733 15734 15735 15736 15737 15738 15739 15740 15741 15742 15743 15744 15745 15746 15747 15748 15749 15750 15751 15752 15753 15754 15755 15756 15757 15758 15759 15760 15761 15762 15763 15764 15765 15766 15767 15768 15769 15770 15771 15772 15773 15774 15775 15776 15777 15778 15779 15780 15781 15782 15783 15784 15785 15786 15787 15788 15789 15790 15791 15792 15793 15794 15795 15796 15797 15798 15799 15800 15801 15802 15803 15804 15805 15806 15807 15808 15809 15810 15811 15812 15813 15814 15815 15816 15817 15818 15819 15820 15821 15822 15823 15824 15825 15826 15827 15828 15829 15830 15831 15832 15833 15834 15835 15836 15837 15838 15839 15840 15841 15842 15843 15844 15845 15846 15847 15848 15849 15850 15851 15852 15853 15854 15855 15856 15857 15858 15859 15860 15861 15862 15863 15864 15865 15866 15867 15868 15869 15870 15871 15872 15873 15874 15875 15876 15877 15878 15879 15880 15881 15882 15883 15884 15885 15886 15887 15888 15889 15890 15891 15892 15893 15894 15895 15896 15897 15898 15899 15900 15901 15902 15903 15904 15905 15906 15907 15908 15909 15910 15911 15912 15913 15914 15915 15916 15917 15918 15919 15920 15921 15922 15923 15924 15925 15926 15927 15928 15929 15930 15931 15932 15933 15934 15935 15936 15937 15938 15939 15940 15941 15942 15943 15944 15945 15946 15947 15948 15949 15950 15951 15952 15953 15954 15955 15956 15957 15958 15959 15960 15961 15962 15963 15964 15965 15966 15967 15968 15969 15970 15971 15972 15973 15974 15975 15976 15977 15978 15979 15980 15981 15982 15983 15984 15985 15986 15987 15988 15989 15990 15991 15992 15993 15994 15995 15996 15997 15998 15999 16000 16001 16002 16003 16004 16005 16006 16007 16008 16009 16010 16011 16012 16013 16014 16015 16016 16017 16018 16019 16020 16021 16022 16023 16024 16025 16026 16027 16028 16029 16030 16031 16032 16033 16034 16035 16036 16037 16038 16039 16040 16041 16042 16043 16044 16045 16046 16047 16048 16049 16050 16051 16052 16053 16054 16055 16056 16057 16058 16059 16060 16061 16062 16063 16064 16065 16066 16067 16068 16069 16070 16071 16072 16073 16074 16075 16076 16077 16078 16079 16080 16081 16082 16083 16084 16085 16086 16087 16088 16089 16090 16091 16092 16093 16094 16095 16096 16097 16098 16099 16100 16101 16102 16103 16104 16105 16106 16107 16108 16109 16110 16111 16112 16113 16114 16115 16116 16117 16118 16119 16120 16121 16122 16123 16124 16125 16126 16127 16128 16129 16130 16131 16132 16133 16134 16135 16136 16137 16138 16139 16140 16141 16142 16143 16144 16145 16146 16147 16148 16149 16150 16151 16152 16153 16154 16155 16156 16157 16158 16159 16160 16161 16162 16163 16164 16165 16166 16167 16168 16169 16170 16171 16172 16173 16174 16175 16176 16177 16178 16179 16180 16181 16182 16183 16184 16185 16186 16187 16188 16189 16190 16191 16192 16193 16194 16195 16196 16197 16198 16199 16200 16201 16202 16203 16204 16205 16206 16207 16208 16209 16210 16211 16212 16213 16214 16215 16216 16217 16218 16219 16220 16221 16222 16223 16224 16225 16226 16227 16228 16229 16230 16231 16232 16233 16234 16235 16236 16237 16238 16239 16240 16241 16242 16243 16244 16245 16246 16247 16248 16249 16250 16251 16252 16253 16254 16255 16256 16257 16258 16259 16260 16261 16262 16263 16264 16265 16266 16267 16268 16269 16270 16271 16272 16273 16274 16275 16276 16277 16278 16279 16280 16281 16282 16283 16284 16285 16286 16287 16288 16289 16290 16291 16292 16293 16294 16295 16296 16297 16298 16299 16300 16301 16302 16303 16304 16305 16306 16307 16308 16309 16310 16311 16312 16313 16314 16315 16316 16317 16318 16319 16320 16321 16322 16323 16324 16325 16326 16327 16328 16329 16330 16331 16332 16333 16334 16335 16336 16337 16338 16339 16340 16341 16342 16343 16344 16345 16346 16347 16348 16349 16350 16351 16352 16353 16354 16355 16356 16357 16358 16359 16360 16361 16362 16363 16364 16365 16366 16367 16368 16369 16370 16371 16372 16373 16374 16375 16376 16377 16378 16379 16380 16381 16382 16383 16384 16385 16386 16387 16388 16389 16390 16391 16392 16393 16394 16395 16396 16397 16398 16399 16400 16401 16402 16403 16404 16405 16406 16407 16408 16409 16410 16411 16412 16413 16414 16415 16416 16417 16418 16419 16420 16421 16422 16423 16424 16425 16426 16427 16428 16429 16430 16431 16432 16433 16434 16435 16436 16437 16438 16439 16440 16441 16442 16443 16444 16445 16446 16447 16448 16449 16450 16451 16452 16453 16454 16455 16456 16457 16458 16459 16460 16461 16462 16463 16464 16465 16466 16467 16468 16469 16470 16471 16472 16473 16474 16475 16476 16477 16478 16479 16480 16481 16482 16483 16484 16485 16486 16487 16488 16489 16490 16491 16492 16493 16494 16495 16496 16497 16498 16499 16500 16501 16502 16503 16504 16505 16506 16507 16508 16509 16510 16511 16512 16513 16514 16515 16516 16517 16518 16519 16520 16521 16522 16523 16524 16525 16526 16527 16528 16529 16530 16531 16532 16533 16534 16535 16536 16537 16538 16539 16540 16541 16542 16543 16544 16545 16546 16547 16548 16549 16550 16551 16552 16553 16554 16555 16556 16557 16558 16559 16560 16561 16562 16563 16564 16565 16566 16567 16568 16569 16570 16571 16572 16573 16574 16575 16576 16577 16578 16579 16580 16581 16582 16583 16584 16585 16586 16587 16588 16589 16590 16591 16592 16593 16594 16595 16596 16597 16598 16599 16600 16601 16602 16603 16604 16605 16606 16607 16608 16609 16610 16611 16612 16613 16614 16615 16616 16617 16618 16619 16620 16621 16622 16623 16624 16625 16626 16627 16628 16629 16630 16631 16632 16633 16634 16635 16636 16637 16638 16639 16640 16641 16642 16643 16644 16645 16646 16647 16648 16649 16650 16651 16652 16653 16654 16655 16656 16657 16658 16659 16660 16661 16662 16663 16664 16665 16666 16667 16668 16669 16670 16671 16672 16673 16674 16675 16676 16677 16678 16679 16680 16681 16682 16683 16684 16685 16686 16687 16688 16689 16690 16691 16692 16693 16694 16695 16696 16697 16698 16699 16700 16701 16702 16703 16704 16705 16706 16707 16708 16709 16710 16711 16712 16713 16714 16715 16716 16717 16718 16719 16720 16721 16722 16723 16724 16725 16726 16727 16728 16729 16730 16731 16732 16733 16734 16735 16736 16737 16738 16739 16740 16741 16742 16743 16744 16745 16746 16747 16748 16749 16750 16751 16752 16753 16754 16755 16756 16757 16758 16759 16760 16761 16762 16763 16764 16765 16766 16767 16768 16769 16770 16771 16772 16773 16774 16775 16776 16777 16778 16779 16780 16781 16782 16783 16784 16785 16786 16787 16788 16789 16790 16791 16792 16793 16794 16795 16796 16797 16798 16799 16800 16801 16802 16803 16804 16805 16806 16807 16808 16809 16810 16811 16812 16813 16814 16815 16816 16817 16818 16819 16820 16821 16822 16823 16824 16825 16826 16827 16828 16829 16830 16831 16832 16833 16834 16835 16836 16837 16838 16839 16840 16841 16842 16843 16844 16845 16846 16847 16848 16849 16850 16851 16852 16853 16854 16855 16856 16857 16858 16859 16860 16861 16862 16863 16864 16865 16866 16867 16868 16869 16870 16871 16872 16873 16874 16875 16876 16877 16878 16879 16880 16881 16882 16883 16884 16885 16886 16887 16888 16889 16890 16891 16892 16893 16894 16895 16896 16897 16898 16899 16900 16901 16902 16903 16904 16905 16906 16907 16908 16909 16910 16911 16912 16913 16914 16915 16916 16917 16918 16919 16920 16921 16922 16923 16924 16925 16926 16927 16928 16929 16930 16931 16932 16933 16934 16935 16936 16937 16938 16939 16940 16941 16942 16943 16944 16945 16946 16947 16948 16949 16950 16951 16952 16953 16954 16955 16956 16957 16958 16959 16960 16961 16962 16963 16964 16965 16966 16967 16968 16969 16970 16971 16972 16973 16974 16975 16976 16977 16978 16979 16980 16981 16982 16983 16984 16985 16986 16987 16988 16989 16990 16991 16992 16993 16994 16995 16996 16997 16998 16999 17000 17001 17002 17003 17004 17005 17006 17007 17008 17009 17010 17011 17012 17013 17014 17015 17016 17017 17018 17019 17020 17021 17022 17023 17024 17025 17026 17027 17028 17029 17030 17031 17032 17033 17034 17035 17036 17037 17038 17039 17040 17041 17042 17043 17044 17045 17046 17047 17048 17049 17050 17051 17052 17053 17054 17055 17056 17057 17058 17059 17060 17061 17062 17063 17064 17065 17066 17067 17068 17069 17070 17071 17072 17073 17074 17075 17076 17077 17078 17079 17080 17081 17082 17083 17084 17085 17086 17087 17088 17089 17090 17091 17092 17093 17094 17095 17096 17097 17098 17099 17100 17101 17102 17103 17104 17105 17106 17107 17108 17109 17110 17111 17112 17113 17114 17115 17116 17117 17118 17119 17120 17121 17122 17123 17124 17125 17126 17127 17128 17129 17130 17131 17132 17133 17134 17135 17136 17137 17138 17139 17140 17141 17142 17143 17144 17145 17146 17147 17148 17149 17150 17151 17152 17153 17154 17155 17156 17157 17158 17159 17160 17161 17162 17163 17164 17165 17166 17167 17168 17169 17170 17171 17172 17173 17174 17175 17176 17177 17178 17179 17180 17181 17182 17183 17184 17185 17186 17187 17188 17189 17190 17191 17192 17193 17194 17195 17196 17197 17198 17199 17200 17201 17202 17203 17204 17205 17206 17207 17208 17209 17210 17211 17212 17213 17214 17215 17216 17217 17218 17219 17220 17221 17222 17223 17224 17225 17226 17227 17228 17229 17230 17231 17232 17233 17234 17235 17236 17237 17238 17239 17240 17241 17242 17243 17244 17245 17246 17247 17248 17249 17250 17251 17252 17253 17254 17255 17256 17257 17258 17259 17260 17261 17262 17263 17264 17265 17266 17267 17268 17269 17270 17271 17272 17273 17274 17275 17276 17277 17278 17279 17280 17281 17282 17283 17284 17285 17286 17287 17288 17289 17290 17291 17292 17293 17294 17295 17296 17297 17298 17299 17300 17301 17302 17303 17304 17305 17306 17307 17308 17309 17310 17311 17312 17313 17314 17315 17316 17317 17318 17319 17320 17321 17322 17323 17324 17325 17326 17327 17328 17329 17330 17331 17332 17333 17334 17335 17336 17337 17338 17339 17340 17341 17342 17343 17344 17345 17346 17347 17348 17349 17350 17351 17352 17353 17354 17355 17356 17357 17358 17359 17360 17361 17362 17363 17364 17365 17366 17367 17368 17369 17370 17371 17372 17373 17374 17375 17376 17377 17378 17379 17380 17381 17382 17383 17384 17385 17386 17387 17388 17389 17390 17391 17392 17393 17394 17395 17396 17397 17398 17399 17400 17401 17402 17403 17404 17405 17406 17407 17408 17409 17410 17411 17412 17413 17414 17415 17416 17417 17418 17419 17420 17421 17422 17423 17424 17425 17426 17427 17428 17429 17430 17431 17432 17433 17434 17435 17436 17437 17438 17439 17440 17441 17442 17443 17444 17445 17446 17447 17448 17449 17450 17451 17452 17453 17454 17455 17456 17457 17458 17459 17460 17461 17462 17463 17464 17465 17466 17467 17468 17469 17470 17471 17472 17473 17474 17475 17476 17477 17478 17479 17480 17481 17482 17483 17484 17485 17486 17487 17488 17489 17490 17491 17492 17493 17494 17495 17496 17497 17498 17499 17500 17501 17502 17503 17504 17505 17506 17507 17508 17509 17510 17511 17512 17513 17514 17515 17516 17517 17518 17519 17520 17521 17522 17523 17524 17525 17526 17527 17528 17529 17530 17531 17532 17533 17534 17535 17536 17537 17538 17539 17540 17541 17542 17543 17544 17545 17546 17547 17548 17549 17550 17551 17552 17553 17554 17555 17556 17557 17558 17559 17560 17561 17562 17563 17564 17565 17566 17567 17568 17569 17570 17571 17572 17573 17574 17575 17576 17577 17578 17579 17580 17581 17582 17583 17584 17585 17586 17587 17588 17589 17590 17591 17592 17593 17594 17595 17596 17597 17598 17599 17600 17601 17602 17603 17604 17605 17606 17607 17608 17609 17610 17611 17612 17613 17614 17615 17616 17617 17618 17619 17620 17621 17622 17623 17624 17625 17626 17627 17628 17629 17630 17631 17632 17633 17634 17635 17636 17637 17638 17639 17640 17641 17642 17643 17644 17645 17646 17647 17648 17649 17650 17651 17652 17653 17654 17655 17656 17657 17658 17659 17660 17661 17662 17663 17664 17665 17666 17667 17668 17669 17670 17671 17672 17673 17674 17675 17676 17677 17678 17679 17680 17681 17682 17683 17684 17685 17686 17687 17688 17689 17690 17691 17692 17693 17694 17695 17696 17697 17698 17699 17700 17701 17702 17703 17704 17705 17706 17707 17708 17709 17710 17711 17712 17713 17714 17715 17716 17717 17718 17719 17720 17721 17722 17723 17724 17725 17726 17727 17728 17729 17730 17731 17732 17733 17734 17735 17736 17737 17738 17739 17740 17741 17742 17743 17744 17745 17746 17747 17748 17749 17750 17751 17752 17753 17754 17755 17756 17757 17758 17759 17760 17761 17762 17763 17764 17765 17766 17767 17768 17769 17770 17771 17772 17773 17774 17775 17776 17777 17778 17779 17780 17781 17782 17783 17784 17785 17786 17787 17788 17789 17790 17791 17792 17793 17794 17795 17796 17797 17798 17799 17800 17801 17802 17803 17804 17805 17806 17807 17808 17809 17810 17811 17812 17813 17814 17815 17816 17817 17818 17819 17820 17821 17822 17823 17824 17825 17826 17827 17828 17829 17830 17831 17832 17833 17834 17835 17836 17837 17838 17839 17840 17841 17842 17843 17844 17845 17846 17847 17848 17849 17850 17851 17852 17853 17854 17855 17856 17857 17858 17859 17860 17861 17862 17863 17864 17865 17866 17867 17868 17869 17870 17871 17872 17873 17874 17875 17876 17877 17878 17879 17880 17881 17882 17883 17884 17885 17886 17887 17888 17889 17890 17891 17892 17893 17894 17895 17896 17897 17898 17899 17900 17901 17902 17903 17904 17905 17906 17907 17908 17909 17910 17911 17912 17913 17914 17915 17916 17917 17918 17919 17920 17921 17922 17923 17924 17925 17926 17927 17928 17929 17930 17931 17932 17933 17934 17935 17936 17937 17938 17939 17940 17941 17942 17943 17944 17945 17946 17947 17948 17949 17950 17951 17952 17953 17954 17955 17956 17957 17958 17959 17960 17961 17962 17963 17964 17965 17966 17967 17968 17969 17970 17971 17972 17973 17974 17975 17976 17977 17978 17979 17980 17981 17982 17983 17984 17985 17986 17987 17988 17989 17990 17991 17992 17993 17994 17995 17996 17997 17998 17999 18000 18001 18002 18003 18004 18005 18006 18007 18008 18009 18010 18011 18012 18013 18014 18015 18016 18017 18018 18019 18020 18021 18022 18023 18024 18025 18026 18027 18028 18029 18030 18031 18032 18033 18034 18035 18036 18037 18038 18039 18040 18041 18042 18043 18044 18045 18046 18047 18048 18049 18050 18051 18052 18053 18054 18055 18056 18057 18058 18059 18060 18061 18062 18063 18064 18065 18066 18067 18068 18069 18070 18071 18072 18073 18074 18075 18076 18077 18078 18079 18080 18081 18082 18083 18084 18085 18086 18087 18088 18089 18090 18091 18092 18093 18094 18095 18096 18097 18098 18099 18100 18101 18102 18103 18104 18105 18106 18107 18108 18109 18110 18111 18112 18113 18114 18115 18116 18117 18118 18119 18120 18121 18122 18123 18124 18125 18126 18127 18128 18129 18130 18131 18132 18133 18134 18135 18136 18137 18138 18139 18140 18141 18142 18143 18144 18145 18146 18147 18148 18149 18150 18151 18152 18153 18154 18155 18156 18157 18158 18159 18160 18161 18162 18163 18164 18165 18166 18167 18168 18169 18170 18171 18172 18173 18174 18175 18176 18177 18178 18179 18180 18181 18182 18183 18184 18185 18186 18187 18188 18189 18190 18191 18192 18193 18194 18195 18196 18197 18198 18199 18200 18201 18202 18203 18204 18205 18206 18207 18208 18209 18210 18211 18212 18213 18214 18215 18216 18217 18218 18219 18220 18221 18222 18223 18224 18225 18226 18227 18228 18229 18230 18231 18232 18233 18234 18235 18236 18237 18238 18239 18240 18241 18242 18243 18244 18245 18246 18247 18248 18249 18250 18251 18252 18253 18254 18255 18256 18257 18258 18259 18260 18261 18262 18263 18264 18265 18266 18267 18268 18269 18270 18271 18272 18273 18274 18275 18276 18277 18278 18279 18280 18281 18282 18283 18284 18285 18286 18287 18288 18289 18290 18291 18292 18293 18294 18295 18296 18297 18298 18299 18300 18301 18302 18303 18304 18305 18306 18307 18308 18309 18310 18311 18312 18313 18314 18315 18316 18317 18318 18319 18320 18321 18322 18323 18324 18325 18326 18327 18328 18329 18330 18331 18332 18333 18334 18335 18336 18337 18338 18339 18340 18341 18342 18343 18344 18345 18346 18347 18348 18349 18350 18351 18352 18353 18354 18355 18356 18357 18358 18359 18360 18361 18362 18363 18364 18365 18366 18367 18368 18369 18370 18371 18372 18373 18374 18375 18376 18377 18378 18379 18380 18381 18382 18383 18384 18385 18386 18387 18388 18389 18390 18391 18392 18393 18394 18395 18396 18397 18398 18399 18400 18401 18402 18403 18404 18405 18406 18407 18408 18409 18410 18411 18412 18413 18414 18415 18416 18417 18418 18419 18420 18421 18422 18423 18424 18425 18426 18427 18428 18429 18430 18431 18432 18433 18434 18435 18436 18437 18438 18439 18440 18441 18442 18443 18444 18445 18446 18447 18448 18449 18450 18451 18452 18453 18454 18455 18456 18457 18458 18459 18460 18461 18462 18463 18464 18465 18466 18467 18468 18469 18470 18471 18472 18473 18474 18475 18476 18477 18478 18479 18480 18481 18482 18483 18484 18485 18486 18487 18488 18489 18490 18491 18492 18493 18494 18495 18496 18497 18498 18499 18500 18501 18502 18503 18504 18505 18506 18507 18508 18509 18510 18511 18512 18513 18514 18515 18516 18517 18518 18519 18520 18521 18522 18523 18524 18525 18526 18527 18528 18529 18530 18531 18532 18533 18534 18535 18536 18537 18538 18539 18540 18541 18542 18543 18544 18545 18546 18547 18548 18549 18550 18551 18552 18553 18554 18555 18556 18557 18558 18559 18560 18561 18562 18563 18564 18565 18566 18567 18568 18569 18570 18571 18572 18573 18574 18575 18576 18577 18578 18579 18580 18581 18582 18583 18584 18585 18586 18587 18588 18589 18590 18591 18592 18593 18594 18595 18596 18597 18598 18599 18600 18601 18602 18603 18604 18605 18606 18607 18608 18609 18610 18611 18612 18613 18614 18615 18616 18617 18618 18619 18620 18621 18622 18623 18624 18625 18626 18627 18628 18629 18630 18631 18632 18633 18634 18635 18636 18637 18638 18639 18640 18641 18642 18643 18644 18645 18646 18647 18648 18649 18650 18651 18652 18653 18654 18655 18656 18657 18658 18659 18660 18661 18662 18663 18664 18665 18666 18667 18668 18669 18670 18671 18672 18673 18674 18675 18676 18677 18678 18679 18680 18681 18682 18683 18684 18685 18686 18687 18688 18689 18690 18691 18692 18693 18694 18695 18696 18697 18698 18699 18700 18701 18702 18703 18704 18705 18706 18707 18708 18709 18710 18711 18712 18713 18714 18715 18716 18717 18718 18719 18720 18721 18722 18723 18724 18725 18726 18727 18728 18729 18730 18731 18732 18733 18734 18735 18736 18737 18738 18739 18740 18741 18742 18743 18744 18745 18746 18747 18748 18749 18750 18751 18752 18753 18754 18755 18756 18757 18758 18759 18760 18761 18762 18763 18764 18765 18766 18767 18768 18769 18770 18771 18772 18773 18774 18775 18776 18777 18778 18779 18780 18781 18782 18783 18784 18785 18786 18787 18788 18789 18790 18791 18792 18793 18794 18795 18796 18797 18798 18799 18800 18801 18802 18803 18804 18805 18806 18807 18808 18809 18810 18811 18812 18813 18814 18815 18816 18817 18818 18819 18820 18821 18822 18823 18824 18825 18826 18827 18828 18829 18830 18831 18832 18833 18834 18835 18836 18837 18838 18839 18840 18841 18842 18843 18844 18845 18846 18847 18848 18849 18850 18851 18852 18853 18854 18855 18856 18857 18858 18859 18860 18861 18862 18863 18864 18865 18866 18867 18868 18869 18870 18871 18872 18873 18874 18875 18876 18877 18878 18879 18880 18881 18882 18883 18884 18885 18886 18887 18888 18889 18890 18891 18892 18893 18894 18895 18896 18897 18898 18899 18900 18901 18902 18903 18904 18905 18906 18907 18908 18909 18910 18911 18912 18913 18914 18915 18916 18917 18918 18919 18920 18921 18922 18923 18924 18925 18926 18927 18928 18929 18930 18931 18932 18933 18934 18935 18936 18937 18938 18939 18940 18941 18942 18943 18944 18945 18946 18947 18948 18949 18950 18951 18952 18953 18954 18955 18956 18957 18958 18959 18960 18961 18962 18963 18964 18965 18966 18967 18968 18969 18970 18971 18972 18973 18974 18975 18976 18977 18978 18979 18980 18981 18982 18983 18984 18985 18986 18987 18988 18989 18990 18991 18992 18993 18994 18995 18996 18997 18998 18999 19000 19001 19002 19003 19004 19005 19006 19007 19008 19009 19010 19011 19012 19013 19014 19015 19016 19017 19018 19019 19020 19021 19022 19023 19024 19025 19026 19027 19028 19029 19030 19031 19032 19033 19034 19035 19036 19037 19038 19039 19040 19041 19042 19043 19044 19045 19046 19047 19048 19049 19050 19051 19052 19053 19054 19055 19056 19057 19058 19059 19060 19061 19062 19063 19064 19065 19066 19067 19068 19069 19070 19071 19072 19073 19074 19075 19076 19077 19078 19079 19080 19081 19082 19083 19084 19085 19086 19087 19088 19089 19090 19091 19092 19093 19094 19095 19096 19097 19098 19099 19100 19101 19102 19103 19104 19105 19106 19107 19108 19109 19110 19111 19112 19113 19114 19115 19116 19117 19118 19119 19120 19121 19122 19123 19124 19125 19126 19127 19128 19129 19130 19131 19132 19133 19134 19135 19136 19137 19138 19139 19140 19141 19142 19143 19144 19145 19146 19147 19148 19149 19150 19151 19152 19153 19154 19155 19156 19157 19158 19159 19160 19161 19162 19163 19164 19165 19166 19167 19168 19169 19170 19171 19172 19173 19174 19175 19176 19177 19178 19179 19180 19181 19182 19183 19184 19185 19186 19187 19188 19189 19190 19191 19192 19193 19194 19195 19196 19197 19198 19199 19200 19201 19202 19203 19204 19205 19206 19207 19208 19209 19210 19211 19212 19213 19214 19215 19216 19217 19218 19219 19220 19221 19222 19223 19224 19225 19226 19227 19228 19229 19230 19231 19232 19233 19234 19235 19236 19237 19238 19239 19240 19241 19242 19243 19244 19245 19246 19247 19248 19249 19250 19251 19252 19253 19254 19255 19256 19257 19258 19259 19260 19261 19262 19263 19264 19265 19266 19267 19268 19269 19270 19271 19272 19273 19274 19275 19276 19277 19278 19279 19280 19281 19282 19283 19284 19285 19286 19287 19288 19289 19290 19291 19292 19293 19294 19295 19296 19297 19298 19299 19300 19301 19302 19303 19304 19305 19306 19307 19308 19309 19310 19311 19312 19313 19314 19315 19316 19317 19318 19319 19320 19321 19322 19323 19324 19325 19326 19327 19328 19329 19330 19331 19332 19333 19334 19335 19336 19337 19338 19339 19340 19341 19342 19343 19344 19345 19346 19347 19348 19349 19350 19351 19352 19353 19354 19355 19356 19357 19358 19359 19360 19361 19362 19363 19364 19365 19366 19367 19368 19369 19370 19371 19372 19373 19374 19375 19376 19377 19378 19379 19380 19381 19382 19383 19384 19385 19386 19387 19388 19389 19390 19391 19392 19393 19394 19395 19396 19397 19398 19399 19400 19401 19402 19403 19404 19405 19406 19407 19408 19409 19410 19411 19412 19413 19414 19415 19416 19417 19418 19419 19420 19421 19422 19423 19424 19425 19426 19427 19428 19429 19430 19431 19432 19433 19434 19435 19436 19437 19438 19439 19440 19441 19442 19443 19444 19445 19446 19447 19448 19449 19450 19451 19452 19453 19454 19455 19456 19457 19458 19459 19460 19461 19462 19463 19464 19465 19466 19467 19468 19469 19470 19471 19472 19473 19474 19475 19476 19477 19478 19479 19480 19481 19482 19483 19484 19485 19486 19487 19488 19489 19490 19491 19492 19493 19494 19495 19496 19497 19498 19499 19500 19501 19502 19503 19504 19505 19506 19507 19508 19509 19510 19511 19512 19513 19514 19515 19516 19517 19518 19519 19520 19521 19522 19523 19524 19525 19526 19527 19528 19529 19530 19531 19532 19533 19534 19535 19536 19537 19538 19539 19540 19541 19542 19543 19544 19545 19546 19547 19548 19549 19550 19551 19552 19553 19554 19555 19556 19557 19558 19559 19560 19561 19562 19563 19564 19565 19566 19567 19568 19569 19570 19571 19572 19573 19574 19575 19576 19577 19578 19579 19580 19581 19582 19583 19584 19585 19586 19587 19588 19589 19590 19591 19592 19593 19594 19595 19596 19597 19598 19599 19600 19601 19602 19603 19604 19605 19606 19607 19608 19609 19610 19611 19612 19613 19614 19615 19616 19617 19618 19619 19620 19621 19622 19623 19624 19625 19626 19627 19628 19629 19630 19631 19632 19633 19634 19635 19636 19637 19638 19639 19640 19641 19642 19643 19644 19645 19646 19647 19648 19649 19650 19651 19652 19653 19654 19655 19656 19657 19658 19659 19660 19661 19662 19663 19664 19665 19666 19667 19668 19669 19670 19671 19672 19673 19674 19675 19676 19677 19678 19679 19680 19681 19682 19683 19684 19685 19686 19687 19688 19689 19690 19691 19692 19693 19694 19695 19696 19697 19698 19699 19700 19701 19702 19703 19704 19705 19706 19707 19708 19709 19710 19711 19712 19713 19714 19715 19716 19717 19718 19719 19720 19721 19722 19723 19724 19725 19726 19727 19728 19729 19730 19731 19732 19733 19734 19735 19736 19737 19738 19739 19740 19741 19742 19743 19744 19745 19746 19747 19748 19749 19750 19751 19752 19753 19754 19755 19756 19757 19758 19759 19760 19761 19762 19763 19764 19765 19766 19767 19768 19769 19770 19771 19772 19773 19774 19775 19776 19777 19778 19779 19780 19781 19782 19783 19784 19785 19786 19787 19788 19789 19790 19791 19792 19793 19794 19795 19796 19797 19798 19799 19800 19801 19802 19803 19804 19805 19806 19807 19808 19809 19810 19811 19812 19813 19814 19815 19816 19817 19818 19819 19820 19821 19822 19823 19824 19825 19826 19827 19828 19829 19830 19831 19832 19833 19834 19835 19836 19837 19838 19839 19840 19841 19842 19843 19844 19845 19846 19847 19848 19849 19850 19851 19852 19853 19854 19855 19856 19857 19858 19859 19860 19861 19862 19863 19864 19865 19866 19867 19868 19869 19870 19871 19872 19873 19874 19875 19876 19877 19878 19879 19880 19881 19882 19883 19884 19885 19886 19887 19888 19889 19890 19891 19892 19893 19894 19895 19896 19897 19898 19899 19900 19901 19902 19903 19904 19905 19906 19907 19908 19909 19910 19911 19912 19913 19914 19915 19916 19917 19918 19919 19920 19921 19922 19923 19924 19925 19926 19927 19928 19929 19930 19931 19932 19933 19934 19935 19936 19937 19938 19939 19940 19941 19942 19943 19944 19945 19946 19947 19948 19949 19950 19951 19952 19953 19954 19955 19956 19957 19958 19959 19960 19961 19962 19963 19964 19965 19966 19967 19968 19969 19970 19971 19972 19973 19974 19975 19976 19977 19978 19979 19980 19981 19982 19983 19984 19985 19986 19987 19988 19989 19990 19991 19992 19993 19994 19995 19996 19997 19998 19999 20000 20001 20002 20003 20004 20005 20006 20007 20008 20009 20010 20011 20012 20013 20014 20015 20016 20017 20018 20019 20020 20021 20022 20023 20024 20025 20026 20027 20028 20029 20030 20031 20032 20033 20034 20035 20036 20037 20038 20039 20040 20041 20042 20043 20044 20045 20046 20047 20048 20049 20050 20051 20052 20053 20054 20055 20056 20057 20058 20059 20060 20061 20062 20063 20064 20065 20066 20067 20068 20069 20070 20071 20072 20073 20074 20075 20076 20077 20078 20079 20080 20081 20082 20083 20084 20085 20086 20087 20088 20089 20090 20091 20092 20093 20094 20095 20096 20097 20098 20099 20100 20101 20102 20103 20104 20105 20106 20107 20108 20109 20110 20111 20112 20113 20114 20115 20116 20117 20118 20119 20120 20121 20122 20123 20124 20125 20126 20127 20128 20129 20130 20131 20132 20133 20134 20135 20136 20137 20138 20139 20140 20141 20142 20143 20144 20145 20146 20147 20148 20149 20150 20151 20152 20153 20154 20155 20156 20157 20158 20159 20160 20161 20162 20163 20164 20165 20166 20167 20168 20169 20170 20171 20172 20173 20174 20175 20176 20177 20178 20179 20180 20181 20182 20183 20184 20185 20186 20187 20188 20189 20190 20191 20192 20193 20194 20195 20196 20197 20198 20199 20200 20201 20202 20203 20204 20205 20206 20207 20208 20209 20210 20211 20212 20213 20214 20215 20216 20217 20218 20219 20220 20221 20222 20223 20224 20225 20226 20227 20228 20229 20230 20231 20232 20233 20234 20235 20236 20237 20238 20239 20240 20241 20242 20243 20244 20245 20246 20247 20248 20249 20250 20251 20252 20253 20254 20255 20256 20257 20258 20259 20260 20261 20262 20263 20264 20265 20266 20267 20268 20269 20270 20271 20272 20273 20274 20275 20276 20277 20278 20279 20280 20281 20282 20283 20284 20285 20286 20287 20288 20289 20290 20291 20292 20293 20294 20295 20296 20297 20298 20299 20300 20301 20302 20303 20304 20305 20306 20307 20308 20309 20310 20311 20312 20313 20314 20315 20316 20317 20318 20319 20320 20321 20322 20323 20324 20325 20326 20327 20328 20329 20330 20331 20332 20333 20334 20335 20336 20337 20338 20339 20340 20341 20342 20343 20344 20345 20346 20347 20348 20349 20350 20351 20352 20353 20354 20355 20356 20357 20358 20359 20360 20361 20362 20363 20364 20365 20366 20367 20368 20369 20370 20371 20372 20373 20374 20375 20376 20377 20378 20379 20380 20381 20382 20383 20384 20385 20386 20387 20388 20389 20390 20391 20392 20393 20394 20395 20396 20397 20398 20399 20400 20401 20402 20403 20404 20405 20406 20407 20408 20409 20410 20411 20412 20413 20414 20415 20416 20417 20418 20419 20420 20421 20422 20423 20424 20425 20426 20427 20428 20429 20430 20431 20432 20433 20434 20435 20436 20437 20438 20439 20440 20441 20442 20443 20444 20445 20446 20447 20448 20449 20450 20451 20452 20453 20454 20455 20456 20457 20458 20459 20460 20461 20462 20463 20464 20465 20466 20467 20468 20469 20470 20471 20472 20473 20474 20475 20476 20477 20478 20479 20480 20481 20482 20483 20484 20485 20486 20487 20488 20489 20490 20491 20492 20493 20494 20495 20496 20497 20498 20499 20500 20501 20502 20503 20504 20505 20506 20507 20508 20509 20510 20511 20512 20513 20514 20515 20516 20517 20518 20519 20520 20521 20522 20523 20524 20525 20526 20527 20528 20529 20530 20531 20532 20533 20534 20535 20536 20537
|
---
Documentation/kdb/bt_x86 | 1837 +++++++++++++++++++
Documentation/kdb/kdb.mm | 492 +++++
Documentation/kdb/kdb_bp.man | 197 ++
Documentation/kdb/kdb_bt.man | 315 +++
Documentation/kdb/kdb_env.man | 46
Documentation/kdb/kdb_ll.man | 134 +
Documentation/kdb/kdb_md.man | 136 +
Documentation/kdb/kdb_ps.man | 96
Documentation/kdb/kdb_rd.man | 170 +
Documentation/kdb/kdb_sr.man | 68
Documentation/kdb/kdb_ss.man | 109 +
Documentation/kdb/slides | 1382 ++++++++++++++
Makefile | 1
drivers/char/keyboard.c | 10
drivers/hid/usbhid/hid-core.c | 28
drivers/hid/usbhid/usbkbd.c | 17
drivers/serial/8250.c | 53
drivers/serial/8250_early.c | 29
drivers/serial/sn_console.c | 73
drivers/usb/core/hcd.c | 14
drivers/usb/core/hcd.h | 4
drivers/usb/host/ehci-hcd.c | 42
drivers/usb/host/ehci-pci.c | 8
drivers/usb/host/ehci-q.c | 222 ++
drivers/usb/host/ohci-hcd.c | 67
drivers/usb/host/ohci-pci.c | 8
drivers/usb/host/ohci-q.c | 62
fs/proc/mmu.c | 16
fs/proc/proc_misc.c | 114 +
include/linux/console.h | 5
include/linux/dis-asm.h | 347 +++
include/linux/kdb.h | 162 +
include/linux/kdbprivate.h | 497 +++++
include/linux/sysctl.h | 1
init/main.c | 32
kdb/ChangeLog | 1894 +++++++++++++++++++
kdb/Makefile | 43
kdb/kdb_bp.c | 619 ++++++
kdb/kdb_bt.c | 180 +
kdb/kdb_cmds | 32
kdb/kdb_id.c | 236 ++
kdb/kdb_io.c | 676 +++++++
kdb/kdbmain.c | 4037 ++++++++++++++++++++++++++++++++++++++++++
kdb/kdbsupport.c | 1153 +++++++++++
kdb/modules/Makefile | 14
kdb/modules/kdbm_pg.c | 644 ++++++
kdb/modules/kdbm_sched.c | 57
kdb/modules/kdbm_task.c | 199 ++
kdb/modules/kdbm_vm.c | 843 ++++++++
kdb/modules/kdbm_x86.c | 1094 +++++++++++
kdb/modules/kdbm_xpc.c | 1105 +++++++++++
kernel/exit.c | 3
kernel/kallsyms.c | 22
kernel/module.c | 19
kernel/printk.c | 14
kernel/sched.c | 78
kernel/signal.c | 49
kernel/sysctl_check.c | 1
mm/hugetlb.c | 19
mm/swapfile.c | 22
60 files changed, 19840 insertions(+), 7 deletions(-)
Index: linux/Documentation/kdb/bt_x86
===================================================================
--- /dev/null
+++ linux/Documentation/kdb/bt_x86
@@ -0,0 +1,1837 @@
+Copyright Keith Owens, 2007.
+
+How the KDB backtrace for x86 works, how to diagnose problems and submit a bug
+==============================================================================
+
+Unlike ia64, x86 architectures do not mandate unwind information in the kernel.
+gcc will include some unwind information for C functions, but not for assembler
+code. Attempts have been made to add unwind information to the assembler code
+by hand, with little success. Eventually Linus rejected the x86 unwind code
+because it was breaking too often and destroying useful debugging data.
+
+Even if the x86 unwinder worked correctly, it would only give an accurate
+backtrace, it would not give function arguments. Needless to say, function
+arguments are what people really want. To get function arguments requires much
+more support from the compiler than simple unwind data, the compiler has to
+track line by line where each argument is held and make that data available to
+the debugger. Compiling with gcc -g will provide that information, but the
+resulting kernel is several times larger than normal.
+
+Although the gcc -g data can be stored on another machine, there are constructs
+in the kernel that cannot be tracked by this method. i386 builds with 4K stacks
+and all x86_64 builds have multiple kernel stacks. The compiler knows nothing
+about these extra stacks and cannot backtrace through them correctly. The
+assembler code in arch/{i386,x86_64}/kernel/entry.S is a maze of twisty logic
+paths, some of which eventually jump to common labels. Describing this twisty
+logic to an unwinder is very difficult, expecially when you try to describe
+where arguments and/or registers are held).
+
+KDB gets an accurate x86 backtrace and extracts the arguments by performing code
+decomposition and analysis at run time. This avoids the need to bloat the
+running kernel to several times its normal size with gcc -g data. KDB (unlike
+gdb) also knows about the additional kernel stacks and twisty assembler code
+paths.
+
+The x86 backtrace code for i386 is very similar to the x86_64 code, with 80%
+common code and data. Most of the differences between the backtrace for the two
+architectures is due to the assembler code and stack handling. To avoid code
+duplication between KDB patches, the x86 backtrace code is actually stored in
+the kdb common patch, in source kdb/kdba_bt_x86.c. kdb/Makefile only builds
+kdba_bt_x86.o for i386 or x86_64. Most of the code reads as if the architecture
+is x86_64, using register names like rsp and rip. i386 is treated as a subset
+of x86_64, with fewer registers and printing the names as esp and eip. When
+this documentation refers to rsp and rip, read it as esp and eip for i386. The
+20% of code and data that is different in held in two large #ifdef sections,
+scan kdba_bt_x86.c for CONFIG_X86_64. Be careful when changing anything in the
+architecture specific sections, you will need to review the other architecture
+to see if it needs changes as well.
+
+The idea behind the x86 backtrace is to trace one function at a time, which
+gives us the calling function. Then apply the same algorithm to the calling
+function until you unwind to the first function in the process. The starting
+point for tracing any process is to extract the current stack pointer and
+current instruction pointer (rsp and rip). The way that these values are
+extracted varies between running tasks and blocked tasks, the method is
+described later (Process Starting Point) but ignore it for now, just assume that
+we have a starting rsp and rip.
+
+Given the instruction pointer (rip), we identify the start and end of the kernel
+or module function it is in, using the kernel symbol table. This is easy for C
+code, it is significantly harder for assembler code because of the twisty code
+paths that branch to common labels. The method of identifying the current
+function is described later (Identifying The Current Function) but ignore it for
+now, just assumes that we have the start and end address of the function plus
+its name.
+
+After the rip has been mapped to a function name with sensible start and end
+addresses, the next step is to analyse the code paths in that function. KDB
+already has a built in disassembler (copied with slight modifications from
+binutils) which knows how to decode each x86 instruction. Instead of
+duplicating that logic in kdba_bt_x86, it takes advantage of the fact that you
+can override the disassembler's print function, sending the output line to a
+buffer instead of printing it. kdba_bt_x86 stills has to decode the buffer but
+that is a lot easier than decoding the x86 instruction set.
+
+The code analysis consists of two main passes. There are example below of the
+analysis with basic block (bb) debugging activated (Examples of Basic Block
+Debugging Output).
+
+The first pass (bb_pass1) identifies all the basic blocks in the function. For
+our purposes, a basic block has a single entry point and one or more exit
+points. The start of the function is the start of basic block 0, all other
+blocks are the target of jump instructions (conditional or unconditional) from
+within the rest of the code. A block ends with an unconditional jump or with a
+terminating instruction such as ret, iret, sysexit, sysret or ud2a (BUG). A
+block can also end because the next instruction is the start of a new block
+(target of jmp or jcc), in this case there is an implied drop through from one
+block to the next.
+
+Although a call instruction also transfers control, it returns to the next
+instruction so call is not treated as a transfer. Instead call is treated as a
+normal instruction with side effects, the scratch registers are cleared after a
+call.
+
+At the end of the first pass over the function we have a directed graph that
+starts at bb[0]. The nodes of the graph (bb_list[]) are the basic blocks with
+their start and end address. The vertices are the jmp or jcc instructions
+(bb_jmp_list[]) that transfer control between blocks, plus any implied drop
+through transfers between consecutive blocks. This graph can have cycles, many
+functions have loops in them which transfer control back to earlier in the code
+body.
+
+The second pass (bb_pass2) runs over the directed graph analysing the effect of
+each instruction on the register and memory state. It is important to
+understand that the analysis in this pass is an abstract one, it does not use
+actual hex values for the register contents, instead it uses symbolic values.
+When the basic block code says that "register rsi contains value rax" it means
+that whatever value was in rax on entry to the function has also been copied to
+register rsi at this point in the logic flow.
+
+At an abstract level, all C functions start with exactly the same state, each
+register contains its own symbolic value (except for the stack pointer, see
+later) with no local stack variables defined yet. Assembler functions tend to
+have unusual starting points, with some registers and/or memory contents defined
+differently on entry. For example, ret_from_intr on i386 already has a struct
+pt_regs on its stack, ret_from_intr on x86_64 already has a partial struct
+pt_regs plus another two words stacked on top of it. The special starting cases
+are listed in the arch specific bb_special_cases[].
+
+Once the input state of bb[0] has been defined (including any special cases),
+bb_pass2_do_changed_blocks() runs over all the nodes in bb_list[]. Each
+instruction in each block is analysed (Tracking the Effects of Instructions) to
+see what effect it has on the abstract register state, the analysis of each
+instruction is done in bb_usage(). An instruction can copy one register to
+another, it can copy a register to stack, move from stack to a register or it
+can invalidate the contents of a register or memory location. A general rule in
+bb_usage() is that any operation whose results cannot be calculated in terms of
+an original input value gives an undefined result. Remember that it is the
+abstract value that becomes undefined, moving a constant to a register gives a
+defined value for the view of the program but it is undefined as far as the
+abstract state is concerned.
+
+References to data on the stack are a little awkward because the stack pointer
+frequently changes. To overcome this, kdba_bt_x86 defines a pseudo register
+called the 'original stack pointer' (osp). This always represents the stack
+pointer on entry to the function, so on entry rsp contains osp+0x0. As rsp is
+modified, it still points at osp, but its offset from osp changes. Copying rsp
+to another register (e.g. mov %rsp,%rbp) copies the osp offset as well. At the
+point that this function calls the next function down the stack, kdba_bt_x86
+knows the delta from osp to rsp. Applying that delta to the actual value of the
+stack pointer gives the stack pointer value on input to the current function,
+that location contains the return address so we can go up one stack frame and
+repeat the process.
+
+After doing basic block analysis on the current function, kdba_bt_x86 knows what
+the abstract register and memory state is at the point this function was
+interrupted or it called the next function down the stack, this is the exit
+state. For an interrupt the actual register values are saved in a struct
+pt_regs, for a call we have unwound from the KDB interrupt back to the called
+function so we have some idea of what the register values are in the called
+function. The abstract exit state is merged with the known actual register
+values to derive the original stack pointer. That in turn gives us any
+registers that were saved on stack. The original stack pointer gives the return
+address from the calling function, go up one stack frame and repeat the
+analysis.
+
+
+Process Starting Point
+======================
+
+All backtrace code needs a starting point which defines at least the stack
+pointer and instruction pointer, it may define other registers as well. The
+first part of kdba_bt_stack() extracts the starting point. Processes can be in
+one of three states, running (currently on a cpu), blocked (sleeping or ready to
+run but not currently on a cpu) or unknown.
+
+For running processes, the current rsp and rip are dynamic. Because KDB stops
+the entire machine by sending an interrupt to the other cpus, KDB can save the
+rsp and rip for each cpu at the point where KDB is entered. This data is held
+in array kdb_running_process and is stored by kdb_save_running() and the arch
+specific kdba_save_running() functions. When backtracing a running process, KDB
+uses the data in kdb_running_process as its starting point.
+
+For blocked processes we always have the saved rsp, it is held in the process's
+thread_info. For i386 blocked processes, thread_info also contains the saved
+rip. For x86_64 blocked processes, rip is no longer saved in thread_info, it is
+assumed that all blocked processes will resume at assembler label thread_return,
+so that rip is used on x86_64. See arch specific kdba_bt_stack_rip().
+
+Unknown process state only occurs when the user does 'bt <stack_address>'.
+Unlike other bt commands, 'bt <stack_address>' does not identify any specific
+process, instead it identifies a kernel stack. <stack_address> must be inside a
+valid kernel stack and must point to a saved rip from a call instruction.
+kdba_bt_x86.c uses the common kdba_get_stack_info() and arch specific
+kdba_get_stack_info_alternate() functions to check that the address falls within
+a valid kernel stack. If the user gives a stack address that does not point to
+a saved rip from a call instruction then the backtrace will be garbage.
+
+
+Identifying The Current Function
+================================
+
+Given a rip value, KDB uses the kallsyms data to find the start of the function
+(first address <= rip) and the end of the function (next symbol in kallsyms).
+This works for plain C code because gcc only generates one label per function.
+It does not work for assembler code or for assembler code embedded in C
+functions, because the assembler labels appear as global entries in kallsyms.
+For example, arch/i386/kernel/entry.S has function ret_from_exception which
+contains three global labels ret_from_intr, check_userspace and
+resume_userspace. If rip points to any of those global labels, KDB wants the
+start of the real function, i.e. ret_from_exception. In addition, if rip points
+to ret_from_exception, KDB wants the end of the function to be after the last
+global label in that function, i.e. after resume_userspace.
+
+The simplest way to handle these unwanted global labels is to list the spurious
+assembler labels, which is done in the arch specific array bb_spurious. After
+mapping rip to the nearest start and end labels from kallsyms, kdb_bb() works
+backwards until it finds a non-spurious label then works forwards to the next
+non-spurious label. That gives a real start and end address and a real name for
+the current function.
+
+Note that this algorithm only applies in kdb_bb() when it maps rip to a suitable
+start and end address. When disassembling the code, you will still see the
+spurious label names, users need to see the extra labels. ret_from_exception on
+i386 disassembles like this (2.6.22) :-
+
+[0]kdb> id ret_from_exception
+0xc0102554 ret_from_exception: cli
+0xc0102555 ret_from_intr: mov $0xfffff000,%ebp
+0xc010255a ret_from_intr+0x5: and %esp,%ebp
+0xc010255c check_userspace: mov 0x34(%esp),%eax
+0xc0102560 check_userspace+0x4: mov 0x30(%esp),%al
+0xc0102564 check_userspace+0x8: and $0x20003,%eax
+0xc0102569 check_userspace+0xd: cmp $0x3,%eax
+0xc010256c check_userspace+0x10: jb 0xc010258c resume_kernel
+0xc0102572 check_userspace+0x16: mov %esi,%esi
+0xc0102574 resume_userspace: cli
+0xc0102575 resume_userspace+0x1: mov 0x8(%ebp),%ecx
+0xc0102578 resume_userspace+0x4: and $0xfe3e,%ecx
+0xc010257e resume_userspace+0xa: jne 0xc01026f4 work_pending
+0xc0102584 resume_userspace+0x10: jmp 0xc01026a7 restore_all
+0xc0102589 resume_userspace+0x15: lea 0x0(%esi),%esi
+0xc010258c resume_kernel: cli
+
+For the purposes of kdba_bt_x86.c, any rip from 0xc0102554 to 0xc0102589 needs
+to map to the range 0xc0102554 (start) to 0xc010258c (end) with function name
+ret_from_exception. Therefore ret_from_intr, check_userspace and
+resume_userspace are listed in bb_spurious[] for i386 so those symbols are
+ignored. The comments in bb_spurious[] list the function that encloses each
+spurious label, those comments are only for humans, they do not affect the code.
+
+Once rip has been mapped to non-spurious labels, the module name, function name,
+start and end address are stored in variables bb_mod_name, bb_func_name,
+bb_func_start, bb_func_end. These variables are used throughout kdba_bt_x86.c
+for processing each function in turn.
+
+Watch for changes to assembler code, especially in arch/i386/kernel/entry.S,
+arch/x86_64/kernel/entry.S and arch/x86_64/ia32/ia32entry.S. When new labels
+are added you may need to adjust bb_spurious[] for that architecture. Running
+bb_all can help identify assembler labels that have been added or deleted.
+
+
+Tracking the Effects of Instructions
+====================================
+
+bb_pass2_do_changed_blocks() uses the KDB disassembler to decode the x86
+instructions to something a human can read. bb_dis_pass2() is used as a print
+routine to store data for a single instruction in a buffer then
+bb_parse_buffer() starts the analysis. Any instruction prefixes like lock or
+rep are stripped out. The opcode string is isolated then up to 3 operands are
+extracted (imul can have 3 operands), these are src, dst and dst2. The operand
+is matched against table bb_opcode_usage_all[] which lists all the instructions
+that actually appear in i386 and x86_64 kernels. A lot of the x86 instrcution
+set is not used by the kernel so instructions such as SSE do not appear in
+bb_opcode_usage_all[].
+
+Each operand is decoded by bb_parse_operand() to see whether it has a segment
+prefix, displacement, base, index or scale. An indirect call or jmp is
+identified. Operands consisting only of a register are classified as 'reg'
+type, displacements starting with '$' are immediate values otherwise the operand
+refers to a memory location. Any base or index register name is mapped to the
+abstract register name that contains it, this takes care of mapping (say) %ah to
+rax.
+
+After decoding the opcode and all its operands, bb_usage() decides what effect
+the instruction will have on the abstract state machine. Some x86 instructions
+list all the affected registers in their operands and these can be handled as
+generic cases. Alas many x86 instructions have side effects and change
+registers that are not listed in the operands, these have to be handled as
+special cases. enum bb_operand_usage lists the generic and special cases.
+
+bb_usage() is basically one huge switch statement over the special values in
+enum bb_operand_usage. For each special case it tracks the side effects of the
+instruction. Once all the special cases have been handled and converted to
+generic cases then bb_usage() handles the generic cases.
+
+bb_usage() detects when a register is copied to another register, a register is
+copied to stack or a known stack value is copied to a register and updates the
+state data accordingly. It is particularly important that all stack pointer
+updates and copies of the stack pointer are tracked, much of the saved state is
+on stack and can be accessed via any register that points to the stack, not just
+via rsp.
+
+i386 built with 4K stacks and all x86_64 builds have multiple kernel stacks.
+bb_usage() knows which instructions or locations are used to switch stacks and
+pretends that these instructions have no effect on the contents of rsp. The
+higher level backtrace code knows how to handle stack switching, it is too
+complicated for basic block analysis.
+
+
+Transfer of Control Outside the Current Function
+================================================
+
+Ignoring call instructions, most C code does not transfer control outside the
+current function, IOW there are no jump instructions to instructions outside the
+function. There are a few cases that this can occur for C code, inline
+assembler and tail recursion.
+
+Tail recursion occurs when a function ends by returning the value from a second
+function and that second function has exactly the same arguments and return
+value as the current function. For example,
+
+ int bar(int i, char *p)
+ {
+ ... do some work and return an int ...
+ }
+
+ int foo(int i, char *p)
+ {
+ return bar(i, p);
+ }
+
+If tail recursion is active (gcc -foptimize-sibling-calls) then instead of foo
+calling bar, bar returning to foo then foo returning to its caller, gcc will end
+foo with a direct jmp to bar. The source code says that something called foo
+but the stack trace will show bar is active, with no sign of foo on stack. When
+bar returns it will use the return address from the code that called foo.
+
+bb_transfer() detects an unconditional jmp to code outside the function body and
+assumes that this represents tail recursion. For tail recursion to work
+correctly, all the preserved registers must contain their original values,
+bb_sanity_check() validates this. Any deviation from the expected state will
+stop basic block analysis and fall back on the old unreliable backtrace code.
+
+Besides tail recursion in C code, assembler code can jump to labels outside the
+current function. Unfortunately this occurs all the time in the twisty
+assembler code and, to make things worse, many of these transfers are done with
+non-standard register or memory state. bb_special_case() and the arch specific
+bb_special_cases[] handle all the known special cases, including what the
+register and/or memory state should be. Any deviation from the expected state
+will stop basic block analysis and fall back on the old unreliable backtrace
+code.
+
+
+Locating Arguments
+==================
+
+Function arguments can be passed in registers or on stack. The full ABI for
+passing arguments is described in
+
+ http://www.caldera.com/developers/devspecs/abi386-4.pdf
+ http://www.x86-64.org/documentation/abi.pdf
+
+The short description, ignoring special cases like passing structures by name
+and floating point arguments which tend not to apply to the kernel, is :-
+
+i386. With -mpregparm=0, all arguments are passed on stack, except for
+ functions defined as FASTCALL, where the first 3 arguments are passed in
+ registers.
+
+ With -mregparm=3, the first 3 arguments are passed in registers except
+ for functions defined as asmlinkage or with variable number of
+ arguments, when arguments are still passed on stack. -mpregparm=3 used
+ to be a config option, in recent kernels it is the default.
+
+ Arguments defined as long long (64 bit) are passed in two registers or
+ in two locations on stack. Being passed in two pieces makes a 64 bit
+ argument look like two 32 bit arguments to KDB, it will be printed as
+ two separate arguments.
+
+ When compiled with -mregparm=3, if a 64 bit argument is argument number
+ 2 then it will not be split between register and stack, instead it will
+ all be on stack and the third argument register will not be used. This
+ makes it look like there is an extra argument in the list. There is
+ nothing that KDB can do to detect these corner cases with 64 bit
+ arguments on i386, which is a pity because they can confuse users.
+
+ The preserved registers are ebx, ebp, esp, esi, edi. Arguments are
+ passed in eax, edx, ecx. The return value is in eax.
+
+x86_64. The first 6 arguments are passed in registers, the 7th and later
+ arguments are passed on stack. Except for functions with a variable
+ number of arguments (e.g. printk) where all arguments are on stack
+ except for rax which contains the number of SSE arguments (always 0 for
+ the kernel).
+
+ The preserved registers are rbx, rbp, rsp, r12, r13, r14, r15.
+ Arguments are passed in rdi, rsi, rdx, rcx, r8, r9. The return value is
+ in rax.
+
+For both architectures, kdba_bt detects an argument that is passed in a register
+by the fact that the function code reads from that argument type register while
+it contains its original value. IOW, testing the value of rax, copying rax to
+another register or storing it on stack without first overwriting rax means that
+rax contains a useful input value. Reading from memory which is above the
+original stack pointer means that there is a argument at that location on
+stack.
+
+There are some functions in the kernel whose definition contains arguments that
+are not actually used. Typically these functions are instantiations of generic
+function definitions where some, but not all, instantiations use all the
+arguments. For example, a filesystem function may take flags that are not used
+by this particular filesystem, but the function definition has to match the
+generic filesystem declarations. If the unused arguments are at the end of the
+list then there is no way of telling from the object code that they exist, the
+function that does not use the trailing aguments will have no code that refers
+to them. KDB will print a truncated argument list for this case.
+
+If the unused arguments are not at the end of the list then KDB can detect the
+presence of the unused arguments, because there is code that refers to later
+arguments. KDB will print the unused argument, although gcc may have
+overwritten the register it is in, in which case KDB prints "invalid".
+
+Originally kdba_bt_x86 would detect that there was no reference to arguments in
+registers but there were still references to arguments on stack and assume that
+the function had all its arguments on stack. Unfortunately this did not work
+with the large number of 'pass through' functions in the kernel. A 'pass
+through' function is one which calls another function with roughly the same
+argument list and makes no other reference to the register arguments. For
+example, ipv4_doint_and_flush_strategy() takes 7 arguments, calls
+devinet_conf_sysctl() with those 7 arguments in the same order and has no other
+reference to any of its arguments.
+
+Pass through functions do not touch the arguments that are passed in registers
+because they are already in the right location for the routine about to be
+called, so the pass through function has no code that references the argument
+registers. No code means that kdba_bt_x86 cannot tell if the function has
+register arguments or not. The arguments passed on stack must always be copied
+to the new stack frame, even for pass through functions, so the arguments on
+stack can always be detected.
+
+kdba_bt_x86 was changed to assume that if there are any arguments on stack then
+there are always arguments in registers, except for a list of functions that are
+known to be asmlinkage or to have a variable number of arguments.
+bb_assume_pass_through() ignores the known special cases, for other functions
+which have stack arguments but no register arguments it assumes the function is
+pass through and prints a warning about that assumption.
+
+The above heuristics mean that there is one case that kdba_bt_x86 cannot detect:
+pass through functions where all the arguments are in registers. These have no
+argument references at all in their code, so they are printed with no arguments.
+All they do is call another function so this class of functions never fails, or
+if it does fail then it is due to something that is not argument related. If
+the failure is further down the call stack then the arguments are printed at the
+next function down the stack, so the user still has the arguments.
+
+This list of limitations on getting the x86 arguments may seem to be a long one,
+but kdba_bt_x86 gives sensible results for most functions. For kernel
+debugging, any arguments are far better than none at all.
+
+
+Kernel Stack Switching
+======================
+
+Understanding the unusual way that x86 kernel stacks are used is very important
+when diagnosing backtrace problems. Every process has its own normal kernel
+stack, even processes that run entirely within the kernel such as kthread or the
+per cpu migration processes. The normal stacks are 4K or 8K on i386 (depending
+on CONFIG_4KSTACKS) and 8K on x86_64. The normal stacks are global, they are
+not tied to any cpu.
+
+For i386 with 8K stacks there are no other kernel stacks so there is no stack
+switching to worry about.
+
+For i386 with 4K process stacks, each cpu also has a 4K soft irq stack and a 4K
+hard irq stack. It is possible for a process to be running on its own process
+stack, for the process to be interrupted by a soft irq which is then interrupted
+by a hard irq. At that point the backtrace is split between the hard irq, the
+soft irq and the normal normal stacks.
+
+On x86_64, each cpu always has stacks for stackfault, doublefault, nmi, debug,
+mce and interrupts. See Documentation/x86_64/kernel-stacks.
+
+The arch specific kdba_get_stack_info_alternate() function works out which stack
+the backtrace starts on, how big the stack is and how to switch to the next
+stack. This information is stored in the kdb_activation_record and used by the
+higher level backtrace code to detect a stack switch.
+
+The normal stack has some padding at the end, this reflects the stack pointer
+when the process was created in the kernel. kdba_bt_x86 cannot backtrace
+through this padding data, mainly because the code that set the nitial stack
+pointer no longer exists after boot. ARCH_NORMAL_PADDING defines how many words
+to ignore at the end of the normal stack.
+
+
+Debugging KDB
+=============
+
+KDB has conditional debugging print statements scattered throughout the code.
+If KDB is not behaving as expected, you can turn on debugging and rerun the
+command. Before debugging KDB, set LINES 10000 and capture the output via a
+serial console. If using minicom, turn on word wrap (control-A W) and capture
+mode (control-A L). If you are using a serial console via a serial to Ethernet
+interface using ssh or telnet, use the 'script' command to start the session.
+
+The various KDB_DEBUG_FLAG_* flags are listed in include/linux/kdbprivate.h.
+You set debug with 'set KDBDEBUG 0xnn' where nn is the or'd value of the desired
+flags. 'set KDBDEBUG 0' turns off KDB debugging. When diagnosing x86 backtrace
+problems, the most useful debug flags are
+
+ KDB_DEBUG_FLAG_ARA 0x10 Activation record, arch specific
+ KDB_DEBUG_FLAG_BB_SUMM 0x04 Basic block analysis, summary only
+ KDB_DEBUG_FLAG_BB 0x20 All basic block analysis
+
+ARA prints information about the different kernel stacks as kdba_bt_x86 unwinds
+through the switched kernel stacks. BB_SUMM prints a summary of the basic block
+analysis for each function, including the abstract exit state and the rollback
+calculations. BB prints a huge amount of basic block debugging, you probably
+only want to turn this for the full backtrace on as a last resort.
+
+I find 'set KDBDEBUG 0x14' to be best to get an overview of a problem. It gives
+both the kernel stack information plus the abstract state and actual location of
+data for each function.
+
+Command 'bb1' does a detailed debug session for a single function, bb1 takes a
+single parameter, the address of the exit point from the function, by number,
+not by name. bb1 turns on KDB_DEBUG_FLAG_BB, does basic block analysis for the
+function that contains the exit point then resets the debug flags to their
+previous value.
+
+Command 'bb_all' runs through every function in the base kernel (not module
+functions) and does a basic block analysis of every function. It also validates
+the various tables in kdba_bt_x86 where possible. bb_all is meant for the KDB
+maintainer to check that all the base kernel function pass the sanity checks, it
+can also be used by end users when reporting a bug. bb_all takes no parameters.
+It prints a '.' for every 100 functions it has analysed and allows for up to 20
+errors before giving up. The output from bb_all also includes the config
+variables that affect basic block analysis plus any assumptions about 'pass
+through' functions.
+
+
+Submitting a Bug Report Against kdba_bt_x86
+===========================================
+
+Capture the KDB output via a serial console.
+
+set LINES 10000
+set BTSP 1
+set KDBDEBUG 0x14
+Reproduce the problem.
+set KDBDEBUG 0
+bb_all
+
+If you can identify the rip/eip where kdba_bt_x86 gets confused, run bb1 with
+that address.
+
+Find each set of output from kdba_get_stack_info in the trace, extract the last
+two lines and type those lines into KDB. That will give a hex and symbolic dump
+of the raw kernel stacks. For example, if the trace data is
+
+kdba_get_stack_info: esp=0xc04fbef8 cpu=0 task=c047b3e0
+kdba_get_stack_info: ar->stack
+ physical_start=0xc04fb000
+ physical_end=0xc04fc000
+ logical_start=0xc04fb038
+ logical_end=0xc04fc000
+ next=0xc04b4f44
+ id=hardirq_ctx
+ set MDCOUNT 1024
+ mds 0xc04fb000
+
+then type the last two lines into KDB. Repeat this for each stack listed by
+kdba_get_stack_info on the failing backtrace.
+
+Send all the console output to the KDB maintainer.
+
+
+Examples of Basic Block Debugging Output
+========================================
+
+Example of the basic block analysis of fs/namei::getname() on i386. Kernel
+2.6.22, i386, compiled with frame pointers, gcc 4.1.0.
+
+Basic block debugging is very verbose, so set a high number of output lines.
+You really need a reliable serial console to capture this amount of output.
+
+ [0]kdb> set LINES 10000
+
+A simple disassemble of getname(). This is not required for debugging purposes
+since each instruction is printed as part of basic block debugging, but this can
+be easier to read.
+
+ [0]kdb> id getname
+ 0xc015cce8 getname: push %ebp
+ 0xc015cce9 getname+0x1: mov %esp,%ebp
+ 0xc015cceb getname+0x3: push %edi
+ 0xc015ccec getname+0x4: push %esi
+ 0xc015cced getname+0x5: push %ebx
+ 0xc015ccee getname+0x6: sub $0x4,%esp
+ 0xc015ccf1 getname+0x9: mov %eax,%edi
+ 0xc015ccf3 getname+0xb: mov $0xd0,%edx
+ 0xc015ccf8 getname+0x10: mov 0xc04b2120,%eax
+ 0xc015ccfd getname+0x15: call 0xc0153009 kmem_cache_alloc
+ 0xc015cd02 getname+0x1a: mov %eax,0xfffffff0(%ebp)
+ 0xc015cd05 getname+0x1d: mov $0xfffffff4,%eax
+ 0xc015cd0a getname+0x22: cmpl $0x0,0xfffffff0(%ebp)
+ 0xc015cd0e getname+0x26: je 0xc015cd7d getname+0x95
+ 0xc015cd10 getname+0x28: mov %esp,%eax
+ 0xc015cd12 getname+0x2a: and $0xfffff000,%eax
+ 0xc015cd17 getname+0x2f: cmpl $0xffffffff,0x18(%eax)
+ 0xc015cd1b getname+0x33: je 0xc015cd39 getname+0x51
+ 0xc015cd1d getname+0x35: mov $0xfffffff2,%esi
+ 0xc015cd22 getname+0x3a: cmp $0xbfffffff,%edi
+ 0xc015cd28 getname+0x40: ja 0xc015cd60 getname+0x78
+ 0xc015cd2a getname+0x42: mov $0xc0000000,%ebx
+ 0xc015cd2f getname+0x47: sub %edi,%ebx
+ 0xc015cd31 getname+0x49: cmp $0xfff,%ebx
+ 0xc015cd37 getname+0x4f: jbe 0xc015cd3e getname+0x56
+ 0xc015cd39 getname+0x51: mov $0x1000,%ebx
+ 0xc015cd3e getname+0x56: mov %ebx,%ecx
+ 0xc015cd40 getname+0x58: mov %edi,%edx
+ 0xc015cd42 getname+0x5a: mov 0xfffffff0(%ebp),%eax
+ 0xc015cd45 getname+0x5d: call 0xc023dbb4 strncpy_from_user
+ 0xc015cd4a getname+0x62: cmp $0x0,%eax
+ 0xc015cd4d getname+0x65: jle 0xc015cd5a getname+0x72
+ 0xc015cd4f getname+0x67: mov $0xffffffdc,%esi
+ 0xc015cd54 getname+0x6c: cmp %ebx,%eax
+ 0xc015cd56 getname+0x6e: jae 0xc015cd60 getname+0x78
+ 0xc015cd58 getname+0x70: jmp 0xc015cd71 getname+0x89
+ 0xc015cd5a getname+0x72: je 0xc015cd76 getname+0x8e
+ 0xc015cd5c getname+0x74: jge 0xc015cd71 getname+0x89
+ 0xc015cd5e getname+0x76: mov %eax,%esi
+ 0xc015cd60 getname+0x78: mov 0xfffffff0(%ebp),%edx
+ 0xc015cd63 getname+0x7b: mov 0xc04b2120,%eax
+ 0xc015cd68 getname+0x80: call 0xc01521f1 kmem_cache_free
+ 0xc015cd6d getname+0x85: mov %esi,%eax
+ 0xc015cd6f getname+0x87: jmp 0xc015cd7d getname+0x95
+ 0xc015cd71 getname+0x89: mov 0xfffffff0(%ebp),%eax
+ 0xc015cd74 getname+0x8c: jmp 0xc015cd7d getname+0x95
+ 0xc015cd76 getname+0x8e: mov $0xfffffffe,%esi
+ 0xc015cd7b getname+0x93: jmp 0xc015cd60 getname+0x78
+ 0xc015cd7d getname+0x95: pop %edx
+ 0xc015cd7e getname+0x96: pop %ebx
+ 0xc015cd7f getname+0x97: pop %esi
+ 0xc015cd80 getname+0x98: pop %edi
+ 0xc015cd81 getname+0x99: pop %ebp
+ 0xc015cd82 getname+0x9a: ret
+
+The bb1 command only one argument which must be an address, not a name. bb1
+turns on full basic block debugging and analyses the function containing the
+supplied address. Give bb1 the address of the exit point from this function,
+IOW the return address that is stored on stack due to a call from this function
+to the next function down the call stack. Assume that getname() has called
+kmem_cache_free() and something went wrong in kmem_cache_free() or one of the
+functions that it calls. The call to kmem_cache_free is at 0xc015cd68 and the
+return address on stack is the instruction after the call, i.e. 0xc015cd6d, so
+
+ [0]kdb> bb1 0xc015cd6d
+ bb_pass1: func_name getname func_start 0xc015cce8 func_end 0xc015cd83
+
+bb_pass1 has identified the function name and its start and end address. For C
+functions these are just the function start address and the next symbol in
+kallsyms. For Assembler code there may be spurious labels so the function name
+may not match the label prior to the address given to bb1. For an example of
+that on i386, find the address of resume_userspace then pass that address to the
+bb1 KDB command.
+
+ bb_pass1: end
+ bb[0] start 0xc015cce8 end 0xc015cd38 drop_through 1
+ bb[1] start 0xc015cd39 end 0xc015cd3d drop_through 1
+ bb[2] start 0xc015cd3e end 0xc015cd58 drop_through 0
+ bb[3] start 0xc015cd5a end 0xc015cd5f drop_through 1
+ bb[4] start 0xc015cd60 end 0xc015cd6f drop_through 0
+ bb[5] start 0xc015cd71 end 0xc015cd74 drop_through 0
+ bb[6] start 0xc015cd76 end 0xc015cd7b drop_through 0
+ bb[7] start 0xc015cd7d end 0xc015cd82 drop_through 0
+ bb_jmp[0] from 0xc015cd0e to 0xc015cd7d drop_through 0
+ bb_jmp[1] from 0xc015cd1b to 0xc015cd39 drop_through 0
+ bb_jmp[2] from 0xc015cd28 to 0xc015cd60 drop_through 0
+ bb_jmp[3] from 0xc015cd37 to 0xc015cd3e drop_through 0
+ bb_jmp[4] from 0xc015cd4d to 0xc015cd5a drop_through 0
+ bb_jmp[5] from 0xc015cd56 to 0xc015cd60 drop_through 0
+ bb_jmp[6] from 0xc015cd58 to 0xc015cd71 drop_through 0
+ bb_jmp[7] from 0xc015cd5a to 0xc015cd76 drop_through 0
+ bb_jmp[8] from 0xc015cd5c to 0xc015cd71 drop_through 0
+ bb_jmp[9] from 0xc015cd6f to 0xc015cd7d drop_through 0
+ bb_jmp[10] from 0xc015cd74 to 0xc015cd7d drop_through 0
+ bb_jmp[11] from 0xc015cd7b to 0xc015cd60 drop_through 0
+ bb_jmp[12] from 0xc015cd38 to 0xc015cd39 drop_through 1
+ bb_jmp[13] from 0xc015cd3d to 0xc015cd3e drop_through 1
+ bb_jmp[14] from 0xc015cd5f to 0xc015cd60 drop_through 1
+
+After analysing the logic flow, we can see that getname() consists of 8 basic
+blocks (nodes in bb_list[]). 5 of these blocks end in unconditional jumps, the
+other 3 drop through to the next block. There are 15 transfers of control
+(vertices in bb_jmp_list[]). 12 of these transfers are explicit jmp or jcc
+instructions, the other 3 are implicit transfers when dropping through from one
+block to the next. The node list is sorted by start address, the vertex list is
+not sorted.
+
+Basic block 0 starts at the function start (0xc015cce8) and ends at 0xc015cd38.
+0xc015cd39 is the target of a jump instruction (0xc015cd1b: je 0xc015cd39) so
+0xc015cd39 starts a new block, which means that 0xc015cd38 becomes the end of
+the previous block. Because bb[0] does not end in an explicit jmp instruction,
+there is a drop through from the end of bb[0] to the start of bb[1], see
+bb_jmp[12].
+
+ bb_pass2: start
+
+To get the most accurate results from pass2, try to scan the directed graph by
+only looking at nodes whose inputs are all defined. Initially only process
+nodes with no missing inputs.
+
+ bb_pass2_do_changed_blocks: allow_missing 0
+
+ bb[0]
+ bb_reg_state c07282e0
+ rax = rax
+ rbx = rbx
+ rcx = rcx
+ rdx = rdx
+ rdi = rdi
+ rsi = rsi
+ rbp = rbp
+ rsp = osp+0x0
+
+The initial state for bb[0] is the same for all C functions. Each register
+contains its own abstract value, except for rsp which is defined in terms of the
+original stack pointer (osp).
+
+ '0xc015cce8 getname: push %ebp'
+
+The first instruction of getname() saves the frame pointer.
+
+ opcode 'push' matched by 'push', usage 44
+ src R: %ebp base_rc 8 (rbp)
+
+bb_usage() reports how the instruction was recognised and how its operands were
+decoded. Although this is i386 (ebp), it is reported as rbp. Using the x86_64
+names for registers throughout makes it easier to create common code for the two
+architecures.
+
+ rsp osp offset +0x0 -> -0x4
+
+A push instruction decrements rsp by 4 (i386) or 8 (x86_64) bytes. rsp
+originally contained the original stack pointer (osp), now it contains the
+original stack pointer - 4.
+
+ *(rsp+0x0 osp-0x4) = rbp slot 0
+
+The stack location pointed to by *rsp now contains the original value of rbp.
+Since rsp contains (osp-0x4), *(osp-0x4) contains rbp. It is slot 0 in the
+memory array associated with the register state.
+
+ '0xc015cce9 getname+0x1: mov %esp,%ebp'
+ opcode 'mov' matched by 'mov', usage 36
+ src R: %esp base_rc 9 (rsp)
+ dst R: %ebp base_rc 8 (rbp)
+ rbp = rsp (osp-0x4)
+
+Copy esp (rsp) to ebp (rbp). rsp contained (osp-0x4) so rbp also contains
+(osp-0x4). Any reference to data via either rbp or rsp will now be tracked as a
+stack location.
+
+ '0xc015cceb getname+0x3: push %edi'
+ opcode 'push' matched by 'push', usage 44
+ src R: %edi base_rc 6 (rdi)
+ rsp osp offset -0x4 -> -0x8
+ *(rsp+0x0 osp-0x8) = rdi slot 1
+ '0xc015ccec getname+0x4: push %esi'
+ opcode 'push' matched by 'push', usage 44
+ src R: %esi base_rc 7 (rsi)
+ rsp osp offset -0x8 -> -0xc
+ *(rsp+0x0 osp-0xc) = rsi slot 2
+ '0xc015cced getname+0x5: push %ebx'
+ opcode 'push' matched by 'push', usage 44
+ src R: %ebx base_rc 3 (rbx)
+ rsp osp offset -0xc -> -0x10
+ *(rsp+0x0 osp-0x10) = rbx slot 3
+
+Push 3 registers to stack. rsp is adjusted for each push and stack locations
+are assigned to contain the values of edi, esi and ebx. This sequence is very
+common in i386 C functions. edi, esi and ebx are preserved registers on i386,
+but gcc wants to use them for scratch space. The original contents iof these
+registers must be saved on stack and restored before returning to our caller.
+
+ '0xc015ccee getname+0x6: sub $0x4,%esp'
+ opcode 'sub' matched by 'sub', usage 51
+ src I: $0x4
+ dst R: %esp base_rc 9 (rsp)
+ rsp osp offset -0x10 -> -0x14
+
+Subtract 4 bytes from esp. This defines the local stack variables. Sorry,
+names for local stack variables are not available to KDB.
+
+ '0xc015ccf1 getname+0x9: mov %eax,%edi'
+ opcode 'mov' matched by 'mov', usage 36
+ src R: %eax base_rc 2 (rax)
+ dst R: %edi base_rc 6 (rdi)
+ rdi = rax (rax)
+
+Having saved edi on stack, gcc now overwrites edi with eax. At this point rax
+still contains its original value, so rdi now contains a copy of rax, as well as
+the original value which is still in rax. This is a common sequence in C code.
+rax contains argument 0 but it is also a scratch register. If the code needs to
+use argument 0 later then its value must be saved somewhere before executing any
+instruction that changes rax. edi is a preserved register so its contents will
+not be changed by any function that we call, or if it is changed then it will be
+restored before returning to this function.
+
+rax is listed in the arch specific bb_param_reg[] list and the code is reading
+from rax while it still contains its original value. The only way that makes
+any sense is when rax is an input argument to getname(). We note that fact in
+bb_reg_read().
+
+ '0xc015ccf3 getname+0xb: mov $0xd0,%edx'
+ opcode 'mov' matched by 'mov', usage 36
+ src I: $0xd0
+ dst R: %edx base_rc 5 (rdx)
+ rdx = undefined
+
+Moving an constant value to edx. Although this is a constant, it does not refer
+to any of the original values that were supplied to this function. Therefore
+rdx becomes undefined for the purposes of the code analysis.
+
+ '0xc015ccf8 getname+0x10: mov 0xc04b2120,%eax'
+ opcode 'mov' matched by 'mov', usage 36
+ src M: 0xc04b2120
+ dst R: %eax base_rc 2 (rax)
+ rax = undefined
+
+Moving a constant value to eax makes rax undefined.
+
+ '0xc015ccfd getname+0x15: call 0xc0153009 <kmem_cache_alloc>'
+ opcode 'call' matched by 'call', usage 17
+ src M: 0xc0153009
+ bb_reg_state c0728658
+ rax = undefined
+ rbx = rbx
+ rcx = rcx
+ rdx = undefined
+ rdi = rax
+ rsi = rsi
+ rbp = osp-0x4
+ rsp = osp-0x14
+ slot 0 offset_address -0x4 rbp
+ slot 1 offset_address -0x8 rdi
+ slot 2 offset_address -0xc rsi
+ slot 3 offset_address -0x10 rbx
+
+Basic block debugging prints the register and memory state when transfering
+control between blocks and when issuing call instructions. The call state is
+mainly useful when C code calls assembler routines, especially if you are not
+sure what state the assembler code expects. Not all of our assembler is as well
+documented as it could be :(
+
+ rax = undefined
+ rcx = undefined
+ rdx = undefined
+
+The i386 ABI says that some registers are preserved across calls, see the arch
+specific bb_preserved_reg[] list. Any registers not in that list automatically
+become undefined after a call instruction.
+
+ '0xc015cd02 getname+0x1a: mov %eax,0xfffffff0(%ebp)'
+ opcode 'mov' matched by 'mov', usage 36
+ src R: %eax base_rc 2 (rax)
+ dst M: 0xfffffff0(%ebp) base_rc 8 (rbp)
+
+eax is the return value from the call, it is being saved at offset 0xfffffff0
+(-0x10) from ebp. Since rbp contains (osp-0x4) the return value is being stored
+at (osp-0x14). This is a stack location but we have no record of any data being
+held at that location, it is part of the local stack variables.
+
+ '0xc015cd05 getname+0x1d: mov $0xfffffff4,%eax'
+ opcode 'mov' matched by 'mov', usage 36
+ src I: $0xfffffff4
+ dst R: %eax base_rc 2 (rax)
+ rax = undefined
+ '0xc015cd0a getname+0x22: cmpl $0x0,0xfffffff0(%ebp)'
+ opcode 'cmpl' matched by 'cmp', usage 3
+ src I: $0x0
+ dst M: 0xfffffff0(%ebp) base_rc 8 (rbp)
+ '0xc015cd0e getname+0x26: je 0xc015cd7d <getname+0x95>'
+ opcode 'je' matched by 'j', usage 28
+ src M: 0xc015cd7d
+ bb_reg_state c0728658
+ rax = undefined
+ rbx = rbx
+ rcx = undefined
+ rdx = undefined
+ rdi = rax
+ rsi = rsi
+ rbp = osp-0x4
+ rsp = osp-0x14
+ slot 0 offset_address -0x4 rbp
+ slot 1 offset_address -0x8 rdi
+ slot 2 offset_address -0xc rsi
+ slot 3 offset_address -0x10 rbx
+
+Transfer of control, print the register and memory state.
+
+ matched: from 0xc015cd0e to 0xc015cd7d drop_through 0 bb_jmp[0]
+
+Which bb_jmp_list[] entry matches this transfer.
+
+ new state c07286b8
+
+The current abstract register and memory state is cloned at address c07286b8.
+This state becomes one of the inputs to the basic block whose start address is
+0xc015cd7d.
+
+ '0xc015cd10 getname+0x28: mov %esp,%eax'
+ opcode 'mov' matched by 'mov', usage 36
+ src R: %esp base_rc 9 (rsp)
+ dst R: %eax base_rc 2 (rax)
+ rax = rsp (osp-0x14)
+
+Copy rsp which contains (osp-0x14) to rax. rax contains a valid stack pointer.
+
+ '0xc015cd12 getname+0x2a: and $0xfffff000,%eax'
+ opcode 'and' matched by 'and', usage 11
+ src I: $0xfffff000
+ dst R: %eax base_rc 2 (rax)
+ rax = undefined
+
+But not for long.
+
+ '0xc015cd17 getname+0x2f: cmpl $0xffffffff,0x18(%eax)'
+ opcode 'cmpl' matched by 'cmp', usage 3
+ src I: $0xffffffff
+ dst M: 0x18(%eax) base_rc 2 (rax)
+ '0xc015cd1b getname+0x33: je 0xc015cd39 <getname+0x51>'
+ opcode 'je' matched by 'j', usage 28
+ src M: 0xc015cd39
+ bb_reg_state c0728658
+ rax = undefined
+ rbx = rbx
+ rcx = undefined
+ rdx = undefined
+ rdi = rax
+ rsi = rsi
+ rbp = osp-0x4
+ rsp = osp-0x14
+ slot 0 offset_address -0x4 rbp
+ slot 1 offset_address -0x8 rdi
+ slot 2 offset_address -0xc rsi
+ slot 3 offset_address -0x10 rbx
+
+Another transfer of control, print the state.
+
+ matched: from 0xc015cd1b to 0xc015cd39 drop_through 0 bb_jmp[1]
+
+Which bb_jmp_list[] entry was used.
+
+ reuse bb_jmp[0]
+
+To save space, we only clone the state if it is different. Otherwise we reuse
+the state from another vertex and bump the reference count.
+
+ '0xc015cd1d getname+0x35: mov $0xfffffff2,%esi'
+ opcode 'mov' matched by 'mov', usage 36
+ src I: $0xfffffff2
+ dst R: %esi base_rc 7 (rsi)
+ rsi = undefined
+
+Using esi as a scratch register, even though the i386 ABi says that esi is a
+preserved register. Not to worry, the original value of rsi was saved on stack
+on entry and it will be restored before exit.
+
+ '0xc015cd22 getname+0x3a: cmp $0xbfffffff,%edi'
+ opcode 'cmp' matched by 'cmp', usage 3
+ src I: $0xbfffffff
+ dst R: %edi base_rc 6 (rdi)
+ '0xc015cd28 getname+0x40: ja 0xc015cd60 <getname+0x78>'
+ opcode 'ja' matched by 'j', usage 28
+ src M: 0xc015cd60
+ bb_reg_state c0728658
+ rax = undefined
+ rbx = rbx
+ rcx = undefined
+ rdx = undefined
+ rdi = rax
+ rsi = undefined
+ rbp = osp-0x4
+ rsp = osp-0x14
+ slot 0 offset_address -0x4 rbp
+ slot 1 offset_address -0x8 rdi
+ slot 2 offset_address -0xc rsi
+ slot 3 offset_address -0x10 rbx
+ matched: from 0xc015cd28 to 0xc015cd60 drop_through 0 bb_jmp[2]
+ new state c0728710
+
+This state is different from any states already saved, clone to a new entry.
+
+ '0xc015cd2a getname+0x42: mov $0xc0000000,%ebx'
+ opcode 'mov' matched by 'mov', usage 36
+ src I: $0xc0000000
+ dst R: %ebx base_rc 3 (rbx)
+ rbx = undefined
+ '0xc015cd2f getname+0x47: sub %edi,%ebx'
+ opcode 'sub' matched by 'sub', usage 51
+ src R: %edi base_rc 6 (rdi)
+ dst R: %ebx base_rc 3 (rbx)
+ rbx = undefined
+ '0xc015cd31 getname+0x49: cmp $0xfff,%ebx'
+ opcode 'cmp' matched by 'cmp', usage 3
+ src I: $0xfff
+ dst R: %ebx base_rc 3 (rbx)
+ '0xc015cd37 getname+0x4f: jbe 0xc015cd3e <getname+0x56>'
+ opcode 'jbe' matched by 'j', usage 28
+ src M: 0xc015cd3e
+ bb_reg_state c0728658
+ rax = undefined
+ rbx = undefined
+ rcx = undefined
+ rdx = undefined
+ rdi = rax
+ rsi = undefined
+ rbp = osp-0x4
+ rsp = osp-0x14
+ slot 0 offset_address -0x4 rbp
+ slot 1 offset_address -0x8 rdi
+ slot 2 offset_address -0xc rsi
+ slot 3 offset_address -0x10 rbx
+ matched: from 0xc015cd37 to 0xc015cd3e drop_through 0 bb_jmp[3]
+ new state c0728768
+
+This state is different from any states already saved, clone to a new entry.
+
+ bb_reg_state c0728658
+ rax = undefined
+ rbx = undefined
+ rcx = undefined
+ rdx = undefined
+ rdi = rax
+ rsi = undefined
+ rbp = osp-0x4
+ rsp = osp-0x14
+ slot 0 offset_address -0x4 rbp
+ slot 1 offset_address -0x8 rdi
+ slot 2 offset_address -0xc rsi
+ slot 3 offset_address -0x10 rbx
+ matched: from 0xc015cd38 to 0xc015cd39 drop_through 1 bb_jmp[12]
+ reuse bb_jmp[3]
+
+Basic block 0 drops through to basic block 1, treat it as an implicit transfer
+of control. The state is the same as the previous jump instruction so reuse it
+and bump the reference count.
+
+That ends basic block 0, now pick the next block in the list that (a) needs to
+be scanned and (b) has all its input states defined. In this case bb[1].
+
+ bb[1]
+
+bb[1] starts at 0xc015cd39 and has two paths that transfer control to it.
+bb_jmp[1] from an explicit jump at 0xc015cd1b and a drop through at bb_jmp[12].
+Where there is more than one input state we have to merge them and reconcile the
+final value.
+
+ first state c07286b8
+
+The first input state is stored at c07286b8. Looking back through the trace we
+find that entry associated with bb_jmp[0], not bb_jmp[1] as expected. However
+bb_jmp[1] reused the state that was stored for bb_jmp[0] so all is well.
+
+ bb_reg_state c0728658
+ rax = undefined
+ rbx = rbx
+ rcx = undefined
+ rdx = undefined
+ rdi = rax
+ rsi = rsi
+ rbp = osp-0x4
+ rsp = osp-0x14
+ slot 0 offset_address -0x4 rbp
+ slot 1 offset_address -0x8 rdi
+ slot 2 offset_address -0xc rsi
+ slot 3 offset_address -0x10 rbx
+
+The first state for bb[1].
+
+ merging state c0728768
+
+Now merge the second state, which is held at c0728768.
+
+ rbx = undefined
+ rsi = undefined
+
+The two states disagree on the values being tracked in rbx and rsi. Compiler
+theory 101 says that if two or more paths to a basic block have different values
+for a register then that register cannot be relied on at the start of the block,
+so make it undefined. The same logic applies to memory locations.
+
+ final state
+ bb_reg_state c0728658
+ rax = undefined
+ rbx = undefined
+ rcx = undefined
+ rdx = undefined
+ rdi = rax
+ rsi = undefined
+ rbp = osp-0x4
+ rsp = osp-0x14
+ slot 0 offset_address -0x4 rbp
+ slot 1 offset_address -0x8 rdi
+ slot 2 offset_address -0xc rsi
+ slot 3 offset_address -0x10 rbx
+
+After merging all the input states, this is the final starting state for bb[1].
+Now track what bb[1] does to the state.
+
+ '0xc015cd39 getname+0x51: mov $0x1000,%ebx'
+ opcode 'mov' matched by 'mov', usage 36
+ src I: $0x1000
+ dst R: %ebx base_rc 3 (rbx)
+ rbx = undefined
+ bb_reg_state c0728658
+ rax = undefined
+ rbx = undefined
+ rcx = undefined
+ rdx = undefined
+ rdi = rax
+ rsi = undefined
+ rbp = osp-0x4
+ rsp = osp-0x14
+ slot 0 offset_address -0x4 rbp
+ slot 1 offset_address -0x8 rdi
+ slot 2 offset_address -0xc rsi
+ slot 3 offset_address -0x10 rbx
+ matched: from 0xc015cd3d to 0xc015cd3e drop_through 1 bb_jmp[13]
+ reuse bb_jmp[3]
+
+bb[1] is a single instruction which drops through to bb[2].
+
+ bb[2]
+ first state c0728768
+ bb_reg_state c0728658
+ rax = undefined
+ rbx = undefined
+ rcx = undefined
+ rdx = undefined
+ rdi = rax
+ rsi = undefined
+ rbp = osp-0x4
+ rsp = osp-0x14
+ slot 0 offset_address -0x4 rbp
+ slot 1 offset_address -0x8 rdi
+ slot 2 offset_address -0xc rsi
+ slot 3 offset_address -0x10 rbx
+ merging state c0728768
+
+bb[2] has two inputs, both vertices are pointing to input state c0728768.
+Merging an entry with itself has no effect.
+
+ '0xc015cd3e getname+0x56: mov %ebx,%ecx'
+ opcode 'mov' matched by 'mov', usage 36
+ src R: %ebx base_rc 3 (rbx)
+ dst R: %ecx base_rc 4 (rcx)
+ rcx = rbx (undefined)
+ '0xc015cd40 getname+0x58: mov %edi,%edx'
+ opcode 'mov' matched by 'mov', usage 36
+ src R: %edi base_rc 6 (rdi)
+ dst R: %edx base_rc 5 (rdx)
+ rdx = rdi (rax)
+ '0xc015cd42 getname+0x5a: mov 0xfffffff0(%ebp),%eax'
+ opcode 'mov' matched by 'mov', usage 36
+ src M: 0xfffffff0(%ebp) base_rc 8 (rbp)
+ dst R: %eax base_rc 2 (rax)
+ rax = *(rbp-0x10) (osp-0x14) rax = undefined
+ '0xc015cd45 getname+0x5d: call 0xc023dbb4 <strncpy_from_user>'
+ opcode 'call' matched by 'call', usage 17
+ src M: 0xc023dbb4
+ bb_reg_state c0728658
+ rax = undefined
+ rbx = undefined
+ rcx = undefined
+ rdx = rax
+ rdi = rax
+ rsi = undefined
+ rbp = osp-0x4
+ rsp = osp-0x14
+ slot 0 offset_address -0x4 rbp
+ slot 1 offset_address -0x8 rdi
+ slot 2 offset_address -0xc rsi
+ slot 3 offset_address -0x10 rbx
+ rax = undefined
+ rcx = undefined
+ rdx = undefined
+ '0xc015cd4a getname+0x62: cmp $0x0,%eax'
+ opcode 'cmp' matched by 'cmp', usage 3
+ src I: $0x0
+ dst R: %eax base_rc 2 (rax)
+ '0xc015cd4d getname+0x65: jle 0xc015cd5a <getname+0x72>'
+ opcode 'jle' matched by 'j', usage 28
+ src M: 0xc015cd5a
+ bb_reg_state c0728658
+ rax = undefined
+ rbx = undefined
+ rcx = undefined
+ rdx = undefined
+ rdi = rax
+ rsi = undefined
+ rbp = osp-0x4
+ rsp = osp-0x14
+ slot 0 offset_address -0x4 rbp
+ slot 1 offset_address -0x8 rdi
+ slot 2 offset_address -0xc rsi
+ slot 3 offset_address -0x10 rbx
+ matched: from 0xc015cd4d to 0xc015cd5a drop_through 0 bb_jmp[4]
+ reuse bb_jmp[3]
+ '0xc015cd4f getname+0x67: mov $0xffffffdc,%esi'
+ opcode 'mov' matched by 'mov', usage 36
+ src I: $0xffffffdc
+ dst R: %esi base_rc 7 (rsi)
+ rsi = undefined
+ '0xc015cd54 getname+0x6c: cmp %ebx,%eax'
+ opcode 'cmp' matched by 'cmp', usage 3
+ src R: %ebx base_rc 3 (rbx)
+ dst R: %eax base_rc 2 (rax)
+ '0xc015cd56 getname+0x6e: jae 0xc015cd60 <getname+0x78>'
+ opcode 'jae' matched by 'j', usage 28
+ src M: 0xc015cd60
+ bb_reg_state c0728658
+ rax = undefined
+ rbx = undefined
+ rcx = undefined
+ rdx = undefined
+ rdi = rax
+ rsi = undefined
+ rbp = osp-0x4
+ rsp = osp-0x14
+ slot 0 offset_address -0x4 rbp
+ slot 1 offset_address -0x8 rdi
+ slot 2 offset_address -0xc rsi
+ slot 3 offset_address -0x10 rbx
+ matched: from 0xc015cd56 to 0xc015cd60 drop_through 0 bb_jmp[5]
+ reuse bb_jmp[3]
+ '0xc015cd58 getname+0x70: jmp 0xc015cd71 <getname+0x89>'
+ opcode 'jmp' matched by 'j', usage 28
+ src M: 0xc015cd71
+ bb_reg_state c0728658
+ rax = undefined
+ rbx = undefined
+ rcx = undefined
+ rdx = undefined
+ rdi = rax
+ rsi = undefined
+ rbp = osp-0x4
+ rsp = osp-0x14
+ slot 0 offset_address -0x4 rbp
+ slot 1 offset_address -0x8 rdi
+ slot 2 offset_address -0xc rsi
+ slot 3 offset_address -0x10 rbx
+ matched: from 0xc015cd58 to 0xc015cd71 drop_through 0 bb_jmp[6]
+ reuse bb_jmp[3]
+
+ bb[3]
+ first state c0728768
+ bb_reg_state c0728658
+ rax = undefined
+ rbx = undefined
+ rcx = undefined
+ rdx = undefined
+ rdi = rax
+ rsi = undefined
+ rbp = osp-0x4
+ rsp = osp-0x14
+ slot 0 offset_address -0x4 rbp
+ slot 1 offset_address -0x8 rdi
+ slot 2 offset_address -0xc rsi
+ slot 3 offset_address -0x10 rbx
+
+bb[3] only has one input, nothing to merge.
+
+ '0xc015cd5a getname+0x72: je 0xc015cd76 <getname+0x8e>'
+ opcode 'je' matched by 'j', usage 28
+ src M: 0xc015cd76
+ bb_reg_state c0728658
+ rax = undefined
+ rbx = undefined
+ rcx = undefined
+ rdx = undefined
+ rdi = rax
+ rsi = undefined
+ rbp = osp-0x4
+ rsp = osp-0x14
+ slot 0 offset_address -0x4 rbp
+ slot 1 offset_address -0x8 rdi
+ slot 2 offset_address -0xc rsi
+ slot 3 offset_address -0x10 rbx
+ matched: from 0xc015cd5a to 0xc015cd76 drop_through 0 bb_jmp[7]
+ reuse bb_jmp[3]
+ '0xc015cd5c getname+0x74: jge 0xc015cd71 <getname+0x89>'
+ opcode 'jge' matched by 'j', usage 28
+ src M: 0xc015cd71
+ bb_reg_state c0728658
+ rax = undefined
+ rbx = undefined
+ rcx = undefined
+ rdx = undefined
+ rdi = rax
+ rsi = undefined
+ rbp = osp-0x4
+ rsp = osp-0x14
+ slot 0 offset_address -0x4 rbp
+ slot 1 offset_address -0x8 rdi
+ slot 2 offset_address -0xc rsi
+ slot 3 offset_address -0x10 rbx
+ matched: from 0xc015cd5c to 0xc015cd71 drop_through 0 bb_jmp[8]
+ reuse bb_jmp[3]
+ '0xc015cd5e getname+0x76: mov %eax,%esi'
+ opcode 'mov' matched by 'mov', usage 36
+ src R: %eax base_rc 2 (rax)
+ dst R: %esi base_rc 7 (rsi)
+ rsi = rax (undefined)
+ bb_reg_state c0728658
+ rax = undefined
+ rbx = undefined
+ rcx = undefined
+ rdx = undefined
+ rdi = rax
+ rsi = undefined
+ rbp = osp-0x4
+ rsp = osp-0x14
+ slot 0 offset_address -0x4 rbp
+ slot 1 offset_address -0x8 rdi
+ slot 2 offset_address -0xc rsi
+ slot 3 offset_address -0x10 rbx
+ matched: from 0xc015cd5f to 0xc015cd60 drop_through 1 bb_jmp[14]
+ reuse bb_jmp[3]
+
+ bb[5]
+ first state c0728768
+ bb_reg_state c0728658
+ rax = undefined
+ rbx = undefined
+ rcx = undefined
+ rdx = undefined
+ rdi = rax
+ rsi = undefined
+ rbp = osp-0x4
+ rsp = osp-0x14
+ slot 0 offset_address -0x4 rbp
+ slot 1 offset_address -0x8 rdi
+ slot 2 offset_address -0xc rsi
+ slot 3 offset_address -0x10 rbx
+ merging state c0728768
+ '0xc015cd71 getname+0x89: mov 0xfffffff0(%ebp),%eax'
+ opcode 'mov' matched by 'mov', usage 36
+ src M: 0xfffffff0(%ebp) base_rc 8 (rbp)
+ dst R: %eax base_rc 2 (rax)
+ rax = *(rbp-0x10) (osp-0x14) rax = undefined
+ '0xc015cd74 getname+0x8c: jmp 0xc015cd7d <getname+0x95>'
+ opcode 'jmp' matched by 'j', usage 28
+ src M: 0xc015cd7d
+ bb_reg_state c0728658
+ rax = undefined
+ rbx = undefined
+ rcx = undefined
+ rdx = undefined
+ rdi = rax
+ rsi = undefined
+ rbp = osp-0x4
+ rsp = osp-0x14
+ slot 0 offset_address -0x4 rbp
+ slot 1 offset_address -0x8 rdi
+ slot 2 offset_address -0xc rsi
+ slot 3 offset_address -0x10 rbx
+ matched: from 0xc015cd74 to 0xc015cd7d drop_through 0 bb_jmp[10]
+ reuse bb_jmp[3]
+
+ bb[6]
+ first state c0728768
+ bb_reg_state c0728658
+ rax = undefined
+ rbx = undefined
+ rcx = undefined
+ rdx = undefined
+ rdi = rax
+ rsi = undefined
+ rbp = osp-0x4
+ rsp = osp-0x14
+ slot 0 offset_address -0x4 rbp
+ slot 1 offset_address -0x8 rdi
+ slot 2 offset_address -0xc rsi
+ slot 3 offset_address -0x10 rbx
+ '0xc015cd76 getname+0x8e: mov $0xfffffffe,%esi'
+ opcode 'mov' matched by 'mov', usage 36
+ src I: $0xfffffffe
+ dst R: %esi base_rc 7 (rsi)
+ rsi = undefined
+ '0xc015cd7b getname+0x93: jmp 0xc015cd60 <getname+0x78>'
+ opcode 'jmp' matched by 'j', usage 28
+ src M: 0xc015cd60
+ bb_reg_state c0728658
+ rax = undefined
+ rbx = undefined
+ rcx = undefined
+ rdx = undefined
+ rdi = rax
+ rsi = undefined
+ rbp = osp-0x4
+ rsp = osp-0x14
+ slot 0 offset_address -0x4 rbp
+ slot 1 offset_address -0x8 rdi
+ slot 2 offset_address -0xc rsi
+ slot 3 offset_address -0x10 rbx
+ matched: from 0xc015cd7b to 0xc015cd60 drop_through 0 bb_jmp[11]
+ reuse bb_jmp[3]
+
+ bb[4]
+ first state c0728710
+ bb_reg_state c0728658
+ rax = undefined
+ rbx = rbx
+ rcx = undefined
+ rdx = undefined
+ rdi = rax
+ rsi = undefined
+ rbp = osp-0x4
+ rsp = osp-0x14
+ slot 0 offset_address -0x4 rbp
+ slot 1 offset_address -0x8 rdi
+ slot 2 offset_address -0xc rsi
+ slot 3 offset_address -0x10 rbx
+ merging state c0728768
+ rbx = undefined
+ merging state c0728768
+ merging state c0728768
+
+bb[4] has 4 inputs, 3 of which have the same state. One one path (state
+c0728710) rbx is defined, on the others (c0728768) rbx is undefined so the final
+state has rbx as undefined.
+
+ final state
+ bb_reg_state c0728658
+ rax = undefined
+ rbx = undefined
+ rcx = undefined
+ rdx = undefined
+ rdi = rax
+ rsi = undefined
+ rbp = osp-0x4
+ rsp = osp-0x14
+ slot 0 offset_address -0x4 rbp
+ slot 1 offset_address -0x8 rdi
+ slot 2 offset_address -0xc rsi
+ slot 3 offset_address -0x10 rbx
+ '0xc015cd60 getname+0x78: mov 0xfffffff0(%ebp),%edx'
+ opcode 'mov' matched by 'mov', usage 36
+ src M: 0xfffffff0(%ebp) base_rc 8 (rbp)
+ dst R: %edx base_rc 5 (rdx)
+ rdx = *(rbp-0x10) (osp-0x14) rdx = undefined
+ '0xc015cd63 getname+0x7b: mov 0xc04b2120,%eax'
+ opcode 'mov' matched by 'mov', usage 36
+ src M: 0xc04b2120
+ dst R: %eax base_rc 2 (rax)
+ rax = undefined
+ '0xc015cd68 getname+0x80: call 0xc01521f1 <kmem_cache_free>'
+ opcode 'call' matched by 'call', usage 17
+ src M: 0xc01521f1
+ bb_reg_state c0728658
+ rax = undefined
+ rbx = undefined
+ rcx = undefined
+ rdx = undefined
+ rdi = rax
+ rsi = undefined
+ rbp = osp-0x4
+ rsp = osp-0x14
+ slot 0 offset_address -0x4 rbp
+ slot 1 offset_address -0x8 rdi
+ slot 2 offset_address -0xc rsi
+ slot 3 offset_address -0x10 rbx
+ rax = undefined
+ rcx = undefined
+ rdx = undefined
+ bb_reg_state c0728658
+ rax = undefined
+ rbx = undefined
+ rcx = undefined
+ rdx = undefined
+ rdi = rax
+ rsi = undefined
+ rbp = osp-0x4
+ rsp = osp-0x14
+ slot 0 offset_address -0x4 rbp
+ slot 1 offset_address -0x8 rdi
+ slot 2 offset_address -0xc rsi
+ slot 3 offset_address -0x10 rbx
+ '0xc015cd6d getname+0x85: mov %esi,%eax'
+ opcode 'mov' matched by 'mov', usage 36
+ src R: %esi base_rc 7 (rsi)
+ dst R: %eax base_rc 2 (rax)
+ rax = rsi (undefined)
+ '0xc015cd6f getname+0x87: jmp 0xc015cd7d <getname+0x95>'
+ opcode 'jmp' matched by 'j', usage 28
+ src M: 0xc015cd7d
+ bb_reg_state c0728658
+ rax = undefined
+ rbx = undefined
+ rcx = undefined
+ rdx = undefined
+ rdi = rax
+ rsi = undefined
+ rbp = osp-0x4
+ rsp = osp-0x14
+ slot 0 offset_address -0x4 rbp
+ slot 1 offset_address -0x8 rdi
+ slot 2 offset_address -0xc rsi
+ slot 3 offset_address -0x10 rbx
+ matched: from 0xc015cd6f to 0xc015cd7d drop_through 0 bb_jmp[9]
+ reuse bb_jmp[3]
+
+ bb[7]
+ first state c07286b8
+ bb_reg_state c0728658
+ rax = undefined
+ rbx = rbx
+ rcx = undefined
+ rdx = undefined
+ rdi = rax
+ rsi = rsi
+ rbp = osp-0x4
+ rsp = osp-0x14
+ slot 0 offset_address -0x4 rbp
+ slot 1 offset_address -0x8 rdi
+ slot 2 offset_address -0xc rsi
+ slot 3 offset_address -0x10 rbx
+ merging state c0728768
+ rbx = undefined
+ rsi = undefined
+ merging state c0728768
+ final state
+ bb_reg_state c0728658
+ rax = undefined
+ rbx = undefined
+ rcx = undefined
+ rdx = undefined
+ rdi = rax
+ rsi = undefined
+ rbp = osp-0x4
+ rsp = osp-0x14
+ slot 0 offset_address -0x4 rbp
+ slot 1 offset_address -0x8 rdi
+ slot 2 offset_address -0xc rsi
+ slot 3 offset_address -0x10 rbx
+ '0xc015cd7d getname+0x95: pop %edx'
+ opcode 'pop' matched by 'pop', usage 42
+ src R: %edx base_rc 5 (rdx)
+ rdx = *(rsp+0x0) (osp-0x14) rdx = undefined
+ rsp osp offset -0x14 -> -0x10
+
+This instruction is a bit misleading. It looks like gcc is restoring a value
+from the stack *(osp-0x14) to edx, but we have no record of any useful data
+being stored at osp-0x14. In fact gcc is just reducing the stack pointer by 4
+bytes to reverse the effect of 0xc015ccee: sub $0x4,%esp, the value popped into
+edx contains nothing useful. Why gcc does pop instead of add $0x4,%esp is a
+puzzle, probably some micro optimization.
+
+ '0xc015cd7e getname+0x96: pop %ebx'
+ opcode 'pop' matched by 'pop', usage 42
+ src R: %ebx base_rc 3 (rbx)
+ rbx = *(rsp+0x0) (osp-0x10) value rbx
+ rsp osp offset -0x10 -> -0xc
+ delete rbx from osp-0x10 slot 3
+
+This pop is doing something useful. It is restoring the original value of the
+preserved register ebx from stack, reversing 0xc015cced: push %ebx. Note that
+incrementing rsp from osp-0x10 to osp-0xc invalidates the data held in memory at
+osp-0x10, so we delete our record of it.
+
+ '0xc015cd7f getname+0x97: pop %esi'
+ opcode 'pop' matched by 'pop', usage 42
+ src R: %esi base_rc 7 (rsi)
+ rsi = *(rsp+0x0) (osp-0xc) value rsi
+ rsp osp offset -0xc -> -0x8
+ delete rsi from osp-0xc slot 2
+ '0xc015cd80 getname+0x98: pop %edi'
+ opcode 'pop' matched by 'pop', usage 42
+ src R: %edi base_rc 6 (rdi)
+ rdi = *(rsp+0x0) (osp-0x8) value rdi
+ rsp osp offset -0x8 -> -0x4
+ delete rdi from osp-0x8 slot 1
+
+Pop the other preserved registers, in reverse order to the push sequence at the
+start.
+
+ '0xc015cd81 getname+0x99: pop %ebp'
+ opcode 'pop' matched by 'pop', usage 42
+ src R: %ebp base_rc 8 (rbp)
+ rbp = *(rsp+0x0) (osp-0x4) value rbp
+ rsp osp offset -0x4 -> +0x0
+ delete rbp from osp-0x4 slot 0
+
+Pop the previous frame pointer.
+
+ '0xc015cd82 getname+0x9a: ret '
+ opcode 'ret' matched by 'ret', usage 48
+
+When a ret instruction is executed, all the preserved registers must be back to
+their original value and the stack pointer must contain osp+0.
+bb_sanity_check() will complain and abort the backtrace if this is not true. No
+complaints here.
+
+ bb_pass2: end bb_reg_params 1 bb_memory_params 0
+
+We identified one argument passed in a register (the read of rax at 0xc015ccf1)
+and no reference to memory locations above the stack frame. So we have one
+argument being passed in a register and no arguments being passed on stack.
+This matches
+
+ char * getname(const char __user * filename)
+
+ bb_pass2: bb_exit_state at 0xc015cd6d
+ bb_reg_state c07287c0
+ rax = undefined
+ rbx = undefined
+ rcx = undefined
+ rdx = undefined
+ rdi = rax
+ rsi = undefined
+ rbp = osp-0x4
+ rsp = osp-0x14
+ slot 0 offset_address -0x4 rbp
+ slot 1 offset_address -0x8 rdi
+ slot 2 offset_address -0xc rsi
+ slot 3 offset_address -0x10 rbx
+
+We told bb1 that the exit address from this function is 0xc015cd6d. The
+abstract state at this exit point was saved, it defines how we rollback the
+actual register values from the next function down the stack (kmem_cache_free)
+to get the actual register values on entry to this function (getname). See
+bb_actual_rollback() which updates bb_actual[].
+
+Looking at the exit state above, we see that rsp contains the abstracte value
+osp-0x14. It is a given that we have the actual value of rsp after the call
+from getname() to kmem_cache_free(), otherwise we would not have found the
+return address on stack and we would not be analysing getname(). Adding 0x14
+(the delta from osp to rsp) to our current actual rsp gives us the actual value
+of osp on entry to getname().
+
+The main aim of doing all this work is to track the function arguments so we can
+print them if possible. getname() only has one argument which was passed in
+eax. According to the abstract exit state, the original value of rax is
+currently in rdi, so by looking at the actual value of rdi from the next stack
+frame down we are able to get the argument to getname().
+
+It is not always possible to get register arguments, gcc will only preserve
+input arguments as long as it needs them so there may be no saved copy of
+arguments that are passed in register. In this case, bt_print_one() prints
+"invalid".
+
+If basic block analysis detected any arguments were passed on stack, their
+contents can now be extracted based on the known value of the stack pointer.
+bt_print_one() prints the arguments, if BT_ARGS is non-zero then any argument
+that might be a kernel address is printed as a symbol.
+
+Once rsp has been rolled back to osp, we can calculate that actual address of
+the stack locations that contain useful data. The previous values of rbp, rdi,
+rsi and rbx are then copied from those locations into bb_actual[]. That gives
+the values for those registers at the exit point from the function that called
+getname(). Go up one level and repeat the analysis.
+
+There are two references to rdi in the exit state, which can be confusing.
+
+ rdi = rax
+ slot 1 offset_address -0x8 rdi
+
+The first reference says that "register rdi contains the original value of rax",
+the second reference says that "*(osp-0x8) contains the original value of rdi".
+Do not confuse the two, one is by name, the other is by value.
+
+getname() is a fairly simple function, it has no loops. __follow_mount is more
+complicated, it has loops as well as BUG() statements.
+
+ [0]kdb> id __follow_mount
+ 0xc015be76 __follow_mount: push %ebp
+ 0xc015be77 __follow_mount+0x1: mov %esp,%ebp
+ 0xc015be79 __follow_mount+0x3: push %edi
+ 0xc015be7a __follow_mount+0x4: push %esi
+ 0xc015be7b __follow_mount+0x5: push %ebx
+ 0xc015be7c __follow_mount+0x6: mov %eax,%esi
+ 0xc015be7e __follow_mount+0x8: xor %edi,%edi
+ 0xc015be80 __follow_mount+0xa: jmp 0xc015beca __follow_mount+0x54
+ 0xc015be82 __follow_mount+0xc: mov (%esi),%eax
+ 0xc015be84 __follow_mount+0xe: call 0xc0169664 lookup_mnt
+ 0xc015be89 __follow_mount+0x13: mov %eax,%ebx
+ 0xc015be8b __follow_mount+0x15: test %eax,%eax
+ 0xc015be8d __follow_mount+0x17: je 0xc015bed3 __follow_mount+0x5d
+ 0xc015be8f __follow_mount+0x19: mov 0x4(%esi),%eax
+ 0xc015be92 __follow_mount+0x1c: call 0xc0163de2 dput
+ 0xc015be97 __follow_mount+0x21: test %edi,%edi
+ 0xc015be99 __follow_mount+0x23: je 0xc015bead __follow_mount+0x37
+ 0xc015be9b __follow_mount+0x25: mov (%esi),%eax
+ 0xc015be9d __follow_mount+0x27: test %eax,%eax
+ 0xc015be9f __follow_mount+0x29: je 0xc015bead __follow_mount+0x37
+ 0xc015bea1 __follow_mount+0x2b: movl $0x0,0x64(%eax)
+ 0xc015bea8 __follow_mount+0x32: call 0xc016835b mntput_no_expire
+ 0xc015bead __follow_mount+0x37: mov %ebx,(%esi)
+ 0xc015beaf __follow_mount+0x39: mov 0x10(%ebx),%eax
+ 0xc015beb2 __follow_mount+0x3c: test %eax,%eax
+ 0xc015beb4 __follow_mount+0x3e: je 0xc015bec2 __follow_mount+0x4c
+ 0xc015beb6 __follow_mount+0x40: cmpl $0x0,(%eax)
+ 0xc015beb9 __follow_mount+0x43: jne 0xc015bebf __follow_mount+0x49
+ 0xc015bebb __follow_mount+0x45: ud2a
+ 0xc015bebd __follow_mount+0x47: jmp 0xc015bebd __follow_mount+0x47
+ 0xc015bebf __follow_mount+0x49: lock incl (%eax)
+ 0xc015bec2 __follow_mount+0x4c: mov %eax,0x4(%esi)
+ 0xc015bec5 __follow_mount+0x4f: mov $0x1,%edi
+ 0xc015beca __follow_mount+0x54: mov 0x4(%esi),%edx
+ 0xc015becd __follow_mount+0x57: cmpl $0x0,0x74(%edx)
+ 0xc015bed1 __follow_mount+0x5b: jne 0xc015be82 __follow_mount+0xc
+ 0xc015bed3 __follow_mount+0x5d: mov %edi,%eax
+ 0xc015bed5 __follow_mount+0x5f: pop %ebx
+ 0xc015bed6 __follow_mount+0x60: pop %esi
+ 0xc015bed7 __follow_mount+0x61: pop %edi
+ 0xc015bed8 __follow_mount+0x62: pop %ebp
+ 0xc015bed9 __follow_mount+0x63: ret
+
+ [0]kdb> bb1 0xc015bed9
+ bb_pass1: func_name __follow_mount func_start 0xc015be76 func_end 0xc015beda
+ bb_pass1: end
+ bb[0] start 0xc015be76 end 0xc015be80 drop_through 0
+ bb[1] start 0xc015be82 end 0xc015beac drop_through 1
+ bb[2] start 0xc015bead end 0xc015bebb drop_through 0
+
+Note that the ud2a (BUG) instruction at 0xc015bebb ends bb[2].
+
+ bb[3] start 0xc015bebd end 0xc015bebd drop_through 0
+
+bb[3] is peculiar, it is a jmp to itself, nothing else refers to 0xc015bebd and
+you cannot drop through from the previous instruction because ud2a kills the
+kernel. The i386 and x86_64 BUG() macros contain for(;;) after ud2a, for no
+good reason that I can see (is there old hardware that does not abort on ud2a?).
+ia64 and the generic versions of BUG() do not contain for(;;). for(;;) after
+ud2a generates a branch to itself than can never be executed.
+
+ bb[4] start 0xc015bebf end 0xc015bec1 drop_through 1
+ bb[5] start 0xc015bec2 end 0xc015bec9 drop_through 1
+ bb[6] start 0xc015beca end 0xc015bed2 drop_through 1
+ bb[7] start 0xc015bed3 end 0xc015bed9 drop_through 0
+ bb_jmp[0] from 0xc015be80 to 0xc015beca drop_through 0
+ bb_jmp[1] from 0xc015be8d to 0xc015bed3 drop_through 0
+ bb_jmp[2] from 0xc015be99 to 0xc015bead drop_through 0
+ bb_jmp[3] from 0xc015be9f to 0xc015bead drop_through 0
+ bb_jmp[4] from 0xc015beb4 to 0xc015bec2 drop_through 0
+ bb_jmp[5] from 0xc015beb9 to 0xc015bebf drop_through 0
+ bb_jmp[6] from 0xc015bebd to 0xc015bebd drop_through 0
+ bb_jmp[7] from 0xc015bed1 to 0xc015be82 drop_through 0
+ bb_jmp[8] from 0xc015beac to 0xc015bead drop_through 1
+ bb_jmp[9] from 0xc015bec1 to 0xc015bec2 drop_through 1
+ bb_jmp[10] from 0xc015bec9 to 0xc015beca drop_through 1
+ bb_jmp[11] from 0xc015bed2 to 0xc015bed3 drop_through 1
+
+Apart from bb[0] and the special case bb[3], all the other blocks are part of a
+cycle. That cycle goes bb[0] -> bb[6]. bb[6] -> {bb[1], bb[7]}. bb[1] ->
+{bb[2], bb[7]}. bb[2] -> {bb[4], bb[5]}. bb[4] -> bb[5]. bb[5] -> bb[6] and
+back to the start. bb[7] ends with 'ret', it does not feed into other blocks.
+
+ bb_pass2: start
+
+ bb_pass2_do_changed_blocks: allow_missing 0
+
+ bb[0]
+ [ ... detail snipped ... ]
+ matched: from 0xc015be80 to 0xc015beca drop_through 0 bb_jmp[0]
+ new state c07286d8
+
+ bb_pass2_do_changed_blocks: allow_missing 1
+
+Because of the cycle, only bb[0] can be processed with 0 missing inputs, all the
+other blocks have at least one missing input. Call bb_pass2_do_changed_blocks()
+again, this time allowing one missing input per blocks.
+
+ bb[6]
+ first state c07286d8
+ [ ... detail snipped ... ]
+ matched: from 0xc015bed2 to 0xc015bed3 drop_through 1 bb_jmp[11]
+ reuse bb_jmp[7]
+
+ bb[7]
+ first state c0728730
+ [ ... detail snipped ... ]
+
+ bb[1]
+ first state c0728730
+ [ ... detail snipped ... ]
+ matched: from 0xc015beac to 0xc015bead drop_through 1 bb_jmp[8]
+ reuse bb_jmp[1]
+
+ bb[2]
+ first state c0728788
+ [ ... detail snipped ... ]
+ merging state c0728788
+ merging state c0728788
+ [ ... detail snipped ... ]
+ matched: from 0xc015beb9 to 0xc015bebf drop_through 0 bb_jmp[5]
+ reuse bb_jmp[1]
+
+ bb[4]
+ first state c0728788
+ [ ... detail snipped ... ]
+ matched: from 0xc015bec1 to 0xc015bec2 drop_through 1 bb_jmp[9]
+ reuse bb_jmp[1]
+
+ bb[5]
+ first state c0728788
+ [ ... detail snipped ... ]
+ merging state c0728788
+ [ ... detail snipped ... ]
+ matched: from 0xc015bec9 to 0xc015beca drop_through 1 bb_jmp[10]
+ reuse bb_jmp[1]
+
+ bb[6]
+ first state c07286d8
+ [ ... detail snipped ... ]
+ merging state c0728788
+ matched: from 0xc015bed2 to 0xc015bed3 drop_through 1 bb_jmp[11]
+ reuse bb_jmp[1]
+
+Note the rescan of bb[6]. The first scan only had one input from bb[0]. After
+traversing the cycle and getting back from bb[5] to bb[6], bb[6] now has more
+inputs so we need to rescan it. With the additional input, the output state
+from bb[6] has changed since the first scan, which means that every block it
+feeds has to be rescanned. bb[6] feeds bb[1] and bb[7].
+
+ bb[7]
+ first state c0728788
+ [ ... detail snipped ... ]
+ merging state c0728788
+ [ ... detail snipped ... ]
+
+bb[7] being rescanned, this time it has data for both its inputs.
+
+ bb[1]
+ first state c0728788
+ [ ... detail snipped ... ]
+ matched: from 0xc015beac to 0xc015bead drop_through 1 bb_jmp[8]
+ no state change
+
+bb[1] is being rescanned because the input from bb[6] has changed, however the
+rescan of bb[1] reports 'no state change', the changed input from bb[6] did not
+affect the final output state from bb[1]. Because the output state from bb[1]
+has not changed since the previous scan, there is no need to rescan bb[2], bb[7]
+or bb[4]. Since bb[4] is not being rescanned, there is no need to rescan bb[5]
+or bb[6] and the cycle is closed.
Index: linux/Documentation/kdb/kdb.mm
===================================================================
--- /dev/null
+++ linux/Documentation/kdb/kdb.mm
@@ -0,0 +1,492 @@
+.TH KDB 8 "September 21, 2005"
+.hy 0
+.SH NAME
+Built-in Kernel Debugger for Linux - v4.4
+.SH "Overview"
+This document describes the built-in kernel debugger available
+for linux. This debugger allows the programmer to interactively
+examine kernel memory, disassemble kernel functions, set breakpoints
+in the kernel code and display and modify register contents.
+.P
+A symbol table is included in the kernel image and in modules which
+enables all non-stack symbols (including static symbols) to be used as
+arguments to the kernel debugger commands.
+.SH "Getting Started"
+To include the kernel debugger in a linux kernel, use a
+configuration mechanism (e.g. xconfig, menuconfig, et. al.)
+to enable the \fBCONFIG_KDB\fP option. Additionally, for accurate
+stack tracebacks, it is recommended that the \fBCONFIG_FRAME_POINTER\fP
+option be enabled (if present). \fBCONFIG_FRAME_POINTER\fP changes the compiler
+flags so that the frame pointer register will be used as a frame
+pointer rather than a general purpose register.
+.P
+After linux has been configured to include the kernel debugger,
+make a new kernel with the new configuration file (a make clean
+is recommended before making the kernel), and install the kernel
+as normal.
+.P
+You can compile a kernel with kdb support but have kdb off by default,
+select \fBCONFIG_KDB_OFF\fR. Then the user has to explicitly activate
+kdb by booting with the 'kdb=on' flag or, after /proc is mounted, by
+.nf
+ echo "1" > /proc/sys/kernel/kdb
+.fi
+You can also do the reverse, compile a kernel with kdb on and
+deactivate kdb with the boot flag 'kdb=off' or, after /proc is mounted,
+by
+.nf
+ echo "0" > /proc/sys/kernel/kdb
+.fi
+.P
+When booting the new kernel, the 'kdb=early' flag
+may be added after the image name on the boot line to
+force the kernel to stop in the kernel debugger early in the
+kernel initialization process. 'kdb=early' implies 'kdb=on'.
+If the 'kdb=early' flag isn't provided, then kdb will automatically be
+invoked upon system panic or when the \fBPAUSE\fP key is used from the
+keyboard, assuming that kdb is on. Older versions of kdb used just a
+boot flag of 'kdb' to activate kdb early, this is no longer supported.
+.P
+KDB can also be used via the serial port. Set up the system to
+have a serial console (see \fIDocumentation/serial-console.txt\fP), you
+must also have a user space program such as agetty set up to read from
+the serial console.
+The control sequence \fB<esc>KDB\fP on the serial port will cause the
+kernel debugger to be entered, assuming that kdb is on, that some
+program is reading from the serial console, at least one cpu is
+accepting interrupts and the serial console driver is still usable.
+.P
+\fBNote:\fR\ When the serial console sequence consists of multiple
+characters such as <esc>KDB then all but the last character are passed
+through to the application that is reading from the serial console.
+After exiting from kdb, you should use backspace to delete the rest of
+the control sequence.
+.P
+You can boot with kdb activated but without the ability to enter kdb
+via any keyboard sequence.
+In this mode, kdb will only be entered after a system failure.
+Booting with kdb=on-nokey will activate kdb but ignore keyboard
+sequences that would normally drop you into kdb.
+kdb=on-nokey is mainly useful when you are using a PC keyboard and your
+application needs to use the Pause key.
+You can also activate this mode by
+.nf
+ echo "2" > /proc/sys/kernel/kdb
+.fi
+.P
+If the console is sitting on the login prompt when you enter kdb, then
+the login command may switch into upper case mode.
+This is not a kdb bug, it is a "feature" of login - if the userid is
+all upper case then login assumes that you using a TeleType (circa
+1960) which does not have lower case characters.
+Wait 60 seconds for login to timeout and it will switch back to lower
+case mode.
+.P
+\fBNote:\fR\ Your distributor may have chosen a different kdb
+activation sequence for the serial console.
+Consult your distribution documentation.
+.P
+If you have both a keyboard+video and a serial console, you can use
+either for kdb.
+Define both video and serial consoles with boot parameters
+.P
+.nf
+ console=tty0 console=ttyS0,38400
+.fi
+.P
+Any kdb data entered on the keyboard or the serial console will be echoed
+to both.
+.P
+If you are using a USB keyboard then kdb commands cannot be entered
+until the kernel has initialised the USB subsystem and recognised the
+keyboard.
+Using kdb=early with a USB keyboard will not work, the USB subsystem is
+initialised too late.
+.P
+While kdb is active, the keyboard (not serial console) indicators may strobe.
+The caps lock and scroll lock lights will turn on and off, num lock is not used
+because it can confuse laptop keyboards where the numeric keypad is mapped over
+the normal keys.
+On exit from kdb the keyboard indicators will probably be wrong, they will not match the kernel state.
+Pressing caps lock twice should get the indicators back in sync with
+the kernel.
+.SH "Basic Commands"
+There are several categories of commands available to the
+kernel debugger user including commands providing memory
+display and modification, register display and modification,
+instruction disassemble, breakpoints and stack tracebacks.
+Any command can be prefixed with '-' which will cause kdb to ignore any
+errors on that command, this is useful when packaging commands using
+defcmd.
+A line whose first non-space character is '#' is printed and ignored.
+.P
+The following table shows the currently implemented standard commands,
+these are always available. Other commands can be added by extra
+debugging modules, type '?' at the kdb prompt to get a list of all
+available commands.
+.DS
+.TS
+box, center;
+l | l
+l | l.
+Command Description
+_
+bc Clear Breakpoint
+bd Disable Breakpoint
+be Enable Breakpoint
+bl Display breakpoints
+bp Set or Display breakpoint
+bph Set or Display hardware breakpoint
+bpa Set or Display breakpoint globally
+bpha Set or Display hardware breakpoint globally
+bt Stack backtrace for current process
+btp Stack backtrace for specific process
+bta Stack backtrace for all processes
+btc Cycle over all live cpus and backtrace each one
+cpu Display or switch cpus
+dmesg Display system messages
+defcmd Define a command as a set of other commands
+ef Print exception frame
+env Show environment
+go Restart execution
+handlers Control the display of IA64 MCA/INIT handlers
+help Display help message
+id Disassemble Instructions
+kill Send a signal to a process
+ll Follow Linked Lists
+lsmod List loaded modules
+md Display memory contents
+mdWcN Display memory contents with width W and count N.
+mdp Display memory based on a physical address
+mdr Display raw memory contents
+mds Display memory contents symbolically
+mm Modify memory contents, words
+mmW Modify memory contents, bytes
+per_cpu Display per_cpu variables
+pid Change the default process context
+ps Display process status
+reboot Reboot the machine
+rd Display register contents
+rm Modify register contents
+rq Display runqueue for one cpu
+rqa Display runqueue for all cpus
+set Add/change environment variable
+sr Invoke SysReq commands
+ss Single step a cpu
+ssb Single step a cpu until a branch instruction
+stackdepth Print the stack depth for selected processes
+summary Summarize the system
+.TE
+.DE
+.P
+Some commands can be abbreviated, such commands are indicated by a
+non-zero \fIminlen\fP parameter to \fBkdb_register\fP; the value of
+\fIminlen\fP being the minimum length to which the command can be
+abbreviated (for example, the \fBgo\fP command can be abbreviated
+legally to \fBg\fP).
+.P
+If an input string does not match a command in the command table,
+it is treated as an address expression and the corresponding address
+value and nearest symbol are shown.
+.P
+Some of the commands are described here.
+Information on the more complicated commands can be found in the
+appropriate manual pages.
+.TP 8
+cpu
+With no parameters, it lists the available cpus.
+\&'*' after a cpu number indicates a cpu that did not respond to the kdb
+stop signal.
+\&'+' after a cpu number indicates a cpu for which kdb has some data, but
+that cpu is no longer responding to kdb, so you cannot switch to it.
+This could be a cpu that has failed after entering kdb, or the cpu may
+have saved its state for debugging then entered the prom, this is
+normal for an IA64 MCA event.
+\&'I' after a cpu number means that the cpu was idle before it entered
+kdb, it is unlikely to contain any useful data.
+\&'F' after a cpu number means that the cpu is offline.
+There is currenly no way to distinguish between cpus that used to be
+online but are now offline and cpus that were never online, the kernel
+does not maintain the information required to separate those two cases.
+.I cpu
+followed by a number will switch to that cpu, you cannot switch to
+a cpu marked '*', '+' or 'F'.
+This command is only available if the kernel was configured for SMP.
+.TP 8
+dmesg [lines] [adjust]
+Displays the system messages from the kernel buffer.
+If kdb logging is on, it is disabled by dmesg and is left as disabled.
+With no parameters or a zero value for 'lines', dmesg dumps the entire
+kernel buffer.
+If lines is specified and is positive, dmesg dumps the last 'lines'
+from the buffer.
+If lines is specified and is negative, dmesg dumps the first 'lines'
+from the buffer.
+If adjust is specified, adjust the starting point for the lines that
+are printed.
+When 'lines' is positive, move the starting point back by 'adjust'
+lines, when 'lines' is negative, move the starting point forward by
+\&'adjust' lines.
+.I dmesg -100
+will dump 100 lines, from the start of the buffer.
+.I dmesg 100
+will dump 100 lines, starting 100 lines from the end of the buffer,
+.I dmesg 100 100
+will dump 100 lines, starting 200 lines from the end of the buffer.
+.I dmesg -100 100
+will dump 100 lines, starting 100 lines from the start of the buffer.
+.TP 8
+defcmd
+Defines a new command as a set of other commands, all input until
+.I endefcmd
+is saved and executed as a package.
+.I defcmd
+takes three parameters, the command name to be defined and used to
+invoke the package, a quoted string containing the usage text and a
+quoted string containing the help text for the command.
+When using defcmd, it is a good idea to prefix commands that might fail
+with '-', this ignores errors so the following commands are still
+executed.
+For example,
+.P
+.nf
+ defcmd diag "" "Standard diagnostics"
+ set LINES 2000
+ set BTAPROMPT 0
+ -id %eip-0x40
+ -cpu
+ -ps
+ -dmesg 80
+ -bt
+ -bta
+ endefcmd
+.fi
+.P
+When used with no parameters, defcmd prints all the defined commands.
+.TP 8
+go
+Continue normal execution.
+Active breakpoints are reestablished and the processor(s) allowed to
+run normally.
+To continue at a specific address, use
+.I rm
+to change the instruction pointer then go.
+.TP 8
+handlers
+Control the display of IA64 MCA/INIT handlers.
+The IA64 MCA/INIT handlers run on separate tasks.
+During an MCA/INIT event, the active tasks are typically the handlers,
+rather than the original tasks, which is not very useful for debugging.
+By default, KDB hides the MCA/INIT handlers so commands such as ps and
+btc will display the original task.
+You can change this behaviour by using
+.I handlers show
+to display the MCA/INIT handlers instead of the original tasks or use
+.I handlers hide
+(the default) to hide the MCA/INIT handlers and display the original
+tasks.
+.I handlers status
+will list the address of the handler task and the original task for
+each cpu.
+\fBNote:\fR\ If the original task was running in user space or it
+failed any of the MCA/INIT verification tests then there is no original
+task to display.
+In this case, the handler will be displayed even if
+.I handlers hide
+is set and
+.I handlers status
+will not show an original task.
+.TP 8
+id
+Disassemble instructions starting at an address.
+Environment variable IDCOUNT controls how many lines of disassembly
+output the command produces.
+.TP 8
+kill
+Internal command to send a signal (like kill(1)) to a process.
+kill -signal pid.
+.TP 8
+lsmod
+Internal command to list modules.
+This does not use any kernel nor user space services so can be used at any time.
+.TP 8
+per_cpu <variable_name> [<length>] [<cpu>]
+Display the values of a per_cpu variable, the variable_name is
+specified without the \fIper_cpu__\fR prefix.
+Length is the length of the variable, 1-8, if omitted or 0 it defaults
+to the size of the machine's register.
+To display the variable on a specific cpu, the third parameter is the
+cpu number.
+When the third parameter is omitted, the variable's value is printed
+from all cpus, except that zero values are suppressed.
+For each cpu, per_cpu prints the cpu number, the address of the
+variable and its value.
+.TP 8
+pid <number>
+Change the current process context, with no parameters it displays the
+current process.
+The current process is used to display registers, both kernel and user
+space.
+It is also used when dumping user pages.
+.I pid R
+resets to the original process that was running when kdb was entered.
+This command is useful if you have been looking at other processes and/or
+cpus and you want to get back to the original process.
+It does not switch cpus, it only resets the context to the original process.
+.TP 8
+reboot
+Reboot the system, with no attempt to do a clean close down.
+.TP 8
+rq <cpu>
+Display the runqueues for the specified cpu.
+.TP 8
+rqa
+Display the runqueues for all cpus.
+.TP 8
+stackdepth <percentage>
+Print the stack usage for processes using more than the specified
+percentage of their stack.
+If percentage is not supplied, it defaults to 60.
+This command is only implemented on i386 and ia64 architectures,
+patches for other architectures will be gratefully accepted.
+.TP 8
+summary
+Print a summary of the system, including the time (no timezone is
+applied), uname information and various critical system counters.
+.SH INITIAL KDB COMMANDS
+kdb/kdb_cmds is a plain text file where you can define kdb commands
+which are to be issued during kdb_init(). One command per line, blank
+lines are ignored, lines starting with '#' are ignored. kdb_cmds is
+intended for per user customization of kdb, you can use it to set
+environment variables to suit your hardware or to set standard
+breakpoints for the problem you are debugging. This file is converted
+to a small C object, compiled and linked into the kernel. You must
+rebuild and reinstall the kernel after changing kdb_cmds. This file
+will never be shipped with any useful data so you can always override
+it with your local copy. Sample kdb_cmds:
+.P
+.nf
+# Initial commands for kdb, alter to suit your needs.
+# These commands are executed in kdb_init() context, no SMP, no
+# processes. Commands that require process data (including stack or
+# registers) are not reliable this early. set and bp commands should
+# be safe. Global breakpoint commands affect each cpu as it is booted.
+
+set LINES=50
+set MDCOUNT=25
+set RECURSE=1
+bp sys_init_module
+.fi
+.SH INTERRUPTS AND KDB
+When a kdb event occurs, one cpu (the initial cpu) enters kdb state.
+It uses a cross system interrupt to interrupt the
+other cpus and bring them all into kdb state. All cpus run with
+interrupts disabled while they are inside kdb, this prevents most
+external events from disturbing the kernel while kdb is running.
+.B Note:
+Disabled interrupts means that any I/O that relies on interrupts cannot
+proceed while kdb is in control, devices can time out. The clock tick
+is also disabled, machines will lose track of time while they are
+inside kdb.
+.P
+Even with interrupts disabled, some non-maskable interrupt events will
+still occur, these can disturb the kernel while you are debugging it.
+The initial cpu will still accept NMI events, assuming that kdb was not
+entered for an NMI event. Any cpu where you use the SS or SSB commands
+will accept NMI events, even after the instruction has finished and the
+cpu is back in kdb. This is an unavoidable side effect of the fact that
+doing SS[B] requires the cpu to drop all the way out of kdb, including
+exiting from the event that brought the cpu into kdb. Under normal
+circumstances the only NMI event is for the NMI oopser and that is kdb
+aware so it does not disturb the kernel while kdb is running.
+.P
+Sometimes doing SS or SSB on ix86 will allow one interrupt to proceed,
+even though the cpu is disabled for interrupts. I have not been able
+to track this one down but I suspect that the interrupt was pending
+when kdb was entered and it runs when kdb exits through IRET even
+though the popped flags are marked as cli(). If any ix86 hardware
+expert can shed some light on this problem, please notify the kdb
+maintainer.
+.SH RECOVERING FROM KDB ERRORS
+If a kdb command breaks and kdb has enough of a recovery environment
+then kdb will abort the command and drop back into mainline kdb code.
+This means that user written kdb commands can follow bad pointers
+without killing kdb. Ideally all code should verify that data areas
+are valid (using kdb_getarea) before accessing it but lots of calls to
+kdb_getarea can be clumsy.
+.P
+The sparc64 port does not currently provide this error recovery.
+If someone would volunteer to write the necessary longjmp/setjmp
+code, their efforts would be greatly appreciated. In the
+meantime, it is possible for kdb to trigger a panic by accessing
+a bad address.
+.SH DEBUGGING THE DEBUGGER
+kdb has limited support for debugging problems within kdb. If you
+suspect that kdb is failing, you can set environment variable KDBDEBUG
+to a bit pattern which will activate kdb_printf statements within kdb.
+See include/linux/kdb.h, KDB_DEBUG_FLAG_xxx defines. For example
+.nf
+ set KDBDEBUG=0x60
+.fi
+activates the event callbacks into kdb plus state tracing in sections
+of kdb.
+.nf
+ set KDBDEBUG=0x18
+.fi
+gives lots of tracing as kdb tries to decode the process stack.
+.P
+You can also perform one level of recursion in kdb. If environment
+variable RECURSE is not set or is 0 then kdb will either recover from
+an error (if the recovery environment is satisfactory) or kdb will
+allow the error to percolate, usually resulting in a dead system. When
+RECURSE is 1 then kdb will recover from an error or, if there is no
+satisfactory recovery environment, it will drop into kdb state to let
+you diagnose the problem. When RECURSE is 2 then all errors drop into
+kdb state, kdb does not attempt recovery first. Errors while in
+recursive state all drop through, kdb does not even attempt to recover
+from recursive errors.
+.SH KEYBOARD EDITING
+kdb supports a command history, which can be accessed via keyboard
+sequences.
+It supports the special keys on PC keyboards, control characters and
+vt100 sequences on a serial console or a PC keyboard.
+.P
+.DS
+.TS
+box, center;
+l | l | l l | l
+l | l | l l | l.
+PC Special keys Control VT100 key Codes Action
+_
+Backspace ctrl-H Backspace 0x7f Delete character to the left of the cursor
+Delete ctrl-D Delete \\e[3~ Delete character to the right of the cursor
+Home ctrl-A Home \\e[1~ Go to start of line
+End ctrl-E End \\e[4~ Go to end of line
+Up arrow ctrl-P Up arrow \\e[A Up one command in history
+Down arrow ctrl-N Down arrow \\e[B Down one command in history
+Left arrow ctrl-B Left arrow \\e[D Left one character in current command
+Right arrow ctrl-F Right arrow \\e[C Right one character in current command
+.TE
+.DE
+.P
+There is no toggle for insert/replace mode, kdb editing is always in
+insert mode.
+Use delete and backspace to delete characters.
+.P
+kdb also supports tab completion for kernel symbols
+Type the start of a kernel symbol and press tab (ctrl-I) to complete
+the name
+If there is more than one possible match, kdb will append any common
+characters and wait for more input, pressing tab a second time will
+display the possible matches
+The number of matches is limited by environment variable DTABCOUNT,
+with a default of 30 if that variable is not set.
+.SH AUTHORS
+Scott Lurndal, Richard Bass, Scott Foehner, Srinivasa Thirumalachar,
+Masahiro Adegawa, Marc Esipovich, Ted Kline, Steve Lord, Andi Kleen,
+Sonic Zhang.
+.br
+Keith Owens <kaos@sgi.com> - kdb maintainer.
+.SH SEE ALSO
+.P
+linux/Documentation/kdb/kdb_{bp,bt,env,ll,md,ps,rd,sr,ss}.man
Index: linux/Documentation/kdb/kdb_bp.man
===================================================================
--- /dev/null
+++ linux/Documentation/kdb/kdb_bp.man
@@ -0,0 +1,197 @@
+.TH BD 1 "July 12, 2004"
+.SH NAME
+bp, bpa, bph, bpha, bd, bc, be, bl \- breakpoint commands
+.SH SYNOPSIS
+bp \fIaddress-expression\fP
+.LP
+bpa \fIaddress-expression\fP
+.LP
+bph \fIaddress-expression\fP [\f(CWDATAR|DATAW|DATAA|IO\fP [\fIlength\fP]]
+.LP
+bpha \fIaddress-expression\fP [\f(CWDATAR|DATAW|DATAA|IO\fP [\fIlength\fP]]
+.LP
+bd \fIbreakpoint-number\fP
+.LP
+bc \fIbreakpoint-number\fP
+.LP
+be \fIbreakpoint-number\fP
+.LP
+bl
+.SH DESCRIPTION
+.hy 0
+The
+.B bp
+family of commands are used to establish a breakpoint.
+The \fIaddress-expression\fP may be a numeric value (decimal or
+hexidecimal), a symbol name, a register name preceeded by a
+percent symbol '%', or a simple expression consisting of a
+symbol name, an addition or subtraction character and a numeric
+value (decimal or hexidecimal).
+.P
+\fBbph\fP and \fBbpha\fP will force the use of a hardware register, provided
+the processor architecture supports them.
+.P
+The \fIaddress-expression\fP may also consist of a single
+asterisk '*' symbol which indicates that the command should
+operate on all existing breakpoints (valid only for \fBbc\fP,
+\fBbd\fP and \fBbe\fP).
+.P
+Four different types of
+breakpoints may be set:
+
+.TP 8
+Instruction
+Causes the kernel debugger to be invoked from the debug exception
+path when an instruction is fetched from the specified address. This
+is the default if no other type of breakpoint is requested or when
+the \fBbp\fP command is used.
+
+.TP 8
+DATAR
+Causes the kernel debugger to be entered when data of length
+\fIlength\fP is read from or written to the specified address.
+This type of breakpoint must use a processor debug register which
+places an architecture dependent limit on the number of data and I/O
+breakpoints that may be established. On arm mode XScale platform
+(thumb mode is not supported yet),
+debugger is triggered by reading from the specified address.
+The \fBbph\fP or \fBbpha\fP commands must be used.
+
+.TP 8
+DATAW
+Enters the kernel debugger when data of length \fIlength\fP
+is written to the specified address. \fIlength\fP defaults
+to four bytes if it is not explicitly specified.
+Note that the processor may have already overwritten the prior data at
+the breakpoint location before the kernel debugger is invoked.
+The prior data should be saved before establishing the breakpoint, if
+required. On arm mode XScale platform, the debugger is triggered
+after having overwritten the specified address.
+The \fBbph\fP or \fBbpha\fP commands must be used.
+
+.TP 8
+IO
+Enters the kernel debugger when an \fBin\fP or \fBout\fP instruction
+targets the specified I/O address. The \fBbph\fP or \fBbpha\fP
+commands must be used. This type of breakpoint is not valid in
+arm mode XScale platform. This option is not valid in arm
+mode XScale platform.
+
+.TP 8
+DATAA
+Enters the kernel debugger after the data in specified address has
+been accessed (read or write), this option is only used in arm
+mode XScale platform.
+
+.P
+The
+.B bpha
+command will establish a breakpoint on all processors in an
+SMP system. This command is not available in an uniprocessor
+kernel.
+.P
+The
+.B bd
+command will disable a breakpoint without removing it from the kernel
+debugger's breakpoint table.
+This can be used to keep breakpoints in the table without exceeding the
+architecture limit on breakpoint registers.
+A breakpoint-number of \fI*\fR will disable all break points.
+.P
+The
+.B be
+command will re-enable a disabled breakpoint.
+A breakpoint-number of \fI*\fR will enable all break points.
+.P
+The
+.B bc
+command will clear a breakpoint from the breakpoint table.
+A breakpoint-number of \fI*\fR will clear all break points.
+.P
+The
+.B bl
+command will list the existing set of breakpoints.
+.SH LIMITATIONS
+There is a compile time limit of sixteen entries in the
+breakpoint table at any one time.
+.P
+There are architecture dependent limits on the number of hardware
+breakpoints that can be set.
+.IP ix86 8
+Four.
+.PD 0
+.IP xscale 8
+Two for insruction breakpoints and another two for data breakpoint.
+.PD 0
+.IP ia64 8
+?
+.PD 0
+.IP sparc64 8
+None.
+.PD 1
+When issuing the "go" command after entering the debugger due to
+a breakpoint, kdb will silently perform a single step in order to
+reapply the breakpoint. The sparc64 port has some limitations on
+single stepping, which may limit where a breakpoint may be safely
+set. Please read the man page for \fBss\fP for more information.
+.SH ENVIRONMENT
+The breakpoint subsystem does not currently use any environment
+variables.
+.SH SMP CONSIDERATIONS
+Using
+.B bc
+is risky on SMP systems.
+If you clear a breakpoint when another cpu has hit that breakpoint but
+has not been processed then it may not be recognised as a kdb
+breakpoint, usually resulting in incorrect program counters and kernel
+panics.
+It is safer to disable the breakpoint with
+.BR bd ,
+then
+.B go
+to let any other processors that are waiting on the breakpoint to
+clear.
+After all processors are clear of the disabled breakpoint then it is
+safe to clear it using
+.BR bc .
+.P
+Breakpoints which use the processor breakpoint registers
+are only established on the processor which is
+currently active. If you wish breakpoints to be universal
+use the
+.B bpa
+or
+.B bpha
+commands.
+.SH EXAMPLES
+.TP 8
+bp schedule
+Sets an instruction breakpoint at the begining of the
+function \fBschedule\fP.
+
+.TP 8
+bp schedule+0x12e
+Sets an instruction breakpoint at the instruction located
+at \fBschedule\fP+\fI0x12e\fP.
+
+.TP 8
+bph ttybuffer+0x24 dataw
+Sets a data write breakpoint at the location referenced by
+\fBttybuffer\fP+\fI0x24\fP for a length of four bytes.
+
+.TP 8
+bph 0xc0254010 datar 1
+Establishes a data reference breakpoint at address \fB0xc0254010\fP
+for a length of one byte.
+
+.TP 8
+bp
+List current breakpoint table.
+
+.TP 8
+bd 0
+Disable breakpoint #0.
+
+.TP 8
+bc *
+Clear all breakpoints
Index: linux/Documentation/kdb/kdb_bt.man
===================================================================
--- /dev/null
+++ linux/Documentation/kdb/kdb_bt.man
@@ -0,0 +1,315 @@
+.TH BT 1 "July 20, 2007"
+.SH NAME
+bt \- Stack Traceback command
+.SH SYNOPSIS
+bt [ <stack-frame-address> ]
+.LP
+btp <pid>
+.LP
+btt <struct-task-address>
+.LP
+bta [ DRSTZUIMA ]
+.LP
+btc [<cpu>]
+.SH DESCRIPTION
+.hy 0
+The
+.B bt
+command is used to print a stack traceback. It uses the
+current registers (see \fBrd\fP command) to determine
+the starting context and attempts to provide a complete
+stack traceback for the active thread. If \fIstack-frame-address\fP
+is supplied, it is assumed to point to the start of a valid
+stack frame and the stack will be traced back from that
+point.
+On x86 architecture, \fIstack-frame-address\fP must be the stack address of a
+saved \fB%eip\fP (\fB%rip\fP for x86_64) value from a \fBcall\fP instruction.
+.P
+The \fBbtp\fP command will analyze the stack for the given
+process identification (see the \fBps\fP command).
+\fBbtp\fP sets the current process for any following register display or update
+commands.
+.P
+The \fBbtt\fP command will analyze the stack for the given task
+structure.
+It is exactly equivalent to \fBbtp\fR on the pid extracted from the
+task structure.
+\fBbtt\fP sets the current process for any following register display or update
+commands.
+.P
+The \fBbta\fP command lists the stack for all processes in the desired
+state.
+Without any parameters, \fBbta\fP gives a backtrace for all useful processes.
+If a parameter is specified, it is a single string consisting of the
+letters D, R, S, T, Z, U, I, M and A in any order.
+See the kdb \fBps\fR man page for more details.
+\fBbta\fP does not change the current process.
+.P
+The \fBbtc\fP command will analyze the stack for the current process on
+a specified cpu or, if no cpu number is supplied, for the current
+process on all cpus.
+It does not switch to the other cpus, instead it uses the task
+structures to identify and issue \fBbtt\fR against the current task on
+the desired cpus.
+\fBbtc\fP with no arguments does not change the current process.
+\fBbtc\fP with a cpu number sets the current process for any following register
+display or update commands.
+.P
+For each function, the stack trace prints at least two lines.
+The first line contains four or five fields\ :-
+.IP * 3
+The pointer to the stack frame.
+.PD 0
+.IP * 3
+The current address within this frame.
+.IP * 3
+The address converted to a function name (actually the first non-local
+label which is <= the address).
+.IP * 3
+The offset of the address within the function.
+.IP * 3
+Any parameters to the function.
+.PD 1
+.PP
+If environment variable NOSECT is set to 0 then the next line contains
+five fields which are designed to make it easier to match the trace
+against the kernel code\ :-
+.IP * 3
+The module name that contains the address, "kernel" if it is in the
+base kernel.
+.PD 0
+.IP * 3
+The section name that contains the address (not available on 2.6 kernels).
+.IP * 3
+The start address of the section (not available on 2.6 kernels).
+.IP * 3
+The start address of the function.
+.IP * 3
+The end address of the function (the first non-local label which is >
+the address).
+.PD 1
+.PP
+If arguments are being converted to symbols, any argument which
+converts to a kernel or module address is printed as\ :-
+.IP * 3
+Argument address.
+.PD 0
+.IP * 3
+The module name that contains the address, "kernel" if it is in the
+base kernel.
+.IP * 3
+The symbol name the argument maps to.
+.IP * 3
+The offset of the argument from the symbol, suppressed if 0.
+.PD 1
+.P
+On architectures that use nested stacks, the backtrace will indicate a
+switch to a new stack by printing a line of equal signs and the type of
+stack.
+.SH MATCHING TRACE TO KERNEL CODE
+The command "objdump\ -S" will disassemble an object and, if the code
+was compiled with debugging (gcc flag -g), objdump will interleave the
+C source lines with the generated object.
+.PP
+A complete objdump of the kernel or a module is too big, normally you
+only want specific functions.
+By default objdump will only print the .text section but Linux uses
+other section names for executable code.
+When objdump prints relocatable objects (modules) it uses an offset of
+0 which is awkward to relate to the stack trace.
+The five fields which are printed for each function are designed to
+make it easier to match the stack trace against the kernel code using
+"objdump\ -S".
+.PP
+If the function is in the kernel then you need the section name, the
+start and end address of the function. The command is
+.PP
+.nf
+ objdump -S -j <section_name> \\
+ --start-address=<start-address> \\
+ --stop-address=<end-address> \\
+ /usr/src/linux/vmlinux
+.fi
+.PP
+If the function is in a module then you need the section name, the
+start address of the section, the start and end address of the
+function, the module name. The command is
+.PP
+.nf
+ objdump -S -j <section_name> \\
+ --adjust-vma=<section-start> \\
+ --start-address=<start-address> \\
+ --stop-address=<end-address> \\
+ /path/to/module/<module-name>.o
+.fi
+.PP
+Unfortunately the 2.6 kernel does not provide the information required
+to locate the start of the section, which makes it very difficult to
+perform a reliable objdump on a module.
+.PP
+All addresses to objdump must be preceded by '0x' if they are in hex,
+objdump does not assume hex.
+The stack trace values are printed with leading '0x' to make it easy to
+run objdump.
+.SH LIMITATIONS
+Some architectures pass parameters in registers; ia64, x86_64 and i386 (with
+gcc flag -mregparm) fall into this category.
+On these architectures, the compiler may reuse input parameter registers as
+scratch space.
+For example, if a function takes a pointer to a structure and only accesses one
+field in that structure, the compiler may calculate the address of the field by
+adding a value to the input register.
+Once the input register has been updated, it no longer points to the
+start of the structure, but to some field within it.
+This also occurs with array pointers, the compiler may update the input pointer
+directly, leaving it pointing to some element of the array instead of the start
+of the array.
+Always treat parameter values that have been passed in registers with extreme
+suspicion, the compiler may have changed the value.
+The x86 backtrace can generally identify register parameters that are no longer
+valid, it prints them as 'invalid' instead of as a misleading number.
+The ia64 backtrace cannot identify parameter registers that have been
+overwritten.
+.P
+x86 architectures do not have full unwind information in the kernel.
+The KDB backtrace on x86 performs code decomposition and analysis to track the
+frames on the call stack (including stack switches) and to locate parameters.
+if this code analysis does not yield a valid result, KDB falls back on the old
+method of scanning the process stack and printing anything that looks like a
+kernel address.
+This old method is unreliable (it produces lots of false positives in the
+trace) and cannot track parameters at all, so no parameters are printed.
+If you get an x86 backtrace that falls back to the old method, read
+Documentation/kdb/bt_x86 and follow the steps listed to get diagnostics and to
+submit a bug report.
+.P
+There are a lot of functions in the kernel which take some arguments then do
+nothing except call another function with the same initial arguments, sometimes
+adding parameters at the end. For example\ :-
+.nf
+.na
+.ft CW
+
+int ipv4_doint_and_flush_strategy(ctl_table *table, int __user *name, int nlen,
+ void __user *oldval, size_t __user *oldlenp,
+ void __user *newval, size_t newlen)
+{
+ int ret = devinet_conf_sysctl(table, name, nlen, oldval, oldlenp,
+ newval, newlen);
+
+ if (ret == 1)
+ rt_cache_flush(0);
+
+ return ret;
+}
+.ad b
+.fi
+.P
+ipv4_doint_and_flush_strategy() passes all its parameters directly to
+devinet_conf_sysctl() and makes no other use of those parameters,
+so ipv4_doint_and_flush_strategy is a 'pass through' function.
+The x86_64 calling sequence mandates that the first 6 parameters are passed in
+registers, with other parameters being passed on stack.
+The i386 calling sequence with -mregparm=3 (which is the default since about
+2.6.18) passes the first 3 parameters in registers, with other parameters being
+passed on stack.
+The only exceptions to the above calling sequence are for functions declared as
+asmlinkage or functions with a variable number of parameters (e.g. printk).
+.P
+When a pass through function calls another function, the first 3 (i386) or 6
+(x86) parameters are already in their correct registers so the pass through
+function does not need to access the registers, which means that there are no
+references to these registers in the assembler code for the function.
+Users still want to see those arguments so the x86 backtrace has to assume that
+if\ :-
+.IP * 2
+There are parameters passed on the stack and
+.IP *
+There are no code references to parameters passed in registers and
+.IP *
+The function is not a known asmlinkage or variadic function, then
+there are pass through register arguments.
+.P
+The x86 backtrace will warn you when it makes this assumption, like this\ :-
+.nf
+.na
+.ft CW
+
+ <function_name> has memory parameters but no register parameters.
+ Assuming it is a 'pass through' function that does not refer to its register
+ parameters and setting <n> register parameters
+.ad b
+.fi
+.P
+The above 3 line message is only printed once, any future assumptions will
+print a shorter message.
+.P
+The \fBbt\fP command may print more or less arguments for a function
+than that function accepts.
+For x86, trailing arguments that are passed in but not used by the function
+will not be printed, resulting in fewer arguments than expected.
+For ia64, the hardware does not distinguish between input and local registers,
+some local registers may be printed as function arguments, resulting in more
+arguments than expected.
+.P
+On i386, 64 bit arguments (long long) occupy two adjacent 32 bit fields.
+There is no way for KDB to tell that this has occurred, so 64 bit arguments
+will be printed as two separate 32 bit arguments.
+.SH ENVIRONMENT
+The \fBBTARGS\fP environment variable governs the maximum number
+of arguments that are printed for any single function.
+On IA64 hardware, there is no difference between input and local registers, the
+first \fBBTARGS\fP registers are printed, up to the total limit of input plus
+local registers.
+Use a large value for \fBBTARGS\fP if you want to see the local registers on
+IA64.
+.PP
+If the \fBBTSP\fP environment variable is non-zero then the entire backtrace is
+printed, otherwise only the backtrace to the point of the last interrupt is
+printed.
+Printing the entire backtrace with 'set\ BTSP\ 1' is useful for diagnosing
+problems with the backtrace algorithms.
+In addition, when BTSP is non-zero, each backtrace frame may print extra lines
+giving information about the stack pointers, this is architecture specific.
+.PP
+If the \fBBTSYMARG\fP environment variable is non-zero then any
+arguments that fall within the kernel or modules are converted to symbols.
+.PP
+If the \fBNOSECT\fP environment variable is non-zero then the
+section information is suppressed.
+The default is NOSECT=1 so section data is suppressed; use set\ NOSECT=0
+to see section information.
+.PP
+The \fBBTAPROMPT\fP environment variable controls the prompt after each
+process is listed by the \fBbta\fP command. If \fBBTAPROMPT\fP is not
+set or is non-zero then \fBbta\fP issues a prompt after each process is
+listed. If \fBBTAPROMPT\fP is set to zero then no prompt is issued and
+all processes are listed without human intervention.
+.PP
+\fBbt\fR with no parameters uses the \fBPS\fR environment variable, see
+the kdb \fBps\fR man page.
+.SH SMP CONSIDERATIONS
+None.
+.SH EXAMPLES
+.nf
+.na
+.ft CW
+[0]kdb> bt
+Stack traceback for pid 2873
+0xc2efc0f0 2873 2836 1 0 R 0xc2efc2a0 *mount
+esp eip Function (args)
+0xf65a3c88 0xc0201f9f xfs_mount_validate_sb (0xf68bcb08, 0xf68bcb48, 0x0)
+0xf65a3c94 0xc0202f17 xfs_readsb+0x9d (0xf68bcb08, 0x0)
+0xf65a3cc0 0xc020a72e xfs_mount+0x21d (invalid, 0xf68bc2f0, 0x0)
+0xf65a3cf4 0xc021a84a vfs_mount+0x1a (invalid)
+0xf65a3d04 0xc021a721 xfs_fs_fill_super+0x76 (0xf76b6200, invalid, invalid)
+0xf65a3d78 0xc015ad81 get_sb_bdev+0xd4 (invalid, invalid, invalid, 0xf7257000, 0xc021a6ab, 0xf7594b38)
+ xfs_fs_get_sb has memory parameters but no register parameters.
+ Assuming it is a 'pass through' function that does not refer to its register
+ parameters and setting 3 register parameters
+0xf65a3db4 0xc0219a3a xfs_fs_get_sb+0x21 (invalid, invalid, invalid, 0xf7257000, 0xf7594b38)
+0xf65a3dcc 0xc015a992 vfs_kern_mount+0x41 (0xc04847e0, 0x0, 0xf68e9000, 0xf7257000)
+0xf65a3df0 0xc015aa11 do_kern_mount+0x38 (0xf6818000, 0x0, 0xf68e9000, 0xf7257000)
+0xf65a3e10 0xc016c8b0 do_mount+0x5df (0xf68e9000, 0xf65d6000, 0xf6818000, 0xc0ed0000, 0xf7257000)
+0xf65a3f90 0xc016c996 sys_mount+0x6f (0x8069b50, 0x8069b60, 0x8069b70, 0xc0ed0000, 0x8069ba0)
+0xf65a3fb4 0xc0102646 sysenter_past_esp+0x5f (invalid, invalid, invalid, 0x73, 0x246, 0xbfe52f50)
Index: linux/Documentation/kdb/kdb_env.man
===================================================================
--- /dev/null
+++ linux/Documentation/kdb/kdb_env.man
@@ -0,0 +1,46 @@
+.TH ENV 1 "24 September 2000"
+.SH NAME
+env, set \- Environment manipulation commands
+.SH SYNOPSIS
+env
+.LP
+set \fIenvironment-variable\fP=\fIvalue\fP
+.SH DESCRIPTION
+The kernel debugger contains an environment which contains a series
+of name-value pairs. Some environment variables are known to the
+various kernel debugger commands and have specific meaning to the
+command; such are enumerated on the respective reference material.
+.P
+Arbitrary environment variables may be created and used with
+many commands (those which require an \fIaddress-expression\fP).
+.P
+The
+.B env
+command is used to display the current environment.
+.P
+The
+.B set
+command is used to alter an existing environment variable or
+establish a new environment variable.
+.SH LIMITATIONS
+There is a compile-time limit of 33 environment variables.
+.P
+There is a compile-time limit of 512 bytes (\fBKDB_ENVBUFSIZE\fP)
+of heap space available for new environment variables and for
+environment variables changed from their compile-time values.
+.SH ENVIRONMENT
+These commands explicitly manipulate the environment.
+.SH SMP CONSIDERATIONS
+None.
+.SH USER SETTINGS
+You can include "set" commands in kdb/kdb_cmds (see kdb.mm) to define
+your environment variables at kernel startup.
+.SH EXAMPLES
+.TP 8
+env
+Display current environment settings.
+
+.TP 8
+set IDCOUNT=100
+Set the number of lines to display for the \fBid\fP command
+to the value \fI100\fP.
Index: linux/Documentation/kdb/kdb_ll.man
===================================================================
--- /dev/null
+++ linux/Documentation/kdb/kdb_ll.man
@@ -0,0 +1,134 @@
+.TH LL 1 "19 April 1999"
+.SH NAME
+ll \- Linked List examination
+.SH SYNOPSIS
+ll <addr> <link-offset> <cmd>
+.SH DESCRIPTION
+The
+.B ll
+command is used to execute a single command repetitively for
+each element of a linked list.
+.P
+The command specified by <cmd> will be executed with a single
+argument, the address of the current element.
+.SH LIMITATIONS
+Be careful if using this command recursively.
+.SH ENVIRONMENT
+None.
+.SH SMP CONSIDERATIONS
+None.
+.SH EXAMPLES
+.nf
+.na
+.ft CW
+# cd modules
+# insmod kdbm_vm.o
+# Entering kdb on processor 0 due to PAUSE
+kdb> ps
+Task Addr Pid Parent cpu lcpu Tss Command
+0xc03de000 0000000001 0000000000 0000 0000 0xc03de2d4 init
+0xc0090000 0000000002 0000000001 0000 0000 0xc00902d4 kflushd
+0xc000e000 0000000003 0000000001 0000 0000 0xc000e2d4 kpiod
+0xc000c000 0000000004 0000000001 0000 0000 0xc000c2d4 kswapd
+0xc7de2000 0000000056 0000000001 0000 0000 0xc7de22d4 kerneld
+0xc7d3a000 0000000179 0000000001 0000 0000 0xc7d3a2d4 syslogd
+0xc7a7e000 0000000188 0000000001 0000 0000 0xc7a7e2d4 klogd
+0xc7a04000 0000000199 0000000001 0000 0000 0xc7a042d4 atd
+0xc7b84000 0000000210 0000000001 0000 0000 0xc7b842d4 crond
+0xc79d6000 0000000221 0000000001 0000 0000 0xc79d62d4 portmap
+0xc798e000 0000000232 0000000001 0000 0000 0xc798e2d4 snmpd
+0xc7904000 0000000244 0000000001 0000 0000 0xc79042d4 inetd
+0xc78fc000 0000000255 0000000001 0000 0000 0xc78fc2d4 lpd
+0xc77ec000 0000000270 0000000001 0000 0000 0xc77ec2d4 sendmail
+0xc77b8000 0000000282 0000000001 0000 0000 0xc77b82d4 gpm
+0xc7716000 0000000300 0000000001 0000 0000 0xc77162d4 smbd
+0xc7ee2000 0000000322 0000000001 0000 0000 0xc7ee22d4 mingetty
+0xc7d6e000 0000000323 0000000001 0000 0000 0xc7d6e2d4 login
+0xc778c000 0000000324 0000000001 0000 0000 0xc778c2d4 mingetty
+0xc78b6000 0000000325 0000000001 0000 0000 0xc78b62d4 mingetty
+0xc77e8000 0000000326 0000000001 0000 0000 0xc77e82d4 mingetty
+0xc7708000 0000000327 0000000001 0000 0000 0xc77082d4 mingetty
+0xc770e000 0000000328 0000000001 0000 0000 0xc770e2d4 mingetty
+0xc76b0000 0000000330 0000000001 0000 0000 0xc76b02d4 update
+0xc7592000 0000000331 0000000323 0000 0000 0xc75922d4 ksh
+0xc7546000 0000000338 0000000331 0000 0000 0xc75462d4 su
+0xc74dc000 0000000339 0000000338 0000 0000 0xc74dc2d4 ksh
+kdb> md 0xc74dc2d4
+c74dc2d4: 00000000 c74de000 00000018 00000000 .....`MG........
+c74dc2e4: 00000000 00000000 00000000 074de000 .............`M.
+c74dc2f4: c01123ff 00000000 00000000 00000000 #.@............
+c74dc304: 00000000 00000000 c74dded0 00000000 ........P^MG....
+[omitted]
+c74dc474: 00000000 00000000 00000000 00000000 ................
+c74dc484: 00000000 c7c15d00 c77b0900 c026fbe0 .....]AG..{G`{&@
+c74dc494: 00000000 c76c2000 00000000 00000000 ..... lG........
+c74dc4a4: 00000000 00000000 00000000 c74dc4ac ............,DMG
+kdb> md 0xc026fbe0
+c026fbe0: c0262b60 00000000 c7594940 c74de000 @HYG....@IYG.`MG
+[omitted]
+kdb> md 0xc0262b60
+c0262b60: c0266660 08048000 0804c000 c7bec360 `f&@.....@..`C>G
+kdb> ll c0262b60 12 md
+c0262b60: c0266660 08048000 0804c000 c7bec360 `f&@.....@..`C>G
+c7bec360: c0266660 0804c000 0804d000 c7becb20 `f&@.@...P.. K>G
+c7becb20: c0266660 0804d000 08050000 c7bec3a0 `f&@.P...... C>G
+c7bec3a0: c0266660 40000000 40009000 c7bec420 `f&@...@...@ D>G
+c7bec420: c0266660 40009000 4000b000 c7bec4a0 `f&@...@.0.@ D>G
+c7bec4a0: c0266660 4000b000 40010000 c7bec8e0 `f&@.0.@...@`H>G
+c7bec8e0: c0266660 40010000 400a1000 c7becbe0 `f&@...@...@`K>G
+c7becbe0: c0266660 400a1000 400a8000 c7becc60 `f&@...@...@`L>G
+c7becc60: c0266660 400a8000 400b4000 c7952300 `f&@...@.@.@.#.G
+c7952300: c0266660 400b5000 400bc000 c79521c0 `f&@.P.@.@.@@!.G
+c79521c0: c0266660 400bc000 400bd000 c7bec6e0 `f&@.@.@.P.@`F>G
+c7bec6e0: c0266660 bffff000 c0000000 00000000 `f&@.p?...@....
+kdb>
+kdb> ll c0262b60 12 vm
+struct vm_area_struct at 0xc0262b60 for 56 bytes
+vm_start = 0x8048000 vm_end = 0x804c000
+page_prot = 0x25 avl_height = 2244 vm_offset = 0x0
+flags: READ EXEC MAYREAD MAYWRITE MAYEXEC DENYWRITE EXECUTABLE
+struct vm_area_struct at 0xc7bec360 for 56 bytes
+vm_start = 0x804c000 vm_end = 0x804d000
+page_prot = 0x25 avl_height = -31808 vm_offset = 0x3000
+flags: READ WRITE MAYREAD MAYWRITE MAYEXEC DENYWRITE EXECUTABLE
+struct vm_area_struct at 0xc7becb20 for 56 bytes
+vm_start = 0x804d000 vm_end = 0x8050000
+page_prot = 0x25 avl_height = -28664 vm_offset = 0x0
+flags: READ WRITE EXEC MAYREAD MAYWRITE MAYEXEC
+struct vm_area_struct at 0xc7bec3a0 for 56 bytes
+vm_start = 0x40000000 vm_end = 0x40009000
+page_prot = 0x25 avl_height = 30126 vm_offset = 0x0
+flags: READ EXEC MAYREAD MAYWRITE MAYEXEC DENYWRITE
+struct vm_area_struct at 0xc7bec420 for 56 bytes
+vm_start = 0x40009000 vm_end = 0x4000b000
+page_prot = 0x25 avl_height = 30126 vm_offset = 0x8000
+flags: READ WRITE MAYREAD MAYWRITE MAYEXEC DENYWRITE
+struct vm_area_struct at 0xc7bec4a0 for 56 bytes
+vm_start = 0x4000b000 vm_end = 0x40010000
+page_prot = 0x25 avl_height = 26853 vm_offset = 0x0
+flags: READ MAYREAD MAYWRITE MAYEXEC
+struct vm_area_struct at 0xc7bec8e0 for 56 bytes
+vm_start = 0x40010000 vm_end = 0x400a1000
+page_prot = 0x25 avl_height = 2244 vm_offset = 0x0
+flags: READ EXEC MAYREAD MAYWRITE MAYEXEC
+struct vm_area_struct at 0xc7becbe0 for 56 bytes
+vm_start = 0x400a1000 vm_end = 0x400a8000
+page_prot = 0x25 avl_height = 30126 vm_offset = 0x90000
+flags: READ WRITE MAYREAD MAYWRITE MAYEXEC
+struct vm_area_struct at 0xc7becc60 for 56 bytes
+vm_start = 0x400a8000 vm_end = 0x400b4000
+page_prot = 0x25 avl_height = 2244 vm_offset = 0x0
+flags: READ WRITE MAYREAD MAYWRITE MAYEXEC
+struct vm_area_struct at 0xc7952300 for 56 bytes
+vm_start = 0x400b5000 vm_end = 0x400bc000
+page_prot = 0x25 avl_height = 30126 vm_offset = 0x0
+flags: READ EXEC MAYREAD MAYWRITE MAYEXEC
+struct vm_area_struct at 0xc79521c0 for 56 bytes
+vm_start = 0x400bc000 vm_end = 0x400bd000
+page_prot = 0x25 avl_height = -16344 vm_offset = 0x6000
+flags: READ WRITE MAYREAD MAYWRITE MAYEXEC
+struct vm_area_struct at 0xc7bec6e0 for 56 bytes
+vm_start = 0xbffff000 vm_end = 0xc0000000
+page_prot = 0x25 avl_height = 2244 vm_offset = 0x0
+flags: READ WRITE EXEC MAYREAD MAYWRITE MAYEXEC GROWSDOWN
+kdb>
Index: linux/Documentation/kdb/kdb_md.man
===================================================================
--- /dev/null
+++ linux/Documentation/kdb/kdb_md.man
@@ -0,0 +1,136 @@
+.TH MD 1 "August 4, 2004"
+.SH NAME
+md, mdWcN, mdr, mds, mm, mmW\- Memory manipulation commands
+.SH SYNOPSIS
+md [ \fIaddress-expression\fP [ \fIline-count\fP [\fIoutput-radix\fP ] ] ]
+.LP
+md\fIW\fRc\fIn\fR [ \fIaddress-expression\fP [ \fIline-count\fP [\fIoutput-radix\fP ] ] ]
+.LP
+mdp \fIphysical-address-expression\fP,\fIbytes\fP
+.LP
+mdr \fIaddress-expression\fP,\fIbytes\fP
+.LP
+mds [ \fIaddress-expression\fP [ \fIline-count\fP [\fIoutput-radix\fP ] ] ]
+.LP
+mm \fIaddress-expression\fP \fInew-contents\fP
+.LP
+mm\fIW\fR \fIaddress-expression\fP \fInew-contents\fP
+.SH DESCRIPTION
+The
+.B md
+command is used to display the contents of memory.
+The \fIaddress-expression\fP may be a numeric value (decimal or
+hexidecimal), a symbol name, a register name preceeded by one or more
+percent symbols '%', an environment variable name preceeded by
+a currency symbol '$', or a simple expression consisting of a
+symbol name, an addition or subtraction character and a numeric
+value (decimal or hexidecimal).
+.P
+If an address is specified and the \fIline-count\fP or \fIradix\fP arguments
+are omitted, they default to the values of the \fBMDCOUNT\fP and \fBRADIX\fP
+environment variables respectively. If the \fBMDCOUNT\fP or \fBRADIX\fP
+environment variables are unset, the appropriate defaults will be used [see
+\fBENVIRONMENT\fP below]. If no address is specified then md resumes
+after the last address printed, using the previous values of count and
+radix. The start address is rounded down to a multiple of the
+BYTESPERWORD (md) or width (md\fIW\fR).
+.P
+md uses the current value of environment variable \fBBYTESPERWORD\fP to
+read the data. When reading hardware registers that require special
+widths, it is more convenient to use md\fIW\fRc\fIn\fR where \fIW\fR is
+the width for this command and \fRc\fIn\fR is the number of entries to
+read. For example, md1c20 reads 20 bytes, 1 at a time. To continue
+printing just type md, the width and count apply to following md
+commands with no parameters. \fBNote:\fR The count is the number of
+repeats of the width, unlike MDCOUNT which gives the number of md lines
+to print.
+.P
+The
+.B mdp
+command displays the contents of physical memory, starting at the
+specified physical address for the specified number of bytes.
+The address is preceded by 'phys'.
+.P
+The
+.B mdr
+command displays the raw contents of memory, starting at the specified
+address for the specified number of bytes.
+The data is printed in one line without a leading address and no
+trailing character conversion.
+.B mdr
+is intended for interfacing with external debuggers, it is of little
+use to humans.
+.P
+The
+.B mds
+command displays the contents of memory one word per line and
+attempts to correlate the contents of each word with a symbol
+in the symbol table. If no symbol is found, the ascii representation
+of the word is printed, otherwise the symbol name and offset from
+symbol value are printed.
+By default the section data is printed for kernel symbols.
+.P
+The
+.B mm
+and
+\fBmm\fIW\fR
+commands allow modification of memory. The bytes at the address
+represented by \fIaddress-expression\fP are changed to
+\fInew-contents\fP. \fInew-contents\fP is allowed to be an
+\fIaddress-expression\fP.
+.B mm
+changes a machine word, \fBmm\fIW\fR changes \fIW\fR bytes at that
+address.
+.SH LIMITATIONS
+None.
+.SH ENVIRONMENT
+.TP 8
+MDCOUNT
+This environment variable (default=8) defines the number of lines
+that will be displayed by each invocation of the \fBmd\fP command.
+
+.TP 8
+RADIX
+This environment variable (default=16) defines the radix used to
+print the memory contents.
+
+.TP 8
+BYTESPERWORD
+This environment variable (default=4) selects the width of output
+data when printing memory contents. Select the value two to get
+16-bit word output, select the value one to get byte output.
+
+.TP 8
+LINES
+This environment variable governs the number of lines of output
+that will be presented before the kernel debugger built-in pager
+pauses the output. This variable only affects the functioning
+of the \fBmd\fP and \fBmds\fP if the \fBMDCOUNT\fP variable
+is set to a value greater than the \fBLINES\fP variable.
+
+.TP 8
+NOSECT
+If the \fBNOSECT\fP environment variable is non-zero then the
+section information is suppressed.
+The default is NOSECT=1 so section data is suppressed; use set\ NOSECT=0
+to see section information.
+.SH SMP CONSIDERATIONS
+None.
+.SH EXAMPLES
+.TP 8
+md %edx
+Display memory starting at the address contained in register \fB%edx\fP.
+
+.TP 8
+mds %esp
+Display stack contents symbolically. This command is quite useful
+in manual stack traceback.
+
+.TP 8
+mm 0xc0252110 0x25
+Change the memory location at 0xc0252110 to the value 0x25.
+
+.TP 8
+md chrdev_table 15
+Display 15 lines (at 16 bytes per line) starting at address
+represented by the symbol \fIchrdev_table\fP.
Index: linux/Documentation/kdb/kdb_ps.man
===================================================================
--- /dev/null
+++ linux/Documentation/kdb/kdb_ps.man
@@ -0,0 +1,96 @@
+.TH PS 1 "September 14, 2004"
+.SH NAME
+ps \- Display processes
+.SH SYNOPSIS
+ps [ DRSTCZEUIMA ]
+.SH DESCRIPTION
+The
+.B ps
+command displays the status of all processes in the desired state.
+This command does not take any locks (all cpus should be frozen while
+kdb is running) so it can safely be used to debug lock problems with
+the process table.
+.P
+Without any parameters, \fBps\fP displays all the interesting
+processes, excluding idle tasks and sleeping system daemons.
+If a parameter is specified, it is a single string consisting of the
+letters D, R, S, T, C, Z, E, U, I and M, in any order.
+Each letter selects processes in a specific state, when multiple
+letters are specified, a process will be displayed if it is in any of
+the specified states.
+The states are\ :-
+.P
+.DS
+.TS
+box, center;
+l | l
+l | l.
+D Uninterruptible sleep
+R Running
+S Interruptible sleep
+T Stopped
+C Traced
+Z Zombie
+E Dead
+U Unrunnable
+I Idle task
+M Sleeping system daemon
+A All
+.TE
+.DE
+.P
+For state R (running), the process may not be on a cpu at the moment,
+but it is ready to run.
+The header line above the backtrace contains '1' in the fourth field if
+the process is actually on a cpu.
+.P
+The idle task is run on each cpu when there is no work for that cpu to do.
+Unless the idle task is servicing an interrupt, there is no point in
+printing the idle task.
+An idle task that is not servicing a interrupt is marked as state I,
+while servicing an interrupt it is in state R.
+By default, idle tasks are not printed, use \fBps\ I\fR to print them.
+If the idle tasks are not being printed, the start of the \fBps\R
+output contains a list of which cpus are idle.
+.P
+Each cpu has one or more system daemons to handle per cpu work such as
+soft irqs.
+A system daemon (idenified by a NULL mm pointer) that is sleeping is
+marked as state M.
+These processes rarely have any useful data and generate a lot of
+output on large machines, so sleeping system daemons are not printed by
+default.
+Use \fBps\ M\fR to print them.
+.P
+At the start of the \fBps\fR output is a line giving the cpu status,
+see the kdb \fBcpu\fR command.
+.SH LIMITATIONS
+None.
+.SH ENVIRONMENT
+.TP 8
+PS
+This environment variable (default=DRSTCZEU) is used when \fBps\fR
+is issued with no parameters.
+
+.SH SMP CONSIDERATIONS
+None.
+.SH EXAMPLES
+.TP 8
+\fBps\fR
+displays the useful tasks, suppressing idle tasks and sleeping
+system daemons.
+
+.TP 8
+\fBps\ RD\fR
+displays only tasks that are running or are in an uninterruptible
+sleep.
+
+.TP 8
+\fBps\ DRSTCZEUIM\fR
+displays all tasks.
+
+.TP 8
+\fBps\ A\fR
+displays all tasks.
+This is easier than remembering DRSTCZEUIM.
+
Index: linux/Documentation/kdb/kdb_rd.man
===================================================================
--- /dev/null
+++ linux/Documentation/kdb/kdb_rd.man
@@ -0,0 +1,170 @@
+.TH RD 1 "September 20, 2005"
+.SH NAME
+rd, rm\- Register manipulation commands
+.SH SYNOPSIS
+rd [[c [n]]|d|u]
+.LP
+rm \fIregister-name\fP \fInew-contents\fP
+.LP
+ef <address>
+.SH DESCRIPTION
+The
+.B rd
+command is used to display the contents of processor and coprocessor registers.
+Without any arguments, the rd command displays the contents of the general
+register set at the point at which the kernel debugger was entered.
+If the bt* or pid commands have been used to change the current process then
+.B rd
+and
+.B rm
+may not be able to display any registers.
+'n' argument is only used for XScale platform to identify the desired
+coprocessor number, while 'd' option is not valid for XScale platform.
+.P
+On IA32 and IA64, with the 'c' argument, the processor control registers
+%cr0, %cr1, %cr2 and %cr4 are displayed, while with the 'd' argument
+the processor debug registers are displayed. If the 'u' argument
+is supplied, the registers for the current task as of the last
+time the current task entered the kernel are displayed.
+.P
+On XScale, 'c' argument is used to display the
+all coprocessor control registers or specified coprocessor registers by
+argumnet 'n'. Argument 'u' is used to display the
+registers for the current task as of the last time the current task
+entered the kernel. Argument 'd' is not supported.
+.P
+On ix86, the
+.B rm
+command allows modification of a register. The following
+register names are valid: \fB%eax\fP, \fB%ebx\fP, \fB%ecx\fP,
+\fB%edx\fP, \fB%esi\fP, \fB%edi\fP, \fB%esp\fP, \fB%eip\fP,
+and \fB%ebp\fP. Note that if two '%' symbols are used
+consecutively, the register set displayed by the 'u' argument
+to the \fBrd\fP command is modified.
+.P
+The debug registers, \fBdr0\fP through \fBdr3\fP and both
+\fBdr6\fP and \fBdr7\fP can also be modified with the \fBrm\fP
+command.
+.P
+On sparc64, the valid registers are named \fB%g0\fP through
+\fB%g7\fP, \fB%l0\fP through \fB%l7\fP, \fB%o0\fP through
+\fB%o7\fP, and \fB%i0\fP through \fB%i7\fP, with the exceptions
+that \fB%o6\fP is called \fB%sp\fP and that \fB%i6\fP is called
+\fB%fp\fP. The registers \fB%tstate\fP, \fB%tpc\fP, \fB%tnpc\fP,
+\fB%y\fP, and \fB%fprs\fP provide state information at the time
+the system entered kdb. Additionally, when viewing registers, two
+convenience names are provided: \fB%®s\fP shows the
+address on the stack of the current registers, and \fB%csp\fP
+shows the current stack pointer within kdb itself.
+.P
+While on XScale, both the cpu registers and most coprocessor
+registers can be be modified. \fIregister-name\fP can be followings like
+r0, r1, r2, r3, r4, r5, r6, r7, r8, r9, r10, r11, r12, r13, r14,
+r15, cpsr to address cpu registers. For the coprocessor registers in XSacle,
+either alias name or \fICpcc[CRndd[CRmbb[Opaa]]]\fP can be used to address
+the register in coprocessor cc with CRn=dd, CRm=bb and opcode2=aa. All aa, bb, cc, dd can be
+1 or 2 decimal digitals, the default value is 0 when any of them is omitted. Name
+acc0_h and acc0_l are used to identify the high byte and
+low word of accumulator in coprocessor 0.
+.P
+On IA64, the parameter to
+.B rd
+can be d (debug registers), u (user registers at most recent entry to kernel),
+i (interrupt registers), %isr (current interrupt status), s (stacked
+registers), k (kernel registers). You can also specify these individual
+registers -
+psr,
+ifs,
+ip,
+unat,
+pfs,
+rsc,
+rnat,
+bsps,
+pr,
+ldrs,
+ccv,
+fpsr,
+b0,
+b6,
+b7,
+r1,
+r2,
+r3,
+r8,
+r9,
+r10,
+r11,
+r12,
+r13,
+r14,
+r15,
+r16,
+r17,
+r18,
+r19,
+r20,
+r21,
+r22,
+r23,
+r24,
+r25,
+r26,
+r27,
+r28,
+r29,
+r30,
+r31.
+.B rm
+can change any of the individual registers or the stacked registers.
+.P
+The
+.B ef
+command displays an exception frame at the specified address.
+.SH LIMITATIONS
+Currently the \fBrm\fP command will not allow modification of the
+control registers.
+.P
+Currently neither the \fBrd\fP command nor the \fBrm\fP command will
+display or modify the model specific registers on the Pentium
+and Pentium Pro families.
+.SH ENVIRONMENT
+None.
+.SH SMP CONSIDERATIONS
+None.
+.SH EXAMPLES
+.TP 8
+rd
+Display general register set from kdb's current task.
+
+.TP 8
+rd c 0
+Display coprocessor 0 registers.
+
+.TP 8
+rm %eax 0
+Set the contents of \fB%eax\fP to zero. This will be the
+value of %eax when kdb returns from the condition which
+invoked it.
+
+.TP 8
+rm %%eax 0
+Set the value of the \fB%eax\fP register to zero. This will
+be the value the user-mode application will see upon returning
+from the kernel.
+
+.TP 8
+rm %acc0_h 0
+Set the contents of high byte of accumulator to zero.
+
+.TP 8
+rm dr0 0xc1287220
+Set the value of the \fBdr0\fB register to \f(CW0xc1287220\fP.
+
+.TP 8
+rm %InVLD_BTB 0
+Write 0 to coprocessor 15 register with CRn=7, CRm=5, opcode2=6.
+
+.TP 8
+rm %CP15CRn7CRm5Op6 0
+Same with above.
Index: linux/Documentation/kdb/kdb_sr.man
===================================================================
--- /dev/null
+++ linux/Documentation/kdb/kdb_sr.man
@@ -0,0 +1,68 @@
+.TH SR 1 "7 October 2002"
+.SH NAME
+sr \- invoke sysrq commands from kdb
+.SH SYNOPSIS
+sr \fIx\fP
+.SH DESCRIPTION
+.hy 0
+The
+.B sr
+command invokes the existing sysrq handler code in the kernel.
+This command takes a single character which is passed to sysrq
+processing, as if you had entered the sysrq key sequence followed by
+that character.
+.P
+.B Caveats:
+.P
+kdb will always call the sysrq code but sysrq may be disabled.
+If you expect to use sysrq functions during debugging then
+.IP ""
+echo "1" > /proc/sys/kernel/sysrq
+.P
+before starting the debug session.
+Alternatively issue
+.IP ""
+mm4 sysrq_enabled 1
+.P
+during debugging.
+.P
+The sysrq code prints a heading using console loglevel 7 then reverts
+to the original loglevel for the rest of the sysrq processing.
+If the rest of the sysrq output is printed at a level below your
+current loglevel then you will not see the output on the kdb console,
+the output will only appear in the printk buffer.
+It is the user's responsibility to set the loglevel correctly if they
+want to see the sysrq output on the console.
+Issue
+.IP ""
+sr 7
+.P
+before any other
+.B sr
+commands if you want to see the output on the console.
+You may even have to adjust the default message loglevel in order to
+see any output from
+.BR sr .
+See Documentation/sysctl/kernel.txt for details on setting console
+loglevels via /proc.
+You can also adjust the loglevel variables via kdb
+.BR mm ;
+on older kernels there are variables such as default_message_level, on
+newer kernels all the loglevel variables are in array console_printk,
+see kernel/printk.c for your kernel.
+.P
+Operations that require interrupt driven I/O can be invoked from kdb
+.BR sr ,
+but they will not do anything until you type 'go' to exit from kdb
+(interrupts are disabled while in kdb).
+There is no guarantee that these operations will work, if the machine
+entered kdb because of an error then interrupt driven I/O may already
+be dead.
+Do not assume that
+.B sr\ s
+does anything useful.
+.P
+The sysrq handler uses locks and calls printk which also uses locks.
+If the sysrq handler or any of the sysrq functions have to wait for a
+lock then they will never return and kdb will appear to hang.
+Invoking sysrq code from kdb is inherently unsafe.
Index: linux/Documentation/kdb/kdb_ss.man
===================================================================
--- /dev/null
+++ linux/Documentation/kdb/kdb_ss.man
@@ -0,0 +1,109 @@
+.TH SS 1 "17 January 2002"
+.SH NAME
+ss, ssb \- Single Step
+.SH SYNOPSIS
+ss
+.LP
+ssb
+.SH DESCRIPTION
+The
+.B ss
+command is used to execute a single instruction and return
+to the kernel debugger.
+.P
+Both the instruction that was single-stepped and the next
+instruction to execute are printed.
+.P
+The \fBssb\fP command will execute instructions from the
+current value of the instruction pointer. Each instruction
+may be printed as it is executed, depending upon architecture;
+execution will stop at any instruction which would cause the flow
+of control to change (e.g. branch, call, interrupt instruction,
+return, etc.)
+.SH LIMITATIONS
+On sparc64, there are some circumstances where single-stepping
+can be dangerous. Do not single-step across an instruction which
+changes the interrupt-enable bit in %tstate. Do not single step
+through code which is invoked when entering or leaving the
+kernel, particularly any kernel entry code before %tl is set to
+0, or any kernel exit code after %tl is set to 1.
+.SH ENVIRONMENT
+None.
+.SH SMP CONSIDERATIONS
+Other processors are held in the kernel debugger when the instruction
+is traced. Single stepping though code that requires a lock which is
+in use by another processor is an exercise in futility, it will never
+succeed.
+.SH INTERRUPT CONSIDERATIONS
+When a kdb event occurs, one cpu (the initial cpu) enters kdb state.
+It uses a cross system interrupt to interrupt the
+other cpus and bring them all into kdb state. All cpus run with
+interrupts disabled while they are inside kdb, this prevents most
+external events from disturbing the kernel while kdb is running.
+.B Note:
+Disabled interrupts means that any I/O that relies on interrupts cannot
+proceed while kdb is in control, devices can time out. The clock tick
+is also disabled, machines will lose track of time while they are
+inside kdb.
+.P
+Even with interrupts disabled, some non-maskable interrupt events
+will still occur, these can disturb the kernel while you are
+debugging it. The initial cpu will still accept NMI events,
+assuming that kdb was not entered for an NMI event. Any cpu
+where you use the SS or SSB commands will accept NMI events, even
+after the instruction has finished and the cpu is back in kdb.
+This is an unavoidable side effect of the fact that doing SS[B]
+requires the cpu to drop all the way out of kdb, including
+exiting from the NMI event that brought the cpu into kdb. Under
+normal circumstances the only NMI event is for the NMI oopser and
+that is kdb aware so it does not disturb the kernel while kdb is
+running.
+.P
+Sometimes doing SS or SSB on ix86 will allow one interrupt to proceed,
+even though the cpu is disabled for interrupts. I have not been able
+to track this one down but I suspect that the interrupt was pending
+when kdb was entered and it runs when kdb exits through IRET even
+though the popped flags are marked as cli(). If any ix86 hardware
+expert can shed some light on this problem, please notify the kdb
+maintainer.
+.SH EXAMPLES
+.nf
+.na
+.ft CW
+kdb> bp gendisk_head datar 4
+Data Access Breakpoint #0 at 0xc024ddf4 (gendisk_head) in dr0 is enabled on cpu 0
+for 4 bytes
+kdb> go
+...
+[root@host /root]# cat /proc/partitions
+Entering kdb on processor 0 due to Debug Exception @ 0xc01845e3
+Read/Write breakpoint #0 at 0xc024ddf4
+[0]kdb> ssb
+sd_finish+0x7b: movzbl 0xc02565d4,%edx
+sd_finish+0x82: leal 0xf(%edx),%eax
+sd_finish+0x85: sarl $0x4,%eax
+sd_finish+0x88: movl 0xc0256654,%ecx
+sd_finish+0x8e: leal (%eax,%eax,4),%edx
+sd_finish+0x91: leal (%eax,%edx,2),%edx
+sd_finish+0x94: movl 0xc0251108,%eax
+sd_finish+0x99: movl %eax,0xffffffc(%ecx,%edx,4)
+sd_finish+0x9d: movl %ecx,0xc0251108
+sd_finish+0xa3: xorl %ebx,%ebx
+sd_finish+0xa5: cmpb $0x0,0xc02565d4
+[0]kdb> go
+[root@host /root]#
+
+[0]kdb> ss
+sys_read: pushl %ebp
+SS trap at 0xc01274c1
+sys_read+0x1: movl %esp,%ebp
+[0]kdb> ss
+sys_read+0x1: movl %esp,%ebp
+SS trap at 0xc01274c3
+sys_read+0x3: subl $0xc,%esp
+[0]kdb> ss
+sys_read+0x3: subl $0xc,%esp
+SS trap at 0xc01274c6
+sys_read+0x6: pushl %edi
+[0]kdb>
+
Index: linux/Documentation/kdb/slides
===================================================================
--- /dev/null
+++ linux/Documentation/kdb/slides
@@ -0,0 +1,1382 @@
+#! /opt/cpg/bin/do-mgp
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%%
+%deffont "standard" tfont "comic.ttf"
+%deffont "thick" tfont "arialb.ttf"
+%deffont "typewriter" xfont "courier new-bold-r"
+%deffont "type2writer" xfont "arial narrow-bold-r"
+%%
+%% Default settings per each line numbers.
+%%
+#%default 1 leftfill, size 2, fore "black", back "LemonChiffon2", font "thick"
+%default 1 leftfill, size 2, fore "black", back "white", font "thick"
+%default 2 size 10, vgap 10, prefix " ", center
+%default 3 size 2, bar "gray70", vgap 10
+%default 4 size 6, fore "black", vgap 30, prefix " ", font "standard", left
+%%
+%% Default settings that are applied to TAB-indented lines.
+%%
+%tab 1 size 4, vgap 35, prefix " ", icon arc "red" 40
+%tab 2 size 4, vgap 20, prefix " ", icon delta3 "blue" 40
+%tab 3 size 4, vgap 20, prefix " ", icon delta3 "green" 40
+%%
+%%
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%page
+
+KDB - Kernel Debugger
+
+
+
+%size 7,center, font "thick"
+Introduction
+
+And
+
+Demonstration
+
+
+%size 3
+
+February 5, 2002 IBM Linux Technology Center Paul Dorwin
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%page
+
+IBM Legal
+
+
+ IBM Legal requires this information:
+
+%size 3
+
+ THE INFORMATION IN THE FOLLOWING PRESENTATION IS PREPARED
+ SOLELY FOR THE INFORMATION OF THE READER, AND COMES "AS IS"
+ AND WITHOUT WARRANTY OR REPRESENATION OF ANY KIND.
+
+ ANY PARTY USING THE MATERIALS IN THIS PRESENTATION DOES SO
+ AT ITS OWN RISK LIABILITY AND THE PROVIDER OF THE MATERIALS
+ ACCEPTS NO RISK OR LIABILITY FOR SUCH USE OR RESULTING FROM
+ DISSEMINATION TO OR USE BY ANY OTHER PARTY
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%page
+
+Agenda
+
+%size 5
+
+ Installing and Configuring KDB
+
+ KDB Commands
+
+ Scull Demo
+
+ Setting Breakpoints
+
+ Displaying Data Structures
+
+ Kernel Data structures
+
+ Take a walk through an IO operation
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%page
+
+Installing Configuring KDB
+
+
+ Install KDB patch.
+ Start with a clean source tree
+ Apply architecture specific patches
+ Obtain patch for your kernel version
+ see http://oss.sgi.com/projects/kdb/
+ Apply the kdb patch
+ patch -p 1 -N -u -i /path/to/patch
+ Apply any other patches
+ Build and reboot on your kdb enabled kernel
+ Man pages can be found at Documentation/kdb
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%page
+
+Configuring KDB
+
+
+ Config kernel with the following options:
+ These are documented in Documentation/Configure.help
+
+ CONFIG_KDB=y
+ Enable compilation of KDB in the kernel..
+ Setting this also sets CONFIG_KALLSYMS=y.
+ CONFIG_KDB_MODULES=n
+ KDB may be extended, compiling kdb/modules.
+ CONFIG_KDB_OFF=n
+ y = KDB is disabled by default.
+ boot with kdb=on to enable at boot.
+ /proc/sys/kernel/kdb to enable/disable when system is up.
+ CONFIG_KALLSYMS=y
+ This causes all symbols to be exported.
+ CONFIG_FRAME_POINTER=y
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%page
+
+Invoking KDB
+
+
+ KDB can be invoked in the following ways:
+
+ Early init with "kdb=early" lilo flag
+ Hits breakpoint prior to fork_init() (init/main.c)
+
+ Serial console with CNTRL-A
+
+ Console with PAUSE key
+
+ When a pre-set breakpoint is hit
+
+ On panic
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%page
+
+KDB Commands
+
+
+ KDB environment
+ env Show environment variables
+ set Set environment variables
+ help Display Help Message
+ ? Display Help Message
+
+ System related
+ sections List kernel and module sections
+ lsmod List loaded kernel modules
+ reboot Reboot the machine immediately
+ cpu <cpunum> Switch to new cpu
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%page
+
+KDB Commands
+
+
+ Memory Manipulation
+ md <vaddr> Display Memory Contents
+ mdr <vaddr> <bytes> Display Raw Memory
+ mds <vaddr> Display Symbolically
+ mm <vaddr> <value> Modify Memory Contents
+ id <vaddr> Display Instructions
+
+ Register Manipulation
+ rd Display Registers
+ rm <reg> <value> Modify Registers
+ ef <vaddr> Display exception frame
+
+ Stack
+ bt [<vaddr>] Stack traceback
+ btp <pid> Display stack for <pid>
+ bta Display all stacks
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%page
+
+KDB Commands
+
+
+ Breakpoint
+ bc <bpnum> Clear Breakpoint
+ bd <bpnum> Disable Breakpoint
+ be <bpnum> Enable Breakpoint
+ bl [<vaddr>] Display breakpoints
+ bp [<vaddr>] Set/Display breakpoints
+ bpa [<vaddr>] Set/Display global breakpoints
+ bph [<vaddr>] Set hardware breakpoint
+ bpha [<vaddr>] Set global hardware breakpoint
+ bp* modifiers:
+ instruction - break on instruction fetch (default)
+ datar - break on read at vaddr
+ dataw - break on write at vaddr
+ IO - break on in or out op at vaddress
+
+ Execution control
+ go [<vaddr>] Continue Execution
+ ss [<#steps>] Single Step
+ ssb Single step to branch/call
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%page
+
+KDB Commands
+
+
+ Kernel structures
+ ll <vaddr> <offset> <command> Traverse list and execute command
+ ps Display active task list
+ vm <vaddr> Display vm_area_struct
+ dentry <dentry> Display interesting dentry stuff
+ filp <filp> Display interesting filp stuff
+ sh <vaddr> Show scsi_host
+ sd <vaddr> Show scsi_device
+ sc <vaddr> Show scsi_cmnd
+ kiobuf <vaddr> Display kiobuf
+ page <vaddr> Display page
+ inode <vaddr> Display inode
+ bh <vaddr> Display buffer head
+ inode_pages <inode *> Display pages in an inode
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%page
+
+Scull Demo
+
+
+ Objective
+ Find and display the data associated with a scull device
+
+ The sequence of events
+ Populate the scull device with data
+ Identify the breakpoints
+ Set breakpoint in the device read function
+ Identify the data structure elements
+ Identify device structures used to track data
+ Display data structures containing the data
+ Show the usage of the filp command
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%page
+
+Scull Demo: Populate Device
+
+
+ Obtain the code
+ Surf to http://examples.oreilly.com/linuxdrive2/
+ Download the tarball
+ Untar it to /usr/src
+
+ Build and install the module
+ cd /usr/src/ldd2-samples-1.0.1/scull
+ make
+ ./scull.init start
+
+ Populate the scull device
+ cat main.c > /dev/scull0
+ cat /dev/scull0
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%page
+
+Scull Demo: Driver Details
+
+
+ cat /dev/scull0
+ fd =
+%fore "blue", cont
+open
+%fore "black", cont
+("/dev/scull0", O_RDONLY);
+ Kernel finds the file_operations structure
+ Kernel then invokes the open function
+%fore "blue"
+ read
+%fore "black", cont
+(fd, buf, size);
+ Kernel finds the file_operations structure
+ Kernel then invokes the read function
+
+ Scull device file operations structure
+
+%font "typewriter", size 3
+ struct file_operations scull_fops = {
+ llseek: scull_llseek,
+%fore "blue"
+ read: scull_read,
+%fore "black"
+ write: scull_write,
+ ioctl: scull_ioctl,
+%fore "blue"
+ open: scull_open,
+%fore "black"
+ release: scull_release,
+ };
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%page
+
+Scull Demo: Driver Details
+
+%font "typewriter", size 3
+ scull_open code
+%font "typewriter", size 3
+ int
+%fore "blue", cont
+scull_open
+%fore "black", cont
+(struct inode *inode, struct file *filp)
+ {
+ Scull_Dev *dev; /* device information */
+ int num = NUM(inode->i_rdev);
+
+ <snip>
+
+ dev = (Scull_Dev *)filp->private_data;
+ if (!dev) {
+ if (num >= scull_nr_devs) return -ENODEV;
+%fore "blue"
+ dev = &scull_devices[num];
+ filp->private_data = dev;
+%fore "black"
+ }
+
+ <snip>
+
+ }
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%page
+
+Scull Demo: Driver Details
+
+%font "typewriter", size 3
+ scull_read code
+%font "typewriter", size 3
+ ssize_t
+%fore "blue", cont
+scull_read
+%fore "black", cont
+(struct file *filp, char *buf, size_t count,
+ loff_t *f_pos)
+ {
+
+%fore "blue", cont
+ Scull_Dev *dev = filp->private_data;
+%fore "black", cont
+ /* the first listitem */
+%fore "blue"
+ Scull_Dev *dptr;
+%fore "black"
+ int quantum = dev->quantum;
+ int qset = dev->qset;
+ int itemsize = quantum * qset;
+ if (down_interruptible(&dev->sem))
+ return -ERESTARTSYS;
+ if (*f_pos + count > dev->size)
+ count = dev->size - *f_pos;
+
+ /* find listitem, qset index, and offset in the quantum */
+ item = (long)*f_pos / itemsize;
+ rest = (long)*f_pos % itemsize;
+ s_pos = rest / quantum; q_pos = rest % quantum;
+
+ /* follow the list up to the right position */
+%fore "blue"
+ dptr = scull_follow(dev, item);
+%fore "black"
+
+ <snip>
+
+ }
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%page
+
+Scull Demo: Breakpoints
+
+
+%font "typewriter", size 3
+ Determine where to set breakpoint
+%font "typewriter", size 3
+%fore "blue"
+ dptr = scull_follow(dev, item);
+%fore "black"
+
+%font "typewriter", size 3
+ Disassemble scull_read
+%font "typewriter", size 3
+ [0]kdb>
+%fore "blue", cont
+id scull_read
+%fore "black"
+ 0xf8c083b4 scull_read: push %ebp
+ 0xf8c083b5 scull_read+0x1:mov %esp,%ebp
+ 0xf8c083b7 scull_read+0x3:push %edi
+ <snip>
+ 0xf8c08465 scull_read+0xb1:sub $0x8,%esp
+%fore "blue"
+ 0xf8c08468 scull_read+0xb4:push %ecx
+ 0xf8c08469 scull_read+0xb5:push %esi
+ 0xf8c0846a scull_read+0xb6:call 0xf8c08364 scull_follow:
+%fore "black"
+ 0xf8c0846f scull_read+0xbb:mov %eax,
+%fore "blue", cont
+ %edx
+%fore "black"
+ 0xf8c08471
+%fore "blue", cont
+scull_read+0xbd
+%fore "black", cont
+:add $0x10,%esp
+ <snip>
+
+ Set breakpoint in driver read
+%font "typewriter", size 3
+ [0]kdb>
+%fore "blue",cont
+bp scull_read+0xbd
+%fore "black"
+ Instruction(i) BP #0 at 0xf8c08471 ([scull]scull_read+0xbd)
+ is enabled globally adjust 1
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%page
+
+Scull Demo: Breakpoints
+
+
+%font "typewriter", size 3
+ Restart the system
+%font "typewriter", size 3
+ [0]kdb>
+%fore "blue", cont
+go
+%fore "black"
+
+ Hit the Breakpoint
+%font "typewriter", size 3
+ [root@elm3b77 root]#
+%fore "blue", cont
+cat /dev/scull0
+%fore "black"
+ Instruction(i) breakpoint #0 at 0xf8c08471 (adjusted)
+ 0xf8c08471 scull_read+0xbd:int3
+ Entering kdb (current=0xf73ec000, pid 1249) on processor 2
+ due to Breakpoint @ 0xf8c08471
+
+ Display the registers
+%font "typewriter", size 3
+ [2]kdb>
+%fore "blue", cont
+rd
+%fore "black"
+ eax = 0xf77d7b60 ebx = 0x00000000 ecx = 0x00000000 edx =
+%fore "blue", cont
+0xf77d7b60
+%fore "black"
+ esi =
+%fore "blue", cont
+0xf77d7b60
+%fore "black", cont
+ edi = 0x00001000 esp = 0xf7415f40 eip = 0xf8c08471
+ ebp = 0xf7415f78 xss = 0x00000018 xcs = 0x00000010 eflags = 0x00000246
+ xds = 0xf7590018 xes = 0x00000018 origeax = 0xffffffff ®s = 0xf7415f0c
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%page
+
+Scull Demo: Data Structures
+
+%font "typewriter", size 3
+ Display the Scull_Dev structure
+%font "typewriter", size 3
+ [2]kdb>
+%fore "blue", cont
+md 0xf77d7b60 2
+%fore "black"
+ 0xf77d7b60
+%fore "blue", cont
+f7400000
+%fore "black", cont
+ 00000000 00000fa0 000003e8 ..@w.... ...h...
+ 0xf77d7b70 0000534e 00000000 00000000 00000000 NS..............
+
+ Scull Device Structure
+%font "typewriter", size 3
+ typedef struct Scull_Dev {
+%fore "blue"
+ void **data;
+%fore "black"
+ struct Scull_Dev *next; /* next listitem */
+ int quantum; /* the current quantum size */
+ int qset; /* the current array size */
+ unsigned long size;
+ devfs_handle_t handle; /* only used if devfs is there */
+ unsigned int access_key; /* used by sculluid and scullpriv */
+ struct semaphore sem; /* mutual exclusion semaphore */
+ } Scull_Dev;
+%size 6
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%page
+
+Scull Demo: Data Structures
+
+
+%font "typewriter", size 3
+ Display the quantum set (dev->data)
+%font "typewriter", size 3
+ [2]kdb>
+%fore "blue", cont
+md f7400000 2
+%fore "black"
+ 0xf7400000
+%fore "blue", cont
+f73ea000
+%fore "black", cont
+ f73f1000 f740c000 f7ab4000 . >w..?w.@@w.@+w
+ 0xf7400010 f73ef000 f755b000 00000000 00000000 .p>w.0Uw........
+
+ Display the first quantum (dev->data[0])
+%font "typewriter", size 3
+ [2]kdb>
+%fore "blue", cont
+md f73ea000
+%fore "black"
+ 0xf73ea000 200a2a2f 616d202a 632e6e69 202d2d20 /*. * main.c --
+ 0xf73ea010 20656874 65726162 75637320 63206c6c the bare scull c
+ 0xf73ea020 20726168 75646f6d 200a656c 2a200a2a har module. *. *
+ 0xf73ea030 706f4320 67697279 28207468 32202943 Copyright (C) 2
+ 0xf73ea040 20313030 73656c41 646e6173 52206f72 001 Alessandro R
+ 0xf73ea050 6e696275 6e612069 6f4a2064 6874616e ubini and Jonath
+ 0xf73ea060 43206e61 6562726f 2a200a74 706f4320 an Corbet. * Cop
+ 0xf73ea070 67697279 28207468 32202943 20313030 yright (C) 2001
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%page
+
+Scull Demo: filp command
+
+
+%font "typewriter", size 3
+ Show filp usage - here is the scull_read prototype
+%font "typewriter", size 3
+ ssize_t scull_read(
+%fore "blue", cont
+struct file *filp
+%fore "black", cont
+, char *buf,
+ size_t count, loff_t *f_pos);
+ Show the stack trace:
+%font "typewriter", size 3
+[2]kdb>
+%fore "blue", cont
+bt
+%fore "black"
+ EBP EIP Function(args)
+ 0xee9dbf78 0xf8c08471 [scull]scull_read+0xbd (
+%fore "blue", cont
+0xeaf6c0c0
+%fore "black", cont
+, 0x804e128,
+ 0x1000, 0xeaf6c0e0, 0x804f000)
+ scull .text 0xf8c08060 0xf8c083b4 0xf8c084dc
+ 0xee9dbfbc 0xc0136278 sys_read+0x98 (0x3, 0x804e128, 0x1000, ...
+ kernel .text 0xc0100000 0xc01361e0 0xc01362b0
+ 0xc010702b system_call+0x33
+ kernel .text 0xc0100000 0xc0106ff8 0xc0107030
+ And show the filp output
+%font "typewriter", size 3
+ [2]kdb>
+%fore "blue", cont
+filp 0xeaf6c0c0
+%fore "black"
+ name.name 0xe93889fc name.len 6
+ File Pointer at 0xeaf6c0c0
+ f_list.nxt = 0xe42deca0 f_list.prv = 0xf7e69070
+%fore "blue"
+ f_dentry = 0xe93889a0
+%fore "black", cont
+ f_op = 0xf8c0a200
+ f_count = 2 f_flags = 0x8000 f_mode = 0x1
+ f_pos = 0 f_reada = 0 f_ramax = 0
+ f_raend = 0 f_ralen = 0 f_rawin = 0
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%page
+
+Scull Demo: filp command
+
+
+%font "typewriter", size 3
+ filp output - continued
+%font "typewriter", size 3
+%fore "blue"
+ Directory Entry at 0xe93889a0
+%fore "black"
+ d_name.len = 6
+%fore "orange", cont
+d_name.name = 0xe93889fc
+%fore "black", cont
+>
+ d_count = 1 d_flags = 0x0
+%fore "blue", cont
+d_inode = 0xe827b680
+%fore "black"
+ d_hash.nxt = 0xc215aec8 d_hash.prv = 0xc215aec8
+ d_lru.nxt = 0xe93889b8 d_lru.prv = 0xe93889b8
+ d_child.nxt = 0xe89e1e80 d_child.prv = 0xe9388940
+ d_subdirs.nxt = 0xe93889c8 d_subdirs.prv = 0xe93889c8
+ d_alias.nxt = 0xe827b690 d_alias.prv = 0xe827b690
+ d_op = 0x00000000 d_sb = 0xf7e69000
+
+%fore "blue"
+ Inode Entry at 0xe827b680
+%fore "black"
+ i_mode = 0x21a4 i_nlink = 1 i_rdev = 0xfe00
+ i_ino = 37182 i_count = 1 i_dev = 0x821
+ i_hash.nxt = 0xc20e6be8 i_hash.prv = 0xc20e6be8
+ i_list.nxt = 0xe827b2c8 i_list.prv = 0xe827b868
+ i_dentry.nxt = 0xe93889d0 i_dentry.prv = 0xe93889d0
+
+ Check the filename (display d_name.name)
+%font "typewriter", size 3
+ [2]kdb>
+%fore "orange", cont
+md 0xe93889fc 1
+%fore "black"
+ 0xe93889fc 6c756373 0000306c 00000000 00000000 scull0..........
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%page
+
+Kernel Structures
+
+
+ Objective
+ Show output from various kernel related kdb commands
+
+ Sequence of events
+ Simple Program
+ Write a simple program which allocates memory and hangs
+ Show usage of the ps, vm, and ll commands
+ Walk an IO operation
+ Hit a breakpoint in qlogic driver (isp1020_queuecommand)
+ Show usage of scsi related commands (sc, sh, and sd)
+ Show usage of vm related commands (bh, page, inode, inode_pages)
+
+
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%page
+
+Simple program
+
+%font "typewriter", size 3
+ simple.c - simple program which allocates memory
+%font "typewriter", size 3
+%fore "blue"
+ int foo_global[8192];
+%fore "black"
+ main()
+ {
+ int *
+%fore "blue", cont
+foo_malloc;
+%fore "black"
+ int i;
+ foo_malloc = (int *)malloc(0x8192);
+ for(i = 0; i < 0x100; i++) {
+ foo_global[i] = 0xdead0000 | i;
+ foo_malloc[i] = 0xbeef0000 | i;
+ }
+ printf("foo_global at %x\n", (int)foo_global);
+ printf("foo_malloc at %x\n", (int)foo_malloc);
+ printf("sleep forever\n");
+ sleep(2000000);
+ }
+
+ simple output
+%font "typewriter", size 3
+ [root@elm3b77 scull]# cc -o simple simple.c
+ [root@elm3b77 scull]# ./simple
+ foo_global at
+%fore "blue", cont
+8049780
+%fore "black"
+ foo_malloc at
+%fore "blue", cont
+8051788
+%fore "black"
+ sleep forever
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%page
+
+Simple Program
+
+%font "typewriter", size 3
+ Show the output of the ps command
+%font "typewriter", size 3
+ Entering kdb (current=0xc2010000, pid 0) on processor 3 due to
+ Keyboard Entry
+ [3]kdb>
+%fore "blue", cont
+ps
+%fore "black"
+ Task Addr Pid Parent [*] cpu State Thread Command
+ 0xf7efe000 00000001 00000000 0 003 stop 0xf7efe370 init
+ 0xf7ef0000 00000002 00000001 0 001 stop 0xf7ef0370 keventd
+ 0xf7eec000 00000003 00000000 0 000 stop 0xf7eec370 ksoftirqd_CPU0
+ 0xf7eea000 00000004 00000000 0 001 stop 0xf7eea370 ksoftirqd_CPU1
+ 0xf7ee8000 00000005 00000000 0 002 stop 0xf7ee8370 ksoftirqd_CPU2
+ 0xf7ee6000 00000006 00000000 0 003 stop 0xf7ee6370 ksoftirqd_CPU3
+
+ <snip>
+
+ 0xf7b46000 00001006 00000737 0 003 stop 0xf7b46370 sshd
+ 0xf7ace000 00001007 00001006 0 000 stop 0xf7ace370 bash
+ 0xef06a000 00001066 00001007 0 003 stop 0xef06a370 su
+ 0xeef88000 00001067 00001066 0 000 stop 0xeef88370 bash
+ 0xeef64000 00001119 00000770 0 001 stop 0xeef64370 in.ftpd
+%fore "blue"
+ 0xeeeac000
+%fore "black", cont
+ 00001138 00001067 0 001 stop 0xeeeac370
+%fore "blue", cont
+simple
+%fore "black"
+ [3]kdb>
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%page
+
+Simple Program
+
+%font "typewriter", size 3
+ Display the task struct
+%font "typewriter", size 3
+ [3]kdb>
+%fore "blue", cont
+md 0xeeeac000
+%fore "black"
+ 0xeeeac000 00000001 00000000 00000000 c0000000 ................
+ 0xeeeac010 c0339880 00000000 00000000 ffffffff ................
+ 0xeeeac020 0000000a 00000000 00000000
+%fore "blue", cont
+f7e10f00
+%fore "black", cont
+ ..............aw
+ 0xeeeac030 00000001 ffffffff ffffffff 00000000 ................
+
+%font "typewriter", size 3
+ Determine offset of mm_struct ptr in task_struct
+%font "typewriter", size 3
+ struct task_struct {
+ [0] volatile long state;
+ [4] unsigned long flags;
+ [8] int sigpending;
+ [c] mm_segment_t addr_limit;
+ [10] struct exec_domain *exec_domain;
+ [14] volatile long need_resched;
+ [18] unsigned long ptrace;
+ [1c] int lock_depth;
+ [20] long counter;
+ [24] long nice;
+ [28] unsigned long policy;
+%fore "blue"
+ [2c] struct mm_struct *mm;
+%fore "black"
+ [30] int processor;
+ [34] unsigned long cpus_runnable, cpus_allowed;
+ <snip>
+ };
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%page
+
+Simple Program
+
+
+%font "typewriter", size 3
+ Display the mm_struct associated with simple process
+%font "typewriter", size 3
+ [3]kdb>
+%fore "blue", cont
+md f7e10f00
+%fore "black"
+ 0xf7e10f00
+%fore "blue", cont
+e8357a80
+%fore "black", cont
+ e8357978 f7ac77e0 eb15eac0 .z5hxy5h`w,w@j.k
+ 0xf7e10f10 00000001 00000002 0000000b 00000000 ................
+ 0xf7e10f20 00000001 f7e10f24 f7e10f24 00000001 ................
+ 0xf7e10f30 f7e35e70 eea7e8f0 08048000 0804862b ................
+ 0xf7e10f40 0804962c 08049744 08051780 0805a000 ................
+ 0xf7e10f50 bffffd10 bffffe00 bffffe09 bffffe09 ................
+ 0xf7e10f60 bffffff3 0000005a 00000168 00000000 ................
+ 0xf7e10f70 00000000 00000002 00000000 00000001 ................
+
+%font "typewriter", size 3
+ Determine offset of the first vma in the process
+%font "typewriter", size 3
+ struct mm_struct {
+%fore "blue"
+ struct vm_area_struct * mmap;
+%fore "black"
+ rb_root_t mm_rb;
+ struct vm_area_struct * mmap_cache;
+ <snip>
+ };
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%page
+
+Simple Program
+
+%font "typewriter", size 3
+ Display the first vma using md
+%font "typewriter", size 3
+ [3]kdb>
+%fore "blue", cont
+md e8357a80
+%fore "black"
+ 0xe8357a80 f7e10f00 08048000 08049000
+%fore "blue", cont
+e8727e00
+%fore "black",cont
+ ..aw.........~rh
+ 0xe8357a90 00000025 00001875 e8727e18 00000001 %...u....~rh....
+
+ Display the first vma using vma
+%font "typewriter", size 3
+ [3]kdb>
+%fore "blue", cont
+vma e8357a80
+%fore "black"
+ struct vm_area_struct at 0xe8357a80 for 68 bytes
+ vm_start = 0x8048000 vm_end = 0x8049000
+ page_prot = 0x25
+ flags: READ EXEC MAYREAD MAYWRITE MAYEXEC DENYWRITE EXECUTABLE
+%font "typewriter", size 3
+
+ Determine the offset to the vma list
+%font "typewriter", size 3
+ struct vm_area_struct {
+ [0] struct mm_struct * vm_mm;
+ [4] unsigned long vm_start;
+ [8] unsigned long vm_end;
+%fore "blue"
+ [c] struct vm_area_struct *vm_next;
+%fore "black"
+ <snip>
+ };
+ Display the next vma
+%font "typewriter", size 3
+ [3]kdb> vma e8727e00
+ struct vm_area_struct at 0xe8727e00 for 68 bytes
+ vm_start = 0x8049000 vm_end = 0x804a000
+ page_prot = 0x25
+ flags: READ WRITE MAYREAD MAYWRITE MAYEXEC DENYWRITE EXECUTABLE
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%page
+
+Simple Program
+
+%font "typewriter", size 3
+ Use the ll command to display the list of vma's
+%font "typewriter", size 3
+ [3]kdb> ll e8357a80 0xc vma
+.
+ struct vm_area_struct at 0xe8357a80 for 68 bytes
+ vm_start = 0x8048000 vm_end = 0x8049000
+ page_prot = 0x25
+ flags: READ EXEC MAYREAD MAYWRITE MAYEXEC DENYWRITE EXECUTABLE
+.
+ struct vm_area_struct at 0xe8727e00 for 68 bytes
+ vm_start =
+%fore "orange", cont
+0x8049000
+%fore "black", cont
+ vm_end =
+%fore "orange", cont
+0x804a000
+%fore "black"
+ page_prot = 0x25
+ flags: READ WRITE MAYREAD MAYWRITE MAYEXEC DENYWRITE EXECUTABLE
+.
+ struct vm_area_struct at 0xe8727c80 for 68 bytes
+ vm_start =
+%fore "blue", cont
+0x804a000
+%fore "black", cont
+ vm_end =
+%fore "blue", cont
+0x805a000
+%fore "black"
+ page_prot = 0x25
+ flags: READ WRITE EXEC MAYREAD MAYWRITE MAYEXEC
+ <snip>
+ struct vm_area_struct at 0xe8357900 for 68 bytes
+ vm_start = 0xbfffe000 vm_end = 0xc0000000
+ page_prot = 0x25
+ flags: READ WRITE EXEC MAYREAD MAYWRITE MAYEXEC GROWSDOWN
+
+ Match the vma to the displayed addresses
+%font "typewriter", size 3
+ foo_global at
+%fore "orange", cont
+8049780
+%fore "black"
+ foo_malloc at
+%fore "blue", cont
+8051788
+%fore "black"
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%page
+
+Walking IO structures
+
+
+ Objective
+ Show usage of various scsi and vm related kdb commands
+
+ Sequence:
+ Set a breakpoint in the scsi driver
+ Stops when queueing a command to the controller
+ Cause IO on an idle disk
+ Show various IO stack traces
+ Display the IO data structures
+ Display vm information about the data
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%page
+
+Walking IO structures
+
+
+%font "typewriter", size 3
+ Set the breakpoint
+
+%font "typewriter", size 3
+ [3]kdb>
+%fore "blue", cont
+bp isp1020_queuecommand
+%fore "black"
+ Instruction(i) BP #0 at 0xc01ecfe0 (isp1020_queuecommand)
+ is enabled globally adjust 1
+
+%font "typewriter", size 3
+ Create some activity on a previously unused disk
+
+%font "typewriter", size 3
+ [3]kdb>
+%fore "blue", cont
+go
+%fore "black"
+ [root@elm3b77 root]#
+%fore "blue", cont
+ls /rh62
+%fore "black"
+
+ Instruction(i) breakpoint #0 at 0xc01ecfe0 (adjusted)
+ 0xc01ecfe0 isp1020_queuecommand:int3
+
+ Entering kdb (current=0xf75ba000, pid 1181) on processor 3 due to
+ Breakpoint @ 0xc01ecfe0
+
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%page
+
+Walking IO structures
+
+
+%font "typewriter", size 3
+ Show the stack.
+ This is a read of the /rh62 directory
+
+%font "typewriter", size 3
+ [1]kdb>
+%fore "blue", cont
+bt
+%fore "black"
+ EBP EIP Function(args)
+ 0xf75bbdf4 0xc01ecfe0 isp1020_queuecommand
+ 0xc01e2c77 scsi_dispatch_cmd+0x1f7
+ 0xf75bbe24 0xc01e99b1 scsi_request_fn+0x2f1
+ 0xf75bbe34 0xc01c84fd generic_unplug_device+0x2d
+ 0xf75bbe50 0xc011b3af __run_task_queue+0x5f
+ 0xf75bbe6c 0xc013a63c block_sync_page+0x1c
+ 0xf75bbe98 0xc0128127 __lock_page+0x77
+ 0xf75bbea4 0xc0128178 lock_page+0x18
+ 0xf75bbec8 0xc012a4b3 read_cache_page+0xc3
+ 0xf75bbef4 0xc0168e23 ext2_get_page+0x23
+ 0xf75bbf48 0xc0168fdd ext2_readdir+0xfd
+ 0xf75bbf68 0xc0143d2e vfs_readdir+0x7e
+ 0xf75bbfbc 0xc01442ed
+%fore "blue", cont
+sys_getdents64+0x4d
+%fore "black"
+ 0xc010702b system_call+0x33
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%page
+
+Walking IO structures
+
+
+%font "typewriter", size 3
+ Allow the operation to complete
+
+%font "typewriter", size 3
+ [3]kdb>
+%fore "blue", cont
+go
+%fore "black"
+ bench build etc lib mnt oldsys rh72 spv usr
+ bin data h linux mnt1 opt root test var
+ boot dev home lost+found mnt2 proc sbin tmp
+
+%font "typewriter", size 3
+ Force some more activity
+
+%font "typewriter", size 3
+ [root@elm3b77 root]#
+%fore "blue", cont
+cd /rh62/tmp
+%fore "black"
+ Instruction(i) breakpoint #0 at 0xc01ecfe0 (adjusted)
+ 0xc01ecfe0 isp1020_queuecommand:int3
+
+ Entering kdb (current=0xf768a000, pid 981) on processor 3 due to
+ Breakpoint @ 0xc01ecfe0
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%page
+
+Walking IO structures
+
+
+%font "typewriter", size 3
+ Show the stack.
+ This is an inode read for /rh62/tmp
+
+%font "typewriter", size 3
+ [3]kdb>
+%fore "blue", cont
+bt
+%fore "black"
+ EBP EIP Function(args)
+ 0xf768bd68 0xc01ecfe0 isp1020_queuecommand
+ 0xc01e2c77 scsi_dispatch_cmd+0x1f7
+ 0xf768bd98 0xc01e99b1 scsi_request_fn+0x2f1
+ 0xf768bda8 0xc01c84fd generic_unplug_device+0x2d
+ 0xf768bdc4 0xc011b3af __run_task_queue+0x5f
+ 0xf768bdfc 0xc0137216 __wait_on_buffer+0x56
+ 0xf768be1c 0xc0138600 bread+0x50
+ 0xf768be5c 0xc016b684 ext2_read_inode+0x114
+ 0xf768bf0c 0xc013fbec real_lookup+0x7c
+ 0xf768bf78 0xc014035d link_path_walk+0x5ad
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%page
+
+Walking IO structures
+
+
+%font "typewriter", size 3
+ Create a new file, causing yet more disk activity
+
+%font "typewriter", size 3
+ [3]kdb>
+%fore "blue", cont
+go
+%fore "black"
+
+ [root@elm3b77 tmp]#
+%fore "blue", cont
+echo "Hello linux reading group" > j1;sync
+%fore "black"
+
+ Instruction(i) breakpoint #0 at 0xc01ecfe0 (adjusted)
+ 0xc01ecfe0 isp1020_queuecommand:int3
+
+ Entering kdb (current=0xf768a000, pid 981) on processor 3 due to
+ Breakpoint @ 0xc01ecfe0
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%page
+
+Walking IO structures
+
+
+%font "typewriter", size 3
+ Show the stack
+ This is an inode read in response to the open
+%font "typewriter", size 3
+ [3]kdb>
+%fore "blue", cont
+bt
+%fore "black"
+ EBP EIP Function(args)
+ 0xf768bd78 0xc01ecfe0 isp1020_queuecommand
+ 0xc01e2c77 scsi_dispatch_cmd+0x1f7
+ 0xf768bda8 0xc01e99b1 scsi_request_fn+0x2f1
+ 0xf768bdb8 0xc01c84fd generic_unplug_device+0x2d
+ 0xf768bdd4 0xc011b3af __run_task_queue+0x5f
+ 0xf768bdf0 0xc013a63c block_sync_page+0x1c
+ 0xf768be1c 0xc0128127 __lock_page+0x77
+ 0xf768be28 0xc0128178 lock_page+0x18
+ 0xf768be4c 0xc012a4b3 read_cache_page+0xc3
+ 0xf768be78 0xc0168e23 ext2_get_page+0x23
+ 0xf768beb8 0xc01691ed ext2_find_entry+0x8d
+ 0xf768bed4 0xc016933a ext2_inode_by_name+0x1a
+ 0xf768befc 0xc016c077 ext2_lookup+0x27
+ 0xf768bf1c 0xc014094a lookup_hash+0x9a
+ 0xf768bf64 0xc0140c4d open_namei+0xfd
+ 0xf768bfa0 0xc0135907 filp_open+0x37
+ 0xf768bfbc 0xc0135c64 sys_open+0x34
+ 0xc010702b system_call+0x33
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%page
+
+Walking IO structures
+
+
+%font "typewriter", size 3
+ Let the operation continue
+%font "typewriter", size 3
+ [3]kdb>
+%fore "blue", cont
+go
+%fore "black"
+ Instruction(i) breakpoint #0 at 0xc01ecfe0 (adjusted)
+ 0xc01ecfe0 isp1020_queuecommand: int3
+ Entering kdb (current=0xc0352000, pid 0) on processor 0 due to
+ Breakpoint @ 0xc01ecfe0
+ Show the stack
+ This is an io completion queuing the next request
+%font "typewriter", size 3
+ [0]kdb>
+%fore "blue", cont
+bt
+%fore "black"
+ EBP EIP Function(args)
+ 0xc0353df4 0xc01ecfe0 isp1020_queuecommand(
+%fore "blue", cont
+0xf7e63a00
+%fore "black", cont
+,0xc01e7fc0...
+ 0xc01e2c77 scsi_dispatch_cmd+0x1f7
+ 0xc0353e24 0xc01e99b1 scsi_request_fn+0x2f1
+ 0xc0353e40 0xc01e8f6a
+%fore "blue", cont
+scsi_queue_next_request+0x4a
+%fore "black"
+ 0xc0353e5c 0xc01e9166 __scsi_end_request+0x116
+ 0xc0353ea8 0xc01e93e0
+%fore "blue", cont
+scsi_io_completion+0x170
+%fore "black"
+ 0xc0353ecc 0xc01f658e rw_intr+0x14e
+ 0xc0353ef8 0xc01e8668 scsi_old_done+0x6a8
+ 0xc0353fd4 0xc01052c2 cpu_idle+0x52
+ Function prototype
+%font "typewriter", size 3
+ int isp1020_queuecommand(
+%fore "blue", cont
+Scsi_Cmnd *Cmnd,
+%fore "black"
+ void (*done)(Scsi_Cmnd *))
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%page
+
+Walking IO structures
+
+
+%font "typewriter", size 3
+ Show the command being queued
+%font "typewriter", size 3
+ [0]kdb>
+%fore "blue", cont
+sc 0xf7e63a00
+%fore "black"
+ scsi_cmnd at 0xf7e63a00
+%fore "blue"
+ host = 0xf7e91400
+%fore "black", cont
+ state = 4099 owner = 258
+%fore "blue", cont
+device = 0xf7ed5d80
+%fore "black"
+ bnext = 0x00000000 reset_chain = 0x00000000 eh_state = 0
+ done = 0xc01f6440
+ serial_number = 3402 serial_num_at_to = 0 retries = 0 timeout = 0
+ id/lun/cmnd = [0/0/0] cmd_len = 10 old_cmd_len = 10
+ cmnd = [2a/00/00/28/00/3f/00/00/10/00/ef/f7]
+ data_cmnd = [2a/00/00/28/00/3f/00/00/10/00/ef/f7]
+ request_buffer = 0xc03fd000 bh_next = 0x00000000
+ request_bufflen = 8192
+ use_sg = 2 old_use_sg = 2 sglist_len = 512 abore_reason = 0
+ bufflen = 8192 buffer = 0xc03fd000 underflow = 8192
+ transfersize = 512
+ tag = 0 pid = 3401
+ request struct
+ rq_status = RQ_ACTIVE rq_dev = [8/1] errors = 1 cmd = 0
+ sector = 2621440 nr_sectors = 16 current_nr_sectors = 8
+ buffer = 0xf7599000
+%fore "blue", cont
+bh = 0xf75ca300
+%fore "black", cont
+ bhtail = 0xf75ca3c0
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%page
+
+Walking IO structures
+
+
+%font "typewriter", size 3
+ Display the host adapter
+%font "typewriter", size 3
+ [0]kdb>
+%fore "blue", cont
+sh 0xf7e91400
+%fore "black"
+ Scsi_Host at 0xf7e91400
+ next = 0x00000000
+%fore "blue", cont
+host_queue = 0xf7ed5d80
+%fore "black"
+ ehandler = 0x00000000 eh_wait = 0x00000000 en_notify = 0x00000000
+ eh_action = 0x00000000
+ h_active = 0x0 host_wait = 0xc0353ac4 hostt = 0xc034bce0
+ host_busy = 1
+ host_failed = 0 extra_bytes = 524 host_no = 0 resetting = 0
+ max id/lun/channel = [16/8/0] this_id = 7
+ can_queue = 64 cmd_per_lun = 1 sg_tablesize = 427 u_isa_dma = 0
+ host_blocked = 0 reverse_ordering = 0
+
+%font "typewriter", size 3
+ Display the scsi device
+%font "typewriter", size 3
+ [0]kdb>
+%fore "blue", cont
+sd 0xf7ed5d80
+%fore "black"
+ scsi_device at 0xf7ed5d80
+ next = 0xf7ed5c80 prev = 0x00000000 host = 0xf7e91400
+ device_busy = 1
+%fore "blue", cont
+device_queue 0xf7e63a00
+%fore "black"
+ id/lun/chan = [0/0/0] single_lun = 0 device_blocked = 0
+ queue_depth = 1 current_tag = 0 scsi_level = 4
+ IBM DGHS18X 0360
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%page
+
+Walking IO structures
+
+
+%font "typewriter", size 3
+ Display the Buffer header associated with the command
+%font "typewriter", size 3
+ [0]kdb>
+%fore "blue", cont
+bh 0xf75ca300
+%fore "black"
+ buffer_head at 0xf75ca300
+ next 0x00000000 bno 327680 rsec 2621440 size 4096
+ dev 0x801 rdev 0x801
+ count 2 state 0x1d [Uptodate Lock Req Mapped] ftime 0x7695e
+ b_list 1 b_reqnext 0xf75ca3c0 b_data 0xf7599000
+%fore "blue"
+ b_page 0xc1dd6640
+%fore "black", cont
+ b_this_page 0xf75ca300 b_private 0x00000000
+
+ Display the associated page structure
+%font "typewriter", size 3
+ [0]kdb>
+%fore "blue", cont
+page 0xc1dd6640
+%fore "black"
+ struct page at 0xc1dd6640
+ next 0xc1dd7300 prev 0xc1dd6240
+%fore "blue", cont
+addr space 0xf7af04d0
+%fore "black"
+ index 327680 (offset 0x50000000)
+ count 2 flags PG_referenced PG_lru virtual 0xf7599000
+ buffers 0xf75ca300
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%page
+
+Walking IO structures
+
+
+%font "typewriter", size 3
+ Display the Address space associated with the page
+%font "typewriter", size 3
+ [0]kdb>
+%fore "blue", cont
+md 0xf7af04d0
+%fore "black"
+ 0xf7af04d0 c1dd6240 c1dea740 f7af04d8 f7af04d8 @b]A@'^AX./wX./w
+ 0xf7af04e0 f7af04e0 f7af04e0 00000007 c033b700 `./w`./w.....73@
+ 0xf7af04f0
+%fore "blue", cont
+f7af0420
+%fore "black", cont
+ 00000000 00000000 00000001 ./w............
+ 0xf7af0500 000001d0 00000000 00000000 f7af050c P............./w
+ 0xf7af0510 f7af050c 00000000 f7a8afa0 00000000 ../w.... /(w....
+
+ The structure looks like:
+%size 3
+ struct address_space {
+ struct list_head clean_pages; /* list of clean pages */
+ struct list_head dirty_pages; /* list of dirty pages */
+ struct list_head locked_pages;/* list of locked pages */
+ unsigned long nrpages; /* number of total pages */
+ spinlock_t page_lock; /* spinlock protecting them*/
+ struct address_space_operations *a_ops; /* methods */
+%fore "blue"
+ struct inode *host; /* owner: inode, block_dev */
+%fore "black"
+ <snip>
+ };
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%page
+
+Walking IO structures
+
+
+%font "typewriter", size 3
+ Display the inode associated with the address space
+ I think htis is the inode for the block device.
+
+%font "typewriter", size 3
+ [1]kdb>
+%fore "blue", cont
+inode f7af0420
+%fore "black"
+ struct inode at 0xf7af0420
+ i_ino = 289 i_count = 1 i_dev = 0x801 i_size 4301789184
+ i_mode = 0x8000 i_nlink = 1 i_rdev = 0x801
+ i_hash.nxt = 0xf7af0420 i_hash.prv = 0xf7af0420
+ i_list.nxt = 0xf7af0608 i_list.prv = 0xf7af0068
+ i_dentry.nxt = 0xf7af0430 i_dentry.prv = 0xf7af0430
+ i_dirty_buffers.nxt = 0xf7af0438 i_dirty_buffers.prv = 0xf7af0438
+ i_sb = 0xc201f200 i_op = 0xc03cfdc0 i_data = 0xf7af04d0 nrpages = 6
+ i_mapping = 0xf7af04d0
+ i_flags 0x0 i_state 0x0 [] fs specific info @ 0xf7af0540
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%page
+
+Walking IO structures
+
+
+%font "typewriter", size 3
+ Display the page list associated with the inode
+%font "typewriter", size 3
+ [0]kdb>
+%fore "blue", cont
+inode_pages f7af0420
+%fore "black"
+CLEAN page_struct index cnt flags
+ 0xc1dd6240 327735 2 0x44 bh 0xf75caae0 bno 327735
+ [Lock Req Mapped]
+%fore "blue"
+ 0xc1dd6640 327680 2 0x44 bh 0xf75ca300 bno 327680
+ [Uptodate Lock Req Mapped]
+%fore "black"
+ 0xc1dd7300 327681 2 0x44 bh 0xf75ca3c0 bno 327681
+ [Uptodate Lock Req Mapped]
+ 0xc1dd6e00 327684 2 0x44 bh 0xf75ca420 bno 327684
+ [Uptodate Req Mapped]
+ 0xc1de8fc0 4 2 0xc0 bh 0xf7b5ade0 bno 4
+ [Uptodate Req Mapped]
+ 0xc1dea700 1 2 0x44 bh 0xf7e02740 bno 1
+ [Uptodate Req Mapped]
+ 0xc1dea740 0 2 0x44 bh 0xf7e028c0 bno 0
+ [Uptodate Req Mapped]
+DIRTY page_struct index cnt flags
+LOCKED page_struct index cnt flags
Index: linux/Makefile
===================================================================
--- linux.orig/Makefile
+++ linux/Makefile
@@ -604,6 +604,7 @@ export mod_strip_cmd
ifeq ($(KBUILD_EXTMOD),)
core-y += kernel/ mm/ fs/ ipc/ security/ crypto/ block/
+core-$(CONFIG_KDB) += kdb/
vmlinux-dirs := $(patsubst %/,%,$(filter %/, $(init-y) $(init-m) \
$(core-y) $(core-m) $(drivers-y) $(drivers-m) \
Index: linux/drivers/char/keyboard.c
===================================================================
--- linux.orig/drivers/char/keyboard.c
+++ linux/drivers/char/keyboard.c
@@ -42,6 +42,9 @@
#include <linux/input.h>
#include <linux/reboot.h>
#include <linux/notifier.h>
+#ifdef CONFIG_KDB
+#include <linux/kdb.h>
+#endif /* CONFIG_KDB */
extern void ctrl_alt_del(void);
@@ -1178,6 +1181,13 @@ static void kbd_keycode(unsigned int key
if (keycode < BTN_MISC && printk_ratelimit())
printk(KERN_WARNING "keyboard.c: can't emulate rawmode for keycode %d\n", keycode);
+#ifdef CONFIG_KDB
+ if (down && !rep && keycode == KEY_PAUSE && kdb_on == 1) {
+ kdb(KDB_REASON_KEYBOARD, 0, get_irq_regs());
+ return;
+ }
+#endif /* CONFIG_KDB */
+
#ifdef CONFIG_MAGIC_SYSRQ /* Handle the SysRq Hack */
if (keycode == KEY_SYSRQ && (sysrq_down || (down == 1 && sysrq_alt))) {
if (!sysrq_down) {
Index: linux/drivers/hid/usbhid/hid-core.c
===================================================================
--- linux.orig/drivers/hid/usbhid/hid-core.c
+++ linux/drivers/hid/usbhid/hid-core.c
@@ -44,6 +44,10 @@
#define DRIVER_DESC "USB HID core driver"
#define DRIVER_LICENSE "GPL"
+#ifdef CONFIG_KDB_USB
+#include <linux/kdb.h>
+#endif
+
static char *hid_types[] = {"Device", "Pointer", "Mouse", "Device", "Joystick",
"Gamepad", "Keyboard", "Keypad", "Multi-Axis Controller"};
/*
@@ -930,6 +934,15 @@ static void hid_disconnect(struct usb_in
usbhid = hid->driver_data;
+#ifdef CONFIG_KDB_USB
+ /*
+ * If the URB was for a Keyboard, detach it from kdb.
+ * If the URB was for another type of device, just
+ * allow kdb_usb_keyboard_detach() to silently fail.
+ */
+ kdb_usb_keyboard_detach(usbhid->urbin);
+#endif
+
spin_lock_irq(&usbhid->inlock); /* Sync with error handler */
usb_set_intfdata(intf, NULL);
spin_unlock_irq(&usbhid->inlock);
@@ -1026,6 +1039,21 @@ static int hid_probe(struct usb_interfac
printk(": USB HID v%x.%02x %s [%s] on %s\n",
hid->version >> 8, hid->version & 0xff, c, hid->name, path);
+#ifdef CONFIG_KDB_USB
+ /* Attach USB keyboards to kdb */
+ if (!strcmp(c, "Keyboard")) {
+ int ret;
+ struct usbhid_device *usbhid = hid->driver_data;
+ extern void * usb_hcd_get_kdb_poll_func(struct usb_device *udev);
+ ret = kdb_usb_keyboard_attach(usbhid->urbin, usbhid->inbuf,
+ usb_hcd_get_kdb_poll_func(interface_to_usbdev(intf)));
+
+ if (ret == -1)
+ printk(": FAILED to register keyboard (%s) "
+ "with KDB\n", path);
+ }
+#endif /* CONFIG_KDB_USB */
+
return 0;
}
Index: linux/drivers/hid/usbhid/usbkbd.c
===================================================================
--- linux.orig/drivers/hid/usbhid/usbkbd.c
+++ linux/drivers/hid/usbhid/usbkbd.c
@@ -32,6 +32,9 @@
#include <linux/init.h>
#include <linux/usb/input.h>
#include <linux/hid.h>
+#ifdef CONFIG_KDB_USB
+#include <linux/kdb.h>
+#endif
/*
* Version Information
@@ -299,6 +302,16 @@ static int usb_kbd_probe(struct usb_inte
usb_fill_int_urb(kbd->irq, dev, pipe,
kbd->new, (maxp > 8 ? 8 : maxp),
usb_kbd_irq, kbd, endpoint->bInterval);
+
+#ifdef CONFIG_KDB_USB
+ /* Attach keyboard to kdb */
+ extern void * usb_hcd_get_kdb_poll_func(struct usb_device *udev);
+
+ kdb_usb_keyboard_attach(kbd->irq, kbd->new,
+ usb_hcd_get_kdb_poll_func(dev));
+
+#endif /* CONFIG_KDB_USB */
+
kbd->irq->transfer_dma = kbd->new_dma;
kbd->irq->transfer_flags |= URB_NO_TRANSFER_DMA_MAP;
@@ -336,6 +349,10 @@ static void usb_kbd_disconnect(struct us
usb_set_intfdata(intf, NULL);
if (kbd) {
+#ifdef CONFIG_KDB_USB
+ /* Detach the keyboard from kdb */
+ kdb_usb_keyboard_detach(kbd->irq);
+#endif /* CONFIG_KDB_USB */
usb_kill_urb(kbd->irq);
input_unregister_device(kbd->dev);
usb_kbd_free_mem(interface_to_usbdev(intf), kbd);
Index: linux/drivers/serial/8250.c
===================================================================
--- linux.orig/drivers/serial/8250.c
+++ linux/drivers/serial/8250.c
@@ -45,6 +45,19 @@
#include <asm/irq.h>
#include "8250.h"
+#include <linux/kdb.h>
+#ifdef CONFIG_KDB
+/*
+ * kdb_serial_line records the serial line number of the first serial console.
+ * NOTE: The kernel ignores characters on the serial line unless a user space
+ * program has opened the line first. To enter kdb before user space has opened
+ * the serial line, you can use the 'kdb=early' flag to lilo and set the
+ * appropriate breakpoints.
+ */
+
+static int kdb_serial_line = -1;
+static const char *kdb_serial_ptr = kdb_serial_str;
+#endif /* CONFIG_KDB */
/*
* Configuration:
@@ -1297,6 +1310,20 @@ receive_chars(struct uart_8250_port *up,
do {
ch = serial_inp(up, UART_RX);
+#ifdef CONFIG_KDB
+ if ((up->port.line == kdb_serial_line) && kdb_on == 1) {
+ if (ch == *kdb_serial_ptr) {
+ if (!(*++kdb_serial_ptr)) {
+ atomic_inc(&kdb_8250);
+ kdb(KDB_REASON_KEYBOARD, 0, get_irq_regs());
+ atomic_dec(&kdb_8250);
+ kdb_serial_ptr = kdb_serial_str;
+ break;
+ }
+ } else
+ kdb_serial_ptr = kdb_serial_str;
+ }
+#endif /* CONFIG_KDB */
flag = TTY_NORMAL;
up->port.icount.rx++;
@@ -2479,7 +2506,7 @@ serial8250_console_write(struct console
if (up->port.sysrq) {
/* serial8250_handle_port() already took the lock */
locked = 0;
- } else if (oops_in_progress) {
+ } else if (oops_in_progress || KDB_8250()) {
locked = spin_trylock(&up->port.lock);
} else
spin_lock(&up->port.lock);
@@ -2537,6 +2564,30 @@ static int __init serial8250_console_set
if (!port->iobase && !port->membase)
return -ENODEV;
+#ifdef CONFIG_KDB
+ /*
+ * Remember the line number of the first serial
+ * console. We'll make this the kdb serial console too.
+ */
+ if (co && kdb_serial_line == -1) {
+ kdb_serial_line = co->index;
+ kdb_serial.io_type = port->iotype;
+ switch (port->iotype) {
+ case SERIAL_IO_MEM:
+#ifdef SERIAL_IO_MEM32
+ case SERIAL_IO_MEM32:
+#endif
+ kdb_serial.iobase = (unsigned long)(port->membase);
+ kdb_serial.ioreg_shift = port->regshift;
+ break;
+ default:
+ kdb_serial.iobase = port->iobase;
+ kdb_serial.ioreg_shift = 0;
+ break;
+ }
+ }
+#endif /* CONFIG_KDB */
+
if (options)
uart_parse_options(options, &baud, &parity, &bits, &flow);
Index: linux/drivers/serial/8250_early.c
===================================================================
--- linux.orig/drivers/serial/8250_early.c
+++ linux/drivers/serial/8250_early.c
@@ -38,6 +38,11 @@
#include <asm/fixmap.h>
#endif
+#ifdef CONFIG_KDB
+#include <linux/kdb.h>
+static int kdb_serial_line = -1;
+#endif /* CONFIG_KDB */
+
struct early_serial8250_device {
struct uart_port port;
char options[16]; /* e.g., 115200n8 */
@@ -231,6 +236,30 @@ int __init setup_early_serial8250_consol
register_console(&early_serial8250_console);
+#ifdef CONFIG_KDB
+ /*
+ * Remember the line number of the first serial
+ * console. We'll make this the kdb serial console too.
+ */
+ if (kdb_serial_line == -1) {
+ kdb_serial_line = early_serial8250_console.index;
+ kdb_serial.io_type = early_device.port.iotype;
+ switch (early_device.port.iotype) {
+ case SERIAL_IO_MEM:
+#ifdef SERIAL_IO_MEM32
+ case SERIAL_IO_MEM32:
+#endif
+ kdb_serial.iobase = (unsigned long)(early_device.port.membase);
+ kdb_serial.ioreg_shift = early_device.port.regshift;
+ break;
+ default:
+ kdb_serial.iobase = early_device.port.iobase;
+ kdb_serial.ioreg_shift = 0;
+ break;
+ }
+ }
+#endif /* CONFIG_KDB */
+
return 0;
}
Index: linux/drivers/serial/sn_console.c
===================================================================
--- linux.orig/drivers/serial/sn_console.c
+++ linux/drivers/serial/sn_console.c
@@ -48,6 +48,22 @@
#include <linux/delay.h> /* for mdelay */
#include <linux/miscdevice.h>
#include <linux/serial_core.h>
+#ifdef CONFIG_KDB
+#include <linux/kdb.h>
+#include <linux/kdbprivate.h>
+#include <linux/serial_reg.h>
+/*
+ * kdb_serial_line records the serial line number of the first serial console.
+ * NOTE: The kernel ignores characters on the serial line unless a user space
+ * program has opened the line first. To enter kdb before user space has opened
+ * the serial line, you can use the 'kdb=early' flag to lilo and set the
+ * appropriate breakpoints.
+ */
+
+static int kdb_serial_line = -1;
+static char *kdb_serial_ptr = (char *)kdb_serial_str;
+#endif /* CONFIG_KDB */
+
#include <asm/io.h>
#include <asm/sn/simulator.h>
@@ -485,6 +501,26 @@ sn_receive_chars(struct sn_cons_port *po
"obtaining data from the console (0x%0x)\n", ch);
break;
}
+#ifdef CONFIG_KDB
+ if (kdb_on == 1) {
+ if (ch == *kdb_serial_ptr) {
+ if (!(*++kdb_serial_ptr)) {
+ spin_unlock_irqrestore(&port->sc_port.lock, flags);
+ if (!get_irq_regs()) {
+ KDB_STATE_SET(KEYBOARD);
+ KDB_ENTER(); /* to get some registers */
+ } else
+ kdb(KDB_REASON_KEYBOARD, 0, get_irq_regs());
+ kdb_serial_ptr = (char *)kdb_serial_str;
+ spin_lock_irqsave(&port->sc_port.lock, flags);
+ break;
+ }
+ }
+ else
+ kdb_serial_ptr = (char *)kdb_serial_str;
+ }
+#endif /* CONFIG_KDB */
+
#ifdef CONFIG_MAGIC_SYSRQ
if (sysrq_requested) {
unsigned long sysrq_timeout = sysrq_requested + HZ*5;
@@ -1008,6 +1044,15 @@ sn_sal_console_write(struct console *co,
*/
static int sn_sal_console_setup(struct console *co, char *options)
{
+#ifdef CONFIG_KDB
+ /*
+ * Remember the line number of the first serial
+ * console. We'll make this the kdb serial console too.
+ */
+ if (kdb_serial_line == -1) {
+ kdb_serial_line = co->index;
+ }
+#endif /* CONFIG_KDB */
return 0;
}
@@ -1083,3 +1128,31 @@ static int __init sn_sal_serial_console_
}
console_initcall(sn_sal_serial_console_init);
+
+#ifdef CONFIG_KDB
+int
+l1_control_in_polled(int offset)
+{
+ int sal_call_status = 0, input;
+ int ret = 0;
+ if (offset == UART_LSR) {
+ ret = (UART_LSR_THRE | UART_LSR_TEMT); /* can send anytime */
+ sal_call_status = ia64_sn_console_check(&input);
+ if (!sal_call_status && input) {
+ /* input pending */
+ ret |= UART_LSR_DR;
+ }
+ }
+ return ret;
+}
+
+int
+l1_serial_in_polled(void)
+{
+ int ch;
+ if (!ia64_sn_console_getc(&ch))
+ return ch;
+ else
+ return 0;
+}
+#endif /* CONFIG_KDB */
Index: linux/drivers/usb/host/ohci-hcd.c
===================================================================
--- linux.orig/drivers/usb/host/ohci-hcd.c
+++ linux/drivers/usb/host/ohci-hcd.c
@@ -963,6 +963,73 @@ static int ohci_restart (struct ohci_hcd
/*-------------------------------------------------------------------------*/
+#ifdef CONFIG_KDB_USB
+
+int
+ohci_kdb_poll_char(struct urb *urb)
+{
+ struct ohci_hcd *ohci;
+ struct ohci_regs * regs;
+
+ /* just to make sure */
+ if (!urb || !urb->dev || !urb->dev->bus)
+ return -1;
+
+ ohci = (struct ohci_hcd *) hcd_to_ohci(bus_to_hcd(urb->dev->bus));
+
+ /* make sure */
+ if (!ohci)
+ return -1;
+
+ if (!HC_IS_RUNNING (ohci_to_hcd(ohci)->state))
+ return -1;
+
+ /*
+ * If ohci->lock is held coming into this routine, it could
+ * mean KDB was entered while the HC driver was in the midst
+ * of processing URBs. Therefore it could be dangerous to
+ * processes URBs from this poll routine. And, we can't wait on
+ * the lock since we are in KDB and kernel threads (including the
+ * one holding the lock) are suspended.
+ * So, we punt and return an error. Keyboards attached to this
+ * HC will not be useable from KDB at this time.
+ */
+ if (spin_is_locked(&ohci->lock))
+ return -EBUSY;
+
+ regs = ohci->regs;
+
+ /* if the urb is not currently in progress resubmit it */
+ if (urb->status != -EINPROGRESS) {
+
+ if (usb_submit_urb (urb, GFP_ATOMIC))
+ return -1;
+
+ /* make sure the HC registers are set correctly */
+ ohci_writel (ohci, OHCI_INTR_WDH, ®s->intrenable);
+ ohci_writel (ohci, OHCI_INTR_WDH, ®s->intrstatus);
+ ohci_writel (ohci, OHCI_INTR_MIE, ®s->intrenable);
+
+ // flush those pci writes
+ (void) ohci_readl (ohci, &ohci->regs->control);
+ }
+
+ if (ohci->hcca->done_head) {
+ dl_done_list_kdb (ohci, urb);
+ ohci_writel (ohci, OHCI_INTR_WDH, ®s->intrstatus);
+ // flush the pci write
+ (void) ohci_readl (ohci, &ohci->regs->control);
+
+ return 0;
+ }
+
+ return -1;
+}
+
+#endif /* CONFIG_KDB_USB */
+
+/*-------------------------------------------------------------------------*/
+
#define DRIVER_INFO DRIVER_VERSION " " DRIVER_DESC
MODULE_AUTHOR (DRIVER_AUTHOR);
Index: linux/drivers/usb/host/ohci-pci.c
===================================================================
--- linux.orig/drivers/usb/host/ohci-pci.c
+++ linux/drivers/usb/host/ohci-pci.c
@@ -18,6 +18,10 @@
#error "This file is PCI bus glue. CONFIG_PCI must be defined."
#endif
+#ifdef CONFIG_KDB_USB
+#include <linux/kdb.h>
+#endif
+
/*-------------------------------------------------------------------------*/
static int broken_suspend(struct usb_hcd *hcd)
@@ -235,6 +239,7 @@ static int __devinit ohci_pci_start (str
ohci_err (ohci, "can't start\n");
ohci_stop (hcd);
}
+
return ret;
}
@@ -373,6 +378,9 @@ static const struct hc_driver ohci_pci_h
.bus_resume = ohci_bus_resume,
#endif
.start_port_reset = ohci_start_port_reset,
+#ifdef CONFIG_KDB_USB
+ .kdb_poll_char = ohci_kdb_poll_char,
+#endif
};
/*-------------------------------------------------------------------------*/
Index: linux/drivers/usb/host/ohci-q.c
===================================================================
--- linux.orig/drivers/usb/host/ohci-q.c
+++ linux/drivers/usb/host/ohci-q.c
@@ -1112,3 +1112,65 @@ dl_done_list (struct ohci_hcd *ohci)
td = td_next;
}
}
+
+
+/*-------------------------------------------------------------------------*/
+
+#ifdef CONFIG_KDB_USB
+static void
+dl_done_list_kdb (struct ohci_hcd *ohci, struct urb *kdburb)
+{
+ struct td *td = dl_reverse_done_list (ohci);
+
+ while (td) {
+ struct td *td_next = td->next_dl_td;
+ struct urb *urb = td->urb;
+ urb_priv_t *urb_priv = urb->hcpriv;
+ struct ed *ed = td->ed;
+
+ if (urb != kdburb) {
+ td = td_next;
+ continue;
+ }
+
+ /* update URB's length and status from TD */
+ td_done (ohci, urb, td);
+ urb_priv->td_cnt++;
+
+ /* If all this urb's TDs are done, just resubmit it */
+ if (urb_priv->td_cnt == urb_priv->length) {
+ urb->actual_length = 0;
+ urb->status = -EINPROGRESS;
+ td_submit_urb (ohci, urb);
+ }
+
+ /* clean schedule: unlink EDs that are no longer busy */
+ if (list_empty (&ed->td_list)) {
+ if (ed->state == ED_OPER)
+ start_ed_unlink (ohci, ed);
+
+ /* ... reenabling halted EDs only after fault cleanup */
+ } else if ((ed->hwINFO & cpu_to_hc32 (ohci, ED_SKIP | ED_DEQUEUE))
+ == cpu_to_hc32 (ohci, ED_SKIP)) {
+ td = list_entry (ed->td_list.next, struct td, td_list);
+ if (!(td->hwINFO & cpu_to_hc32 (ohci, TD_DONE))) {
+ ed->hwINFO &= ~cpu_to_hc32 (ohci, ED_SKIP);
+ /* ... hc may need waking-up */
+ switch (ed->type) {
+ case PIPE_CONTROL:
+ ohci_writel (ohci, OHCI_CLF,
+ &ohci->regs->cmdstatus);
+ break;
+ case PIPE_BULK:
+ ohci_writel (ohci, OHCI_BLF,
+ &ohci->regs->cmdstatus);
+ break;
+ }
+ }
+ }
+
+ td = td_next;
+ }
+}
+
+#endif /* CONFIG_KDB_USB */
Index: linux/fs/proc/mmu.c
===================================================================
--- linux.orig/fs/proc/mmu.c
+++ linux/fs/proc/mmu.c
@@ -14,11 +14,21 @@
#include <asm/pgtable.h>
#include "internal.h"
+#ifdef CONFIG_KDB
+#include <linux/kdb.h>
+#endif
+
void get_vmalloc_info(struct vmalloc_info *vmi)
{
struct vm_struct *vma;
unsigned long free_area_size;
unsigned long prev_end;
+#ifdef CONFIG_KDB
+ int get_lock = !KDB_IS_RUNNING();
+#else
+#define get_lock 1
+#endif
+
vmi->used = 0;
@@ -30,7 +40,8 @@ void get_vmalloc_info(struct vmalloc_inf
prev_end = VMALLOC_START;
- read_lock(&vmlist_lock);
+ if (get_lock)
+ read_lock(&vmlist_lock);
for (vma = vmlist; vma; vma = vma->next) {
unsigned long addr = (unsigned long) vma->addr;
@@ -55,6 +66,7 @@ void get_vmalloc_info(struct vmalloc_inf
if (VMALLOC_END - prev_end > vmi->largest_chunk)
vmi->largest_chunk = VMALLOC_END - prev_end;
- read_unlock(&vmlist_lock);
+ if (get_lock)
+ read_unlock(&vmlist_lock);
}
}
Index: linux/fs/proc/proc_misc.c
===================================================================
--- linux.orig/fs/proc/proc_misc.c
+++ linux/fs/proc/proc_misc.c
@@ -223,6 +223,120 @@ static int meminfo_read_proc(char *page,
#undef K
}
+#ifdef CONFIG_KDB
+#include <linux/kdb.h>
+#include <linux/kdbprivate.h>
+/* Like meminfo_read_proc() but without the locks and using kdb_printf() */
+void
+kdb_meminfo_read_proc(void)
+{
+ struct sysinfo i;
+ unsigned long committed;
+ unsigned long allowed;
+ struct vmalloc_info vmi;
+ long cached;
+
+/*
+ * display in kilobytes.
+ */
+#define K(x) ((x) << (PAGE_SHIFT - 10))
+ si_meminfo(&i);
+ kdb_si_swapinfo(&i);
+ committed = atomic_read(&vm_committed_space);
+ allowed = ((totalram_pages - hugetlb_total_pages())
+ * sysctl_overcommit_ratio / 100) + total_swap_pages;
+
+ cached = global_page_state(NR_FILE_PAGES) -
+ total_swapcache_pages - i.bufferram;
+ if (cached < 0)
+ cached = 0;
+
+ get_vmalloc_info(&vmi);
+
+ kdb_printf(
+ "MemTotal: %8lu kB\n"
+ "MemFree: %8lu kB\n"
+ "Buffers: %8lu kB\n",
+ K(i.totalram),
+ K(i.freeram),
+ K(i.bufferram)
+ );
+ kdb_printf(
+ "Cached: %8lu kB\n"
+ "SwapCached: %8lu kB\n"
+ "Active: %8lu kB\n"
+ "Inactive: %8lu kB\n",
+ K(cached),
+ K(total_swapcache_pages),
+ K(global_page_state(NR_ACTIVE)),
+ K(global_page_state(NR_INACTIVE))
+ );
+#ifdef CONFIG_HIGHMEM
+ kdb_printf(
+ "HighTotal: %8lu kB\n"
+ "HighFree: %8lu kB\n"
+ "LowTotal: %8lu kB\n"
+ "LowFree: %8lu kB\n",
+ K(i.totalhigh),
+ K(i.freehigh),
+ K(i.totalram-i.totalhigh),
+ K(i.freeram-i.freehigh)
+ );
+#endif
+ kdb_printf(
+ "SwapTotal: %8lu kB\n"
+ "SwapFree: %8lu kB\n"
+ "Dirty: %8lu kB\n",
+ K(i.totalswap),
+ K(i.freeswap),
+ K(global_page_state(NR_FILE_DIRTY))
+ );
+ kdb_printf(
+ "Writeback: %8lu kB\n"
+ "AnonPages: %8lu kB\n"
+ "Mapped: %8lu kB\n",
+ K(global_page_state(NR_WRITEBACK)),
+ K(global_page_state(NR_ANON_PAGES)),
+ K(global_page_state(NR_FILE_MAPPED))
+ );
+ kdb_printf(
+ "Slab: %8lu kB\n"
+ "SReclaimable: %8lu kB\n"
+ "SUnreclaim: %8lu kB\n",
+ K(global_page_state(NR_SLAB_RECLAIMABLE) +
+ global_page_state(NR_SLAB_UNRECLAIMABLE)),
+ K(global_page_state(NR_SLAB_RECLAIMABLE)),
+ K(global_page_state(NR_SLAB_UNRECLAIMABLE))
+ );
+ kdb_printf(
+ "PageTables: %8lu kB\n"
+ "NFS_Unstable: %8lu kB\n"
+ "Bounce: %8lu kB\n",
+ K(global_page_state(NR_PAGETABLE)),
+ K(global_page_state(NR_UNSTABLE_NFS)),
+ K(global_page_state(NR_BOUNCE))
+ );
+ kdb_printf(
+ "CommitLimit: %8lu kB\n"
+ "Committed_AS: %8lu kB\n"
+ "VmallocTotal: %8lu kB\n",
+ K(allowed),
+ K(committed),
+ (unsigned long)VMALLOC_TOTAL >> 10
+ );
+ kdb_printf(
+ "VmallocUsed: %8lu kB\n"
+ "VmallocChunk: %8lu kB\n",
+ vmi.used >> 10,
+ vmi.largest_chunk >> 10
+ );
+
+#ifdef CONFIG_HUGETLBFS
+ kdb_hugetlb_report_meminfo();
+#endif
+}
+#endif /* CONFIG_KDB */
+
extern const struct seq_operations fragmentation_op;
static int fragmentation_open(struct inode *inode, struct file *file)
{
Index: linux/include/linux/console.h
===================================================================
--- linux.orig/include/linux/console.h
+++ linux/include/linux/console.h
@@ -136,7 +136,12 @@ void vcs_remove_sysfs(struct tty_struct
/* Some debug stub to catch some of the obvious races in the VT code */
#if 1
+#ifdef CONFIG_KDB
+#include <linux/kdb.h>
+#define WARN_CONSOLE_UNLOCKED() WARN_ON(!is_console_locked() && !oops_in_progress && !atomic_read(&kdb_event))
+#else /* !CONFIG_KDB */
#define WARN_CONSOLE_UNLOCKED() WARN_ON(!is_console_locked() && !oops_in_progress)
+#endif /* CONFIG_KDB */
#else
#define WARN_CONSOLE_UNLOCKED()
#endif
Index: linux/include/linux/dis-asm.h
===================================================================
--- /dev/null
+++ linux/include/linux/dis-asm.h
@@ -0,0 +1,347 @@
+/* Interface between the opcode library and its callers.
+
+ Copyright 1999, 2000, 2001, 2002, 2003, 2004, 2005
+ Free Software Foundation, Inc.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2, or (at your option)
+ any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street - Fifth Floor,
+ Boston, MA 02110-1301, USA.
+
+ Written by Cygnus Support, 1993.
+
+ The opcode library (libopcodes.a) provides instruction decoders for
+ a large variety of instruction sets, callable with an identical
+ interface, for making instruction-processing programs more independent
+ of the instruction set being processed. */
+
+/* Extracted from binutils 2.16.91.0.2 (OpenSUSE 10.0) and modified for kdb use.
+ * Any trailing whitespace was removed and #ifdef/ifndef __KERNEL__ added as
+ * required.
+ * Keith Owens <kaos@sgi.com> 15 May 2006
+ */
+
+#ifndef DIS_ASM_H
+#define DIS_ASM_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#ifdef __KERNEL__
+#include <asm/ansidecl.h>
+#include <asm/bfd.h>
+typedef void FILE;
+#else /* __KERNEL__ */
+#include <stdio.h>
+#include "bfd.h"
+#endif /* __KERNEL__ */
+
+typedef int (*fprintf_ftype) (void *, const char*, ...) ATTRIBUTE_FPTR_PRINTF_2;
+
+enum dis_insn_type {
+ dis_noninsn, /* Not a valid instruction */
+ dis_nonbranch, /* Not a branch instruction */
+ dis_branch, /* Unconditional branch */
+ dis_condbranch, /* Conditional branch */
+ dis_jsr, /* Jump to subroutine */
+ dis_condjsr, /* Conditional jump to subroutine */
+ dis_dref, /* Data reference instruction */
+ dis_dref2 /* Two data references in instruction */
+};
+
+/* This struct is passed into the instruction decoding routine,
+ and is passed back out into each callback. The various fields are used
+ for conveying information from your main routine into your callbacks,
+ for passing information into the instruction decoders (such as the
+ addresses of the callback functions), or for passing information
+ back from the instruction decoders to their callers.
+
+ It must be initialized before it is first passed; this can be done
+ by hand, or using one of the initialization macros below. */
+
+typedef struct disassemble_info {
+ fprintf_ftype fprintf_func;
+ void *stream;
+ void *application_data;
+
+ /* Target description. We could replace this with a pointer to the bfd,
+ but that would require one. There currently isn't any such requirement
+ so to avoid introducing one we record these explicitly. */
+ /* The bfd_flavour. This can be bfd_target_unknown_flavour. */
+ enum bfd_flavour flavour;
+ /* The bfd_arch value. */
+ enum bfd_architecture arch;
+ /* The bfd_mach value. */
+ unsigned long mach;
+ /* Endianness (for bi-endian cpus). Mono-endian cpus can ignore this. */
+ enum bfd_endian endian;
+ /* An arch/mach-specific bitmask of selected instruction subsets, mainly
+ for processors with run-time-switchable instruction sets. The default,
+ zero, means that there is no constraint. CGEN-based opcodes ports
+ may use ISA_foo masks. */
+ unsigned long insn_sets;
+
+ /* Some targets need information about the current section to accurately
+ display insns. If this is NULL, the target disassembler function
+ will have to make its best guess. */
+ asection *section;
+
+ /* An array of pointers to symbols either at the location being disassembled
+ or at the start of the function being disassembled. The array is sorted
+ so that the first symbol is intended to be the one used. The others are
+ present for any misc. purposes. This is not set reliably, but if it is
+ not NULL, it is correct. */
+ asymbol **symbols;
+ /* Number of symbols in array. */
+ int num_symbols;
+
+ /* For use by the disassembler.
+ The top 16 bits are reserved for public use (and are documented here).
+ The bottom 16 bits are for the internal use of the disassembler. */
+ unsigned long flags;
+#define INSN_HAS_RELOC 0x80000000
+ void *private_data;
+
+ /* Function used to get bytes to disassemble. MEMADDR is the
+ address of the stuff to be disassembled, MYADDR is the address to
+ put the bytes in, and LENGTH is the number of bytes to read.
+ INFO is a pointer to this struct.
+ Returns an errno value or 0 for success. */
+ int (*read_memory_func)
+ (bfd_vma memaddr, bfd_byte *myaddr, unsigned int length,
+ struct disassemble_info *info);
+
+ /* Function which should be called if we get an error that we can't
+ recover from. STATUS is the errno value from read_memory_func and
+ MEMADDR is the address that we were trying to read. INFO is a
+ pointer to this struct. */
+ void (*memory_error_func)
+ (int status, bfd_vma memaddr, struct disassemble_info *info);
+
+ /* Function called to print ADDR. */
+ void (*print_address_func)
+ (bfd_vma addr, struct disassemble_info *info);
+
+ /* Function called to determine if there is a symbol at the given ADDR.
+ If there is, the function returns 1, otherwise it returns 0.
+ This is used by ports which support an overlay manager where
+ the overlay number is held in the top part of an address. In
+ some circumstances we want to include the overlay number in the
+ address, (normally because there is a symbol associated with
+ that address), but sometimes we want to mask out the overlay bits. */
+ int (* symbol_at_address_func)
+ (bfd_vma addr, struct disassemble_info * info);
+
+ /* Function called to check if a SYMBOL is can be displayed to the user.
+ This is used by some ports that want to hide special symbols when
+ displaying debugging outout. */
+ bfd_boolean (* symbol_is_valid)
+ (asymbol *, struct disassemble_info * info);
+
+ /* These are for buffer_read_memory. */
+ bfd_byte *buffer;
+ bfd_vma buffer_vma;
+ unsigned int buffer_length;
+
+ /* This variable may be set by the instruction decoder. It suggests
+ the number of bytes objdump should display on a single line. If
+ the instruction decoder sets this, it should always set it to
+ the same value in order to get reasonable looking output. */
+ int bytes_per_line;
+
+ /* The next two variables control the way objdump displays the raw data. */
+ /* For example, if bytes_per_line is 8 and bytes_per_chunk is 4, the */
+ /* output will look like this:
+ 00: 00000000 00000000
+ with the chunks displayed according to "display_endian". */
+ int bytes_per_chunk;
+ enum bfd_endian display_endian;
+
+ /* Number of octets per incremented target address
+ Normally one, but some DSPs have byte sizes of 16 or 32 bits. */
+ unsigned int octets_per_byte;
+
+ /* The number of zeroes we want to see at the end of a section before we
+ start skipping them. */
+ unsigned int skip_zeroes;
+
+ /* The number of zeroes to skip at the end of a section. If the number
+ of zeroes at the end is between SKIP_ZEROES_AT_END and SKIP_ZEROES,
+ they will be disassembled. If there are fewer than
+ SKIP_ZEROES_AT_END, they will be skipped. This is a heuristic
+ attempt to avoid disassembling zeroes inserted by section
+ alignment. */
+ unsigned int skip_zeroes_at_end;
+
+ /* Results from instruction decoders. Not all decoders yet support
+ this information. This info is set each time an instruction is
+ decoded, and is only valid for the last such instruction.
+
+ To determine whether this decoder supports this information, set
+ insn_info_valid to 0, decode an instruction, then check it. */
+
+ char insn_info_valid; /* Branch info has been set. */
+ char branch_delay_insns; /* How many sequential insn's will run before
+ a branch takes effect. (0 = normal) */
+ char data_size; /* Size of data reference in insn, in bytes */
+ enum dis_insn_type insn_type; /* Type of instruction */
+ bfd_vma target; /* Target address of branch or dref, if known;
+ zero if unknown. */
+ bfd_vma target2; /* Second target address for dref2 */
+
+ /* Command line options specific to the target disassembler. */
+ char * disassembler_options;
+
+} disassemble_info;
+
+
+/* Standard disassemblers. Disassemble one instruction at the given
+ target address. Return number of octets processed. */
+typedef int (*disassembler_ftype) (bfd_vma, disassemble_info *);
+
+extern int print_insn_big_mips (bfd_vma, disassemble_info *);
+extern int print_insn_little_mips (bfd_vma, disassemble_info *);
+extern int print_insn_i386 (bfd_vma, disassemble_info *);
+extern int print_insn_i386_att (bfd_vma, disassemble_info *);
+extern int print_insn_i386_intel (bfd_vma, disassemble_info *);
+extern int print_insn_ia64 (bfd_vma, disassemble_info *);
+extern int print_insn_i370 (bfd_vma, disassemble_info *);
+extern int print_insn_m68hc11 (bfd_vma, disassemble_info *);
+extern int print_insn_m68hc12 (bfd_vma, disassemble_info *);
+extern int print_insn_m68k (bfd_vma, disassemble_info *);
+extern int print_insn_z8001 (bfd_vma, disassemble_info *);
+extern int print_insn_z8002 (bfd_vma, disassemble_info *);
+extern int print_insn_h8300 (bfd_vma, disassemble_info *);
+extern int print_insn_h8300h (bfd_vma, disassemble_info *);
+extern int print_insn_h8300s (bfd_vma, disassemble_info *);
+extern int print_insn_h8500 (bfd_vma, disassemble_info *);
+extern int print_insn_alpha (bfd_vma, disassemble_info *);
+extern int print_insn_big_arm (bfd_vma, disassemble_info *);
+extern int print_insn_little_arm (bfd_vma, disassemble_info *);
+extern int print_insn_sparc (bfd_vma, disassemble_info *);
+extern int print_insn_big_a29k (bfd_vma, disassemble_info *);
+extern int print_insn_little_a29k (bfd_vma, disassemble_info *);
+extern int print_insn_avr (bfd_vma, disassemble_info *);
+extern int print_insn_d10v (bfd_vma, disassemble_info *);
+extern int print_insn_d30v (bfd_vma, disassemble_info *);
+extern int print_insn_dlx (bfd_vma, disassemble_info *);
+extern int print_insn_fr30 (bfd_vma, disassemble_info *);
+extern int print_insn_hppa (bfd_vma, disassemble_info *);
+extern int print_insn_i860 (bfd_vma, disassemble_info *);
+extern int print_insn_i960 (bfd_vma, disassemble_info *);
+extern int print_insn_ip2k (bfd_vma, disassemble_info *);
+extern int print_insn_m32r (bfd_vma, disassemble_info *);
+extern int print_insn_m88k (bfd_vma, disassemble_info *);
+extern int print_insn_maxq_little (bfd_vma, disassemble_info *);
+extern int print_insn_maxq_big (bfd_vma, disassemble_info *);
+extern int print_insn_mcore (bfd_vma, disassemble_info *);
+extern int print_insn_mmix (bfd_vma, disassemble_info *);
+extern int print_insn_mn10200 (bfd_vma, disassemble_info *);
+extern int print_insn_mn10300 (bfd_vma, disassemble_info *);
+extern int print_insn_ms1 (bfd_vma, disassemble_info *);
+extern int print_insn_msp430 (bfd_vma, disassemble_info *);
+extern int print_insn_ns32k (bfd_vma, disassemble_info *);
+extern int print_insn_crx (bfd_vma, disassemble_info *);
+extern int print_insn_openrisc (bfd_vma, disassemble_info *);
+extern int print_insn_big_or32 (bfd_vma, disassemble_info *);
+extern int print_insn_little_or32 (bfd_vma, disassemble_info *);
+extern int print_insn_pdp11 (bfd_vma, disassemble_info *);
+extern int print_insn_pj (bfd_vma, disassemble_info *);
+extern int print_insn_big_powerpc (bfd_vma, disassemble_info *);
+extern int print_insn_little_powerpc (bfd_vma, disassemble_info *);
+extern int print_insn_rs6000 (bfd_vma, disassemble_info *);
+extern int print_insn_s390 (bfd_vma, disassemble_info *);
+extern int print_insn_sh (bfd_vma, disassemble_info *);
+extern int print_insn_tic30 (bfd_vma, disassemble_info *);
+extern int print_insn_tic4x (bfd_vma, disassemble_info *);
+extern int print_insn_tic54x (bfd_vma, disassemble_info *);
+extern int print_insn_tic80 (bfd_vma, disassemble_info *);
+extern int print_insn_v850 (bfd_vma, disassemble_info *);
+extern int print_insn_vax (bfd_vma, disassemble_info *);
+extern int print_insn_w65 (bfd_vma, disassemble_info *);
+extern int print_insn_xstormy16 (bfd_vma, disassemble_info *);
+extern int print_insn_xtensa (bfd_vma, disassemble_info *);
+extern int print_insn_sh64 (bfd_vma, disassemble_info *);
+extern int print_insn_sh64x_media (bfd_vma, disassemble_info *);
+extern int print_insn_frv (bfd_vma, disassemble_info *);
+extern int print_insn_iq2000 (bfd_vma, disassemble_info *);
+extern int print_insn_m32c (bfd_vma, disassemble_info *);
+
+extern disassembler_ftype arc_get_disassembler (void *);
+extern disassembler_ftype cris_get_disassembler (bfd *);
+
+extern void print_mips_disassembler_options (FILE *);
+extern void print_ppc_disassembler_options (FILE *);
+extern void print_arm_disassembler_options (FILE *);
+extern void parse_arm_disassembler_option (char *);
+extern int get_arm_regname_num_options (void);
+extern int set_arm_regname_option (int);
+extern int get_arm_regnames (int, const char **, const char **, const char *const **);
+extern bfd_boolean arm_symbol_is_valid (asymbol *, struct disassemble_info *);
+
+/* Fetch the disassembler for a given BFD, if that support is available. */
+extern disassembler_ftype disassembler (bfd *);
+
+/* Amend the disassemble_info structure as necessary for the target architecture.
+ Should only be called after initialising the info->arch field. */
+extern void disassemble_init_for_target (struct disassemble_info * info);
+
+/* Document any target specific options available from the disassembler. */
+extern void disassembler_usage (FILE *);
+
+
+/* This block of definitions is for particular callers who read instructions
+ into a buffer before calling the instruction decoder. */
+
+/* Here is a function which callers may wish to use for read_memory_func.
+ It gets bytes from a buffer. */
+extern int buffer_read_memory
+ (bfd_vma, bfd_byte *, unsigned int, struct disassemble_info *);
+
+/* This function goes with buffer_read_memory.
+ It prints a message using info->fprintf_func and info->stream. */
+extern void perror_memory (int, bfd_vma, struct disassemble_info *);
+
+
+/* Just print the address in hex. This is included for completeness even
+ though both GDB and objdump provide their own (to print symbolic
+ addresses). */
+extern void generic_print_address
+ (bfd_vma, struct disassemble_info *);
+
+/* Always true. */
+extern int generic_symbol_at_address
+ (bfd_vma, struct disassemble_info *);
+
+/* Also always true. */
+extern bfd_boolean generic_symbol_is_valid
+ (asymbol *, struct disassemble_info *);
+
+/* Method to initialize a disassemble_info struct. This should be
+ called by all applications creating such a struct. */
+extern void init_disassemble_info (struct disassemble_info *info, void *stream,
+ fprintf_ftype fprintf_func);
+
+/* For compatibility with existing code. */
+#define INIT_DISASSEMBLE_INFO(INFO, STREAM, FPRINTF_FUNC) \
+ init_disassemble_info (&(INFO), (STREAM), (fprintf_ftype) (FPRINTF_FUNC))
+#define INIT_DISASSEMBLE_INFO_NO_ARCH(INFO, STREAM, FPRINTF_FUNC) \
+ init_disassemble_info (&(INFO), (STREAM), (fprintf_ftype) (FPRINTF_FUNC))
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* ! defined (DIS_ASM_H) */
Index: linux/include/linux/kdb.h
===================================================================
--- /dev/null
+++ linux/include/linux/kdb.h
@@ -0,0 +1,162 @@
+#ifndef _KDB_H
+#define _KDB_H
+
+/*
+ * Kernel Debugger Architecture Independent Global Headers
+ *
+ * This file is subject to the terms and conditions of the GNU General Public
+ * License. See the file "COPYING" in the main directory of this archive
+ * for more details.
+ *
+ * Copyright (c) 2000-2007 Silicon Graphics, Inc. All Rights Reserved.
+ * Copyright (C) 2000 Stephane Eranian <eranian@hpl.hp.com>
+ */
+
+#include <linux/init.h>
+#include <linux/sched.h>
+#include <asm/atomic.h>
+
+#ifdef CONFIG_KDB
+/* These are really private, but they must be defined before including
+ * asm-$(ARCH)/kdb.h, so make them public and put them here.
+ */
+extern int kdb_getuserarea_size(void *, unsigned long, size_t);
+extern int kdb_putuserarea_size(unsigned long, void *, size_t);
+
+#include <asm/kdb.h>
+#endif
+
+#define KDB_MAJOR_VERSION 4
+#define KDB_MINOR_VERSION 4
+#define KDB_TEST_VERSION ""
+
+/*
+ * kdb_initial_cpu is initialized to -1, and is set to the cpu
+ * number whenever the kernel debugger is entered.
+ */
+extern volatile int kdb_initial_cpu;
+extern atomic_t kdb_event;
+extern atomic_t kdb_8250;
+#ifdef CONFIG_KDB
+#define KDB_IS_RUNNING() (kdb_initial_cpu != -1)
+#define KDB_8250() (atomic_read(&kdb_8250) != 0)
+#else
+#define KDB_IS_RUNNING() (0)
+#define KDB_8250() (0)
+#endif /* CONFIG_KDB */
+
+/*
+ * kdb_on
+ *
+ * Defines whether kdb is on or not. Default value
+ * is set by CONFIG_KDB_OFF. Boot with kdb=on/off/on-nokey
+ * or echo "[012]" > /proc/sys/kernel/kdb to change it.
+ */
+extern int kdb_on;
+
+#if defined(CONFIG_SERIAL_8250_CONSOLE) || defined(CONFIG_SERIAL_SGI_L1_CONSOLE)
+/*
+ * kdb_serial.iobase is initialized to zero, and is set to the I/O
+ * address of the serial port when the console is setup in
+ * serial_console_setup.
+ */
+extern struct kdb_serial {
+ int io_type;
+ unsigned long iobase;
+ unsigned long ioreg_shift;
+} kdb_serial;
+#endif
+
+/*
+ * kdb_diemsg
+ *
+ * Contains a pointer to the last string supplied to the
+ * kernel 'die' panic function.
+ */
+extern const char *kdb_diemsg;
+
+#define KDB_FLAG_EARLYKDB (1 << 0) /* set from boot parameter kdb=early */
+#define KDB_FLAG_CATASTROPHIC (1 << 1) /* A catastrophic event has occurred */
+#define KDB_FLAG_CMD_INTERRUPT (1 << 2) /* Previous command was interrupted */
+#define KDB_FLAG_NOIPI (1 << 3) /* Do not send IPIs */
+#define KDB_FLAG_ONLY_DO_DUMP (1 << 4) /* Only do a dump, used when kdb is off */
+#define KDB_FLAG_NO_CONSOLE (1 << 5) /* No console is available, kdb is disabled */
+#define KDB_FLAG_NO_VT_CONSOLE (1 << 6) /* No VT console is available, do not use keyboard */
+#define KDB_FLAG_NO_I8042 (1 << 7) /* No i8042 chip is available, do not use keyboard */
+#define KDB_FLAG_RECOVERY (1 << 8) /* kdb is being entered for an error which has been recovered */
+
+extern volatile int kdb_flags; /* Global flags, see kdb_state for per cpu state */
+
+extern void kdb_save_flags(void);
+extern void kdb_restore_flags(void);
+
+#define KDB_FLAG(flag) (kdb_flags & KDB_FLAG_##flag)
+#define KDB_FLAG_SET(flag) ((void)(kdb_flags |= KDB_FLAG_##flag))
+#define KDB_FLAG_CLEAR(flag) ((void)(kdb_flags &= ~KDB_FLAG_##flag))
+
+/*
+ * External entry point for the kernel debugger. The pt_regs
+ * at the time of entry are supplied along with the reason for
+ * entry to the kernel debugger.
+ */
+
+typedef enum {
+ KDB_REASON_ENTER=1, /* KDB_ENTER() trap/fault - regs valid */
+ KDB_REASON_ENTER_SLAVE, /* KDB_ENTER_SLAVE() trap/fault - regs valid */
+ KDB_REASON_BREAK, /* Breakpoint inst. - regs valid */
+ KDB_REASON_DEBUG, /* Debug Fault - regs valid */
+ KDB_REASON_OOPS, /* Kernel Oops - regs valid */
+ KDB_REASON_SWITCH, /* CPU switch - regs valid*/
+ KDB_REASON_KEYBOARD, /* Keyboard entry - regs valid */
+ KDB_REASON_NMI, /* Non-maskable interrupt; regs valid */
+ KDB_REASON_RECURSE, /* Recursive entry to kdb; regs probably valid */
+ KDB_REASON_CPU_UP, /* Add one cpu to kdb; regs invalid */
+ KDB_REASON_SILENT, /* Silent entry/exit to kdb; regs invalid - internal only */
+} kdb_reason_t;
+
+#ifdef CONFIG_KDB
+extern int kdb(kdb_reason_t, int, struct pt_regs *);
+#else
+#define kdb(reason,error_code,frame) (0)
+#endif
+
+/* Mainly used by kdb code, but this function is sometimes used
+ * by hacked debug code so make it generally available, not private.
+ */
+extern void kdb_printf(const char *,...)
+ __attribute__ ((format (printf, 1, 2)));
+typedef void (*kdb_printf_t)(const char *, ...)
+ __attribute__ ((format (printf, 1, 2)));
+extern void kdb_init(void);
+
+#if defined(CONFIG_SMP)
+/*
+ * Kernel debugger non-maskable IPI handler.
+ */
+extern int kdb_ipi(struct pt_regs *, void (*ack_interrupt)(void));
+extern void smp_kdb_stop(void);
+#else /* CONFIG_SMP */
+#define smp_kdb_stop()
+#endif /* CONFIG_SMP */
+
+#ifdef CONFIG_KDB_USB
+
+#include <linux/usb.h>
+
+extern int kdb_usb_keyboard_attach(struct urb *urb, unsigned char *buffer, void *poll_func);
+extern int kdb_usb_keyboard_detach(struct urb *urb);
+
+#endif /* CONFIG_KDB_USB */
+
+static inline
+int kdb_process_cpu(const struct task_struct *p)
+{
+ unsigned int cpu = task_thread_info(p)->cpu;
+ if (cpu > NR_CPUS)
+ cpu = 0;
+ return cpu;
+}
+
+extern const char kdb_serial_str[];
+
+#endif /* !_KDB_H */
Index: linux/include/linux/kdbprivate.h
===================================================================
--- /dev/null
+++ linux/include/linux/kdbprivate.h
@@ -0,0 +1,497 @@
+#ifndef _KDBPRIVATE_H
+#define _KDBPRIVATE_H
+
+/*
+ * Kernel Debugger Architecture Independent Private Headers
+ *
+ * This file is subject to the terms and conditions of the GNU General Public
+ * License. See the file "COPYING" in the main directory of this archive
+ * for more details.
+ *
+ * Copyright (c) 2000-2004 Silicon Graphics, Inc. All Rights Reserved.
+ */
+
+
+#include <linux/dis-asm.h>
+#include <asm/kdbprivate.h>
+#include <asm/bfd.h>
+
+ /*
+ * Kernel Debugger Error codes. Must not overlap with command codes.
+ */
+
+#define KDB_NOTFOUND (-1)
+#define KDB_ARGCOUNT (-2)
+#define KDB_BADWIDTH (-3)
+#define KDB_BADRADIX (-4)
+#define KDB_NOTENV (-5)
+#define KDB_NOENVVALUE (-6)
+#define KDB_NOTIMP (-7)
+#define KDB_ENVFULL (-8)
+#define KDB_ENVBUFFULL (-9 )
+#define KDB_TOOMANYBPT (-10)
+#define KDB_TOOMANYDBREGS (-11)
+#define KDB_DUPBPT (-12)
+#define KDB_BPTNOTFOUND (-13)
+#define KDB_BADMODE (-14)
+#define KDB_BADINT (-15)
+#define KDB_INVADDRFMT (-16)
+#define KDB_BADREG (-17)
+#define KDB_BADCPUNUM (-18)
+#define KDB_BADLENGTH (-19)
+#define KDB_NOBP (-20)
+#define KDB_BADADDR (-21)
+
+ /*
+ * Kernel Debugger Command codes. Must not overlap with error codes.
+ */
+#define KDB_CMD_GO (-1001)
+#define KDB_CMD_CPU (-1002)
+#define KDB_CMD_SS (-1003)
+#define KDB_CMD_SSB (-1004)
+
+ /*
+ * Internal debug flags
+ */
+/* KDB_DEBUG_FLAG_BT 0x0001 Was Stack traceback debug */
+#define KDB_DEBUG_FLAG_BP 0x0002 /* Breakpoint subsystem debug */
+#define KDB_DEBUG_FLAG_BB_SUMM 0x0004 /* Basic block analysis, summary only */
+#define KDB_DEBUG_FLAG_AR 0x0008 /* Activation record, generic */
+#define KDB_DEBUG_FLAG_ARA 0x0010 /* Activation record, arch specific */
+#define KDB_DEBUG_FLAG_BB 0x0020 /* All basic block analysis */
+#define KDB_DEBUG_FLAG_STATE 0x0040 /* State flags */
+#define KDB_DEBUG_FLAG_MASK 0xffff /* All debug flags */
+#define KDB_DEBUG_FLAG_SHIFT 16 /* Shift factor for dbflags */
+
+#define KDB_DEBUG(flag) (kdb_flags & (KDB_DEBUG_FLAG_##flag << KDB_DEBUG_FLAG_SHIFT))
+#define KDB_DEBUG_STATE(text,value) if (KDB_DEBUG(STATE)) kdb_print_state(text, value)
+
+typedef enum {
+ KDB_REPEAT_NONE = 0, /* Do not repeat this command */
+ KDB_REPEAT_NO_ARGS, /* Repeat the command without arguments */
+ KDB_REPEAT_WITH_ARGS, /* Repeat the command including its arguments */
+} kdb_repeat_t;
+
+typedef int (*kdb_func_t)(int, const char **);
+
+ /*
+ * Symbol table format returned by kallsyms.
+ */
+
+typedef struct __ksymtab {
+ unsigned long value; /* Address of symbol */
+ const char *mod_name; /* Module containing symbol or "kernel" */
+ unsigned long mod_start;
+ unsigned long mod_end;
+ const char *sec_name; /* Section containing symbol */
+ unsigned long sec_start;
+ unsigned long sec_end;
+ const char *sym_name; /* Full symbol name, including any version */
+ unsigned long sym_start;
+ unsigned long sym_end;
+ } kdb_symtab_t;
+extern int kallsyms_symbol_next(char *prefix_name, int flag);
+extern int kallsyms_symbol_complete(char *prefix_name, int max_len);
+
+ /*
+ * Exported Symbols for kernel loadable modules to use.
+ */
+extern int kdb_register(char *, kdb_func_t, char *, char *, short);
+extern int kdb_register_repeat(char *, kdb_func_t, char *, char *, short, kdb_repeat_t);
+extern int kdb_unregister(char *);
+
+extern int kdb_getarea_size(void *, unsigned long, size_t);
+extern int kdb_putarea_size(unsigned long, void *, size_t);
+
+/* Like get_user and put_user, kdb_getarea and kdb_putarea take variable
+ * names, not pointers. The underlying *_size functions take pointers.
+ */
+#define kdb_getarea(x,addr) kdb_getarea_size(&(x), addr, sizeof((x)))
+#define kdb_putarea(addr,x) kdb_putarea_size(addr, &(x), sizeof((x)))
+
+extern int kdb_getphysword(unsigned long *word,
+ unsigned long addr, size_t size);
+extern int kdb_getword(unsigned long *, unsigned long, size_t);
+extern int kdb_putword(unsigned long, unsigned long, size_t);
+
+extern int kdbgetularg(const char *, unsigned long *);
+extern char *kdbgetenv(const char *);
+extern int kdbgetintenv(const char *, int *);
+extern int kdbgetaddrarg(int, const char**, int*, unsigned long *,
+ long *, char **);
+extern int kdbgetsymval(const char *, kdb_symtab_t *);
+extern int kdbnearsym(unsigned long, kdb_symtab_t *);
+extern void kdbnearsym_cleanup(void);
+extern char *kdb_read(char *buffer, size_t bufsize);
+extern char *kdb_strdup(const char *str, gfp_t type);
+extern void kdb_symbol_print(kdb_machreg_t, const kdb_symtab_t *, unsigned int);
+
+ /*
+ * Do we have a set of registers?
+ */
+
+#define KDB_NULL_REGS(regs) \
+ (regs == (struct pt_regs *)NULL ? kdb_printf("%s: null regs - should never happen\n", __FUNCTION__), 1 : 0)
+
+ /*
+ * Routine for debugging the debugger state.
+ */
+
+extern void kdb_print_state(const char *, int);
+
+ /*
+ * Per cpu kdb state. A cpu can be under kdb control but outside kdb,
+ * for example when doing single step.
+ */
+volatile extern int kdb_state[ /*NR_CPUS*/ ];
+#define KDB_STATE_KDB 0x00000001 /* Cpu is inside kdb */
+#define KDB_STATE_LEAVING 0x00000002 /* Cpu is leaving kdb */
+#define KDB_STATE_CMD 0x00000004 /* Running a kdb command */
+#define KDB_STATE_KDB_CONTROL 0x00000008 /* This cpu is under kdb control */
+#define KDB_STATE_HOLD_CPU 0x00000010 /* Hold this cpu inside kdb */
+#define KDB_STATE_DOING_SS 0x00000020 /* Doing ss command */
+#define KDB_STATE_DOING_SSB 0x00000040 /* Doing ssb command, DOING_SS is also set */
+#define KDB_STATE_SSBPT 0x00000080 /* Install breakpoint after one ss, independent of DOING_SS */
+#define KDB_STATE_REENTRY 0x00000100 /* Valid re-entry into kdb */
+#define KDB_STATE_SUPPRESS 0x00000200 /* Suppress error messages */
+#define KDB_STATE_LONGJMP 0x00000400 /* longjmp() data is available */
+#define KDB_STATE_GO_SWITCH 0x00000800 /* go is switching back to initial cpu */
+#define KDB_STATE_PRINTF_LOCK 0x00001000 /* Holds kdb_printf lock */
+#define KDB_STATE_WAIT_IPI 0x00002000 /* Waiting for kdb_ipi() NMI */
+#define KDB_STATE_RECURSE 0x00004000 /* Recursive entry to kdb */
+#define KDB_STATE_IP_ADJUSTED 0x00008000 /* Restart IP has been adjusted */
+#define KDB_STATE_GO1 0x00010000 /* go only releases one cpu */
+#define KDB_STATE_KEYBOARD 0x00020000 /* kdb entered via keyboard on this cpu */
+#define KDB_STATE_ARCH 0xff000000 /* Reserved for arch specific use */
+
+#define KDB_STATE_CPU(flag,cpu) (kdb_state[cpu] & KDB_STATE_##flag)
+#define KDB_STATE_SET_CPU(flag,cpu) ((void)(kdb_state[cpu] |= KDB_STATE_##flag))
+#define KDB_STATE_CLEAR_CPU(flag,cpu) ((void)(kdb_state[cpu] &= ~KDB_STATE_##flag))
+
+#define KDB_STATE(flag) KDB_STATE_CPU(flag,smp_processor_id())
+#define KDB_STATE_SET(flag) KDB_STATE_SET_CPU(flag,smp_processor_id())
+#define KDB_STATE_CLEAR(flag) KDB_STATE_CLEAR_CPU(flag,smp_processor_id())
+
+ /*
+ * kdb_nextline
+ *
+ * Contains the current line number on the screen. Used
+ * to handle the built-in pager (LINES env variable)
+ */
+extern volatile int kdb_nextline;
+
+ /*
+ * Breakpoint state
+ *
+ * Each active and inactive breakpoint is represented by
+ * an instance of the following data structure.
+ */
+
+typedef struct _kdb_bp {
+ bfd_vma bp_addr; /* Address breakpoint is present at */
+ kdb_machinst_t bp_inst; /* Replaced instruction */
+
+ unsigned int bp_free:1; /* This entry is available */
+
+ unsigned int bp_enabled:1; /* Breakpoint is active in register */
+ unsigned int bp_global:1; /* Global to all processors */
+
+ unsigned int bp_hardtype:1; /* Uses hardware register */
+ unsigned int bp_forcehw:1; /* Force hardware register */
+ unsigned int bp_installed:1; /* Breakpoint is installed */
+ unsigned int bp_delay:1; /* Do delayed bp handling */
+ unsigned int bp_delayed:1; /* Delayed breakpoint */
+
+ int bp_cpu; /* Cpu # (if bp_global == 0) */
+ kdbhard_bp_t bp_template; /* Hardware breakpoint template */
+ kdbhard_bp_t *bp_hard; /* Hardware breakpoint structure */
+ int bp_adjust; /* Adjustment to PC for real instruction */
+} kdb_bp_t;
+
+ /*
+ * Breakpoint handling subsystem global variables
+ */
+extern kdb_bp_t kdb_breakpoints[/* KDB_MAXBPT */];
+
+ /*
+ * Breakpoint architecture dependent functions. Must be provided
+ * in some form for all architectures.
+ */
+extern void kdba_initbp(void);
+extern void kdba_printbp(kdb_bp_t *);
+extern kdbhard_bp_t *kdba_allocbp(kdbhard_bp_t *, int *);
+extern void kdba_freebp(kdbhard_bp_t *);
+extern int kdba_parsebp(int, const char**, int *, kdb_bp_t*);
+extern char *kdba_bptype(kdbhard_bp_t *);
+extern void kdba_setsinglestep(struct pt_regs *);
+extern void kdba_clearsinglestep(struct pt_regs *);
+
+ /*
+ * Adjust instruction pointer architecture dependent function. Must be
+ * provided in some form for all architectures.
+ */
+extern void kdba_adjust_ip(kdb_reason_t, int, struct pt_regs *);
+
+ /*
+ * KDB-only global function prototypes.
+ */
+extern void kdb_id1(unsigned long);
+extern void kdb_id_init(void);
+
+ /*
+ * Initialization functions.
+ */
+extern void kdba_init(void);
+extern void kdb_io_init(void);
+
+ /*
+ * Architecture specific function to read a string.
+ */
+typedef int (*get_char_func)(void);
+extern get_char_func poll_funcs[];
+
+#ifndef CONFIG_IA64
+ /*
+ * Data for a single activation record on stack.
+ */
+
+struct kdb_stack_info {
+ kdb_machreg_t physical_start;
+ kdb_machreg_t physical_end;
+ kdb_machreg_t logical_start;
+ kdb_machreg_t logical_end;
+ kdb_machreg_t next;
+ const char * id;
+};
+
+typedef struct { DECLARE_BITMAP(bits, KDBA_MAXARGS); } valid_t;
+
+struct kdb_activation_record {
+ struct kdb_stack_info stack; /* information about current stack */
+ int args; /* number of arguments detected */
+ kdb_machreg_t arg[KDBA_MAXARGS]; /* -> arguments */
+ valid_t valid; /* is argument n valid? */
+};
+#endif
+
+ /*
+ * Architecture specific Stack Traceback functions.
+ */
+
+struct task_struct;
+
+extern int kdba_bt_address(kdb_machreg_t, int);
+extern int kdba_bt_process(const struct task_struct *, int);
+
+ /*
+ * KDB Command Table
+ */
+
+typedef struct _kdbtab {
+ char *cmd_name; /* Command name */
+ kdb_func_t cmd_func; /* Function to execute command */
+ char *cmd_usage; /* Usage String for this command */
+ char *cmd_help; /* Help message for this command */
+ short cmd_flags; /* Parsing flags */
+ short cmd_minlen; /* Minimum legal # command chars required */
+ kdb_repeat_t cmd_repeat; /* Does command auto repeat on enter? */
+} kdbtab_t;
+
+ /*
+ * External command function declarations
+ */
+
+extern int kdb_id(int, const char **);
+extern int kdb_bt(int, const char **);
+
+ /*
+ * External utility function declarations
+ */
+extern char* kdb_getstr(char *, size_t, char *);
+
+ /*
+ * Register contents manipulation
+ */
+extern int kdba_getregcontents(const char *, struct pt_regs *, kdb_machreg_t *);
+extern int kdba_setregcontents(const char *, struct pt_regs *, kdb_machreg_t);
+extern int kdba_dumpregs(struct pt_regs *, const char *, const char *);
+extern int kdba_setpc(struct pt_regs *, kdb_machreg_t);
+extern kdb_machreg_t kdba_getpc(struct pt_regs *);
+
+ /*
+ * Debug register handling.
+ */
+extern void kdba_installdbreg(kdb_bp_t*);
+extern void kdba_removedbreg(kdb_bp_t*);
+
+ /*
+ * Breakpoint handling - External interfaces
+ */
+extern void kdb_initbptab(void);
+extern void kdb_bp_install_global(struct pt_regs *);
+extern void kdb_bp_install_local(struct pt_regs *);
+extern void kdb_bp_remove_global(void);
+extern void kdb_bp_remove_local(void);
+
+ /*
+ * Breakpoint handling - Internal to kdb_bp.c/kdba_bp.c
+ */
+extern int kdba_installbp(struct pt_regs *regs, kdb_bp_t *);
+extern int kdba_removebp(kdb_bp_t *);
+
+
+typedef enum {
+ KDB_DB_BPT, /* Breakpoint */
+ KDB_DB_SS, /* Single-step trap */
+ KDB_DB_SSB, /* Single step to branch */
+ KDB_DB_SSBPT, /* Single step over breakpoint */
+ KDB_DB_NOBPT /* Spurious breakpoint */
+} kdb_dbtrap_t;
+
+extern kdb_dbtrap_t kdba_db_trap(struct pt_regs *, int); /* DEBUG trap/fault handler */
+extern kdb_dbtrap_t kdba_bp_trap(struct pt_regs *, int); /* Breakpoint trap/fault hdlr */
+
+ /*
+ * Interrupt Handling
+ */
+typedef unsigned long kdb_intstate_t;
+
+extern void kdba_disableint(kdb_intstate_t *);
+extern void kdba_restoreint(kdb_intstate_t *);
+
+ /*
+ * SMP and process stack manipulation routines.
+ */
+extern int kdba_ipi(struct pt_regs *, void (*)(void));
+extern int kdba_main_loop(kdb_reason_t, kdb_reason_t, int, kdb_dbtrap_t, struct pt_regs *);
+extern int kdb_main_loop(kdb_reason_t, kdb_reason_t, int, kdb_dbtrap_t, struct pt_regs *);
+
+ /*
+ * General Disassembler interfaces
+ */
+extern int kdb_dis_fprintf(PTR, const char *, ...) __attribute__ ((format (printf, 2, 3)));
+extern int kdb_dis_fprintf_dummy(PTR, const char *, ...) __attribute__ ((format (printf, 2, 3)));
+extern disassemble_info kdb_di;
+
+ /*
+ * Architecture Dependent Disassembler interfaces
+ */
+extern int kdba_id_printinsn(kdb_machreg_t, disassemble_info *);
+extern int kdba_id_parsemode(const char *, disassemble_info*);
+extern void kdba_id_init(disassemble_info *);
+extern void kdba_check_pc(kdb_machreg_t *);
+
+ /*
+ * Miscellaneous functions and data areas
+ */
+extern char *kdb_cmds[];
+extern void kdb_syslog_data(char *syslog_data[]);
+extern unsigned long kdb_task_state_string(const char *);
+extern char kdb_task_state_char (const struct task_struct *);
+extern unsigned long kdb_task_state(const struct task_struct *p, unsigned long mask);
+extern void kdb_ps_suppressed(void);
+extern void kdb_ps1(const struct task_struct *p);
+extern int kdb_parse(const char *cmdstr);
+extern void kdb_print_nameval(const char *name, unsigned long val);
+extern void kdb_send_sig_info(struct task_struct *p, struct siginfo *info, int seqno);
+#ifdef CONFIG_SWAP
+extern void kdb_si_swapinfo(struct sysinfo *);
+#else
+#include <linux/swap.h>
+#define kdb_si_swapinfo(x) si_swapinfo(x)
+#endif
+extern void kdb_meminfo_read_proc(void);
+#ifdef CONFIG_HUGETLB_PAGE
+extern void kdb_hugetlb_report_meminfo(void);
+#endif /* CONFIG_HUGETLB_PAGE */
+extern const char *kdb_walk_kallsyms(loff_t *pos);
+
+ /*
+ * Architecture Dependant Local Processor setup & cleanup interfaces
+ */
+extern void kdba_local_arch_setup(void);
+extern void kdba_local_arch_cleanup(void);
+
+ /*
+ * Defines for kdb_symbol_print.
+ */
+#define KDB_SP_SPACEB 0x0001 /* Space before string */
+#define KDB_SP_SPACEA 0x0002 /* Space after string */
+#define KDB_SP_PAREN 0x0004 /* Parenthesis around string */
+#define KDB_SP_VALUE 0x0008 /* Print the value of the address */
+#define KDB_SP_SYMSIZE 0x0010 /* Print the size of the symbol */
+#define KDB_SP_NEWLINE 0x0020 /* Newline after string */
+#define KDB_SP_DEFAULT (KDB_SP_VALUE|KDB_SP_PAREN)
+
+/* Save data about running processes */
+
+struct kdb_running_process {
+ struct task_struct *p;
+ struct pt_regs *regs;
+ int seqno; /* kdb sequence number */
+ int irq_depth; /* irq count */
+ struct kdba_running_process arch; /* arch dependent save data */
+};
+
+extern struct kdb_running_process kdb_running_process[/* NR_CPUS */];
+
+extern int kdb_save_running(struct pt_regs *, kdb_reason_t, kdb_reason_t, int, kdb_dbtrap_t);
+extern void kdb_unsave_running(struct pt_regs *);
+extern struct task_struct *kdb_curr_task(int);
+
+/* Incremented each time the main kdb loop is entered on the initial cpu,
+ * it gives some indication of how old the saved data is.
+ */
+extern int kdb_seqno;
+
+#define kdb_task_has_cpu(p) (task_curr(p))
+extern void kdb_runqueue(unsigned long cpu, kdb_printf_t xxx_printf);
+
+/* Simplify coexistence with NPTL */
+#define kdb_do_each_thread(g, p) do_each_thread(g, p)
+#define kdb_while_each_thread(g, p) while_each_thread(g, p)
+
+#define GFP_KDB (in_interrupt() ? GFP_ATOMIC : GFP_KERNEL)
+
+extern void *debug_kmalloc(size_t size, gfp_t flags);
+extern void debug_kfree(void *);
+extern void debug_kusage(void);
+
+extern void kdba_set_current_task(const struct task_struct *);
+extern const struct task_struct *kdb_current_task;
+extern struct pt_regs *kdb_current_regs;
+
+/* Functions to safely read and write kernel areas. The {to,from}_xxx
+ * addresses are not necessarily valid, these functions must check for
+ * validity. If the arch already supports get and put routines with suitable
+ * validation and/or recovery on invalid addresses then use those routines,
+ * otherwise check it yourself.
+ */
+
+extern int kdba_putarea_size(unsigned long to_xxx, void *from, size_t size);
+extern int kdba_getarea_size(void *to, unsigned long from_xxx, size_t size);
+extern int kdba_verify_rw(unsigned long addr, size_t size);
+
+#ifndef KDB_RUNNING_PROCESS_ORIGINAL
+#define KDB_RUNNING_PROCESS_ORIGINAL kdb_running_process
+#endif
+
+extern int kdb_wait_for_cpus_secs;
+extern void kdba_cpu_up(void);
+extern char kdb_prompt_str[];
+
+#define KDB_WORD_SIZE ((int)sizeof(kdb_machreg_t))
+
+#ifdef CONFIG_KDB_USB
+#include <linux/usb.h>
+
+struct kdb_usb_kbd_info {
+ struct urb *urb; /* pointer to the URB */
+ unsigned char *buffer; /* pointer to the kbd char buffer */
+ int (*poll_func)(struct urb *urb); /* poll function to retrieve chars */
+ int poll_ret; /* return val from poll_func */
+ int caps_lock; /* state of the caps lock for this keyboard */
+};
+#endif /* CONFIG_KDB_USB */
+
+#endif /* !_KDBPRIVATE_H */
Index: linux/include/linux/sysctl.h
===================================================================
--- linux.orig/include/linux/sysctl.h
+++ linux/include/linux/sysctl.h
@@ -163,6 +163,7 @@ enum
KERN_MAX_LOCK_DEPTH=74,
KERN_NMI_WATCHDOG=75, /* int: enable/disable nmi watchdog */
KERN_PANIC_ON_NMI=76, /* int: whether we will panic on an unrecovered */
+ KERN_KDB=77, /* int: kdb on/off */
};
Index: linux/init/main.c
===================================================================
--- linux.orig/init/main.c
+++ linux/init/main.c
@@ -69,6 +69,10 @@
#include <asm/smp.h>
#endif
+#ifdef CONFIG_KDB
+#include <linux/kdb.h>
+#endif /* CONFIG_KDB */
+
/*
* This is one of the first .c files built. Error out early if we have compiler
* trouble.
@@ -193,6 +197,26 @@ static const char *panic_later, *panic_p
extern struct obs_kernel_param __setup_start[], __setup_end[];
+#ifdef CONFIG_KDB
+static int __init kdb_setup(char *str)
+{
+ if (strcmp(str, "on") == 0) {
+ kdb_on = 1;
+ } else if (strcmp(str, "on-nokey") == 0) {
+ kdb_on = 2;
+ } else if (strcmp(str, "off") == 0) {
+ kdb_on = 0;
+ } else if (strcmp(str, "early") == 0) {
+ kdb_on = 1;
+ kdb_flags |= KDB_FLAG_EARLYKDB;
+ } else
+ printk("kdb flag %s not recognised\n", str);
+ return 0;
+}
+
+__setup("kdb=", kdb_setup);
+#endif /* CONFIG_KDB */
+
static int __init obsolete_checksetup(char *line)
{
struct obs_kernel_param *p;
@@ -619,6 +643,14 @@ asmlinkage void __init start_kernel(void
pgtable_cache_init();
prio_tree_init();
anon_vma_init();
+
+#ifdef CONFIG_KDB
+ kdb_init();
+ if (KDB_FLAG(EARLYKDB)) {
+ KDB_ENTER();
+ }
+#endif /* CONFIG_KDB */
+
#ifdef CONFIG_X86
if (efi_enabled)
efi_enter_virtual_mode();
Index: linux/kdb/ChangeLog
===================================================================
--- /dev/null
+++ linux/kdb/ChangeLog
@@ -0,0 +1,1894 @@
+2008-04-17 Jay Lan <jlan@sgi.com>
+
+ * kdb-v4.4-2.6.25-common-1.
+
+2008-03-16 Jay Lan <jlan@sgi.com>
+
+ * kdb-v4.4-2.6.25-rc6-common-1.
+
+2008-03-03 Jay Lan <jlan@sgi.com>
+
+ * kdb-v4.4-2.6.25-rc3-common-1.
+
+2008-02-26 Jay Lan <jlan@sgi.com>
+
+ * remove 'fastcall' from kdb code.
+ * kdb-v4.4-2.6.25-rc2-common-1.
+
+2008-02-19 Jay Lan <jlan@sgi.com>
+
+ * kdb-v4.4-2.6.25-rc1-common-1.
+
+2008-02-06 Jay Lan <jlan@sgi.com>
+
+ * Backed out USB UHCI support since it caused dropped characters and
+ broke OHCI.
+ * Restored "archkdbcommon" commands for x86. It was lost at the x86
+ merge.
+ * Detecting if the HC was "busy", Aaron Young <ayoung@sgi.com>
+ * kdb-v4.4-2.6.24-common-2.
+
+2008-01-29 Jay Lan <jlan@sgi.com>
+
+ * kdb-v4.4-2.6.24-common-1.
+
+2008-01-22 Jay Lan <jlan@sgi.com>
+
+ * USB UHCI kdb support, Konstantin Baydarov <kbaidarov@ru.mvista.com>
+ * kdb-v4.4-2.6.24-rc8-common-3.
+
+2008-01-18 Jay Lan <jlan@sgi.com>
+
+ * USB EHCI kdb support, Aaron Young <ayoung@sgi.com>
+ * kdb-v4.4-2.6.24-rc8-common-2.
+
+2008-01-18 Jay Lan <jlan@sgi.com>
+
+ * kdb-v4.4-2.6.24-rc8-common-1.
+
+2008-01-07 Jay Lan <jlan@sgi.com>
+
+ * kdb-v4.4-2.6.24-rc7-common-1.
+
+2007-12-21 Jay Lan <jlan@sgi.com>
+
+ * Renamed kdb/kdba_bt_x86.c to arch/x86/kdba_bt.c. And thus, the x86
+ backtrace code is now moved into the kdb x86 patch.
+ * kdb v4.4-2.6.24-rc6-common-1.
+
+2007-12-12 Jay Lan <jlan@sgi.com>
+
+ * kdb v4.4-2.6.24-rc5-common-1.
+
+2007-12-05 Jay Lan <jlan@sgi.com>
+
+ * Fixed a 'sysctl table check failed' problem.
+ * kdb v4.4-2.6.24-rc4-common-1.
+
+2007-11-26 Jay Lan <jlan@sgi.com>
+
+ * kdb v4.4-2.6.24-rc3-common-1.
+
+2007-11-13 Jay Lan <jlan@sgi.com>
+
+ * Back ported "New KDB USB interface" from Aaron Young in
+ v4.4-2.6.23-common-2 to 2.6.24 kdb patchset.
+ * kdb v4.4-2.6.24-rc2-common-2.
+
+2007-11-12 Jay Lan <jlan@sgi.com>
+
+ * kdb v4.4-2.6.24-rc2-common-1.
+
+2007-11-09 Jay Lan <jlan@sgi.com>
+
+ * Rebase to 2.6.24-rc1 kernel
+ * - merged kdb-v4.4-2.6.23-i386-1 and kdb-v4.4-2.6.23-x86_64-1
+ * into kdb-v4.4-2.6.24-rc1-x86-1
+ * - Fields "done", "sglist_len", and "pid" are removed from
+ * struct scsi_cmnd. Thus, these fields are no longer displayed
+ * on "sc" command.
+ * kdb v4.4-2.6.24-rc1-common-1.
+
+2007-11-08 Jay Lan <jlan@sgi.com>
+
+ * New KDB USB interface, Aaron Young <ayoung@sgi.com>
+ * 1. This patch allows KDB to work with any Host Contoller driver
+ * and call the correct HC driver poll routine (as long as the
+ * HC driver provides a .kdb_poll_char routine via it's
+ * associated hc_driver struct).
+ * 2. Hotplugged keyboards are now recognized by KDB.
+ * 3. Currently KDB can only make use of 1 USB type keyboard.
+ * New code can handle up to 8 attached keyboards - input is
+ * multiplexed from all of them while in kdb.
+ * kdb v4.4-2.6.23-common-2.
+
+2007-10-24 Jay Lan <jlan@sgi.com>
+
+ * kdb v4.4-2.6.23-common-1.
+
+2007-09-26 Jay Lan <jlan@sgi.com>
+
+ * kdb v4.4-2.6.23-rc8-common-1.
+
+2007-09-21 Jay Lan <jlan@sgi.com>
+
+ * kdb v4.4-2.6.23-rc7-common-1.
+
+2007-09-12 Jay Lan <jlan@sgi.com>
+
+ * kdb v4.4-2.6.23-rc6-common-1.
+
+2007-09-06 Jay Lan <jlan@sgi.com>
+
+ * kdb v4.4-2.6.23-rc5-common-1.
+
+2007-08-30 Keith Owens <kaos@sgi.com>
+
+ * New i386/x86_64 backtrace requires that kdb_save_running() does not
+ exit until after kdb_main_loop() has completed.
+ * List more noret functions in i386/x86_64 backtrace code.
+ * Call to a noret function ends a basic block.
+ * After a call to a noret function, eip/rip may be pointing at the next
+ function or not, depending on function alignment. Jay Lan.
+ * kdb v4.4-2.6.23-rc4-common-2.
+
+2007-08-30 Jay Lan <jlan@sgi.com>
+
+ * kdb v4.4-2.6.23-rc4-common-1.
+
+2007-08-28 Keith Owens <kaos@sgi.com>
+
+ * kdb/kdba_bt_x86.c:
+ * Handle the variable amount of stack data that is pushed by x86_64
+ * hardware on an interrupt.
+ * Add instruction vmsave.
+ * Handle pop to %rsp.
+ * Cope with return address for functions defined as ATTRIB_NORET.
+ * Include CONFIG_DEBUG_INFO in the summary line of bb_all.
+ * Check for an interrupt that was delivered while user space was in
+ * control.
+ * A return to child_rip ends a backtrace.
+ * Ignore level2_kernel_pgt and level3_kernel_pgt data areas if they
+ * occur within the text segment.
+ * kdb v4.4-2.6.23-rc3-common-2.
+
+2007-08-24 Keith Owens <kaos@sgi.com>
+
+ * kdb v4.4-2.6.23-rc3-common-1.
+
+2007-08-24 Jay Lan <jlan@sgi.com>
+
+ * kdb/kdba_bt_x86.c:
+ * retint_kernel is only defined for CONFIG_PREEMPT.
+ * Handle assembler code for CONFIG_HIBERNATION=y.
+ * Handle assembler code for CONFIG_MATH_EMULATION=y.
+ * Handle assembler code for CONFIG_XEN=y.
+ * Handle assembler code for CONFIG_KPROBES=y.
+ * Add CC version to the bb_all header.
+ * Handle spurious label in jprobe_return.
+ * Handle stack switch in jprobe_return.
+ * Prefix register name with '%' in xadd/xchg temporary variable.
+ * Require bb_usage_mov() to handle all the special cases internally.
+ * Handle stack manipulation for kexec.
+ * Handle spurious label in kretprobe_trampoline_holder.
+ * Add instructions clgi, invlpga, rcl, rdpmc, stgi, vmclear,
+ * vmlaunch, vmload, vmptrld, vmread, vmresume, vmrun, vmwrite,
+ * xstore-rng.
+ * Exclude more 16 bit and/or real mode acpi functions from bb_all.
+ * Handle assembler stack switching code in i386 do_softirq.
+ * kdb/kdbmain.c:
+ * Add CC version to the summary output.
+ * Bump debug_kmalloc pool from 128K to 256K, some of the kernel
+ * functions have huge numbers of basic blocks and jumps between them.
+ * Correct reinstallation of breakpoints when exiting KDB.
+ * Keith Owens.
+ * kdb v4.4-2.6.23-rc2-common-2.
+
+2007-08-07 Jay Lan <jlan@sgi.com>
+
+ * kdb v4.4-2.6.23-rc2-common-1.
+
+2007-08-03 Keith Owens <kaos@sgi.com>
+
+ * kdba_bt_x86.c: Rename some variables to make the code more readable.
+ Print more debug information when merging register states and when
+ calculating the new stack pointer.
+ * kdb v4.4-2.6.23-rc1-common-2.
+
+2007-07-30 Keith Owens <kaos@sgi.com>
+
+ * kdb v4.4-2.6.23-rc1-common-1.
+
+2007-07-26 Keith Owens <kaos@sgi.com>
+
+ * New x86 backtrace code.
+ * kdb v4.4-2.6.22-common-4.
+
+2007-07-17 Keith Owens <kaos@sgi.com>
+
+ * Make kdb_printf_lock an irq lock to keep lockdep happy.
+ * kdb v4.4-2.6.22-common-3.
+
+2007-07-13 Keith Owens <kaos@sgi.com>
+
+ * Increase the size of the debug_alloc pool.
+ * Add the caller that obtained each entry in the debug_alloc pool.
+ * Poison entries in the debug_alloc pool.
+ * Track current and maximum usage in debug_alloc pool.
+ * Print the debug_alloc entries that are still in use when kdb exits
+ (memory leaks).
+ * Increase the default value of BTARGS to 9.
+ * kdb v4.4-2.6.22-common-2.
+
+2007-07-09 Keith Owens <kaos@sgi.com>
+
+ * kdb v4.4-2.6.22-common-1.
+
+2007-07-02 Keith Owens <kaos@sgi.com>
+
+ * kdb v4.4-2.6.22-rc7-common-1.
+
+2007-06-20 Keith Owens <kaos@sgi.com>
+
+ * kdb v4.4-2.6.22-rc5-common-1.
+
+2007-06-15 Keith Owens <kaos@sgi.com>
+
+ * Do not include asm/kdb.h unless CONFIG_KDB is on. Dave Jiang.
+ * kdb v4.4-2.6.22-rc4-common-2.
+
+2007-06-08 Keith Owens <kaos@sgi.com>
+
+ * kdb v4.4-2.6.22-rc4-common-1.
+
+2007-05-28 Keith Owens <kaos@sgi.com>
+
+ * kdb v4.4-2.6.22-rc3-common-1.
+
+2007-05-22 Keith Owens <kaos@sgi.com>
+
+ * kdb v4.4-2.6.22-rc2-common-1.
+
+2007-05-22 Keith Owens <kaos@sgi.com>
+
+ * kdb v4.4-2.6.22-rc1-common-1.
+
+2007-05-17 Keith Owens <kaos@sgi.com>
+
+ * Add rdmsr and wrmsr commands for i386 and x86_64. Original patch by
+ Bernardo Innocenti for i386, reworked by Keith Owens to make it safe
+ on all cpu models and to handle both i386 and x86_64.
+ * kdb v4.4-2.6.21-common-3.
+
+2007-05-15 Keith Owens <kaos@sgi.com>
+
+ * Correct alignment of debug_alloc_header.
+ * kdb v4.4-2.6.21-common-2.
+
+2007-04-29 Keith Owens <kaos@sgi.com>
+
+ * kdb v4.4-2.6.21-common-1.
+
+2007-04-16 Keith Owens <kaos@sgi.com>
+
+ * Remove dead symbol declarations.
+ * kdb v4.4-2.6.21-rc7-common-2.
+
+2007-04-16 Keith Owens <kaos@sgi.com>
+
+ * kdb v4.4-2.6.21-rc7-common-1.
+
+2007-04-10 Keith Owens <kaos@sgi.com>
+
+ * kdb v4.4-2.6.21-rc6-common-1.
+
+2007-04-02 Keith Owens <kaos@sgi.com>
+
+ * kdb v4.4-2.6.21-rc5-common-1.
+
+2007-03-19 Keith Owens <kaos@sgi.com>
+
+ * kdb v4.4-2.6.21-rc4-common-1.
+
+2007-03-14 Keith Owens <kaos@sgi.com>
+
+ * kdb v4.4-2.6.21-rc3-common-1.
+
+2007-03-14 Keith Owens <kaos@sgi.com>
+
+ * kdb v4.4-2.6.21-rc2-common-1.
+
+2007-03-01 Keith Owens <kaos@sgi.com>
+
+ * kdb v4.4-2.6.21-rc1-common-1.
+
+2007-03-01 Keith Owens <kaos@sgi.com>
+
+ * Remove sparse warnings.
+ * kdb v4.4-2.6.20-common-6.
+
+2007-02-27 Keith Owens <kaos@sgi.com>
+
+ * set_irq_regs() on entry to kdb() if they are not already set.
+ * kdb v4.4-2.6.20-common-5.
+
+2007-02-22 Keith Owens <kaos@sgi.com>
+
+ * Initialise struct disassemble_info in kdb_id1().
+ * kdb v4.4-2.6.20-common-4.
+
+2007-02-16 Keith Owens <kaos@sgi.com>
+
+ * Clean up debug_alloc_pool code.
+ * kdb v4.4-2.6.20-common-3.
+
+2007-02-16 Keith Owens <kaos@sgi.com>
+
+ * Initialise variable bits of struct disassemble_info each time.
+ * kdb v4.4-2.6.20-common-2.
+
+2007-02-06 Keith Owens <kaos@sgi.com>
+
+ * kdb v4.4-2.6.20-common-1.
+
+2007-02-01 Keith Owens <kaos@sgi.com>
+
+ * kdb v4.4-2.6.20-rc7-common-1.
+
+2007-01-08 Keith Owens <kaos@sgi.com>
+
+ * kdb v4.4-2.6.20-rc4-common-1.
+
+2007-01-02 Keith Owens <kaos@sgi.com>
+
+ * kdb v4.4-2.6.20-rc3-common-1.
+
+2006-12-21 Keith Owens <kaos@sgi.com>
+
+ * Initialize the debug_kmalloc pool on the first call, so it can be
+ used at any time.
+ * kdb v4.4-2.6.20-rc1-common-2.
+
+2006-12-20 Keith Owens <kaos@sgi.com>
+
+ * kdb v4.4-2.6.20-rc1-common-1.
+
+2006-11-30 Keith Owens <kaos@sgi.com>
+
+ * kdb v4.4-2.6.19-common-1.
+
+2006-11-30 Keith Owens <kaos@sgi.com>
+
+ * Do not access registers if kdb_current_regs is NULL.
+ * kdb v4.4-2.6.19-rc6-common-3.
+
+2006-11-27 Keith Owens <kaos@sgi.com>
+
+ * Only use VT keyboard if the command line allows it and ACPI indicates
+ that there is an i8042.
+ * Optimize kdb_read() to reduce the risk of dropping input characters.
+ * Print cpumasks as lists instead of hex, also cope with long lists.
+ * kdb v4.4-2.6.19-rc6-common-2.
+
+2006-11-20 Keith Owens <kaos@sgi.com>
+
+ * kdb v4.4-2.6.19-rc6-common-1.
+
+2006-11-09 Keith Owens <kaos@sgi.com>
+
+ * Change kdb() to fastcall.
+ * Correct loop in kdb_help(). Georg Nikodym.
+ * Only use VT console if the command line allows it.
+ * kdb v4.4-2.6.19-rc5-common-2.
+
+2006-11-08 Keith Owens <kaos@sgi.com>
+
+ * kdb v4.4-2.6.19-rc5-common-1.
+
+2006-11-01 Keith Owens <kaos@sgi.com>
+
+ * kdb v4.4-2.6.19-rc4-common-1.
+
+2006-10-24 Keith Owens <kaos@sgi.com>
+
+ * kdb v4.4-2.6.19-rc3-common-1.
+
+2006-10-24 Keith Owens <kaos@sgi.com>
+
+ * Remove redundant regs and envp parameters.
+ * kdb v4.4-2.6.19-rc2-common-2.
+
+2006-10-18 Keith Owens <kaos@sgi.com>
+
+ * kdb v4.4-2.6.19-rc2-common-1.
+
+2006-10-11 Keith Owens <kaos@sgi.com>
+
+ * Move kdbm_x86.c from the i386 to the common KDB patch.
+ * Expand kdbm_x86.c to work on x86_64 as well as i386.
+ * kdb v4.4-2.6.19-rc1-common-2.
+
+2006-10-09 Keith Owens <kaos@sgi.com>
+
+ * kdb v4.4-2.6.19-rc1-common-1.
+
+2006-10-06 Keith Owens <kaos@sgi.com>
+
+ * Remove #include <linux/config.h>
+ * kdb v4.4-2.6.18-common-2.
+
+2006-09-20 Keith Owens <kaos@sgi.com>
+
+ * kdb v4.4-2.6.18-common-1.
+
+2006-09-15 Keith Owens <kaos@sgi.com>
+
+ * kdb v4.4-2.6.18-rc7-common-1.
+
+2006-08-29 Keith Owens <kaos@sgi.com>
+
+ * Rewrite all backtrace code.
+ * kdb v4.4-2.6.18-rc5-common-2.
+
+2006-08-28 Keith Owens <kaos@sgi.com>
+
+ * kdb v4.4-2.6.18-rc5-common-1.
+
+2006-08-08 Keith Owens <kaos@sgi.com>
+
+ * kdb v4.4-2.6.18-rc4-common-1.
+
+2006-08-04 Keith Owens <kaos@sgi.com>
+
+ * kdb v4.4-2.6.18-rc3-common-1.
+
+2006-07-18 Keith Owens <kaos@sgi.com>
+
+ * 8250.c locking has been fixed so there is no need to break spinlocks
+ for keyboard entry.
+ * kdb v4.4-2.6.18-rc2-common-2.
+
+2006-07-18 Keith Owens <kaos@sgi.com>
+
+ * kdb v4.4-2.6.18-rc2-common-1.
+
+2006-07-12 Keith Owens <kaos@sgi.com>
+
+ * Remove dead KDB_REASON codes.
+ * The main kdb() function is now always entered with interrupts
+ disabled, so there is no need to disable bottom halves.
+ * sparse cleanups.
+ * kdb v4.4-2.6.18-rc1-common-2.
+
+2006-07-07 Keith Owens <kaos@sgi.com>
+
+ * kdb v4.4-2.6.18-rc1-common-1.
+
+2006-07-04 Keith Owens <kaos@sgi.com>
+
+ * Add KDB_REASON_CPU_UP and callbacks for cpus coming online.
+ * Relegate KDB_REASON_SILENT to KDB internal use only.
+ * Backout the v4.4-2.6.15-common-3 change that made KDB_REASON_SILENT
+ wait for cpus, the Dell Xeon problem has been fixed.
+ * notify_die() is not called for KDB_REASON_SILENT nor
+ KDB_REASON_CPU_UP, these events do not stay in KDB.
+ * Export kdb_current_task for kdbm_x86. SuSE patch
+ kdb-missing-export.diff
+ * Scale kdb_wait_for_cpus_secs by the number of online cpus.
+ * Delete kdb_enablehwfault, architectures now do their own setup.
+ * Delete kdba_enable_mce, architectures now do their own setup.
+ * Delete kdba_enable_lbr, kdba_disable_lbr, kdba_print_lbr,
+ page_fault_mca. Only ever implemented on x86, difficult to maintain
+ and rarely used in the field.
+ * Replace #ifdef KDB_HAVE_LONGJMP with #ifdef kdba_setjmp.
+ * kdb v4.4-2.6.17-common-2.
+
+2006-06-19 Keith Owens <kaos@sgi.com>
+
+ * kdb v4.4-2.6.17-common-1.
+
+2006-05-31 Keith Owens <kaos@sgi.com>
+
+ * Break spinlocks for keyboard entry. Hopefully a temporary hack while
+ I track down why keyboard entry to KDB is hanging.
+ * kdb v4.4-2.6.17-rc5-common-2.
+
+2006-05-25 Keith Owens <kaos@sgi.com>
+
+ * kdb v4.4-2.6.17-rc5-common-1.
+
+2006-05-15 Keith Owens <kaos@sgi.com>
+
+ * Refresh bfd related files from binutils 2.16.91.0.2.
+ * kdb v4.4-2.6.17-rc4-common-2.
+
+2006-05-12 Keith Owens <kaos@sgi.com>
+
+ * kdb v4.4-2.6.17-rc4-common-1.
+
+2006-04-28 Keith Owens <kaos@sgi.com>
+
+ * kdb v4.4-2.6.17-rc3-common-1.
+
+2006-04-22 Keith Owens <kaos@sgi.com>
+
+ * kdb v4.4-2.6.17-rc2-common-1.
+
+2006-04-11 Keith Owens <kaos@sgi.com>
+
+ * kdb v4.4-2.6.17-rc1-common-1.
+
+2006-04-05 Keith Owens <kaos@sgi.com>
+
+ * More fixes for the timing race with KDB_ENTER_SLAVE.
+ * kdb v4.4-2.6.16-common-5.
+
+2006-03-30 Keith Owens <kaos@sgi.com>
+
+ * Some code was testing KDB_IS_RUNNING() twice, which left it open to
+ races. Cache the result instead.
+ * kdb v4.4-2.6.16-common-4.
+
+2006-03-30 Keith Owens <kaos@sgi.com>
+
+ * Change CONFIG_LKCD to CONFIG_LKCD_DUMP.
+ * kdb v4.4-2.6.16-common-3.
+
+2006-03-22 Keith Owens <kaos@sgi.com>
+
+ * Add some more xpc flags. Dean Nelson, SGI.
+ * Replace open coded counter references with atomic_read().
+ * Pass early_uart_console to early_uart_setup(). Francois
+ Wellenreiter, Bull.
+ * Replace open code with for_each_online_cpu().
+ * If cpus do not come into kdb after a few seconds then let
+ architectures send a more forceful interrupt.
+ * Close a timing race with KDB_ENTER_SLAVE.
+ * kdb v4.4-2.6.16-common-2.
+
+2006-03-21 Keith Owens <kaos@sgi.com>
+
+ * kdb v4.4-2.6.16-common-1.
+
+2006-03-14 Nathan Scott <nathans@sgi.com>
+
+ * kdb v4.4-2.6.16-rc6-common-1.
+
+2006-02-28 Nathan Scott <nathans@sgi.com>
+
+ * kdb v4.4-2.6.16-rc5-common-1.
+
+2006-02-20 Nathan Scott <nathans@sgi.com>
+
+ * kdb v4.4-2.6.16-rc4-common-1.
+
+2006-02-06 Keith Owens <kaos@sgi.com>
+
+ * Change CONFIG_CRASH_DUMP to CONFIG_LKCD.
+ * Remove obsolete kdb_notifier_list.
+ * kdb v4.4-2.6.16-rc2-common-2.
+
+2006-02-06 Keith Owens <kaos@sgi.com>
+
+ * Add xpcusers command. Dean Nelson, SGI.
+ * kdb v4.4-2.6.16-rc2-common-1.
+
+2006-02-02 Keith Owens <kaos@sgi.com>
+
+ * Check if we have a console before using it for KDB.
+ * kdb v4.4-2.6.16-rc1-common-3.
+
+2006-02-01 Keith Owens <kaos@sgi.com>
+
+ * Add option 'R' to the pid command to reset to the original task.
+ * Include 'pid R' in archkdb* commands to reset up the original failing
+ task. Users may have switched to other cpus and/or tasks before
+ issuing archkdb.
+ * Compile fix for kdbm_pg.c on i386.
+ * kdb v4.4-2.6.16-rc1-common-2.
+
+2006-01-18 Keith Owens <kaos@sgi.com>
+
+ * kdb v4.4-2.6.16-rc1-common-1.
+
+2006-01-11 Keith Owens <kaos@sgi.com>
+
+ * Plug a timing race between KDB_ENTER_SLAVE and KDB_ENTER, and allow
+ the cpu command to switch to a slave cpu.
+ * KDB_REASON_SILENT now waits for other cpus, to avoid spurious NMI
+ events that were seen on some Xeon systems.
+ * kdb v4.4-2.6.15-common-3.
+
+2006-01-08 Keith Owens <kaos@sgi.com>
+
+ * kdb mainline invokes DIE_KDEBUG_ENTER and DIE_KDEBUG_LEAVE via
+ notify_die.
+ * Move xpc debug support from xpc to mainline kdb.
+ * kdbm_cm.c: check if file_lock_operations or lock_manager_operations
+ are set before dereferencing them. Felix Blyakher, SGI.
+ * kdb v4.4-2.6.15-common-2.
+
+2006-01-04 Keith Owens <kaos@sgi.com>
+
+ * Print all buffers on a page in inode pages and update formatting to be
+ legible, too. David Chinner, SGI.
+ * Update page flags in kdbm_pg.
+ * Remove inline from *.c files.
+ * kdb v4.4-2.6.15-common-1.
+
+2005-12-25 Keith Owens <kaos@sgi.com>
+
+ * kdb v4.4-2.6.15-rc7-common-1.
+
+2005-12-20 Keith Owens <kaos@sgi.com>
+
+ * kdb v4.4-2.6.15-rc6-common-1.
+
+2005-12-10 Keith Owens <kaos@sgi.com>
+
+ * Update mapping of flags to strings in kdbm_pg.c and kdbm_vm.c.
+ * kdb v4.4-2.6.15-rc5-common-3.
+
+2005-12-06 Keith Owens <kaos@sgi.com>
+
+ * Add RECOVERY flag to global KDB flags.
+ * Add kdb_{save,restore}_flags.
+ * kdb v4.4-2.6.15-rc5-common-2.
+
+2005-12-05 Keith Owens <kaos@sgi.com>
+
+ * kdb v4.4-2.6.15-rc5-common-1.
+
+2005-12-02 Keith Owens <kaos@sgi.com>
+
+ * kdbm_vm.c: offsets of page macros should be unsigned long. Reported
+ by Dean Nelson, SGI.
+ * kdb v4.4-2.6.15-rc4-common-1.
+
+2005-11-30 Keith Owens <kaos@sgi.com>
+
+ * New follow_page() API.
+ * kdb v4.4-2.6.15-rc3-common-1.
+
+2005-11-21 Keith Owens <kaos@sgi.com>
+
+ * kdb v4.4-2.6.15-rc2-common-1.
+
+2005-11-15 Keith Owens <kaos@sgi.com>
+
+ * kdb v4.4-2.6.15-rc1-common-1.
+
+2005-11-15 Keith Owens <kaos@sgi.com>
+
+ * Allow kdb_printf() to be used outside kdb, in preemptible context.
+ * Build with CONFIG_SWAP=n. Reported by Leo Yuriev.
+ * kdb v4.4-2.6.14-common-2.
+
+2005-10-28 Keith Owens <kaos@sgi.com>
+
+ * kdb v4.4-2.6.14-common-1.
+
+2005-10-21 Keith Owens <kaos@sgi.com>
+
+ * kdb v4.4-2.6.14-rc5-common-1.
+
+2005-10-11 Keith Owens <kaos@sgi.com>
+
+ * Handle removal of USB keyboard. Aaron Young, SGI.
+ * kdb v4.4-2.6.14-rc4-common-1.
+
+2005-10-05 Keith Owens <kaos@sgi.com>
+
+ * Extend kdb_notifier_list() codes to include dumping.
+ * Use emergency_restart() for reboot, it can be called from interrupt
+ context, unlike machine_restart().
+ * kdb v4.4-2.6.14-rc3-common-1.
+
+2005-09-21 Keith Owens <kaos@sgi.com>
+
+ * Support kdb_current_task in register display and modify commands.
+ * Document what changes kdb's notion of the current task.
+ * Update rd documentation for IA64.
+ * Move some definictions to kdbprivate.h and remove some unused symbol
+ exports.
+ * kdb v4.4-2.6.14-rc2-common-1.
+
+2005-09-20 Keith Owens <kaos@sgi.com>
+
+ * Document IA64 handlers command.
+ * Add more fields to the task command.
+ * Cope with MCA/INIT handlers in the ps command.
+ * Namespace cleanup, delete unused exports, make some functions static.
+ * Add a kdb_notifier_list callback when kdb is about to reboot the
+ system.
+ * kdb v4.4-2.6.14-rc1-common-1.
+
+2005-08-29 Keith Owens <kaos@sgi.com>
+
+ * kdb v4.4-2.6.13-common-1.
+
+2005-08-24 Keith Owens <kaos@sgi.com>
+
+ * kdb v4.4-2.6.13-rc7-common-1.
+
+2005-08-08 Keith Owens <kaos@sgi.com>
+
+ * kdb v4.4-2.6.13-rc6-common-1.
+
+2005-08-02 Keith Owens <kaos@sgi.com>
+
+ * Print more fields from filp, dentry.
+ * Add kdb=on-nokey to suppress kdb entry from the keyboard.
+ * kdb v4.4-2.6.13-rc5-common-1.
+
+2005-07-30 Keith Owens <kaos@sgi.com>
+
+ * kdb v4.4-2.6.13-rc4-common-1.
+
+2005-07-26 Keith Owens <kaos@sgi.com>
+
+ * Fix compile problem with CONFIG_USB_KBD.
+ * kdb v4.4-2.6.13-rc3-common-3.
+
+2005-07-22 Keith Owens <kaos@sgi.com>
+
+ * The asmlinkage kdb() patch was lost during packaging. Reinstate it.
+ * kdb v4.4-2.6.13-rc3-common-2.
+
+2005-07-19 Keith Owens <kaos@sgi.com>
+
+ * Add support for USB keyboard (OHCI only). Aaron Young, SGI.
+ * kdb v4.4-2.6.13-rc3-common-1.
+
+2005-07-08 Keith Owens <kaos@sgi.com>
+
+ * kdb v4.4-2.6.13-rc2-common-1.
+
+2005-07-01 Keith Owens <kaos@sgi.com>
+
+ * Make kdb() asmlinkage to avoid problems with CONFIG_REGPARM.
+ * Change some uses of smp_processor_id() to be preempt safe.
+ * Use DEFINE_SPINLOCK().
+ * kdb v4.4-2.6.13-rc1-common-1.
+
+2005-06-18 Keith Owens <kaos@sgi.com>
+
+ * kdb v4.4-2.6.12-common-1.
+
+2005-06-08 Keith Owens <kaos@sgi.com>
+
+ * Correct early exit from bd *.
+ * kdb v4.4-2.6.12-rc6-common-1.
+
+2005-05-25 Keith Owens <kaos@sgi.com>
+
+ * Delete Documentation/kdb/dump.txt. lkcd now has reasonable
+ integration with kdb.
+ * kdb v4.4-2.6.12-rc5-common-1.
+
+2005-05-08 Keith Owens <kaos@sgi.com>
+
+ * kdb v4.4-2.6.12-rc4-common-1.
+
+2005-04-21 Keith Owens <kaos@sgi.com>
+
+ * Add rpte command (find the pte for a physical page).
+ * kdb v4.4-2.6.12-rc3-common-1.
+
+2005-04-06 Keith Owens <kaos@sgi.com>
+
+ * Add rq and rqa commands. John Hawkes, SGI.
+ * kdb v4.4-2.6.12-rc2-common-1.
+
+2005-03-29 Keith Owens <kaos@sgi.com>
+
+ * Use register_sysctl_table() instead of patching kernel/sysctl.c.
+ * Non-ASCII characters are not printable.
+ * kdb v4.4-2.6.12-rc1-common-1.
+
+2005-03-15 Keith Owens <kaos@sgi.com>
+
+ * More coexistence patches for lkcd. Jason Uhlenkott, SGI.
+ * kdb v4.4-2.6.11-common-3.
+
+2005-03-08 Keith Owens <kaos@sgi.com>
+
+ * Coexistence patches for lkcd. Jason Uhlenkott, SGI.
+ * kdb v4.4-2.6.11-common-2.
+
+2005-03-03 Keith Owens <kaos@sgi.com>
+
+ * Add kdb to drivers/serial/8250_early.c. Francois Wellenreiter, Bull.
+ * kdb v4.4-2.6.11-common-1.
+
+2005-02-14 Keith Owens <kaos@sgi.com>
+
+ * kdb v4.4-2.6.11-rc4-common-1.
+
+2005-02-08 Keith Owens <kaos@sgi.com>
+
+ * kdb v4.4-2.6.11-rc3-bk4-common-1.
+
+2005-02-03 Keith Owens <kaos@sgi.com>
+
+ * Print more superblock fields. Nathan Scott, SGI.
+ * Remove kallsyms correction for modules, Linus took it.
+ * kdb v4.4-2.6.11-rc3-common-1.
+
+2005-01-27 Keith Owens <kaos@sgi.com>
+
+ * Add bio command. Nathan Scott, SGI.
+ * kdb v4.4-2.6.11-rc2-common-1.
+
+2005-01-20 Keith Owens <kaos@sgi.com>
+
+ * Include kallsyms correction for modules until Linus takes it.
+ * kdb v4.4-2.6.11-rc1-bk7-common-1.
+
+2005-01-12 Keith Owens <kaos@sgi.com>
+
+ * kallsyms now supports all symbols properly, remove kdb patch.
+ * Add last ditch allocator for debugging.
+ * Update kdb_meminfo_read_proc() for vmalloc changes.
+ * Update kdbm_vm.c for 4 level page tables.
+ * kdb v4.4-2.6.11-rc1-common-1.
+
+2004-12-25 Keith Owens <kaos@sgi.com>
+
+ * Add kobject command.
+ * Ignore low addresses and large offsets in kdbnearsym().
+ * Console updates for sn2 simulator.
+ * kdb v4.4-2.6.10-common-1.
+
+2004-12-07 Keith Owens <kaos@sgi.com>
+
+ * kdb v4.4-2.6.10-rc3-common-1.
+
+2004-11-23 Keith Owens <kaos@sgi.com>
+
+ * Remove warning message from kdb_get_one_user_page(), it was too noisy.
+ * kdb v4.4-2.6.10-rc2-common-1.
+
+2004-11-02 Keith Owens <kaos@sgi.com>
+
+ * Build with kdb patch applied but CONFIG_KDB=n.
+ * kdb v4.4-2.6.10-rc1-common-2.
+
+2004-10-29 Keith Owens <kaos@sgi.com>
+
+ * Handle new compression scheme for kallsyms.
+ * Handle move of DEAD and ZOMBIE for task->state to task->exit_state.
+ * Tweak the concept of a valid kernel address to get all symbols,
+ including the symbols in the ia64 gate page.
+ * kdb v4.4-2.6.10-rc1-common-1.
+
+2004-10-21 Keith Owens <kaos@sgi.com>
+
+ * Handle variable size for the kernel log buffer.
+ * kdb v4.4-2.6.9-common-2.
+
+2004-10-19 Keith Owens <kaos@sgi.com>
+
+ * kdb v4.4-2.6.9-common-1.
+
+2004-10-12 Keith Owens <kaos@sgi.com>
+
+ * kdb v4.4-2.6.9-rc4-common-1.
+
+2004-10-01 Keith Owens <kaos@sgi.com>
+
+ * kdb v4.4-2.6.9-rc3-common-1.
+
+2004-09-30 Keith Owens <kaos@sgi.com>
+
+ * Add stackdepth command to Documentation/kdb/kdb.mm. stackdepth is
+ only supported on i386 and ia64 at the moment.
+ * Skip kdbm_pg memmap build on x86_64. Scott Lurndal, 3leafnetworks.
+ * Export kdb_serial_str for modular I/O. Bryan Cardillo, UPenn.
+ * Reinstate tab completion for symbols.
+ * kdb v4.4-2.6.9-rc2-common-2.
+
+2004-09-14 Keith Owens <kaos@sgi.com>
+
+ * Add task states C (traCed) and E (dEad).
+ * kdb v4.4-2.6.9-rc2-common-1.
+
+2004-08-27 Keith Owens <kaos@sgi.com>
+
+ * kdb v4.4-2.6.9-rc1-common-1.
+
+2004-08-14 Keith Owens <kaos@sgi.com>
+
+ * kdb v4.4-2.6.8-common-1.
+
+2004-08-12 Keith Owens <kaos@sgi.com>
+
+ * kdb v4.4-2.6.8-rc4-common-1.
+
+2004-08-05 Keith Owens <kaos@sgi.com>
+
+ * Mark kdb_initcall as __attribute_used__ for newer gcc.
+ * kdb v4.4-2.6.8-rc3-common-2.
+
+2004-08-04 Keith Owens <kaos@sgi.com>
+
+ * Add mdp (memory display physical) comnmand.
+ Ananth N Mavinakayanahalli, IBM.
+ * kdb v4.4-2.6.8-rc3-common-1.
+
+2004-07-18 Keith Owens <kaos@sgi.com>
+
+ * Patch for new sn_console. Erik Jacobson. SGI.
+ * kdb v4.4-2.6.8-rc2-common-1.
+
+2004-07-12 Keith Owens <kaos@sgi.com>
+
+ * Convert kdbm_task to standard cpumask_t.
+ * Document '*' (all breakpoints) option on bd/be/bc commands.
+ * kdb v4.4-2.6.8-rc1-common-1.
+
+2004-06-30 Keith Owens <kaos@sgi.com>
+
+ * Common changes to help the x86-64 port.
+ * kdb v4.4-2.6.7-common-3.
+
+2004-06-20 Keith Owens <kaos@sgi.com>
+
+ * Move kdb includes in mm/swapfile.c to reduce conflicts with other
+ SGI patches.
+ * kdb v4.4-2.6.7-common-2.
+
+2004-06-16 Keith Owens <kaos@sgi.com>
+
+ * kdb v4.4-2.6.7-common-1.
+
+2004-06-09 Keith Owens <kaos@sgi.com>
+
+ * kdb v4.4-2.6.7-rc3-common-1.
+
+2004-06-09 Keith Owens <kaos@sgi.com>
+
+ * Namespace clean up. Mark code/variables as static when it is only
+ used in one file, delete dead code/variables.
+ * Saved interrupt state requires long, not int.
+ * kdb v4.4-2.6.7-rc2-common-3.
+
+2004-06-08 Keith Owens <kaos@sgi.com>
+
+ * Whitespace clean up, no code changes.
+ * kdb v4.4-2.6.7-rc2-common-2.
+
+2004-06-07 Keith Owens <kaos@sgi.com>
+
+ * kdb v4.4-2.6.7-rc2-common-1.
+
+2004-06-06 Keith Owens <kaos@sgi.com>
+
+ * Avoid recursion problems in kdb_init().
+ * Add standard archkdb commands.
+ * Add per_cpu command.
+ * Move kdb_{get,put}userarea_size definitions to linux/kdb.h.
+ * kdb v4.4-2.6.6-common-2.
+
+2004-05-23 Keith Owens <kaos@sgi.com>
+
+ * Shrink the output from the cpu command.
+ * Add cpu state 'I', the cpu is idle.
+ * Add cpu state '+', some kdb data is available but the cpu is not
+ responding.
+ * Do not print tasks in state I or M by default in ps and bta commands.
+ * Add states I (idle task) and M (sleeping system daemon) to ps and
+ bta commands.
+ * Delete unused variables.
+ * Move private kdb fields from kdb.h to kdbprivate.h.
+ * Print 'for keyboard entry' for the special cases when KDB_ENTER() is
+ used to get registers.
+ * Move bfd.h and ansidecl.h from arch/$(ARCH)/kdb to include/asm-$(ARCH)
+ and remove -I arch/$(ARCH)/kdb.
+ * dmesg command now prints from either the start or end of dmesg, or at
+ an arbitrary point in the middle of the kernel log buffer.
+ * Sensible string dump for multi byte md commands.
+ * 'page' command handles ia64 correctly.
+ * Show some activity when waiting for cpus to enter kdb.
+ * Change the KDB entry code to <esc>KDB.
+ * Allow comment commands, starting with '#'.
+ * Commands defined using defcmd from kdb_cmds are not printed as they
+ are entered, use defcmd with no parameters to print all the defined
+ commands.
+ * Add summary command.
+ * Update copyright notices.
+ * Zero suppression on md command.
+ * Make set NOSECT=1 the default.
+ * PPC64 uses OF-stdout instead of console. Ananth N Mavinakayanahalli.
+ * kdb v4.4-2.6.6-common-1.
+
+2004-05-10 Keith Owens <kaos@sgi.com>
+
+ * kdb v4.3-2.6.6-common-1.
+
+2004-05-06 Keith Owens <kaos@sgi.com>
+
+ * kdb v4.3-2.6.6-rc3-common-1.
+
+2004-05-06 Keith Owens <kaos@sgi.com>
+
+ * kdb v4.3-2.6.6-rc2-common-1.
+
+2004-04-30 Keith Owens <kaos@sgi.com>
+
+ * Rewrite inode_pages command for new radix code in struct page.
+ * kdb v4.3-2.6.6-rc1-common-1.
+
+2004-04-11 Keith Owens <kaos@sgi.com>
+
+ * Unlock sn_sal_lock before entering kdb from sn_serial.
+ * kdb v4.3-2.6.5-common-2.
+
+2004-04-05 Keith Owens <kaos@sgi.com>
+
+ * kdb v4.3-2.6.5-common-1.
+
+2004-03-22 Keith Owens <kaos@sgi.com>
+
+ * kdb v4.3-2.6.5-rc2-common-1.
+
+2004-03-12 Keith Owens <kaos@sgi.com>
+
+ * More work to avoid spurious messages from WARN_CONSOLE_UNLOCKED().
+ * bh command bug fixes. Nathan Scott.
+ * kdb v4.3-2.6.4-common-1.
+
+2004-03-06 Keith Owens <kaos@sgi.com>
+
+ * Set KDB_IS_RUNNING() during kdb_init to avoid spurious messages from
+ WARN_CONSOLE_UNLOCKED().
+ * Correct loss of symbol names in kdbnearsym.
+ * kdb v4.3-2.6.4-rc2-common-1.
+
+2004-02-29 Keith Owens <kaos@sgi.com>
+
+ * kdb v4.3-2.6.4-rc1-common-1.
+
+2004-02-21 Keith Owens <kaos@sgi.com>
+
+ * Correct build of kdb_cmds when using a separate object directory and
+ make it quiet. j-nomura (NEC), Keith Owens.
+ * kdb v4.3-2.6.3-common-2.
+
+2004-02-18 Keith Owens <kaos@sgi.com>
+
+ * kdb v4.3-2.6.3-common-1.
+
+2004-02-17 Keith Owens <kaos@sgi.com>
+
+ * Remove WAR for incorrect console registration patch.
+ * kdb v4.3-2.6.3-rc4-common-1.
+
+2004-02-17 Keith Owens <kaos@sgi.com>
+
+ * Convert longjmp buffers from static to dynamic allocation, for large
+ cpu counts.
+ * Tweak kdbm_task for SMP/UP.
+ * Reconcile with kdb-v4.3 2.4.25-rc1-common-1.
+ * Simplify coexistence with NPTL patches.
+ * Support kill command on new scheduler.
+ * Do not refetch data when printing a value as characters.
+ * Document the pid command.
+ * Work around 2.6 kallsyms 'feature'.
+ * Upgrade to 2.6.3-rc3.
+ * WAR for incorrect console registration patch.
+ * kdb v4.3-2.6.3-rc3-common-1.
+
+2003-12-03 Keith Owens <kaos@sgi.com>
+
+ * Reconcile 2.6-test versions from Xavier Bru (Bull), Greg Banks (SGI),
+ Jim Houston (Concurrent Computer Corp).
+ * Reconcile with kdb v4.3-2.4.23-common-2.
+ * Clean up CONFIG_KDB changes to {scripts,kernel}/kallsyms.c.
+ * Correct handling of kdb command line arguments.
+ * Make hooks into module code less intrusive.
+ * Delete kdb_active_task, not required with O(1) scheduler.
+ * Port kdbm_task.c from 2.4.
+ * Disable debug check in exit.c::next_thread() when kdb is running.
+ * Remove "only bh_disable when interrupts are set". BH must be disabled
+ in kdb to prevent deadlock on breakpoints in interrupt handlers.
+ * Add kdb to drivers/char/sn_serial.c.
+ * kdb v4.3-2.6.0-test11-common-1.
+
+2003-11-11 Xavier Bru <xavier.bru@bull.net>
+ * Merge to 2.6.0-test9
+2003-10-17 Xavier Bru <xavier.bru@bull.net>
+ * fix NUll ptr in kdb_ps at early prompt.
+2003-10-14 Xavier Bru <xavier.bru@bull.net>
+ * fix NUll ptr in kdb_ps when cpu not present.
+2003-10-06 Xavier Bru <xavier.bru@bull.net>
+ * Merge to 2.6.0-test5
+ * fix compile error with CONFIG_MODULES not set.
+
+2003-09-08 Xavier Bru <xavier.bru@bull.net>
+ * Merge to 2.6.0-test4
+
+2003-07-10 Xavier Bru <xavier.bru@bull.net>
+
+ * Merge kdb v4.3 to 2.5.72 ia64
+ * don't call local_bh_enable() with interrupts masked.
+
+2003-04-07 Xavier Bru <xavier.bru@bull.net>
+
+ * Merge kdb v4.1 to 2.5.64 ia64
+ * new kernel parameters support
+ * new module format
+ * new kallsyms support
+
+2003-12-02 Keith Owens <kaos@sgi.com>
+
+ * Use correct page alignment in kdb_get_one_user_page().
+ Prasanna S Panchamukhi, IBM.
+ * Split pte command into pte -m and pte -p. Dean Roe, SGI.
+ * kdb v4.3-2.4.23-common-2.
+
+2003-12-01 Keith Owens <kaos@sgi.com>
+
+ * kdb v4.3-2.4.23-common-1.
+
+2003-11-11 Keith Owens <kaos@sgi.com>
+
+ * Make KDB for USB keyboards build. Peter T. Breuer.
+ * Do not use USB keyboard if it has not been probed.
+ * kdb v4.3-2.4.23-rc1-common-1.
+
+2003-10-10 Keith Owens <kaos@sgi.com>
+
+ * Sync with XFS 2.4.22 tree.
+ * kdb v4.3-2.4.22-common-2.
+
+2003-08-29 Keith Owens <kaos@sgi.com>
+
+ * kdb v4.3-2.4.22-common-1.
+
+2003-07-27 Keith Owens <kaos@sgi.com>
+
+ * kdb v4.3-2.4.22-pre8-common-8.
+
+2003-07-20 Keith Owens <kaos@sgi.com>
+
+ * Make kdb_serial_str a common constant, the same for all consoles.
+ * Support SGI L1 console.
+ * kdb v4.3-2.4.21-common-8.
+
+2003-07-14 Keith Owens <kaos@sgi.com>
+
+ * Correct ll command.
+ * kdb v4.3-2.4.21-common-7.
+
+2003-07-08 Keith Owens <kaos@sgi.com>
+
+ * Export more kdb symbols. Vamsi Krishna S., IBM.
+ * kdb v4.3-2.4.21-common-6.
+
+2003-07-07 Keith Owens <kaos@sgi.com>
+
+ * Tweak 'waiting for cpus' message.
+ * kdb v4.3-2.4.21-common-5.
+
+2003-07-07 Keith Owens <kaos@sgi.com>
+
+ * 2.4.21-ia64-030702 patches common code that affects kdb. Workaround
+ this nuisance.
+ * kdb v4.3-2.4.21-common-4.
+
+2003-06-24 Keith Owens <kaos@sgi.com>
+
+ * Add task and sigset commands. Mark Goodwin, SGI.
+ * kdb v4.3-2.4.21-common-3.
+
+2003-06-23 Keith Owens <kaos@sgi.com>
+
+ * Sync with XFS 2.4.21 tree.
+ * kdb v4.3-2.4.21-common-2.
+
+2003-06-20 Keith Owens <kaos@sgi.com>
+
+ * kdb v4.3-2.4.21-common-1.
+
+2003-06-20 Keith Owens <kaos@sgi.com>
+
+ * More details on vm command, add vmp and pte commands.
+ Dean Nelson, Dean Roe, SGI.
+ * YAO1SCF (Yet Another O(1) Scheduler Coexistence Fix).
+ * Changes to common code to build on sparc. Tom Duffy.
+ * Move Tom Duffy's changes to drivers/sbus from the sparc64
+ patch to the common patch to keep all the serial changes
+ together.
+ * Changes to common code to build on Xscale. Eddie Dong, Intel.
+ * Remove CROSS_COMPILE_INC.
+ * Remove obsolete boot parameter 'kdb', long since replaced by
+ 'kdb=on'.
+ * Remove obsolete kdb_eframe_t casts.
+ * Add CONFIG_KDB_CONTINUE_CATASTROPHIC.
+ * Wait a short interval for cpus to join kdb before proceeding.
+ * Automatically enable sysrq for sr command.
+ * Correct double free of kdb_printf lock, spotted by Richard Sanders.
+ * Add optional cpu parameter to btc command.
+ * kdb v4.3-2.4.20-common-1.
+
+2003-05-02 Keith Owens <kaos@sgi.com>
+
+ * Some architectures have problems with the initial empty kallsyms
+ section so revert to three kallsyms passes.
+ * Flush buffered input at startup and at 'more' prompt.
+ * Only print 'more' prompt when longjmp data is available.
+ * Print more data for buffers and inodes.
+ * Disable kill command when O(1) scheduler is installed, the code
+ needs to be redone for O(1).
+ * The kernel has an undocumented assumption that enable_bh() is
+ always called with interrupts enabled, make it so.
+ * Print trailing punctuation even for symbols that are not in kernel.
+ * Add read/write access to user pages. Vamsi Krishna S., IBM
+ * Rename cpu_is_online to cpu_online, as in 2.5.
+ * O(1) scheduler removes init_task so kdb maintains its own list of
+ active tasks.
+ * Delete btp 0 <cpuid> option, it needed init_tasks.
+ * Clean up USB keyboard support. Steven Dake.
+ * Sync with XFS 2.4.20 tree.
+ * kdb v4.2-2.4.20-common-1.
+
+2003-04-04 Keith Owens <kaos@sgi.com>
+
+ * Remove one kallsyms pass.
+ * Automatic detection of O(1) scheduler.
+ * Rename cpu_online to cpu_is_online.
+ * Workarounds for scheduler bugs.
+ * Tweak algorithm for detecting if cpu process data is available.
+ * Add 'kill' command. Sonic Zhang, Keith Owens.
+ * kdb v4.1-2.4.20-common-1.
+
+2003-03-16 Keith Owens <kaos@sgi.com>
+
+ * Each cpu saves its state as it enters kdb or before it enters code
+ which cannot call kdb.
+ * Allow btp on process 0 for a specified cpu.
+ * Add btt command, backtrace given a struct task address.
+ * btc command no longer switches cpus, instead it uses the saved data.
+ * bta shows the idle task on each cpu as well as real tasks, the idle
+ task could be handling an interrupt.
+ * ps command shows the idle task on each cpu.
+ * ps checks that the saved data for a cpu matches the process running on
+ that cpu and warns about stale saved data or no saved data at all.
+ * Remove special cases for i386 backtrace from common code and simplify
+ common bt code.
+ * Clean up kdb interaction with CONFIG_SERIAL_CONSOLE.
+ * Do not automatically repeat commands after the user typed 'q'.
+ * O(1) scheduler patch changes the process cpu field but does not set
+ any indicator that O(1) is being used. Adjust kdb_process_cpu() by
+ hand after applying O(1).
+ * Add kdb_print_nameval() to common code.
+ * Convert tests of cpu_online_map to cpu_online() macro.
+ * module.h needs errno.h when compiling with CONFIG_MODULES=n.
+ * Correct duplicate breakpoint handling.
+ * Do not try to send IPI during a catastrophic error, send_ipi can hang
+ and take kdb with it.
+ * kdb memmap command is i386 only, restrict it.
+ * Add large block device (LBD) support from XFS tree. Eric Sandeen.
+ * kdb v4.0-2.4.20-common-1.
+
+2003-02-03 Keith Owens <kaos@sgi.com>
+
+ * Register kdb commands early.
+ * Decode oops via kallsyms if it is available.
+ * Update copyright notices to 2003.
+ * Add defcmd/endefcmd to allow users to package their own macros.
+ * kdb commands that fail are ignored when prefixed with '-'.
+ * Add selection options to bta command.
+ * Add btc command (switch to each cpu and backtrace).
+ * Do real time detection of dead cpus.
+ * Clear ip adjusted flag when leaving kdb.
+ * Clean up ps command.
+ * Print ps output for each task when backtracing.
+ * Bump to version v3.0 to reduce confusion between kdb and kernel
+ version numbers.
+ * Add kdba_local_arch_setup/kdba_local_arch_cleanup to correct
+ keyboard freeze. Ashish Kalra.
+ * Refuse multiple breakpoints at the same address.
+ * Add fl (file_lock) command, from XFS development tree.
+ * Correct inode_pages, from XFS development tree.
+ * Add command history and editing. Sonic Zhang.
+ * Extend command history and editing to handle vt100 escape sequences.
+ * Allow tab completion at start of line.
+ * Touch nmi watchdog on long running bta and btc commands.
+ * Clean up ps output and standardize with bta codes.
+ * Correctly handle escaped characters in commands.
+ * Update man pages for btc and command history/editing.
+ * kdb v3.0-2.4.20-common-1.
+
+2002-11-29 Keith Owens <kaos@sgi.com>
+
+ * Upgrade to 2.4.20.
+ * Correct Documentation/kdb/kdb_sr.man.
+ * Remove leading zeroes from pids, they are decimal, not octal.
+ * kdb v2.5-2.4.20-common-1.
+
+2002-11-14 Keith Owens <kaos@sgi.com>
+
+ * Upgrade to 2.4.20-rc1.
+ * kdb v2.5-2.4.20-rc1-common-1.
+
+2002-11-14 Keith Owens <kaos@sgi.com>
+
+ * Fix processing with O(1) scheduler.
+ * 'go' switches back to initial cpu first.
+ * 'go <address>' only allowed on initial cpu.
+ * 'go' installs the global breakpoints from the initial cpu before
+ releasing the other cpus.
+ * If 'go' has to single step over a breakpoint then it single steps just
+ the initial cpu, installs the global breakpoints then releases the
+ other cpus.
+ * General clean up of handling for breakpoints and single stepping over
+ software breakpoints.
+ * Add kdb_notifier_block so other code can tell when kdb is in control.
+ * kdb v2.5-2.4.19-common-1.
+
+2002-11-02 Keith Owens <kaos@sgi.com>
+
+ * Correct build without CONFIG_KDB.
+ * kdb v2.4-2.4.19-common-3.
+
+2002-11-01 Keith Owens <kaos@sgi.com>
+
+ * Minimize differences from 2.5.44.
+ * kdb v2.4-2.4.19-common-2.
+
+2002-10-31 Keith Owens <kaos@sgi.com>
+
+ * Add defcmd/endefcmd feature.
+ * Remove kdb_eframe_t.
+ * Clear bp data before using.
+ * Sanity check if we have pt_regs.
+ * Force LINES > 1.
+ * Remove special case for KDB_REASON_PANIC, use KDB_ENTER() instead.
+ * Remove kdba_getcurrentframe().
+ * Coexist with O(1) scheduler.
+ * Add lines option to dmesg, speed up dmesg.
+ * kdb v2.4-2.4.19-common-1.
+
+2002-10-17 Keith Owens <kaos@sgi.com>
+
+ * Add selection critera to ps and bta commands.
+ * kdb v2.3-2.4.19-common-4.
+
+2002-10-07 Keith Owens <kaos@sgi.com>
+
+ * New man page, Documentation/kdb/kdb_sr.man.
+
+2002-10-04 Keith Owens <kaos@sgi.com>
+
+ * Minimize differences between patches for 2.4 and 2.5 kernels.
+ * Add Configure.help for CONFIG_KDB_USB.
+ * Reduce stack usage.
+ * kdb v2.3-2.4.19-common-3.
+
+2002-08-10 Keith Owens <kaos@sgi.com>
+
+ * Replace kdb_port with kdb_serial to support memory mapped I/O.
+ David Mosberger.
+ * kdb v2.3-2.4.19-common-2.
+
+2002-08-07 Keith Owens <kaos@sgi.com>
+
+ * Upgrade to 2.4.19.
+ * Remove individual SGI copyrights, the general SGI copyright applies.
+ * Handle md0. Reported by Hugh Dickins, different fix by Keith Owens.
+ * Use page_address() in kdbm_pg.c. Hugh Dickins.
+ * Remove debugging printk from kdbm_pg.c. Hugh Dickins.
+ * Move breakpoint address verification into arch dependent code.
+ * Dynamically resize kdb command table as required.
+ * Common code to support USB keyboard. Sebastien Lelarge.
+ * kdb v2.3-2.4.19-common-1.
+
+2002-07-09 Keith Owens <kaos@sgi.com>
+
+ * Upgrade to 2.4.19-rc1.
+ * Add dmesg command.
+ * Clean up copyrights, Eric Sandeen.
+ * kdb v2.2-2.4.19-rc1-common-1.
+
+2002-06-14 Keith Owens <kaos@sgi.com>
+
+ * Upgrade to 2.4.19-pre10.
+ * Sync with XFS.
+ * kdb v2.1-2.4.19-pre10-common-1.
+
+2002-04-09 Keith Owens <kaos@sgi.com>
+
+ * Upgrade to 2.4.19-pre6.
+ * kdb v2.1-2.4.19-pre6-common-1.
+
+2002-03-18 Keith Owens <kaos@sgi.com>
+
+ * Syntax check mdWcN commands.
+
+2002-03-01 Keith Owens <kaos@sgi.com>
+
+ * Sync with XFS 2.4.18.
+ * kdb v2.1-2.4.18-common-2.
+
+2002-02-26 Keith Owens <kaos@sgi.com>
+
+ * Upgrade to 2.4.18.
+ * Add Paul Dorwin (IBM) magicpoint slides on using kdb as
+ Documentation/kdb/slides.
+ * kdb v2.1-2.4.18-common-1.
+
+2002-01-23 Keith Owens <kaos@sgi.com>
+
+ * Sync with XFS pagebuf changes.
+ * kdb v2.1-2.4.17-common-2.
+
+2002-01-18 Keith Owens <kaos@sgi.com>
+
+ * Ignore single stepping during panic.
+ * Remove kdba_getword, kdba_putword. Replace with kdb_getword,
+ kdb_putword that rely on copy_xx_user. The new functions return
+ an error code, like copy_xx_user.
+ * New functions kdb_getarea, kdb_putarea for copying areas of data
+ such as structures. These functions also return an error code.
+ * Change all common code to use the new functions.
+ * bp command checks that it can read and write the word at the
+ breakpoint before accepting the address.
+ * Break points are now set FIFO and cleared LIFO so overlapping
+ entries give sensible results.
+ * Verify address before disassembling code.
+ * Common changes for sparc64. Ethan Solomita, Tom Duffy.
+ * Remove ss <count>, never supported.
+ * Remove kallsyms entries from arch vmlinux.lds files.
+ * Specify which commands auto repeat.
+ * kdb v2.1-2.4.17-common-1.
+
+2002-01-07 Keith Owens <kaos@sgi.com>
+
+ * Remove console semaphore code, not good in interrupt.
+ * Remove fragment of ia64 patch that had crept into kdb.
+ * Release as kdb v2.0-2.4.17-common-3.
+
+2002-01-04 Keith Owens <kaos@sgi.com>
+
+ * Sync xfs <-> kdb common code.
+
+2001-12-22 Keith Owens <kaos@sgi.com>
+
+ * Upgrade to 2.4.17.
+ * Clean up ifdef CONFIG_KDB.
+ * Add ifdef CONFIG_KDB around include kdb.h.
+ * Delete dummy kdb.h files for unsupported architectures.
+ * Delete arch i386 and ia64 specific files. This changelog now
+ applies to kdb common code only.
+ * Release as kdb v2.0-2.4.17-common-1.
+
+2001-12-03 Keith Owens <kaos@sgi.com>
+
+ * Upgrade to 2.4.16.
+ * Add include/asm-um/kdb.h stub to allow XFS to be tested under UML.
+ * Check if an interrupt frame on i386 came from user space.
+ * Out of scope bug fix in kdb_id.c. Ethan Solomita.
+ * Changes to common code to support sparc64. Ethan Solomita.
+ * Change GFP_KERNEL to GFP_ATOMIC in disasm. Ethan Solomita.
+
+2001-11-16 Keith Owens <kaos@sgi.com>
+
+ * Upgrade to 2.4.15-pre5.
+ * Wrap () around #define expressions with unary operators.
+
+2001-11-13 Keith Owens <kaos@sgi.com>
+
+ * Upgrade to 2.4.15-pre4.
+ * kbdm_pg.c patch from Hugh Dickins.
+
+2001-11-07 Keith Owens <kaos@sgi.com>
+
+ * Upgrade to 2.4.14-ia64-011105.
+ * Change name of l1 serial I/O routine, add ia64 init command. SGI.
+ * Sync kdbm_pg with XFS.
+
+2001-11-06 Keith Owens <kaos@sgi.com>
+
+ * Upgrade to kernel 2.4.14.
+
+2001-11-02 Keith Owens <kaos@sgi.com>
+
+ * Sync kdbm_pg.c with XFS.
+
+2001-10-24 Keith Owens <kaos@sgi.com>
+
+ * Upgrade to kernel 2.4.13.
+
+2001-10-14 Keith Owens <kaos@melbourne.sgi.com>
+
+ * More use of TMPPREFIX in top level Makefile to speed up NFS compiles.
+
+ * Correct repeat calculations in md/mds commands.
+
+2001-10-10 Keith Owens <kaos@melbourne.sgi.com>
+
+ * Copy bfd.h and ansidecl.h to arch/$(ARCH)/kdb, remove dependecies on
+ user space includes.
+
+ * Update kdb v1.9 to kernel 2.4.11.
+
+2001-10-01 Keith Owens <kaos@melbourne.sgi.com>
+
+ * Update kdb v1.9 to kernel 2.4.11-pre1 and 2.4.10-ac1.
+
+ * Correct loop in kdb_parse, reported by Tachino Nobuhiro.
+
+2001-09-25 Keith Owens <kaos@melbourne.sgi.com>
+
+ * Update kdb v1.8 to kernel 2.4.10.
+
+ * kdbm_pg patch from Hugh Dickens.
+
+ * DProbes patch from Bharata B Rao.
+
+ * mdWcn and mmW patch from Vamsi Krishna S.
+
+ * i386 disasm layout patch from Jean-Marc Saffroy.
+
+ * Work around for 64 bit binutils, Simon Munton.
+
+ * kdb.mm doc correction by Chris Pascoe.
+
+ * Enter repeats the last command, IA64 disasm only prints one
+ instruction. Don Dugger.
+
+ * Allow kdb/modules to be linked into vmlinux.
+
+ * Remove obsolete code from kdb/modules/kdbm_{pg,vm}.c.
+
+ * Warn when commands are entered at more prompt.
+
+ * Add MODULE_AUTHOR, DESCRIPTION, LICENSE.
+
+ * Release as kdb v1.9.
+
+2001-02-27 Keith Owens <kaos@melbourne.sgi.com>
+
+ * Update kdb v1.8 to kernel 2.4.2, sync kdb/modules with XFS.
+
+ * Hook into panic() call.
+
+2000-12-18 Keith Owens <kaos@melbourne.sgi.com>
+
+ * Update kdb v1.7 to kernel 2.4.0-test13-pre3, sync kdb/modules with
+ XFS.
+
+2000-11-18 Keith Owens <kaos@melbourne.sgi.com>
+
+ * Update to kernel 2.4.0-test11-pre7, including forward port of
+ bug fixes from WIP 2.4.0-test9 tree.
+
+ * Update to Cygnus CVS trees for disassembly code.
+
+ * Bump to kdb v1.6.
+
+2000-10-19 Keith Owens <kaos@melbourne.sgi.com>
+
+ * Update to kernel 2.4.0-test10-pre4.
+
+2000-10-15 Keith Owens <kaos@melbourne.sgi.com>
+
+ * kdb/kdbmain.c (kdb_parse): Correctly handle blank input.
+
+ * kdb/kdbmain.c (kdb_local, kdb): Reason SILENT can have NULL regs.
+
+2000-10-13 Keith Owens <kaos@melbourne.sgi.com>
+
+ * kdb/kdbmain.c: Reduce CMD_LEN to avoid overflowing kdb_printf buffer.
+
+2000-10-11 Keith Owens <kaos@melbourne.sgi.com>
+
+ * kdb/kdbmain.c (kdb): Test for userspace breakpoints before driving
+ other cpus into kdb. Speeds up gdb and avoids SMP race.
+
+ * arch/i386/kdb/kdba_io.c (get_serial_char, get_kbd_char): Ignore
+ unprintable characters.
+
+ * arch/i386/kdb/kdba_io.c (kdba_read): Better handling of buffer size.
+
+2000-10-04 Keith Owens <kaos@melbourne.sgi.com>
+
+ * arch/i386/kdb/kdba_bt.c (kdba_bt_process): Verify that esp is inside
+ task_struct. Original patch by Mike Galbraith.
+
+ * kdb/kdb_io.c (kdb_getstr): Reset output line counter, remove
+ unnecessary prompts.
+
+ * arch/i386/kdb/kdbasupport.c (kdb_getregcontents): Change " cs" to
+ "xcs", ditto ss, ds, es. gdb2kdb does not like leading spaces.
+
+ * include/asm-xxx/kdb.h: Add dummy kdb.h for all architectures except
+ ix86. This allows #include <linux/kdb.h> to appear in arch independent
+ code without causing compile errors.
+
+ * kdb/modules/kdbm_pg: Sync with XFS.
+
+2000-10-03 Keith Owens <kaos@melbourne.sgi.com>
+
+ * kdb/kdb_io.c (kdb_read): Ignore NMI while waiting for input.
+
+ * kdb/kdb_io.c, kdb/Makefile: Export kdb_read.
+
+2000-10-02 Keith Owens <kaos@melbourne.sgi.com>
+
+ * arch/i386/kernel/smpboot.c (do_boot_cpu): Set nmi_watchdog_source to 2
+ to avoid premature NMI oops during cpu bring up. We have to assume that
+ a box with more than 1 cpu has a working IO-APIC.
+
+ * Documentation/kdb/{kdb.mm,kdb_md.man}: Add mdr command.
+
+ * kdb/kdbmain.c (kdb_md): Add mdr command.
+
+ * Release as kdb v1.5 against 2.4.0-test9-pre8.
+
+ * arch/i386/kdb/kdba_io.c, arch/i386/kdb/kdbasupport.c, kdb/kdbmain.c,
+ kdb/kdb_io.c, kdb/kdb_id.c: Remove zero initializers for static
+ variables.
+
+2000-09-28 Keith Owens <kaos@melbourne.sgi.com>
+
+ * various: Add nmi_watchdog_source, 1 local APIC, 2 IO-APIC.
+ Test nmi_watchdog_source instead of nr_ioapics so UP works on SMP hardware.
+
+ * arch/i386/kernel/io_apic.c: Rename setup_nmi to setup_nmi_io for clarity.
+
+ * kdb/kdbmain.c (kdb_parse): Only set NO_WATCHDOG if it was already set.
+
+ * kdb/kdbmain.c (kdb): Clear NO_WATCHDOG on all exit paths.
+
+ * include/linux/kdb.h: Add KDB_REASON_SILENT.
+
+ * kdb/kdbmain.c (kdb_local): Treat reason SILENT as immediate 'go'.
+
+ * kdb/kdbmain.c (kdb_init): Invoke kdb with reason SILENT to instantiate
+ any breakpoints on boot cpu.
+
+ * arch/i386/kernel/smpboot.c (smp_callin): Invoke kdb with reason SILENT
+ to instantiate any global breakpoints on this cpu.
+
+ * kdb/kdb_cmds: Remove comment that said initial commands only worked on
+ boot cpu.
+
+2000-09-27 Keith Owens <kaos@melbourne.sgi.com>
+
+ * arch/i386/kernel/msr.c: Move {rd,wr}msr_eio to include/asm-i386/apic.h.
+
+ * include/asm-i386/apic.h: Define NMI interfaces.
+
+ * kernel/sysctl.c (kern_table):
+ * kernel/sysctl.c (do_proc_set_nmi_watchdog):
+ Add /proc/sys/kernel/nmi_watchdog.
+
+ * arch/i386/kernel/apic.c: New routines set_nmi_counter_local,
+ setup_apic_nmi_watchdog.
+
+ * arch/i386/kernel/traps.c: New routine set_nmi_watchdog(). Call apic
+ routines to set/clear local apic timer.
+
+2000-09-26 Keith Owens <kaos@melbourne.sgi.com>
+
+ * include/linux/sysctl.h (enum): Add NMI_WATCHDOG.
+
+ * arch/i386/kernel/traps.c (nmi_watchdog_tick): Check nmi_watchdog is
+ still on.
+
+ * arch/i386/config.in: Add CONFIG_UP_NMI_WATCHDOG.
+
+ * Documentation/Configure.help: Add CONFIG_UP_NMI_WATCHDOG.
+
+ * Documentation/nmi_watchdog.txt: Update for UP NMI watchdog.
+
+2000-09-25 Keith Owens <kaos@melbourne.sgi.com>
+
+ * arch/i386/kernel/apic.c (init_apic_mappings):
+ * arch/i386/kernel/io_apic.c (IO_APIC_init_uniprocessor):
+ Merge Keir Fraser's local APIC for uniprocessors patch.
+
+2000-09-24 Keith Owens <kaos@melbourne.sgi.com>
+
+ * Various: Declare initialization routines as __init.
+
+ * Makefile: Define and export AWK.
+
+ * kdb/Makefile: Generate gen-kdb_cmds.c from kdb/kdb_cmds.
+
+ * kdb/kdbmain.c (kdb_init): Call new routine kdb_cmds_init to execute
+ whatever the user put in kdb/kdb_cmds.
+
+ * arch/i386/kdb/kdba_bt.c (kdba_bt_stack): New parameter to
+ indicate if esp in regs is known to be valid or not.
+
+ * kdb/kdb_bp.c, arch/i386/kdb/kdba_bp.c: More trace prints for
+ breakpoint handling.
+
+ * arch/i386/kdb/kdba_bp.c (kdba_installbp): Finally found and fixed the
+ annoying breakpoint bug where breakpoints where not always installed
+ after 'go'.
+
+ * Documentation/kdb: Update man pages kdb.mm, kdb_env.man, kdb_ss.man.
+
+ * Released as kdb-v1.5-beta1-2.4.0-test8.
+
+ * Sync to 2.4.0-test9-pre6 and release as kdb-v1.5-beta1-2.4.0-test9-pre6.
+
+2000-09-23 Keith Owens <kaos@melbourne.sgi.com>
+
+ * arch/i386/kdb/kdbasupport.c (kdba_getregcontents): New pseudo
+ registers cesp and ceflags to help with debugging the debugger.
+
+ * kdb/kdbmain.c (kdb_local, kdb): Add KDB_REASON_RECURSE. Add
+ environment variable RECURSE. Add code to cope with some types of
+ recursion.
+
+ * kdb/kdbmain.c (kdb), arch/i386/kdba/kdba_bp.c: Add
+ kdba_clearsinglestep.
+
+2000-09-22 Keith Owens <kaos@melbourne.sgi.com>
+
+ * drivers/video/vgacon.c (write_vga): No cli() if kdb is running, avoid
+ console deadlock.
+
+ * arch/i386/kernel/irq.c (get_irqlock): Warn if kdb is running, may hang.
+
+ * include/linux/kdb.h: Define KDB_IS_RUNNING as (0) if no CONFIG_KDB.
+
+ * arch/i386/kdb/kdba_bt.c (kdba_bt_stack): Do not attempt a backtrace if
+ the code segment is not in the kernel.
+
+ * kdb/modules: Change modules from MX_OBJS to M_OBJS. Remove EXPORT_NOSYMBOLS.
+
+2000-09-21 Keith Owens <kaos@melbourne.sgi.com>
+
+ * arch/i386/kernel/i386_ksyms.c: Move EXPORT_SYMBOLS for kdb to kdb/kdbmain.c.
+
+ * kdb/Makefile: Change kdb/kdbmain.o from O_OBJS to OX_OBJS.
+
+ * arch/i386/kernel/smp.c: Remove some #ifdef CONFIG_KDB. Remove kdbprivate.h.
+
+ * include/linux/kdb.h: Add kdb_print_state. Add KDB_STATE_WAIT_IPI.
+
+ * kdb/kdbmain.c (kdb): Only mark cpu as leaving if it is in KDB state. Maintain
+ WAIT_IPI state so a cpu is only driven through NMI once.
+
+ * arch/i386/kernel/smp.c (smp_kdb_stop): All state fiddling moved to kdb().
+
+2000-09-20 Keith Owens <kaos@melbourne.sgi.com>
+
+ * include/linux/kdb.h: #define kdb() as (0) if kdb is not configured.
+
+ * arch/i386/kernel/traps.c: Remove some #ifdef CONFIG_KDB.
+
+ * include/linux/kdbprivate.h: Move per cpu state to kdb.h.
+
+ * include/linux/kdb.h: Add KDB_STATE_NO_WATCHDOG, KDB_STATE_PRINTF_LOCK.
+ Rename KDB_DEBUG_xxx to KDB_DEBUG_FLAG_xxx. Clean up debug flag
+ definitions.
+
+ * arch/i386/kernel/traps.c (nmi_watchdog_tick): Check no watchdog.
+
+ * kdb/kdbmain.c (kdb): Set no watchdog in normal kdb code.
+
+ * kdb/kdbmain.c (kdb_parse): Allow watchdog in commands.
+
+ * kdb/kdb_io.c (kdb_printf): No watchdog during printing. Clean up lock handling.
+
+ * kdb/kdbmain.c (kdb_set): Clean up debug flag handling.
+
+2000-09-19 Juan J. Quintela <quintela@fi.udc.es>
+
+ * kdb/arch/i386/kdb/kdba_io.c: Allow kdb to compile without CONFIG_VT and/or
+ serial console.
+
+2000-09-19 Keith Owens <kaos@melbourne.sgi.com>
+
+ * include/linux/kdb.h: Define KDB_DEBUG_STATE().
+
+ * kdb/kdbmain.c (kdb): Add kdb_print_state(), calls to KDB_DEBUG_STATE().
+
+2000-09-16 Keith Owens <kaos@melbourne.sgi.com>
+
+ * Move to finer grained control over individual processors in kdb with
+ per cpu kdb state. Needed to allow ss[b] to only release one processor,
+ previously ss[b] released all processors. Also need to recover from
+ errors inside kdb commands, e.g. oops in kdbm_pg code.
+
+ * various:
+ Move global flags KDB_FLAG_SSB, KDB_FLAG_SUPRESS, KDB_FLAG_FAULT,
+ KDB_FLAG_SS, KDB_FLAG_SSBPT, kdb_active, to per cpu state and macros
+ KDB_STATE(xxx).
+ Replace kdb_flags & KDB_FLAG_xxx with KDB_FLAG(xxx).
+ Replace kdb_flags & KDB_DEBUG_xxx with KDB_DEBUG(xxx).
+ Replace specific tests with wrapper KDB_IS_RUNNING().
+
+ * various: Remove #ifdef CONFIG_SMP from kdb code wherever
+ possible. Simplifies the code and makes it much more readable.
+
+ * arch/i386/kdb/kdbasupport.c (kdb_setjmp): Record if we have reliable
+ longjmp data instead of assuming it is always set.
+
+ * various: Replace smp_kdb_wait with per cpu state, HOLD_CPU.
+
+ * init/main.c : Replace #ifdef KDB_DEBUG with KDB_DEBUG(CALLBACK).
+
+ * include/linux/kdbprivate.h: Separate command return codes from error
+ codes. Add more detailed command codes.
+
+ * arch/i386/kernel/traps.c (die): Change spin_lock_irq to
+ spin_lock_irqsave. Why did I do this?
+
+ * kdb/kdbmain.c (kdb_parse): Set per cpu flag CMD before executing kdb
+ command. More detailed return codes for commands that affect
+ processors.
+
+ * kdb/kdbmain.c (kdb_previous_event): New, check if any processors are
+ still executing the previous kdb event. Removes a race window where a
+ second event could enter kdb before the first had completely ended.
+
+ * kdb/kdbmain.c (kdb): Document all the concurrency conditions and how
+ kdb handles them. ss[b] now releases only the current cpu. Do not set
+ breakpoints when releasing for ss[b]. Recover from errors in kdb
+ commands. Check that we have reliable longjmp data before using it.
+
+ * various: Update return code documentation.
+
+ * kdb/kdb_bp.c (kdb_ss): Separate ss and ssb return codes.
+
+ * kdb/kdbsupport.c (kdb_ipi): Finer grained algorithm for deciding
+ whether to call send a stop signal to a cpu.
+
+ * arch/i386/kdb/kdba_bp.c (kdba_db_trap): Separate ss and ssb return
+ codes. Reinstall delayed software breakpoints per cpu instead of
+ globally. Changed algorithm for handling ss[b].
+
+ * arch/i386/kdb/kdba_bp.c (kdba_bp_trap): Match software breakpoints per
+ cpu instead of globally.
+
+ * include/linux/kdb.h: Bump version to kdb v1.5.
+
+2000-09-16 Keith Owens <kaos@melbourne.sgi.com>
+
+ * kernel/sysctl.c (kern_table): add /proc/sys/kernel/kdb.
+
+ * init/main.c (parse_options): add boot flags kdb=on, kdb=off,
+ kdb=early.
+
+ * include/linux/sysctl.h (enum): add KERN_KDB.
+
+ * drivers/char/serial.c (receive_chars): check kdb_on.
+
+ * drivers/char/keyboard.c (handle_scancode): check kdb_on.
+
+ * arch/i386/kernel/traps.c (nmi_watchdog_tick): check kdb_on.
+
+ * arch/i386/config.in: add CONFIG_KDB_OFF.
+
+ * Documentation/Configure.help: add CONFIG_KDB_OFF.
+
+ * kdb/kdbmain.c: add kdb_initial_cpu, kdb_on.
+
+ * kdb/kdbmain.c (kdb): check kdb_on, set kdb_initial_cpu.
+
+ * kdb/kdbmain.c (kdb_init): add Keith Owens to kdb banner.
+
+ * kdb/kdb_io.c (kdb_printf): serialize kdb_printf output.
+
+ * kdb/kdb_bt.c (kdb_bt): check environment variable BTAPROMPT.
+
+ * kdb/kdbsupport.c (kdb_ipi): ignore NMI for kdb_initial_cpu.
+
+ * kdb/modules/kdbm_pg.c (kdbm_page): merge updates from 2.4.0-test5-xfs.
+
+ * kdb/kdb_bt.man: add btp, bta, BTAPROMPT.
+
+ * kdb/kdb.mm: add CONFIG_KDB_OFF, boot flags, btp, bta.
+
+ * include/linux/kdbprivate.h: add kdb_initial_cpu.
+
+ * include/linux/kdb.h: add kdb_on, bump version to kdb v1.4.
Index: linux/kdb/Makefile
===================================================================
--- /dev/null
+++ linux/kdb/Makefile
@@ -0,0 +1,43 @@
+#
+# This file is subject to the terms and conditions of the GNU General Public
+# License. See the file "COPYING" in the main directory of this archive
+# for more details.
+#
+# Copyright (c) 1999-2004 Silicon Graphics, Inc. All Rights Reserved.
+#
+
+CCVERSION := $(shell $(CC) -v 2>&1 | sed -ne '$$p')
+obj-y := kdb_bt.o kdb_bp.o kdb_id.o kdbsupport.o gen-kdb_cmds.o kdbmain.o kdb_io.o
+CFLAGS_kdbmain.o += -DCCVERSION="$(CCVERSION)"
+
+subdir-$(CONFIG_KDB_MODULES) := modules
+obj-y += $(addsuffix /built-in.o, $(subdir-y))
+
+clean-files := gen-kdb_cmds.c
+
+override CFLAGS := $(CFLAGS:%-pg=% )
+
+# define architecture dependent kdb_cmds
+ifeq ($(CONFIG_IA64),y)
+ KDB_CMDS = ia64/kdb/kdb_cmds
+else
+ ifeq ($(CONFIG_X86_64),y)
+ KDB_CMDS = x86/kdb/kdb_cmds_64
+ else
+ ifeq ($(CONFIG_X86_32),y)
+ KDB_CMDS = x86/kdb/kdb_cmds_32
+ endif
+ endif
+endif
+
+quiet_cmd_gen-kdb = GENKDB $@
+ cmd_gen-kdb = $(AWK) 'BEGIN {print "\#include <linux/stddef.h>"; print "\#include <linux/init.h>"} \
+ /^\#/{next} \
+ /^[ \t]*$$/{next} \
+ {gsub(/"/, "\\\"", $$0); \
+ print "static __initdata char kdb_cmd" cmds++ "[] = \"" $$0 "\\n\";"} \
+ END {print "extern char *kdb_cmds[]; char __initdata *kdb_cmds[] = {"; for (i = 0; i < cmds; ++i) {print " kdb_cmd" i ","}; print(" NULL\n};");}' \
+ $(filter-out %/Makefile,$^) > $@
+
+$(obj)/gen-kdb_cmds.c: $(src)/kdb_cmds $(wildcard $(TOPDIR)/arch/$(KDB_CMDS)) $(src)/Makefile
+ $(call cmd,gen-kdb)
Index: linux/kdb/kdb_bp.c
===================================================================
--- /dev/null
+++ linux/kdb/kdb_bp.c
@@ -0,0 +1,619 @@
+/*
+ * Kernel Debugger Architecture Independent Breakpoint Handler
+ *
+ * This file is subject to the terms and conditions of the GNU General Public
+ * License. See the file "COPYING" in the main directory of this archive
+ * for more details.
+ *
+ * Copyright (c) 1999-2004 Silicon Graphics, Inc. All Rights Reserved.
+ */
+
+#include <linux/string.h>
+#include <linux/kernel.h>
+#include <linux/init.h>
+#include <linux/kdb.h>
+#include <linux/kdbprivate.h>
+#include <linux/smp.h>
+#include <linux/sched.h>
+#include <linux/interrupt.h>
+#include <asm/system.h>
+
+/*
+ * Table of kdb_breakpoints
+ */
+kdb_bp_t kdb_breakpoints[KDB_MAXBPT];
+
+/*
+ * kdb_bp_install_global
+ *
+ * Install global kdb_breakpoints prior to returning from the
+ * kernel debugger. This allows the kdb_breakpoints to be set
+ * upon functions that are used internally by kdb, such as
+ * printk().
+ *
+ * Parameters:
+ * regs Execution frame.
+ * Outputs:
+ * None.
+ * Returns:
+ * None.
+ * Locking:
+ * None.
+ * Remarks:
+ *
+ * This function is only called once per kdb session.
+ */
+
+void
+kdb_bp_install_global(struct pt_regs *regs)
+{
+ int i;
+
+ for(i=0; i<KDB_MAXBPT; i++) {
+ if (KDB_DEBUG(BP)) {
+ kdb_printf("kdb_bp_install_global bp %d bp_enabled %d bp_global %d\n",
+ i, kdb_breakpoints[i].bp_enabled, kdb_breakpoints[i].bp_global);
+ }
+ if (kdb_breakpoints[i].bp_enabled
+ && kdb_breakpoints[i].bp_global) {
+ kdba_installbp(regs, &kdb_breakpoints[i]);
+ }
+ }
+}
+
+/*
+ * kdb_bp_install_local
+ *
+ * Install local kdb_breakpoints prior to returning from the
+ * kernel debugger. This allows the kdb_breakpoints to be set
+ * upon functions that are used internally by kdb, such as
+ * printk().
+ *
+ * Parameters:
+ * regs Execution frame.
+ * Outputs:
+ * None.
+ * Returns:
+ * None.
+ * Locking:
+ * None.
+ * Remarks:
+ *
+ * This function is called once per processor.
+ */
+
+void
+kdb_bp_install_local(struct pt_regs *regs)
+{
+ int i;
+
+ for(i=0; i<KDB_MAXBPT; i++) {
+ if (KDB_DEBUG(BP)) {
+ kdb_printf("kdb_bp_install_local bp %d bp_enabled %d bp_global %d cpu %d bp_cpu %d\n",
+ i, kdb_breakpoints[i].bp_enabled, kdb_breakpoints[i].bp_global,
+ smp_processor_id(), kdb_breakpoints[i].bp_cpu);
+ }
+ if (kdb_breakpoints[i].bp_enabled
+ && kdb_breakpoints[i].bp_cpu == smp_processor_id()
+ && !kdb_breakpoints[i].bp_global){
+ kdba_installbp(regs, &kdb_breakpoints[i]);
+ }
+ }
+}
+
+/*
+ * kdb_bp_remove_global
+ *
+ * Remove global kdb_breakpoints upon entry to the kernel debugger.
+ *
+ * Parameters:
+ * None.
+ * Outputs:
+ * None.
+ * Returns:
+ * None.
+ * Locking:
+ * None.
+ * Remarks:
+ */
+
+void
+kdb_bp_remove_global(void)
+{
+ int i;
+
+ for(i=KDB_MAXBPT-1; i>=0; i--) {
+ if (KDB_DEBUG(BP)) {
+ kdb_printf("kdb_bp_remove_global bp %d bp_enabled %d bp_global %d\n",
+ i, kdb_breakpoints[i].bp_enabled, kdb_breakpoints[i].bp_global);
+ }
+ if (kdb_breakpoints[i].bp_enabled
+ && kdb_breakpoints[i].bp_global) {
+ kdba_removebp(&kdb_breakpoints[i]);
+ }
+ }
+}
+
+
+/*
+ * kdb_bp_remove_local
+ *
+ * Remove local kdb_breakpoints upon entry to the kernel debugger.
+ *
+ * Parameters:
+ * None.
+ * Outputs:
+ * None.
+ * Returns:
+ * None.
+ * Locking:
+ * None.
+ * Remarks:
+ */
+
+void
+kdb_bp_remove_local(void)
+{
+ int i;
+
+ for(i=KDB_MAXBPT-1; i>=0; i--) {
+ if (KDB_DEBUG(BP)) {
+ kdb_printf("kdb_bp_remove_local bp %d bp_enabled %d bp_global %d cpu %d bp_cpu %d\n",
+ i, kdb_breakpoints[i].bp_enabled, kdb_breakpoints[i].bp_global,
+ smp_processor_id(), kdb_breakpoints[i].bp_cpu);
+ }
+ if (kdb_breakpoints[i].bp_enabled
+ && kdb_breakpoints[i].bp_cpu == smp_processor_id()
+ && !kdb_breakpoints[i].bp_global){
+ kdba_removebp(&kdb_breakpoints[i]);
+ }
+ }
+}
+
+/*
+ * kdb_printbp
+ *
+ * Internal function to format and print a breakpoint entry.
+ *
+ * Parameters:
+ * None.
+ * Outputs:
+ * None.
+ * Returns:
+ * None.
+ * Locking:
+ * None.
+ * Remarks:
+ */
+
+static void
+kdb_printbp(kdb_bp_t *bp, int i)
+{
+ if (bp->bp_forcehw) {
+ kdb_printf("Forced ");
+ }
+
+ if (!bp->bp_template.bph_free) {
+ kdb_printf("%s ", kdba_bptype(&bp->bp_template));
+ } else {
+ kdb_printf("Instruction(i) ");
+ }
+
+ kdb_printf("BP #%d at ", i);
+ kdb_symbol_print(bp->bp_addr, NULL, KDB_SP_DEFAULT);
+
+ if (bp->bp_enabled) {
+ kdba_printbp(bp);
+ if (bp->bp_global)
+ kdb_printf(" globally");
+ else
+ kdb_printf(" on cpu %d", bp->bp_cpu);
+ if (bp->bp_adjust)
+ kdb_printf(" adjust %d", bp->bp_adjust);
+ } else {
+ kdb_printf("\n is disabled");
+ }
+
+ kdb_printf("\n");
+}
+
+/*
+ * kdb_bp
+ *
+ * Handle the bp, and bpa commands.
+ *
+ * [bp|bpa|bph] <addr-expression> [DATAR|DATAW|IO [length]]
+ *
+ * Parameters:
+ * argc Count of arguments in argv
+ * argv Space delimited command line arguments
+ * Outputs:
+ * None.
+ * Returns:
+ * Zero for success, a kdb diagnostic if failure.
+ * Locking:
+ * None.
+ * Remarks:
+ *
+ * bp Set breakpoint. Only use hardware assist if necessary.
+ * bpa Set breakpoint on all cpus, only use hardware regs if necessary
+ * bph Set breakpoint - force hardware register
+ * bpha Set breakpoint on all cpus, force hardware register
+ */
+
+static int
+kdb_bp(int argc, const char **argv)
+{
+ int i, bpno;
+ kdb_bp_t *bp, *bp_check;
+ int diag;
+ int free;
+ kdb_machreg_t addr;
+ char *symname = NULL;
+ long offset = 0ul;
+ int nextarg;
+ int hardware;
+ int global;
+
+ if (argc == 0) {
+ /*
+ * Display breakpoint table
+ */
+ for(bpno=0,bp=kdb_breakpoints; bpno<KDB_MAXBPT; bpno++, bp++) {
+ if (bp->bp_free) continue;
+
+ kdb_printbp(bp, bpno);
+ }
+
+ return 0;
+ }
+
+ global = ((strcmp(argv[0], "bpa") == 0)
+ || (strcmp(argv[0], "bpha") == 0));
+ hardware = ((strcmp(argv[0], "bph") == 0)
+ || (strcmp(argv[0], "bpha") == 0));
+
+ nextarg = 1;
+ diag = kdbgetaddrarg(argc, argv, &nextarg, &addr, &offset, &symname);
+ if (diag)
+ return diag;
+ if (!addr)
+ return KDB_BADINT;
+
+ /*
+ * Allocate a new bp structure
+ */
+ free = KDB_MAXBPT;
+ for(bpno=0,bp=kdb_breakpoints; bpno<KDB_MAXBPT; bpno++,bp++) {
+ if (bp->bp_free) {
+ break;
+ }
+ }
+
+ if (bpno == KDB_MAXBPT)
+ return KDB_TOOMANYBPT;
+
+ memset(bp, 0, sizeof(*bp));
+ bp->bp_free = 1;
+ kdba_check_pc(&addr);
+ for(i=0,bp_check=kdb_breakpoints; i<KDB_MAXBPT; i++,bp_check++) {
+ if (!bp_check->bp_free && bp_check->bp_addr == addr) {
+ kdb_printf("You already have a breakpoint at " kdb_bfd_vma_fmt0 "\n", addr);
+ return KDB_DUPBPT;
+ }
+ }
+ bp->bp_addr = addr;
+ bp->bp_free = 0;
+
+ bp->bp_forcehw = hardware;
+ if (KDB_DEBUG(BP))
+ kdb_printf("kdb_bp: forcehw is %d hardware is %d\n", bp->bp_forcehw, hardware);
+
+ /*
+ * Handle architecture dependent parsing
+ */
+ diag = kdba_parsebp(argc, argv, &nextarg, bp);
+ if (diag) {
+ return diag;
+ }
+
+ bp->bp_enabled = 1;
+ bp->bp_global = 1; /* Most breakpoints are global */
+
+ if (hardware && !global) {
+ bp->bp_global = 0;
+ bp->bp_cpu = smp_processor_id();
+ }
+
+ /*
+ * Allocate a hardware breakpoint. If one is not available,
+ * disable the breakpoint, but leave it in the breakpoint
+ * table. When the breakpoint is re-enabled (via 'be'), we'll
+ * attempt to allocate a hardware register for it.
+ */
+ if (!bp->bp_template.bph_free) {
+ bp->bp_hard = kdba_allocbp(&bp->bp_template, &diag);
+ if (diag) {
+ bp->bp_enabled = 0;
+ return diag;
+ }
+ bp->bp_hardtype = 1;
+ }
+
+ kdb_printbp(bp, bpno);
+
+ return 0;
+}
+
+/*
+ * kdb_bc
+ *
+ * Handles the 'bc', 'be', and 'bd' commands
+ *
+ * [bd|bc|be] <breakpoint-number>
+ * [bd|bc|be] *
+ *
+ * Parameters:
+ * argc Count of arguments in argv
+ * argv Space delimited command line arguments
+ * Outputs:
+ * None.
+ * Returns:
+ * Zero for success, a kdb diagnostic for failure
+ * Locking:
+ * None.
+ * Remarks:
+ */
+
+#define KDBCMD_BC 0
+#define KDBCMD_BE 1
+#define KDBCMD_BD 2
+
+static int
+kdb_bc(int argc, const char **argv)
+{
+ kdb_machreg_t addr;
+ kdb_bp_t *bp = NULL;
+ int lowbp = KDB_MAXBPT;
+ int highbp = 0;
+ int done = 0;
+ int i;
+ int diag;
+ int cmd; /* KDBCMD_B? */
+
+ if (strcmp(argv[0], "be") == 0) {
+ cmd = KDBCMD_BE;
+ } else if (strcmp(argv[0], "bd") == 0) {
+ cmd = KDBCMD_BD;
+ } else
+ cmd = KDBCMD_BC;
+
+ if (argc != 1)
+ return KDB_ARGCOUNT;
+
+ if (strcmp(argv[1], "*") == 0) {
+ lowbp = 0;
+ highbp = KDB_MAXBPT;
+ } else {
+ diag = kdbgetularg(argv[1], &addr);
+ if (diag)
+ return diag;
+
+ /*
+ * For addresses less than the maximum breakpoint number,
+ * assume that the breakpoint number is desired.
+ */
+ if (addr < KDB_MAXBPT) {
+ bp = &kdb_breakpoints[addr];
+ lowbp = highbp = addr;
+ highbp++;
+ } else {
+ for(i=0, bp=kdb_breakpoints; i<KDB_MAXBPT; i++, bp++) {
+ if (bp->bp_addr == addr) {
+ lowbp = highbp = i;
+ highbp++;
+ break;
+ }
+ }
+ }
+ }
+
+ /*
+ * Now operate on the set of breakpoints matching the input
+ * criteria (either '*' for all, or an individual breakpoint).
+ */
+ for(bp=&kdb_breakpoints[lowbp], i=lowbp;
+ i < highbp;
+ i++, bp++) {
+ if (bp->bp_free)
+ continue;
+
+ done++;
+
+ switch (cmd) {
+ case KDBCMD_BC:
+ if (bp->bp_hardtype) {
+ kdba_freebp(bp->bp_hard);
+ bp->bp_hard = NULL;
+ bp->bp_hardtype = 0;
+ }
+
+ bp->bp_enabled = 0;
+ bp->bp_global = 0;
+
+ kdb_printf("Breakpoint %d at " kdb_bfd_vma_fmt " cleared\n",
+ i, bp->bp_addr);
+
+ bp->bp_addr = 0;
+ bp->bp_free = 1;
+
+ break;
+ case KDBCMD_BE:
+ /*
+ * Allocate a hardware breakpoint. If one is not
+ * available, don't enable the breakpoint.
+ */
+ if (!bp->bp_template.bph_free
+ && !bp->bp_hardtype) {
+ bp->bp_hard = kdba_allocbp(&bp->bp_template, &diag);
+ if (diag) {
+ bp->bp_enabled = 0;
+ return diag;
+ }
+ bp->bp_hardtype = 1;
+ }
+
+ bp->bp_enabled = 1;
+
+ kdb_printf("Breakpoint %d at " kdb_bfd_vma_fmt " enabled",
+ i, bp->bp_addr);
+
+ kdb_printf("\n");
+ break;
+ case KDBCMD_BD:
+ if (!bp->bp_enabled)
+ break;
+
+ /*
+ * Since this breakpoint is now disabled, we can
+ * give up the hardware register which is allocated
+ * to it.
+ */
+ if (bp->bp_hardtype) {
+ kdba_freebp(bp->bp_hard);
+ bp->bp_hard = NULL;
+ bp->bp_hardtype = 0;
+ }
+
+ bp->bp_enabled = 0;
+
+ kdb_printf("Breakpoint %d at " kdb_bfd_vma_fmt " disabled\n",
+ i, bp->bp_addr);
+
+ break;
+ }
+ if (bp->bp_delay && (cmd == KDBCMD_BC || cmd == KDBCMD_BD)) {
+ bp->bp_delay = 0;
+ KDB_STATE_CLEAR(SSBPT);
+ }
+ }
+
+ return (!done)?KDB_BPTNOTFOUND:0;
+}
+
+/*
+ * kdb_ss
+ *
+ * Process the 'ss' (Single Step) and 'ssb' (Single Step to Branch)
+ * commands.
+ *
+ * ss
+ * ssb
+ *
+ * Parameters:
+ * argc Argument count
+ * argv Argument vector
+ * Outputs:
+ * None.
+ * Returns:
+ * KDB_CMD_SS[B] for success, a kdb error if failure.
+ * Locking:
+ * None.
+ * Remarks:
+ *
+ * Set the arch specific option to trigger a debug trap after the next
+ * instruction.
+ *
+ * For 'ssb', set the trace flag in the debug trap handler
+ * after printing the current insn and return directly without
+ * invoking the kdb command processor, until a branch instruction
+ * is encountered.
+ */
+
+static int
+kdb_ss(int argc, const char **argv)
+{
+ int ssb = 0;
+ struct pt_regs *regs = get_irq_regs();
+
+ ssb = (strcmp(argv[0], "ssb") == 0);
+ if (argc != 0)
+ return KDB_ARGCOUNT;
+
+ if (!regs) {
+ kdb_printf("%s: pt_regs not available\n", __FUNCTION__);
+ return KDB_BADREG;
+ }
+
+ /*
+ * Set trace flag and go.
+ */
+ KDB_STATE_SET(DOING_SS);
+ if (ssb)
+ KDB_STATE_SET(DOING_SSB);
+
+ kdba_setsinglestep(regs); /* Enable single step */
+
+ if (ssb)
+ return KDB_CMD_SSB;
+ return KDB_CMD_SS;
+}
+
+/*
+ * kdb_initbptab
+ *
+ * Initialize the breakpoint table. Register breakpoint commands.
+ *
+ * Parameters:
+ * None.
+ * Outputs:
+ * None.
+ * Returns:
+ * None.
+ * Locking:
+ * None.
+ * Remarks:
+ */
+
+void __init
+kdb_initbptab(void)
+{
+ int i;
+ kdb_bp_t *bp;
+
+ /*
+ * First time initialization.
+ */
+ memset(&kdb_breakpoints, '\0', sizeof(kdb_breakpoints));
+
+ for (i=0, bp=kdb_breakpoints; i<KDB_MAXBPT; i++, bp++) {
+ bp->bp_free = 1;
+ /*
+ * The bph_free flag is architecturally required. It
+ * is set by architecture-dependent code to false (zero)
+ * in the event a hardware breakpoint register is required
+ * for this breakpoint.
+ *
+ * The rest of the template is reserved to the architecture
+ * dependent code and _must_ not be touched by the architecture
+ * independent code.
+ */
+ bp->bp_template.bph_free = 1;
+ }
+
+ kdb_register_repeat("bp", kdb_bp, "[<vaddr>]", "Set/Display breakpoints", 0, KDB_REPEAT_NO_ARGS);
+ kdb_register_repeat("bl", kdb_bp, "[<vaddr>]", "Display breakpoints", 0, KDB_REPEAT_NO_ARGS);
+ kdb_register_repeat("bpa", kdb_bp, "[<vaddr>]", "Set/Display global breakpoints", 0, KDB_REPEAT_NO_ARGS);
+ kdb_register_repeat("bph", kdb_bp, "[<vaddr>]", "Set hardware breakpoint", 0, KDB_REPEAT_NO_ARGS);
+ kdb_register_repeat("bpha", kdb_bp, "[<vaddr>]", "Set global hardware breakpoint", 0, KDB_REPEAT_NO_ARGS);
+ kdb_register_repeat("bc", kdb_bc, "<bpnum>", "Clear Breakpoint", 0, KDB_REPEAT_NONE);
+ kdb_register_repeat("be", kdb_bc, "<bpnum>", "Enable Breakpoint", 0, KDB_REPEAT_NONE);
+ kdb_register_repeat("bd", kdb_bc, "<bpnum>", "Disable Breakpoint", 0, KDB_REPEAT_NONE);
+
+ kdb_register_repeat("ss", kdb_ss, "", "Single Step", 1, KDB_REPEAT_NO_ARGS);
+ kdb_register_repeat("ssb", kdb_ss, "", "Single step to branch/call", 0, KDB_REPEAT_NO_ARGS);
+ /*
+ * Architecture dependent initialization.
+ */
+ kdba_initbp();
+}
Index: linux/kdb/kdb_bt.c
===================================================================
--- /dev/null
+++ linux/kdb/kdb_bt.c
@@ -0,0 +1,180 @@
+/*
+ * Kernel Debugger Architecture Independent Stack Traceback
+ *
+ * This file is subject to the terms and conditions of the GNU General Public
+ * License. See the file "COPYING" in the main directory of this archive
+ * for more details.
+ *
+ * Copyright (c) 1999-2004 Silicon Graphics, Inc. All Rights Reserved.
+ */
+
+#include <linux/ctype.h>
+#include <linux/string.h>
+#include <linux/kernel.h>
+#include <linux/sched.h>
+#include <linux/kdb.h>
+#include <linux/kdbprivate.h>
+#include <linux/nmi.h>
+#include <asm/system.h>
+
+
+/*
+ * kdb_bt
+ *
+ * This function implements the 'bt' command. Print a stack
+ * traceback.
+ *
+ * bt [<address-expression>] (addr-exp is for alternate stacks)
+ * btp <pid> Kernel stack for <pid>
+ * btt <address-expression> Kernel stack for task structure at <address-expression>
+ * bta [DRSTCZEUIMA] All useful processes, optionally filtered by state
+ * btc [<cpu>] The current process on one cpu, default is all cpus
+ *
+ * bt <address-expression> refers to a address on the stack, that location
+ * is assumed to contain a return address.
+ *
+ * btt <address-expression> refers to the address of a struct task.
+ *
+ * Inputs:
+ * argc argument count
+ * argv argument vector
+ * Outputs:
+ * None.
+ * Returns:
+ * zero for success, a kdb diagnostic if error
+ * Locking:
+ * none.
+ * Remarks:
+ * Backtrack works best when the code uses frame pointers. But even
+ * without frame pointers we should get a reasonable trace.
+ *
+ * mds comes in handy when examining the stack to do a manual traceback or
+ * to get a starting point for bt <address-expression>.
+ */
+
+static int
+kdb_bt1(const struct task_struct *p, unsigned long mask, int argcount, int btaprompt)
+{
+ int diag;
+ char buffer[2];
+ if (kdb_getarea(buffer[0], (unsigned long)p) ||
+ kdb_getarea(buffer[0], (unsigned long)(p+1)-1))
+ return KDB_BADADDR;
+ if (!kdb_task_state(p, mask))
+ return 0;
+ kdb_printf("Stack traceback for pid %d\n", p->pid);
+ kdb_ps1(p);
+ diag = kdba_bt_process(p, argcount);
+ if (btaprompt) {
+ kdb_getstr(buffer, sizeof(buffer), "Enter <q> to end, <cr> to continue:");
+ if (buffer[0] == 'q') {
+ kdb_printf("\n");
+ return 1;
+ }
+ }
+ touch_nmi_watchdog();
+ return 0;
+}
+
+int
+kdb_bt(int argc, const char **argv)
+{
+ int diag;
+ int argcount = 5;
+ int btaprompt = 1;
+ int nextarg;
+ unsigned long addr;
+ long offset;
+
+ kdbgetintenv("BTARGS", &argcount); /* Arguments to print */
+ kdbgetintenv("BTAPROMPT", &btaprompt); /* Prompt after each proc in bta */
+
+ if (strcmp(argv[0], "bta") == 0) {
+ struct task_struct *g, *p;
+ unsigned long cpu;
+ unsigned long mask = kdb_task_state_string(argc ? argv[1] : NULL);
+ if (argc == 0)
+ kdb_ps_suppressed();
+ /* Run the active tasks first */
+ for (cpu = 0; cpu < NR_CPUS; ++cpu) {
+ if (!cpu_online(cpu))
+ continue;
+ p = kdb_curr_task(cpu);
+ if (kdb_bt1(p, mask, argcount, btaprompt))
+ return 0;
+ }
+ /* Now the inactive tasks */
+ kdb_do_each_thread(g, p) {
+ if (task_curr(p))
+ continue;
+ if (kdb_bt1(p, mask, argcount, btaprompt))
+ return 0;
+ } kdb_while_each_thread(g, p);
+ } else if (strcmp(argv[0], "btp") == 0) {
+ struct task_struct *p;
+ unsigned long pid;
+ if (argc != 1)
+ return KDB_ARGCOUNT;
+ if ((diag = kdbgetularg((char *)argv[1], &pid)))
+ return diag;
+ if ((p = find_task_by_pid(pid))) {
+ kdba_set_current_task(p);
+ return kdb_bt1(p, ~0UL, argcount, 0);
+ }
+ kdb_printf("No process with pid == %ld found\n", pid);
+ return 0;
+ } else if (strcmp(argv[0], "btt") == 0) {
+ if (argc != 1)
+ return KDB_ARGCOUNT;
+ if ((diag = kdbgetularg((char *)argv[1], &addr)))
+ return diag;
+ kdba_set_current_task((struct task_struct *)addr);
+ return kdb_bt1((struct task_struct *)addr, ~0UL, argcount, 0);
+ } else if (strcmp(argv[0], "btc") == 0) {
+ unsigned long cpu = ~0;
+ struct kdb_running_process *krp;
+ const struct task_struct *save_current_task = kdb_current_task;
+ char buf[80];
+ if (argc > 1)
+ return KDB_ARGCOUNT;
+ if (argc == 1 && (diag = kdbgetularg((char *)argv[1], &cpu)))
+ return diag;
+ /* Recursive use of kdb_parse, do not use argv after this point */
+ argv = NULL;
+ if (cpu != ~0) {
+ krp = kdb_running_process + cpu;
+ if (cpu >= NR_CPUS || !krp->seqno || !cpu_online(cpu)) {
+ kdb_printf("no process for cpu %ld\n", cpu);
+ return 0;
+ }
+ sprintf(buf, "btt 0x%p\n", krp->p);
+ kdb_parse(buf);
+ return 0;
+ }
+ kdb_printf("btc: cpu status: ");
+ kdb_parse("cpu\n");
+ for (cpu = 0, krp = kdb_running_process; cpu < NR_CPUS; ++cpu, ++krp) {
+ if (!cpu_online(cpu) || !krp->seqno)
+ continue;
+ sprintf(buf, "btt 0x%p\n", krp->p);
+ kdb_parse(buf);
+ touch_nmi_watchdog();
+ }
+ kdba_set_current_task(save_current_task);
+ return 0;
+ } else {
+ if (argc) {
+ nextarg = 1;
+ diag = kdbgetaddrarg(argc, argv, &nextarg, &addr,
+ &offset, NULL);
+ if (diag)
+ return diag;
+ return kdba_bt_address(addr, argcount);
+ } else {
+ return kdb_bt1(kdb_current_task, ~0UL, argcount, 0);
+ }
+ }
+
+ /* NOTREACHED */
+ return 0;
+}
Index: linux/kdb/kdb_cmds
===================================================================
--- /dev/null
+++ linux/kdb/kdb_cmds
@@ -0,0 +1,32 @@
+# Initial commands for kdb, alter to suit your needs.
+# These commands are executed in kdb_init() context, no SMP, no
+# processes. Commands that require process data (including stack or
+# registers) are not reliable this early. set and bp commands should
+# be safe. Global breakpoint commands affect each cpu as it is booted.
+
+# Standard debugging information for first level support, just type archkdb
+# or archkdbcpu or archkdbshort at the kdb prompt.
+
+defcmd archkdb "" "First line arch debugging"
+ set BTSYMARG 1
+ set BTARGS 9
+ pid R
+ -archkdbcommon
+ -bta
+endefcmd
+
+defcmd archkdbcpu "" "archkdb with only tasks on cpus"
+ set BTSYMARG 1
+ set BTARGS 9
+ pid R
+ -archkdbcommon
+ -btc
+endefcmd
+
+defcmd archkdbshort "" "archkdb with less detailed backtrace"
+ set BTSYMARG 0
+ set BTARGS 0
+ pid R
+ -archkdbcommon
+ -bta
+endefcmd
Index: linux/kdb/kdb_id.c
===================================================================
--- /dev/null
+++ linux/kdb/kdb_id.c
@@ -0,0 +1,236 @@
+/*
+ * Kernel Debugger Architecture Independent Instruction Disassembly
+ *
+ * This file is subject to the terms and conditions of the GNU General Public
+ * License. See the file "COPYING" in the main directory of this archive
+ * for more details.
+ *
+ * Copyright (c) 1999-2004 Silicon Graphics, Inc. All Rights Reserved.
+ */
+
+#include <stdarg.h>
+#include <linux/kernel.h>
+#include <linux/init.h>
+#include <linux/ctype.h>
+#include <linux/string.h>
+#include <linux/kdb.h>
+#include <linux/kdbprivate.h>
+
+disassemble_info kdb_di;
+
+/*
+ * kdb_id
+ *
+ * Handle the id (instruction display) command.
+ *
+ * id [<addr>]
+ *
+ * Parameters:
+ * argc Count of arguments in argv
+ * argv Space delimited command line arguments
+ * Outputs:
+ * None.
+ * Returns:
+ * Zero for success, a kdb diagnostic if failure.
+ * Locking:
+ * None.
+ * Remarks:
+ */
+
+int
+kdb_id(int argc, const char **argv)
+{
+ kdb_machreg_t pc;
+ int icount;
+ int diag;
+ int i;
+ char *mode;
+ int nextarg;
+ long offset = 0;
+ static kdb_machreg_t lastpc;
+ struct disassemble_info *dip = &kdb_di;
+ char lastbuf[50];
+ unsigned long word;
+
+ kdb_di.fprintf_func = kdb_dis_fprintf;
+ kdba_id_init(&kdb_di);
+
+ if (argc != 1) {
+ if (lastpc == 0) {
+ return KDB_ARGCOUNT;
+ } else {
+ sprintf(lastbuf, "0x%lx", lastpc);
+ argv[1] = lastbuf;
+ argc = 1;
+ }
+ }
+
+
+ /*
+ * Fetch PC. First, check to see if it is a symbol, if not,
+ * try address.
+ */
+ nextarg = 1;
+ diag = kdbgetaddrarg(argc, argv, &nextarg, &pc, &offset, NULL);
+ if (diag)
+ return diag;
+ kdba_check_pc(&pc);
+ if (kdb_getarea(word, pc))
+ return(0);
+
+ /*
+ * Number of lines to display
+ */
+ diag = kdbgetintenv("IDCOUNT", &icount);
+ if (diag)
+ return diag;
+
+ mode = kdbgetenv("IDMODE");
+ diag = kdba_id_parsemode(mode, dip);
+ if (diag) {
+ return diag;
+ }
+
+ for(i=0; i<icount; i++) {
+ pc += kdba_id_printinsn(pc, &kdb_di);
+ kdb_printf("\n");
+ }
+
+ lastpc = pc;
+
+ return 0;
+}
+
+/*
+ * kdb_id1
+ *
+ * Disassemble a single instruction at 'pc'.
+ *
+ * Parameters:
+ * pc Address of instruction to disassemble
+ * Outputs:
+ * None.
+ * Returns:
+ * Zero for success, a kdb diagnostic if failure.
+ * Locking:
+ * None.
+ * Remarks:
+ */
+
+void
+kdb_id1(unsigned long pc)
+{
+ char *mode;
+ int diag;
+
+ kdb_di.fprintf_func = kdb_dis_fprintf;
+ kdba_id_init(&kdb_di);
+
+ /*
+ * Allow the user to specify that this instruction
+ * should be treated differently.
+ */
+
+ mode = kdbgetenv("IDMODE");
+ diag = kdba_id_parsemode(mode, &kdb_di);
+ if (diag) {
+ kdb_printf("kdb_id: bad value in 'IDMODE' environment variable ignored\n");
+ }
+
+ (void) kdba_id_printinsn(pc, &kdb_di);
+ kdb_printf("\n");
+}
+
+/*
+ * kdb_dis_fprintf
+ *
+ * Format and print a string.
+ *
+ * Parameters:
+ * file Unused paramter.
+ * fmt Format string
+ * ... Optional additional parameters.
+ * Returns:
+ * 0
+ * Locking:
+ * Remarks:
+ * Result of format conversion cannot exceed 255 bytes.
+ */
+
+int
+kdb_dis_fprintf(PTR file, const char *fmt, ...)
+{
+ char buffer[256];
+ va_list ap;
+
+ va_start(ap, fmt);
+ vsprintf(buffer, fmt, ap);
+ va_end(ap);
+
+ kdb_printf("%s", buffer);
+
+ return 0;
+}
+
+/*
+ * kdb_dis_fprintf_dummy
+ *
+ * A dummy printf function for the disassembler, it does nothing.
+ * This lets code call the disassembler to step through
+ * instructions without actually printing anything.
+ * Inputs:
+ * Always ignored.
+ * Outputs:
+ * None.
+ * Returns:
+ * Always 0.
+ * Locking:
+ * none.
+ * Remarks:
+ * None.
+ */
+
+int
+kdb_dis_fprintf_dummy(PTR file, const char *fmt, ...)
+{
+ return(0);
+}
+
+/*
+ * kdb_disinit
+ *
+ * Initialize the disassembly information structure
+ * for the GNU disassembler.
+ *
+ * Parameters:
+ * None.
+ * Outputs:
+ * None.
+ * Returns:
+ * Zero for success, a kdb diagnostic if failure.
+ * Locking:
+ * None.
+ * Remarks:
+ */
+
+void __init
+kdb_id_init(void)
+{
+ kdb_di.stream = NULL;
+ kdb_di.application_data = NULL;
+ kdb_di.symbols = NULL;
+ kdb_di.num_symbols = 0;
+ kdb_di.flags = 0;
+ kdb_di.private_data = NULL;
+ kdb_di.buffer = NULL;
+ kdb_di.buffer_vma = 0;
+ kdb_di.buffer_length = 0;
+ kdb_di.bytes_per_line = 0;
+ kdb_di.bytes_per_chunk = 0;
+ kdb_di.insn_info_valid = 0;
+ kdb_di.branch_delay_insns = 0;
+ kdb_di.data_size = 0;
+ kdb_di.insn_type = 0;
+ kdb_di.target = 0;
+ kdb_di.target2 = 0;
+}
Index: linux/kdb/kdb_io.c
===================================================================
--- /dev/null
+++ linux/kdb/kdb_io.c
@@ -0,0 +1,676 @@
+/*
+ * Kernel Debugger Architecture Independent Console I/O handler
+ *
+ * This file is subject to the terms and conditions of the GNU General Public
+ * License. See the file "COPYING" in the main directory of this archive
+ * for more details.
+ *
+ * Copyright (c) 1999-2006 Silicon Graphics, Inc. All Rights Reserved.
+ */
+
+#include <linux/module.h>
+#include <linux/types.h>
+#include <linux/ctype.h>
+#include <linux/kernel.h>
+#include <linux/init.h>
+#include <linux/kdev_t.h>
+#include <linux/console.h>
+#include <linux/string.h>
+#include <linux/sched.h>
+#include <linux/smp.h>
+#include <linux/nmi.h>
+#include <linux/delay.h>
+
+#include <linux/kdb.h>
+#include <linux/kdbprivate.h>
+#include <linux/kallsyms.h>
+
+static struct console *kdbcons;
+
+#ifdef CONFIG_PPC64
+#include <asm/udbg.h>
+#endif
+
+#define CMD_BUFLEN 256
+char kdb_prompt_str[CMD_BUFLEN];
+
+/*
+ * kdb_read
+ *
+ * This function reads a string of characters, terminated by
+ * a newline, or by reaching the end of the supplied buffer,
+ * from the current kernel debugger console device.
+ * Parameters:
+ * buffer - Address of character buffer to receive input characters.
+ * bufsize - size, in bytes, of the character buffer
+ * Returns:
+ * Returns a pointer to the buffer containing the received
+ * character string. This string will be terminated by a
+ * newline character.
+ * Locking:
+ * No locks are required to be held upon entry to this
+ * function. It is not reentrant - it relies on the fact
+ * that while kdb is running on any one processor all other
+ * processors will be spinning at the kdb barrier.
+ * Remarks:
+ *
+ * Davidm asks, why doesn't kdb use the console abstraction;
+ * here are some reasons:
+ * - you cannot debug the console abstraction with kdb if
+ * kdb uses it.
+ * - you rely on the correct functioning of the abstraction
+ * in the presence of general system failures.
+ * - You must acquire the console spinlock thus restricting
+ * the usability - what if the kernel fails with the spinlock
+ * held - one still wishes to debug such situations.
+ * - How about debugging before the console(s) are registered?
+ * - None of the current consoles (sercons, vt_console_driver)
+ * have read functions defined.
+ * - The standard pc keyboard and terminal drivers are interrupt
+ * driven. We cannot enable interrupts while kdb is active,
+ * so the standard input functions cannot be used by kdb.
+ *
+ * An implementation could be improved by removing the need for
+ * lock acquisition - just keep a 'struct console *kdbconsole;' global
+ * variable which refers to the preferred kdb console.
+ *
+ * The bulk of this function is architecture dependent.
+ *
+ * The buffer size must be >= 2. A buffer size of 2 means that the caller only
+ * wants a single key.
+ *
+ * An escape key could be the start of a vt100 control sequence such as \e[D
+ * (left arrow) or it could be a character in its own right. The standard
+ * method for detecting the difference is to wait for 2 seconds to see if there
+ * are any other characters. kdb is complicated by the lack of a timer service
+ * (interrupts are off), by multiple input sources and by the need to sometimes
+ * return after just one key. Escape sequence processing has to be done as
+ * states in the polling loop.
+ */
+
+char *
+kdb_read(char *buffer, size_t bufsize)
+{
+ char *cp = buffer;
+ char *bufend = buffer+bufsize-2; /* Reserve space for newline and null byte */
+
+ char *lastchar;
+ char *p_tmp;
+ char tmp;
+ static char tmpbuffer[CMD_BUFLEN];
+ int len = strlen(buffer);
+ int len_tmp;
+ int tab=0;
+ int count;
+ int i;
+ int diag, dtab_count;
+
+#define ESCAPE_UDELAY 1000
+#define ESCAPE_DELAY 2*1000000/ESCAPE_UDELAY /* 2 seconds worth of udelays */
+ char escape_data[5]; /* longest vt100 escape sequence is 4 bytes */
+ char *ped = escape_data;
+ int escape_delay = 0;
+ get_char_func *f, *f_escape = NULL;
+
+ diag = kdbgetintenv("DTABCOUNT",&dtab_count);
+ if (diag)
+ dtab_count = 30;
+
+ if (len > 0 ) {
+ cp += len;
+ if (*(buffer+len-1) == '\n')
+ cp--;
+ }
+
+ lastchar = cp;
+ *cp = '\0';
+ kdb_printf("%s", buffer);
+
+ for (;;) {
+ int key;
+ for (f = &poll_funcs[0]; ; ++f) {
+ if (*f == NULL) {
+ /* Reset NMI watchdog once per poll loop */
+ touch_nmi_watchdog();
+ f = &poll_funcs[0];
+ }
+ if (escape_delay == 2) {
+ *ped = '\0';
+ ped = escape_data;
+ --escape_delay;
+ }
+ if (escape_delay == 1) {
+ key = *ped++;
+ if (!*ped)
+ --escape_delay;
+ break;
+ }
+ key = (*f)();
+ if (key == -1) {
+ if (escape_delay) {
+ udelay(ESCAPE_UDELAY);
+ --escape_delay;
+ }
+ continue;
+ }
+ if (bufsize <= 2) {
+ if (key == '\r')
+ key = '\n';
+ kdb_printf("%c", key);
+ *buffer++ = key;
+ *buffer = '\0';
+ return buffer;
+ }
+ if (escape_delay == 0 && key == '\e') {
+ escape_delay = ESCAPE_DELAY;
+ ped = escape_data;
+ f_escape = f;
+ }
+ if (escape_delay) {
+ *ped++ = key;
+ if (f_escape != f) {
+ escape_delay = 2;
+ continue;
+ }
+ if (ped - escape_data == 1) {
+ /* \e */
+ continue;
+ }
+ else if (ped - escape_data == 2) {
+ /* \e<something> */
+ if (key != '[')
+ escape_delay = 2;
+ continue;
+ } else if (ped - escape_data == 3) {
+ /* \e[<something> */
+ int mapkey = 0;
+ switch (key) {
+ case 'A': mapkey = 16; break; /* \e[A, up arrow */
+ case 'B': mapkey = 14; break; /* \e[B, down arrow */
+ case 'C': mapkey = 6; break; /* \e[C, right arrow */
+ case 'D': mapkey = 2; break; /* \e[D, left arrow */
+ case '1': /* dropthrough */
+ case '3': /* dropthrough */
+ case '4': mapkey = -1; break; /* \e[<1,3,4>], may be home, del, end */
+ }
+ if (mapkey != -1) {
+ if (mapkey > 0) {
+ escape_data[0] = mapkey;
+ escape_data[1] = '\0';
+ }
+ escape_delay = 2;
+ }
+ continue;
+ } else if (ped - escape_data == 4) {
+ /* \e[<1,3,4><something> */
+ int mapkey = 0;
+ if (key == '~') {
+ switch (escape_data[2]) {
+ case '1': mapkey = 1; break; /* \e[1~, home */
+ case '3': mapkey = 4; break; /* \e[3~, del */
+ case '4': mapkey = 5; break; /* \e[4~, end */
+ }
+ }
+ if (mapkey > 0) {
+ escape_data[0] = mapkey;
+ escape_data[1] = '\0';
+ }
+ escape_delay = 2;
+ continue;
+ }
+ }
+ break; /* A key to process */
+ }
+
+ if (key != 9)
+ tab = 0;
+ switch (key) {
+ case 8: /* backspace */
+ if (cp > buffer) {
+ if (cp < lastchar) {
+ memcpy(tmpbuffer, cp, lastchar - cp);
+ memcpy(cp-1, tmpbuffer, lastchar - cp);
+ }
+ *(--lastchar) = '\0';
+ --cp;
+ kdb_printf("\b%s \r", cp);
+ tmp = *cp;
+ *cp = '\0';
+ kdb_printf(kdb_prompt_str);
+ kdb_printf("%s", buffer);
+ *cp = tmp;
+ }
+ break;
+ case 13: /* enter */
+ *lastchar++ = '\n';
+ *lastchar++ = '\0';
+ kdb_printf("\n");
+ return buffer;
+ case 4: /* Del */
+ if(cp < lastchar) {
+ memcpy(tmpbuffer, cp+1, lastchar - cp -1);
+ memcpy(cp, tmpbuffer, lastchar - cp -1);
+ *(--lastchar) = '\0';
+ kdb_printf("%s \r", cp);
+ tmp = *cp;
+ *cp = '\0';
+ kdb_printf(kdb_prompt_str);
+ kdb_printf("%s", buffer);
+ *cp = tmp;
+ }
+ break;
+ case 1: /* Home */
+ if(cp > buffer) {
+ kdb_printf("\r");
+ kdb_printf(kdb_prompt_str);
+ cp = buffer;
+ }
+ break;
+ case 5: /* End */
+ if(cp < lastchar) {
+ kdb_printf("%s", cp);
+ cp = lastchar;
+ }
+ break;
+ case 2: /* Left */
+ if (cp > buffer) {
+ kdb_printf("\b");
+ --cp;
+ }
+ break;
+ case 14: /* Down */
+ memset(tmpbuffer, ' ', strlen(kdb_prompt_str)+(lastchar-buffer));
+ *(tmpbuffer+strlen(kdb_prompt_str)+(lastchar-buffer)) = '\0';
+ kdb_printf("\r%s\r", tmpbuffer);
+ *lastchar = (char)key;
+ *(lastchar+1) = '\0';
+ return lastchar;
+ case 6: /* Right */
+ if (cp < lastchar) {
+ kdb_printf("%c", *cp);
+ ++cp;
+ }
+ break;
+ case 16: /* Up */
+ memset(tmpbuffer, ' ', strlen(kdb_prompt_str)+(lastchar-buffer));
+ *(tmpbuffer+strlen(kdb_prompt_str)+(lastchar-buffer)) = '\0';
+ kdb_printf("\r%s\r", tmpbuffer);
+ *lastchar = (char)key;
+ *(lastchar+1) = '\0';
+ return lastchar;
+ case 9: /* Tab */
+ if (tab < 2)
+ ++tab;
+ p_tmp = buffer;
+ while(*p_tmp==' ') p_tmp++;
+ if (p_tmp<=cp) {
+ memcpy(tmpbuffer, p_tmp, cp-p_tmp);
+ *(tmpbuffer + (cp-p_tmp)) = '\0';
+ p_tmp = strrchr(tmpbuffer, ' ');
+ if (p_tmp)
+ ++p_tmp;
+ else
+ p_tmp = tmpbuffer;
+ len = strlen(p_tmp);
+ count = kallsyms_symbol_complete(p_tmp, sizeof(tmpbuffer) - (p_tmp - tmpbuffer));
+ if (tab == 2) {
+ if (count > 0) {
+ kdb_printf("\n%d symbols are found.", count);
+ if(count>dtab_count) {
+ count=dtab_count;
+ kdb_printf(" But only first %d symbols will be printed.\nYou can change the environment variable DTABCOUNT.", count);
+ }
+ kdb_printf("\n");
+ for(i=0;i<count;i++) {
+ if(kallsyms_symbol_next(p_tmp, i)<0)
+ break;
+ kdb_printf("%s ",p_tmp);
+ *(p_tmp+len)='\0';
+ }
+ if(i>=dtab_count)kdb_printf("...");
+ kdb_printf("\n");
+ kdb_printf(kdb_prompt_str);
+ kdb_printf("%s", buffer);
+ }
+ }
+ else {
+ if (count > 0) {
+ len_tmp = strlen(p_tmp);
+ strncpy(p_tmp+len_tmp,cp, lastchar-cp+1);
+ len_tmp = strlen(p_tmp);
+ strncpy(cp, p_tmp+len, len_tmp-len+1);
+ len = len_tmp - len;
+ kdb_printf("%s", cp);
+ cp+=len;
+ lastchar+=len;
+ }
+ }
+ kdb_nextline = 1; /* reset output line number */
+ }
+ break;
+ default:
+ if (key >= 32 &&lastchar < bufend) {
+ if (cp < lastchar) {
+ memcpy(tmpbuffer, cp, lastchar - cp);
+ memcpy(cp+1, tmpbuffer, lastchar - cp);
+ *++lastchar = '\0';
+ *cp = key;
+ kdb_printf("%s\r", cp);
+ ++cp;
+ tmp = *cp;
+ *cp = '\0';
+ kdb_printf(kdb_prompt_str);
+ kdb_printf("%s", buffer);
+ *cp = tmp;
+ } else {
+ *++lastchar = '\0';
+ *cp++ = key;
+ kdb_printf("%c", key);
+ }
+ }
+ break;
+ }
+ }
+}
+
+/*
+ * kdb_getstr
+ *
+ * Print the prompt string and read a command from the
+ * input device.
+ *
+ * Parameters:
+ * buffer Address of buffer to receive command
+ * bufsize Size of buffer in bytes
+ * prompt Pointer to string to use as prompt string
+ * Returns:
+ * Pointer to command buffer.
+ * Locking:
+ * None.
+ * Remarks:
+ * For SMP kernels, the processor number will be
+ * substituted for %d, %x or %o in the prompt.
+ */
+
+char *
+kdb_getstr(char *buffer, size_t bufsize, char *prompt)
+{
+ if(prompt && kdb_prompt_str!=prompt)
+ strncpy(kdb_prompt_str, prompt, CMD_BUFLEN);
+ kdb_printf(kdb_prompt_str);
+ kdb_nextline = 1; /* Prompt and input resets line number */
+ return kdb_read(buffer, bufsize);
+}
+
+/*
+ * kdb_input_flush
+ *
+ * Get rid of any buffered console input.
+ *
+ * Parameters:
+ * none
+ * Returns:
+ * nothing
+ * Locking:
+ * none
+ * Remarks:
+ * Call this function whenever you want to flush input. If there is any
+ * outstanding input, it ignores all characters until there has been no
+ * data for approximately half a second.
+ */
+
+#define FLUSH_UDELAY 100
+#define FLUSH_DELAY 500000/FLUSH_UDELAY /* 0.5 seconds worth of udelays */
+
+static void
+kdb_input_flush(void)
+{
+ get_char_func *f;
+ int flush_delay = 1;
+ while (flush_delay--) {
+ touch_nmi_watchdog();
+ for (f = &poll_funcs[0]; *f; ++f) {
+ if ((*f)() != -1) {
+ flush_delay = FLUSH_DELAY;
+ break;
+ }
+ }
+ if (flush_delay)
+ udelay(FLUSH_UDELAY);
+ }
+}
+
+/*
+ * kdb_printf
+ *
+ * Print a string to the output device(s).
+ *
+ * Parameters:
+ * printf-like format and optional args.
+ * Returns:
+ * 0
+ * Locking:
+ * None.
+ * Remarks:
+ * use 'kdbcons->write()' to avoid polluting 'log_buf' with
+ * kdb output.
+ */
+
+static char kdb_buffer[256]; /* A bit too big to go on stack */
+
+void
+kdb_printf(const char *fmt, ...)
+{
+ va_list ap;
+ int diag;
+ int linecount;
+ int logging, saved_loglevel = 0;
+ int do_longjmp = 0;
+ int got_printf_lock = 0;
+ struct console *c = console_drivers;
+ static DEFINE_SPINLOCK(kdb_printf_lock);
+ unsigned long uninitialized_var(flags);
+
+ preempt_disable();
+ /* Serialize kdb_printf if multiple cpus try to write at once.
+ * But if any cpu goes recursive in kdb, just print the output,
+ * even if it is interleaved with any other text.
+ */
+ if (!KDB_STATE(PRINTF_LOCK)) {
+ KDB_STATE_SET(PRINTF_LOCK);
+ spin_lock_irqsave(&kdb_printf_lock, flags);
+ got_printf_lock = 1;
+ atomic_inc(&kdb_event);
+ } else {
+ __acquire(kdb_printf_lock);
+ }
+
+ diag = kdbgetintenv("LINES", &linecount);
+ if (diag || linecount <= 1)
+ linecount = 22;
+
+ diag = kdbgetintenv("LOGGING", &logging);
+ if (diag)
+ logging = 0;
+
+ va_start(ap, fmt);
+ vsnprintf(kdb_buffer, sizeof(kdb_buffer), fmt, ap);
+ va_end(ap);
+
+ /*
+ * Write to all consoles.
+ */
+#ifdef CONFIG_SPARC64
+ if (c == NULL)
+ prom_printf("%s", kdb_buffer);
+ else
+#endif
+
+#ifdef CONFIG_PPC64
+ if (udbg_write)
+ udbg_write(kdb_buffer, strlen(kdb_buffer));
+ else
+#endif
+
+ while (c) {
+ c->write(c, kdb_buffer, strlen(kdb_buffer));
+ c = c->next;
+ }
+ if (logging) {
+ saved_loglevel = console_loglevel;
+ console_loglevel = 0;
+ printk("%s", kdb_buffer);
+ }
+
+ if (KDB_STATE(LONGJMP) && strchr(kdb_buffer, '\n'))
+ kdb_nextline++;
+
+ if (kdb_nextline == linecount) {
+ char buf1[16]="";
+#if defined(CONFIG_SMP)
+ char buf2[32];
+#endif
+ char *moreprompt;
+
+ /* Watch out for recursion here. Any routine that calls
+ * kdb_printf will come back through here. And kdb_read
+ * uses kdb_printf to echo on serial consoles ...
+ */
+ kdb_nextline = 1; /* In case of recursion */
+
+ /*
+ * Pause until cr.
+ */
+ moreprompt = kdbgetenv("MOREPROMPT");
+ if (moreprompt == NULL) {
+ moreprompt = "more> ";
+ }
+
+#if defined(CONFIG_SMP)
+ if (strchr(moreprompt, '%')) {
+ sprintf(buf2, moreprompt, get_cpu());
+ put_cpu();
+ moreprompt = buf2;
+ }
+#endif
+
+ kdb_input_flush();
+ c = console_drivers;
+#ifdef CONFIG_SPARC64
+ if (c == NULL)
+ prom_printf("%s", moreprompt);
+ else
+#endif
+
+#ifdef CONFIG_PPC64
+ if (udbg_write)
+ udbg_write(moreprompt, strlen(moreprompt));
+ else
+#endif
+
+ while (c) {
+ c->write(c, moreprompt, strlen(moreprompt));
+ c = c->next;
+ }
+
+ if (logging)
+ printk("%s", moreprompt);
+
+ kdb_read(buf1, 2); /* '2' indicates to return immediately after getting one key. */
+ kdb_nextline = 1; /* Really set output line 1 */
+
+ if ((buf1[0] == 'q') || (buf1[0] == 'Q')) {
+ do_longjmp = 1;
+ KDB_FLAG_SET(CMD_INTERRUPT); /* command was interrupted */
+ kdb_printf("\n");
+ }
+ else if (buf1[0] && buf1[0] != '\n') {
+ kdb_printf("\nOnly 'q' or 'Q' are processed at more prompt, input ignored\n");
+ }
+ kdb_input_flush();
+ }
+
+ if (logging) {
+ console_loglevel = saved_loglevel;
+ }
+ if (KDB_STATE(PRINTF_LOCK) && got_printf_lock) {
+ got_printf_lock = 0;
+ spin_unlock_irqrestore(&kdb_printf_lock, flags);
+ KDB_STATE_CLEAR(PRINTF_LOCK);
+ atomic_dec(&kdb_event);
+ } else {
+ __release(kdb_printf_lock);
+ }
+ preempt_enable();
+ if (do_longjmp)
+#ifdef kdba_setjmp
+ kdba_longjmp(&kdbjmpbuf[smp_processor_id()], 1)
+#endif /* kdba_setjmp */
+ ;
+}
+
+/*
+ * kdb_io_init
+ *
+ * Initialize kernel debugger output environment.
+ *
+ * Parameters:
+ * None.
+ * Returns:
+ * None.
+ * Locking:
+ * None.
+ * Remarks:
+ * Select a console device. Only use a VT console if the user specified
+ * or defaulted console= /^tty[0-9]*$/
+ */
+
+void __init
+kdb_io_init(void)
+{
+ /*
+ * Select a console.
+ */
+ struct console *c = console_drivers;
+ int vt_console = 0;
+
+ while (c) {
+ if ((c->flags & CON_CONSDEV) && !kdbcons)
+ kdbcons = c;
+ if ((c->flags & CON_ENABLED) &&
+ strncmp(c->name, "tty", 3) == 0) {
+ char *p = c->name + 3;
+ while (isdigit(*p))
+ ++p;
+ if (*p == '\0')
+ vt_console = 1;
+ }
+ c = c->next;
+ }
+
+ if (kdbcons == NULL) {
+ printk(KERN_ERR "kdb: Initialization failed - no console. kdb is disabled.\n");
+ KDB_FLAG_SET(NO_CONSOLE);
+ kdb_on = 0;
+ }
+ if (!vt_console)
+ KDB_FLAG_SET(NO_VT_CONSOLE);
+ kdb_input_flush();
+ return;
+}
+
+#ifdef CONFIG_KDB_USB
+
+int kdb_no_usb = 0;
+
+static int __init opt_kdbnousb(char *str)
+{
+ kdb_no_usb = 1;
+ return 0;
+}
+
+early_param("kdbnousb", opt_kdbnousb);
+
+#endif
+
+EXPORT_SYMBOL(kdb_read);
Index: linux/kdb/kdbmain.c
===================================================================
--- /dev/null
+++ linux/kdb/kdbmain.c
@@ -0,0 +1,4037 @@
+/*
+ * Kernel Debugger Architecture Independent Main Code
+ *
+ * This file is subject to the terms and conditions of the GNU General Public
+ * License. See the file "COPYING" in the main directory of this archive
+ * for more details.
+ *
+ * Copyright (C) 1999-2004 Silicon Graphics, Inc. All Rights Reserved.
+ * Copyright (C) 2000 Stephane Eranian <eranian@hpl.hp.com>
+ * Xscale (R) modifications copyright (C) 2003 Intel Corporation.
+ */
+
+/*
+ * Updated for Xscale (R) architecture support
+ * Eddie Dong <eddie.dong@intel.com> 8 Jan 03
+ */
+
+#include <linux/ctype.h>
+#include <linux/string.h>
+#include <linux/kernel.h>
+#include <linux/reboot.h>
+#include <linux/sched.h>
+#include <linux/sysrq.h>
+#include <linux/smp.h>
+#include <linux/utsname.h>
+#include <linux/vmalloc.h>
+#include <linux/module.h>
+#include <linux/mm.h>
+#include <linux/init.h>
+#include <linux/kallsyms.h>
+#include <linux/kdb.h>
+#include <linux/kdbprivate.h>
+#include <linux/notifier.h>
+#include <linux/interrupt.h>
+#include <linux/delay.h>
+#include <linux/nmi.h>
+#include <linux/ptrace.h>
+#include <linux/sysctl.h>
+#if defined(CONFIG_LKCD_DUMP) || defined(CONFIG_LKCD_DUMP_MODULE)
+#include <linux/dump.h>
+#endif
+#include <linux/cpu.h>
+#include <linux/kdebug.h>
+
+#include <acpi/acpi_bus.h>
+
+#include <asm/system.h>
+#include <asm/kdebug.h>
+
+/*
+ * Kernel debugger state flags
+ */
+volatile int kdb_flags;
+atomic_t kdb_event;
+atomic_t kdb_8250;
+
+/*
+ * kdb_lock protects updates to kdb_initial_cpu. Used to
+ * single thread processors through the kernel debugger.
+ */
+static DEFINE_SPINLOCK(kdb_lock);
+volatile int kdb_initial_cpu = -1; /* cpu number that owns kdb */
+int kdb_seqno = 2; /* how many times kdb has been entered */
+
+volatile int kdb_nextline = 1;
+static volatile int kdb_new_cpu; /* Which cpu to switch to */
+
+volatile int kdb_state[NR_CPUS]; /* Per cpu state */
+
+const struct task_struct *kdb_current_task;
+EXPORT_SYMBOL(kdb_current_task);
+struct pt_regs *kdb_current_regs;
+
+#ifdef CONFIG_KDB_OFF
+int kdb_on = 0; /* Default is off */
+#else
+int kdb_on = 1; /* Default is on */
+#endif /* CONFIG_KDB_OFF */
+
+const char *kdb_diemsg;
+static int kdb_go_count;
+#ifdef CONFIG_KDB_CONTINUE_CATASTROPHIC
+static unsigned int kdb_continue_catastrophic = CONFIG_KDB_CONTINUE_CATASTROPHIC;
+#else
+static unsigned int kdb_continue_catastrophic = 0;
+#endif
+
+#ifdef kdba_setjmp
+ /*
+ * Must have a setjmp buffer per CPU. Switching cpus will
+ * cause the jump buffer to be setup for the new cpu, and
+ * subsequent switches (and pager aborts) will use the
+ * appropriate per-processor values.
+ */
+kdb_jmp_buf *kdbjmpbuf;
+#endif /* kdba_setjmp */
+
+ /*
+ * kdb_commands describes the available commands.
+ */
+static kdbtab_t *kdb_commands;
+static int kdb_max_commands;
+
+typedef struct _kdbmsg {
+ int km_diag; /* kdb diagnostic */
+ char *km_msg; /* Corresponding message text */
+} kdbmsg_t;
+
+#define KDBMSG(msgnum, text) \
+ { KDB_##msgnum, text }
+
+static kdbmsg_t kdbmsgs[] = {
+ KDBMSG(NOTFOUND,"Command Not Found"),
+ KDBMSG(ARGCOUNT, "Improper argument count, see usage."),
+ KDBMSG(BADWIDTH, "Illegal value for BYTESPERWORD use 1, 2, 4 or 8, 8 is only allowed on 64 bit systems"),
+ KDBMSG(BADRADIX, "Illegal value for RADIX use 8, 10 or 16"),
+ KDBMSG(NOTENV, "Cannot find environment variable"),
+ KDBMSG(NOENVVALUE, "Environment variable should have value"),
+ KDBMSG(NOTIMP, "Command not implemented"),
+ KDBMSG(ENVFULL, "Environment full"),
+ KDBMSG(ENVBUFFULL, "Environment buffer full"),
+ KDBMSG(TOOMANYBPT, "Too many breakpoints defined"),
+#ifdef CONFIG_CPU_XSCALE
+ KDBMSG(TOOMANYDBREGS, "More breakpoints than ibcr registers defined"),
+#else
+ KDBMSG(TOOMANYDBREGS, "More breakpoints than db registers defined"),
+#endif
+ KDBMSG(DUPBPT, "Duplicate breakpoint address"),
+ KDBMSG(BPTNOTFOUND, "Breakpoint not found"),
+ KDBMSG(BADMODE, "Invalid IDMODE"),
+ KDBMSG(BADINT, "Illegal numeric value"),
+ KDBMSG(INVADDRFMT, "Invalid symbolic address format"),
+ KDBMSG(BADREG, "Invalid register name"),
+ KDBMSG(BADCPUNUM, "Invalid cpu number"),
+ KDBMSG(BADLENGTH, "Invalid length field"),
+ KDBMSG(NOBP, "No Breakpoint exists"),
+ KDBMSG(BADADDR, "Invalid address"),
+};
+#undef KDBMSG
+
+static const int __nkdb_err = sizeof(kdbmsgs) / sizeof(kdbmsg_t);
+
+
+/*
+ * Initial environment. This is all kept static and local to
+ * this file. We don't want to rely on the memory allocation
+ * mechanisms in the kernel, so we use a very limited allocate-only
+ * heap for new and altered environment variables. The entire
+ * environment is limited to a fixed number of entries (add more
+ * to __env[] if required) and a fixed amount of heap (add more to
+ * KDB_ENVBUFSIZE if required).
+ */
+
+static char *__env[] = {
+#if defined(CONFIG_SMP)
+ "PROMPT=[%d]kdb> ",
+ "MOREPROMPT=[%d]more> ",
+#else
+ "PROMPT=kdb> ",
+ "MOREPROMPT=more> ",
+#endif
+ "RADIX=16",
+ "LINES=24",
+ "COLUMNS=80",
+ "MDCOUNT=8", /* lines of md output */
+ "BTARGS=9", /* 9 possible args in bt */
+ KDB_PLATFORM_ENV,
+ "DTABCOUNT=30",
+ "NOSECT=1",
+ (char *)0,
+ (char *)0,
+ (char *)0,
+ (char *)0,
+ (char *)0,
+ (char *)0,
+ (char *)0,
+ (char *)0,
+ (char *)0,
+ (char *)0,
+ (char *)0,
+ (char *)0,
+ (char *)0,
+ (char *)0,
+ (char *)0,
+ (char *)0,
+ (char *)0,
+ (char *)0,
+ (char *)0,
+ (char *)0,
+ (char *)0,
+ (char *)0,
+ (char *)0,
+};
+
+static const int __nenv = (sizeof(__env) / sizeof(char *));
+
+/*
+ * kdb_serial_str is the sequence that the user must enter on a serial
+ * console to invoke kdb. It can be a single character such as "\001"
+ * (control-A) or multiple characters such as "\eKDB". NOTE: All except the
+ * last character are passed through to the application reading from the serial
+ * console.
+ *
+ * I tried to make the sequence a CONFIG_ option but most of CML1 cannot cope
+ * with '\' in strings. CML2 would have been able to do it but we lost CML2.
+ * KAO.
+ */
+const char kdb_serial_str[] = "\eKDB";
+EXPORT_SYMBOL(kdb_serial_str);
+
+struct task_struct *
+kdb_curr_task(int cpu)
+{
+ struct task_struct *p = curr_task(cpu);
+#ifdef _TIF_MCA_INIT
+ struct kdb_running_process *krp = kdb_running_process + cpu;
+ if ((task_thread_info(p)->flags & _TIF_MCA_INIT) && krp->p)
+ p = krp->p;
+#endif
+ return p;
+}
+
+/*
+ * kdbgetenv
+ *
+ * This function will return the character string value of
+ * an environment variable.
+ *
+ * Parameters:
+ * match A character string representing an environment variable.
+ * Outputs:
+ * None.
+ * Returns:
+ * NULL No environment variable matches 'match'
+ * char* Pointer to string value of environment variable.
+ * Locking:
+ * No locking considerations required.
+ * Remarks:
+ */
+char *
+kdbgetenv(const char *match)
+{
+ char **ep = __env;
+ int matchlen = strlen(match);
+ int i;
+
+ for(i=0; i<__nenv; i++) {
+ char *e = *ep++;
+
+ if (!e) continue;
+
+ if ((strncmp(match, e, matchlen) == 0)
+ && ((e[matchlen] == '\0')
+ ||(e[matchlen] == '='))) {
+ char *cp = strchr(e, '=');
+ return (cp ? ++cp :"");
+ }
+ }
+ return NULL;
+}
+
+/*
+ * kdballocenv
+ *
+ * This function is used to allocate bytes for environment entries.
+ *
+ * Parameters:
+ * match A character string representing a numeric value
+ * Outputs:
+ * *value the unsigned long represntation of the env variable 'match'
+ * Returns:
+ * Zero on success, a kdb diagnostic on failure.
+ * Locking:
+ * No locking considerations required. Must be called with all
+ * processors halted.
+ * Remarks:
+ * We use a static environment buffer (envbuffer) to hold the values
+ * of dynamically generated environment variables (see kdb_set). Buffer
+ * space once allocated is never free'd, so over time, the amount of space
+ * (currently 512 bytes) will be exhausted if env variables are changed
+ * frequently.
+ */
+static char *
+kdballocenv(size_t bytes)
+{
+#define KDB_ENVBUFSIZE 512
+ static char envbuffer[KDB_ENVBUFSIZE];
+ static int envbufsize;
+ char *ep = NULL;
+
+ if ((KDB_ENVBUFSIZE - envbufsize) >= bytes) {
+ ep = &envbuffer[envbufsize];
+ envbufsize += bytes;
+ }
+ return ep;
+}
+
+/*
+ * kdbgetulenv
+ *
+ * This function will return the value of an unsigned long-valued
+ * environment variable.
+ *
+ * Parameters:
+ * match A character string representing a numeric value
+ * Outputs:
+ * *value the unsigned long represntation of the env variable 'match'
+ * Returns:
+ * Zero on success, a kdb diagnostic on failure.
+ * Locking:
+ * No locking considerations required.
+ * Remarks:
+ */
+
+static int
+kdbgetulenv(const char *match, unsigned long *value)
+{
+ char *ep;
+
+ ep = kdbgetenv(match);
+ if (!ep) return KDB_NOTENV;
+ if (strlen(ep) == 0) return KDB_NOENVVALUE;
+
+ *value = simple_strtoul(ep, NULL, 0);
+
+ return 0;
+}
+
+/*
+ * kdbgetintenv
+ *
+ * This function will return the value of an integer-valued
+ * environment variable.
+ *
+ * Parameters:
+ * match A character string representing an integer-valued env variable
+ * Outputs:
+ * *value the integer representation of the environment variable 'match'
+ * Returns:
+ * Zero on success, a kdb diagnostic on failure.
+ * Locking:
+ * No locking considerations required.
+ * Remarks:
+ */
+
+int
+kdbgetintenv(const char *match, int *value) {
+ unsigned long val;
+ int diag;
+
+ diag = kdbgetulenv(match, &val);
+ if (!diag) {
+ *value = (int) val;
+ }
+ return diag;
+}
+
+/*
+ * kdbgetularg
+ *
+ * This function will convert a numeric string
+ * into an unsigned long value.
+ *
+ * Parameters:
+ * arg A character string representing a numeric value
+ * Outputs:
+ * *value the unsigned long represntation of arg.
+ * Returns:
+ * Zero on success, a kdb diagnostic on failure.
+ * Locking:
+ * No locking considerations required.
+ * Remarks:
+ */
+
+int
+kdbgetularg(const char *arg, unsigned long *value)
+{
+ char *endp;
+ unsigned long val;
+
+ val = simple_strtoul(arg, &endp, 0);
+
+ if (endp == arg) {
+ /*
+ * Try base 16, for us folks too lazy to type the
+ * leading 0x...
+ */
+ val = simple_strtoul(arg, &endp, 16);
+ if (endp == arg)
+ return KDB_BADINT;
+ }
+
+ *value = val;
+
+ return 0;
+}
+
+/*
+ * kdb_set
+ *
+ * This function implements the 'set' command. Alter an existing
+ * environment variable or create a new one.
+ *
+ * Inputs:
+ * argc argument count
+ * argv argument vector
+ * Outputs:
+ * None.
+ * Returns:
+ * zero for success, a kdb diagnostic if error
+ * Locking:
+ * none.
+ * Remarks:
+ */
+
+static int
+kdb_set(int argc, const char **argv)
+{
+ int i;
+ char *ep;
+ size_t varlen, vallen;
+
+ /*
+ * we can be invoked two ways:
+ * set var=value argv[1]="var", argv[2]="value"
+ * set var = value argv[1]="var", argv[2]="=", argv[3]="value"
+ * - if the latter, shift 'em down.
+ */
+ if (argc == 3) {
+ argv[2] = argv[3];
+ argc--;
+ }
+
+ if (argc != 2)
+ return KDB_ARGCOUNT;
+
+ /*
+ * Check for internal variables
+ */
+ if (strcmp(argv[1], "KDBDEBUG") == 0) {
+ unsigned int debugflags;
+ char *cp;
+
+ debugflags = simple_strtoul(argv[2], &cp, 0);
+ if (cp == argv[2] || debugflags & ~KDB_DEBUG_FLAG_MASK) {
+ kdb_printf("kdb: illegal debug flags '%s'\n",
+ argv[2]);
+ return 0;
+ }
+ kdb_flags = (kdb_flags & ~(KDB_DEBUG_FLAG_MASK << KDB_DEBUG_FLAG_SHIFT))
+ | (debugflags << KDB_DEBUG_FLAG_SHIFT);
+
+ return 0;
+ }
+
+ /*
+ * Tokenizer squashed the '=' sign. argv[1] is variable
+ * name, argv[2] = value.
+ */
+ varlen = strlen(argv[1]);
+ vallen = strlen(argv[2]);
+ ep = kdballocenv(varlen + vallen + 2);
+ if (ep == (char *)0)
+ return KDB_ENVBUFFULL;
+
+ sprintf(ep, "%s=%s", argv[1], argv[2]);
+
+ ep[varlen+vallen+1]='\0';
+
+ for(i=0; i<__nenv; i++) {
+ if (__env[i]
+ && ((strncmp(__env[i], argv[1], varlen)==0)
+ && ((__env[i][varlen] == '\0')
+ || (__env[i][varlen] == '=')))) {
+ __env[i] = ep;
+ return 0;
+ }
+ }
+
+ /*
+ * Wasn't existing variable. Fit into slot.
+ */
+ for(i=0; i<__nenv-1; i++) {
+ if (__env[i] == (char *)0) {
+ __env[i] = ep;
+ return 0;
+ }
+ }
+
+ return KDB_ENVFULL;
+}
+
+static int
+kdb_check_regs(void)
+{
+ if (!kdb_current_regs) {
+ kdb_printf("No current kdb registers."
+ " You may need to select another task\n");
+ return KDB_BADREG;
+ }
+ return 0;
+}
+
+/*
+ * kdbgetaddrarg
+ *
+ * This function is responsible for parsing an
+ * address-expression and returning the value of
+ * the expression, symbol name, and offset to the caller.
+ *
+ * The argument may consist of a numeric value (decimal or
+ * hexidecimal), a symbol name, a register name (preceeded
+ * by the percent sign), an environment variable with a numeric
+ * value (preceeded by a dollar sign) or a simple arithmetic
+ * expression consisting of a symbol name, +/-, and a numeric
+ * constant value (offset).
+ *
+ * Parameters:
+ * argc - count of arguments in argv
+ * argv - argument vector
+ * *nextarg - index to next unparsed argument in argv[]
+ * regs - Register state at time of KDB entry
+ * Outputs:
+ * *value - receives the value of the address-expression
+ * *offset - receives the offset specified, if any
+ * *name - receives the symbol name, if any
+ * *nextarg - index to next unparsed argument in argv[]
+ *
+ * Returns:
+ * zero is returned on success, a kdb diagnostic code is
+ * returned on error.
+ *
+ * Locking:
+ * No locking requirements.
+ *
+ * Remarks:
+ *
+ */
+
+int
+kdbgetaddrarg(int argc, const char **argv, int *nextarg,
+ kdb_machreg_t *value, long *offset,
+ char **name)
+{
+ kdb_machreg_t addr;
+ unsigned long off = 0;
+ int positive;
+ int diag;
+ int found = 0;
+ char *symname;
+ char symbol = '\0';
+ char *cp;
+ kdb_symtab_t symtab;
+
+ /*
+ * Process arguments which follow the following syntax:
+ *
+ * symbol | numeric-address [+/- numeric-offset]
+ * %register
+ * $environment-variable
+ */
+
+ if (*nextarg > argc) {
+ return KDB_ARGCOUNT;
+ }
+
+ symname = (char *)argv[*nextarg];
+
+ /*
+ * If there is no whitespace between the symbol
+ * or address and the '+' or '-' symbols, we
+ * remember the character and replace it with a
+ * null so the symbol/value can be properly parsed
+ */
+ if ((cp = strpbrk(symname, "+-")) != NULL) {
+ symbol = *cp;
+ *cp++ = '\0';
+ }
+
+ if (symname[0] == '$') {
+ diag = kdbgetulenv(&symname[1], &addr);
+ if (diag)
+ return diag;
+ } else if (symname[0] == '%') {
+ if ((diag = kdb_check_regs()))
+ return diag;
+ diag = kdba_getregcontents(&symname[1], kdb_current_regs, &addr);
+ if (diag)
+ return diag;
+ } else {
+ found = kdbgetsymval(symname, &symtab);
+ if (found) {
+ addr = symtab.sym_start;
+ } else {
+ diag = kdbgetularg(argv[*nextarg], &addr);
+ if (diag)
+ return diag;
+ }
+ }
+
+ if (!found)
+ found = kdbnearsym(addr, &symtab);
+
+ (*nextarg)++;
+
+ if (name)
+ *name = symname;
+ if (value)
+ *value = addr;
+ if (offset && name && *name)
+ *offset = addr - symtab.sym_start;
+
+ if ((*nextarg > argc)
+ && (symbol == '\0'))
+ return 0;
+
+ /*
+ * check for +/- and offset
+ */
+
+ if (symbol == '\0') {
+ if ((argv[*nextarg][0] != '+')
+ && (argv[*nextarg][0] != '-')) {
+ /*
+ * Not our argument. Return.
+ */
+ return 0;
+ } else {
+ positive = (argv[*nextarg][0] == '+');
+ (*nextarg)++;
+ }
+ } else
+ positive = (symbol == '+');
+
+ /*
+ * Now there must be an offset!
+ */
+ if ((*nextarg > argc)
+ && (symbol == '\0')) {
+ return KDB_INVADDRFMT;
+ }
+
+ if (!symbol) {
+ cp = (char *)argv[*nextarg];
+ (*nextarg)++;
+ }
+
+ diag = kdbgetularg(cp, &off);
+ if (diag)
+ return diag;
+
+ if (!positive)
+ off = -off;
+
+ if (offset)
+ *offset += off;
+
+ if (value)
+ *value += off;
+
+ return 0;
+}
+
+static void
+kdb_cmderror(int diag)
+{
+ int i;
+
+ if (diag >= 0) {
+ kdb_printf("no error detected\n");
+ return;
+ }
+
+ for(i=0; i<__nkdb_err; i++) {
+ if (kdbmsgs[i].km_diag == diag) {
+ kdb_printf("diag: %d: %s\n", diag, kdbmsgs[i].km_msg);
+ return;
+ }
+ }
+
+ kdb_printf("Unknown diag %d\n", -diag);
+}
+
+/*
+ * kdb_defcmd, kdb_defcmd2
+ *
+ * This function implements the 'defcmd' command which defines one
+ * command as a set of other commands, terminated by endefcmd.
+ * kdb_defcmd processes the initial 'defcmd' command, kdb_defcmd2
+ * is invoked from kdb_parse for the following commands until
+ * 'endefcmd'.
+ *
+ * Inputs:
+ * argc argument count
+ * argv argument vector
+ * Outputs:
+ * None.
+ * Returns:
+ * zero for success, a kdb diagnostic if error
+ * Locking:
+ * none.
+ * Remarks:
+ */
+
+struct defcmd_set {
+ int count;
+ int usable;
+ char *name;
+ char *usage;
+ char *help;
+ char **command;
+};
+static struct defcmd_set *defcmd_set;
+static int defcmd_set_count;
+static int defcmd_in_progress;
+
+/* Forward references */
+static int kdb_exec_defcmd(int argc, const char **argv);
+
+static int
+kdb_defcmd2(const char *cmdstr, const char *argv0)
+{
+ struct defcmd_set *s = defcmd_set + defcmd_set_count - 1;
+ char **save_command = s->command;
+ if (strcmp(argv0, "endefcmd") == 0) {
+ defcmd_in_progress = 0;
+ if (!s->count)
+ s->usable = 0;
+ if (s->usable)
+ kdb_register(s->name, kdb_exec_defcmd, s->usage, s->help, 0);
+ return 0;
+ }
+ if (!s->usable)
+ return KDB_NOTIMP;
+ s->command = kmalloc((s->count + 1) * sizeof(*(s->command)), GFP_KDB);
+ if (!s->command) {
+ kdb_printf("Could not allocate new kdb_defcmd table for %s\n", cmdstr);
+ s->usable = 0;
+ return KDB_NOTIMP;
+ }
+ memcpy(s->command, save_command, s->count * sizeof(*(s->command)));
+ s->command[s->count++] = kdb_strdup(cmdstr, GFP_KDB);
+ kfree(save_command);
+ return 0;
+}
+
+static int
+kdb_defcmd(int argc, const char **argv)
+{
+ struct defcmd_set *save_defcmd_set = defcmd_set, *s;
+ if (defcmd_in_progress) {
+ kdb_printf("kdb: nested defcmd detected, assuming missing endefcmd\n");
+ kdb_defcmd2("endefcmd", "endefcmd");
+ }
+ if (argc == 0) {
+ int i;
+ for (s = defcmd_set; s < defcmd_set + defcmd_set_count; ++s) {
+ kdb_printf("defcmd %s \"%s\" \"%s\"\n", s->name, s->usage, s->help);
+ for (i = 0; i < s->count; ++i)
+ kdb_printf("%s", s->command[i]);
+ kdb_printf("endefcmd\n");
+ }
+ return 0;
+ }
+ if (argc != 3)
+ return KDB_ARGCOUNT;
+ defcmd_set = kmalloc((defcmd_set_count + 1) * sizeof(*defcmd_set), GFP_KDB);
+ if (!defcmd_set) {
+ kdb_printf("Could not allocate new defcmd_set entry for %s\n", argv[1]);
+ defcmd_set = save_defcmd_set;
+ return KDB_NOTIMP;
+ }
+ memcpy(defcmd_set, save_defcmd_set, defcmd_set_count * sizeof(*defcmd_set));
+ kfree(save_defcmd_set);
+ s = defcmd_set + defcmd_set_count;
+ memset(s, 0, sizeof(*s));
+ s->usable = 1;
+ s->name = kdb_strdup(argv[1], GFP_KDB);
+ s->usage = kdb_strdup(argv[2], GFP_KDB);
+ s->help = kdb_strdup(argv[3], GFP_KDB);
+ if (s->usage[0] == '"') {
+ strcpy(s->usage, s->usage+1);
+ s->usage[strlen(s->usage)-1] = '\0';
+ }
+ if (s->help[0] == '"') {
+ strcpy(s->help, s->help+1);
+ s->help[strlen(s->help)-1] = '\0';
+ }
+ ++defcmd_set_count;
+ defcmd_in_progress = 1;
+ return 0;
+}
+
+/*
+ * kdb_exec_defcmd
+ *
+ * Execute the set of commands associated with this defcmd name.
+ *
+ * Inputs:
+ * argc argument count
+ * argv argument vector
+ * Outputs:
+ * None.
+ * Returns:
+ * zero for success, a kdb diagnostic if error
+ * Locking:
+ * none.
+ * Remarks:
+ */
+
+static int
+kdb_exec_defcmd(int argc, const char **argv)
+{
+ int i, ret;
+ struct defcmd_set *s;
+ if (argc != 0)
+ return KDB_ARGCOUNT;
+ for (s = defcmd_set, i = 0; i < defcmd_set_count; ++i, ++s) {
+ if (strcmp(s->name, argv[0]) == 0)
+ break;
+ }
+ if (i == defcmd_set_count) {
+ kdb_printf("kdb_exec_defcmd: could not find commands for %s\n", argv[0]);
+ return KDB_NOTIMP;
+ }
+ for (i = 0; i < s->count; ++i) {
+ /* Recursive use of kdb_parse, do not use argv after this point */
+ argv = NULL;
+ kdb_printf("[%s]kdb> %s\n", s->name, s->command[i]);
+ if ((ret = kdb_parse(s->command[i])))
+ return ret;
+ }
+ return 0;
+}
+
+/* Command history */
+#define KDB_CMD_HISTORY_COUNT 32
+#define CMD_BUFLEN 200 /* kdb_printf: max printline size == 256 */
+static unsigned int cmd_head=0, cmd_tail=0;
+static unsigned int cmdptr;
+static char cmd_hist[KDB_CMD_HISTORY_COUNT][CMD_BUFLEN];
+static char cmd_cur[CMD_BUFLEN];
+
+/*
+ * kdb_parse
+ *
+ * Parse the command line, search the command table for a
+ * matching command and invoke the command function.
+ * This function may be called recursively, if it is, the second call
+ * will overwrite argv and cbuf. It is the caller's responsibility to
+ * save their argv if they recursively call kdb_parse().
+ *
+ * Parameters:
+ * cmdstr The input command line to be parsed.
+ * regs The registers at the time kdb was entered.
+ * Outputs:
+ * None.
+ * Returns:
+ * Zero for success, a kdb diagnostic if failure.
+ * Locking:
+ * None.
+ * Remarks:
+ * Limited to 20 tokens.
+ *
+ * Real rudimentary tokenization. Basically only whitespace
+ * is considered a token delimeter (but special consideration
+ * is taken of the '=' sign as used by the 'set' command).
+ *
+ * The algorithm used to tokenize the input string relies on
+ * there being at least one whitespace (or otherwise useless)
+ * character between tokens as the character immediately following
+ * the token is altered in-place to a null-byte to terminate the
+ * token string.
+ */
+
+#define MAXARGC 20
+
+int
+kdb_parse(const char *cmdstr)
+{
+ static char *argv[MAXARGC];
+ static int argc = 0;
+ static char cbuf[CMD_BUFLEN+2];
+ const char *cp;
+ char *cpp, quoted;
+ kdbtab_t *tp;
+ int i, escaped, ignore_errors = 0;
+
+ /*
+ * First tokenize the command string.
+ */
+ cp = cmdstr;
+
+ if (KDB_FLAG(CMD_INTERRUPT)) {
+ /* Previous command was interrupted, newline must not repeat the command */
+ KDB_FLAG_CLEAR(CMD_INTERRUPT);
+ argc = 0; /* no repeat */
+ }
+
+ if (*cp != '\n' && *cp != '\0') {
+ argc = 0;
+ cpp = cbuf;
+ while (*cp) {
+ /* skip whitespace */
+ while (isspace(*cp)) cp++;
+ if ((*cp == '\0') || (*cp == '\n') || (*cp == '#' && !defcmd_in_progress))
+ break;
+ if (cpp >= cbuf + CMD_BUFLEN) {
+ kdb_printf("kdb_parse: command buffer overflow, command ignored\n%s\n", cmdstr);
+ return KDB_NOTFOUND;
+ }
+ if (argc >= MAXARGC - 1) {
+ kdb_printf("kdb_parse: too many arguments, command ignored\n%s\n", cmdstr);
+ return KDB_NOTFOUND;
+ }
+ argv[argc++] = cpp;
+ escaped = 0;
+ quoted = '\0';
+ /* Copy to next unquoted and unescaped whitespace or '=' */
+ while (*cp && *cp != '\n' && (escaped || quoted || !isspace(*cp))) {
+ if (cpp >= cbuf + CMD_BUFLEN)
+ break;
+ if (escaped) {
+ escaped = 0;
+ *cpp++ = *cp++;
+ continue;
+ }
+ if (*cp == '\\') {
+ escaped = 1;
+ ++cp;
+ continue;
+ }
+ if (*cp == quoted) {
+ quoted = '\0';
+ } else if (*cp == '\'' || *cp == '"') {
+ quoted = *cp;
+ }
+ if ((*cpp = *cp++) == '=' && !quoted)
+ break;
+ ++cpp;
+ }
+ *cpp++ = '\0'; /* Squash a ws or '=' character */
+ }
+ }
+ if (!argc)
+ return 0;
+ if (defcmd_in_progress) {
+ int result = kdb_defcmd2(cmdstr, argv[0]);
+ if (!defcmd_in_progress) {
+ argc = 0; /* avoid repeat on endefcmd */
+ *(argv[0]) = '\0';
+ }
+ return result;
+ }
+ if (argv[0][0] == '-' && argv[0][1] && (argv[0][1] < '0' || argv[0][1] > '9')) {
+ ignore_errors = 1;
+ ++argv[0];
+ }
+
+ for(tp=kdb_commands, i=0; i < kdb_max_commands; i++,tp++) {
+ if (tp->cmd_name) {
+ /*
+ * If this command is allowed to be abbreviated,
+ * check to see if this is it.
+ */
+
+ if (tp->cmd_minlen
+ && (strlen(argv[0]) <= tp->cmd_minlen)) {
+ if (strncmp(argv[0],
+ tp->cmd_name,
+ tp->cmd_minlen) == 0) {
+ break;
+ }
+ }
+
+ if (strcmp(argv[0], tp->cmd_name)==0) {
+ break;
+ }
+ }
+ }
+
+ /*
+ * If we don't find a command by this name, see if the first
+ * few characters of this match any of the known commands.
+ * e.g., md1c20 should match md.
+ */
+ if (i == kdb_max_commands) {
+ for(tp=kdb_commands, i=0; i < kdb_max_commands; i++,tp++) {
+ if (tp->cmd_name) {
+ if (strncmp(argv[0],
+ tp->cmd_name,
+ strlen(tp->cmd_name))==0) {
+ break;
+ }
+ }
+ }
+ }
+
+ if (i < kdb_max_commands) {
+ int result;
+ KDB_STATE_SET(CMD);
+ result = (*tp->cmd_func)(argc-1,
+ (const char**)argv);
+ if (result && ignore_errors && result > KDB_CMD_GO)
+ result = 0;
+ KDB_STATE_CLEAR(CMD);
+ switch (tp->cmd_repeat) {
+ case KDB_REPEAT_NONE:
+ argc = 0;
+ if (argv[0])
+ *(argv[0]) = '\0';
+ break;
+ case KDB_REPEAT_NO_ARGS:
+ argc = 1;
+ if (argv[1])
+ *(argv[1]) = '\0';
+ break;
+ case KDB_REPEAT_WITH_ARGS:
+ break;
+ }
+ return result;
+ }
+
+ /*
+ * If the input with which we were presented does not
+ * map to an existing command, attempt to parse it as an
+ * address argument and display the result. Useful for
+ * obtaining the address of a variable, or the nearest symbol
+ * to an address contained in a register.
+ */
+ {
+ kdb_machreg_t value;
+ char *name = NULL;
+ long offset;
+ int nextarg = 0;
+
+ if (kdbgetaddrarg(0, (const char **)argv, &nextarg,
+ &value, &offset, &name)) {
+ return KDB_NOTFOUND;
+ }
+
+ kdb_printf("%s = ", argv[0]);
+ kdb_symbol_print(value, NULL, KDB_SP_DEFAULT);
+ kdb_printf("\n");
+ return 0;
+ }
+}
+
+
+static int
+handle_ctrl_cmd(char *cmd)
+{
+#define CTRL_P 16
+#define CTRL_N 14
+
+ /* initial situation */
+ if (cmd_head == cmd_tail) return 0;
+
+ switch(*cmd) {
+ case CTRL_P:
+ if (cmdptr != cmd_tail)
+ cmdptr = (cmdptr-1) % KDB_CMD_HISTORY_COUNT;
+ strncpy(cmd_cur, cmd_hist[cmdptr], CMD_BUFLEN);
+ return 1;
+ case CTRL_N:
+ if (cmdptr != cmd_head)
+ cmdptr = (cmdptr+1) % KDB_CMD_HISTORY_COUNT;
+ strncpy(cmd_cur, cmd_hist[cmdptr], CMD_BUFLEN);
+ return 1;
+ }
+ return 0;
+}
+
+/*
+ * kdb_do_dump
+ *
+ * Call the dump() function if the kernel is configured for LKCD.
+ * Inputs:
+ * None.
+ * Outputs:
+ * None.
+ * Returns:
+ * None. dump() may or may not return.
+ * Locking:
+ * none.
+ * Remarks:
+ */
+
+static void
+kdb_do_dump(void)
+{
+#if defined(CONFIG_LKCD_DUMP) || defined(CONFIG_LKCD_DUMP_MODULE)
+ kdb_printf("Forcing dump (if configured)\n");
+ console_loglevel = 8; /* to see the dump messages */
+ dump("kdb_do_dump");
+#endif
+}
+
+/*
+ * kdb_reboot
+ *
+ * This function implements the 'reboot' command. Reboot the system
+ * immediately.
+ *
+ * Inputs:
+ * argc argument count
+ * argv argument vector
+ * Outputs:
+ * None.
+ * Returns:
+ * zero for success, a kdb diagnostic if error
+ * Locking:
+ * none.
+ * Remarks:
+ * Shouldn't return from this function.
+ */
+
+static int
+kdb_reboot(int argc, const char **argv)
+{
+ emergency_restart();
+ kdb_printf("Hmm, kdb_reboot did not reboot, spinning here\n");
+ while (1) {};
+ /* NOTREACHED */
+ return 0;
+}
+
+static int
+kdb_quiet(int reason)
+{
+ return (reason == KDB_REASON_CPU_UP || reason == KDB_REASON_SILENT);
+}
+
+/*
+ * kdb_local
+ *
+ * The main code for kdb. This routine is invoked on a specific
+ * processor, it is not global. The main kdb() routine ensures
+ * that only one processor at a time is in this routine. This
+ * code is called with the real reason code on the first entry
+ * to a kdb session, thereafter it is called with reason SWITCH,
+ * even if the user goes back to the original cpu.
+ *
+ * Inputs:
+ * reason The reason KDB was invoked
+ * error The hardware-defined error code
+ * regs The exception frame at time of fault/breakpoint. NULL
+ * for reason SILENT or CPU_UP, otherwise valid.
+ * db_result Result code from the break or debug point.
+ * Returns:
+ * 0 KDB was invoked for an event which it wasn't responsible
+ * 1 KDB handled the event for which it was invoked.
+ * KDB_CMD_GO User typed 'go'.
+ * KDB_CMD_CPU User switched to another cpu.
+ * KDB_CMD_SS Single step.
+ * KDB_CMD_SSB Single step until branch.
+ * Locking:
+ * none
+ * Remarks:
+ * none
+ */
+
+static int
+kdb_local(kdb_reason_t reason, int error, struct pt_regs *regs, kdb_dbtrap_t db_result)
+{
+ char *cmdbuf;
+ int diag;
+ struct task_struct *kdb_current = kdb_curr_task(smp_processor_id());
+
+ /* If kdb has been entered for an event which has been/will be
+ * recovered then silently return. We have to get this far into kdb in
+ * order to synchronize all the cpus, typically only one cpu (monarch)
+ * knows that the event is recoverable but the other cpus (slaves) may
+ * also be driven into kdb before that decision is made by the monarch.
+ *
+ * To pause in kdb even for recoverable events, 'set RECOVERY_PAUSE 1'
+ */
+ KDB_DEBUG_STATE("kdb_local 1", reason);
+ if (reason == KDB_REASON_ENTER
+ && KDB_FLAG(RECOVERY)
+ && !KDB_FLAG(CATASTROPHIC)) {
+ int recovery_pause = 0;
+ kdbgetintenv("RECOVERY_PAUSE", &recovery_pause);
+ if (recovery_pause == 0)
+ reason = KDB_REASON_SILENT;
+ else
+ kdb_printf("%s: Recoverable error detected but"
+ " RECOVERY_PAUSE is set, staying in KDB\n",
+ __FUNCTION__);
+ }
+
+ KDB_DEBUG_STATE("kdb_local 2", reason);
+ kdb_go_count = 0;
+ if (kdb_quiet(reason)) {
+ /* no message */
+ } else if (reason == KDB_REASON_DEBUG) {
+ /* special case below */
+ } else {
+ kdb_printf("\nEntering kdb (current=0x%p, pid %d) ", kdb_current, kdb_current->pid);
+#if defined(CONFIG_SMP)
+ kdb_printf("on processor %d ", smp_processor_id());
+#endif
+ }
+
+ switch (reason) {
+ case KDB_REASON_DEBUG:
+ {
+ /*
+ * If re-entering kdb after a single step
+ * command, don't print the message.
+ */
+ switch(db_result) {
+ case KDB_DB_BPT:
+ kdb_printf("\nEntering kdb (0x%p, pid %d) ", kdb_current, kdb_current->pid);
+#if defined(CONFIG_SMP)
+ kdb_printf("on processor %d ", smp_processor_id());
+#endif
+ kdb_printf("due to Debug @ " kdb_machreg_fmt "\n", kdba_getpc(regs));
+ break;
+ case KDB_DB_SSB:
+ /*
+ * In the midst of ssb command. Just return.
+ */
+ KDB_DEBUG_STATE("kdb_local 3", reason);
+ return KDB_CMD_SSB; /* Continue with SSB command */
+
+ break;
+ case KDB_DB_SS:
+ break;
+ case KDB_DB_SSBPT:
+ KDB_DEBUG_STATE("kdb_local 4", reason);
+ return 1; /* kdba_db_trap did the work */
+ default:
+ kdb_printf("kdb: Bad result from kdba_db_trap: %d\n",
+ db_result);
+ break;
+ }
+
+ }
+ break;
+ case KDB_REASON_ENTER:
+ if (KDB_STATE(KEYBOARD))
+ kdb_printf("due to Keyboard Entry\n");
+ else
+ kdb_printf("due to KDB_ENTER()\n");
+ break;
+ case KDB_REASON_KEYBOARD:
+ KDB_STATE_SET(KEYBOARD);
+ kdb_printf("due to Keyboard Entry\n");
+ break;
+ case KDB_REASON_ENTER_SLAVE: /* drop through, slaves only get released via cpu switch */
+ case KDB_REASON_SWITCH:
+ kdb_printf("due to cpu switch\n");
+ if (KDB_STATE(GO_SWITCH)) {
+ KDB_STATE_CLEAR(GO_SWITCH);
+ KDB_DEBUG_STATE("kdb_local 5", reason);
+ return KDB_CMD_GO;
+ }
+ break;
+ case KDB_REASON_OOPS:
+ kdb_printf("Oops: %s\n", kdb_diemsg);
+ kdb_printf("due to oops @ " kdb_machreg_fmt "\n", kdba_getpc(regs));
+ kdba_dumpregs(regs, NULL, NULL);
+ break;
+ case KDB_REASON_NMI:
+ kdb_printf("due to NonMaskable Interrupt @ " kdb_machreg_fmt "\n",
+ kdba_getpc(regs));
+ kdba_dumpregs(regs, NULL, NULL);
+ break;
+ case KDB_REASON_BREAK:
+ kdb_printf("due to Breakpoint @ " kdb_machreg_fmt "\n", kdba_getpc(regs));
+ /*
+ * Determine if this breakpoint is one that we
+ * are interested in.
+ */
+ if (db_result != KDB_DB_BPT) {
+ kdb_printf("kdb: error return from kdba_bp_trap: %d\n", db_result);
+ KDB_DEBUG_STATE("kdb_local 6", reason);
+ return 0; /* Not for us, dismiss it */
+ }
+ break;
+ case KDB_REASON_RECURSE:
+ kdb_printf("due to Recursion @ " kdb_machreg_fmt "\n", kdba_getpc(regs));
+ break;
+ case KDB_REASON_CPU_UP:
+ case KDB_REASON_SILENT:
+ KDB_DEBUG_STATE("kdb_local 7", reason);
+ if (reason == KDB_REASON_CPU_UP)
+ kdba_cpu_up();
+ return KDB_CMD_GO; /* Silent entry, silent exit */
+ break;
+ default:
+ kdb_printf("kdb: unexpected reason code: %d\n", reason);
+ KDB_DEBUG_STATE("kdb_local 8", reason);
+ return 0; /* Not for us, dismiss it */
+ }
+
+ kdba_local_arch_setup();
+
+ kdba_set_current_task(kdb_current);
+
+ while (1) {
+ /*
+ * Initialize pager context.
+ */
+ kdb_nextline = 1;
+ KDB_STATE_CLEAR(SUPPRESS);
+#ifdef kdba_setjmp
+ /*
+ * Use kdba_setjmp/kdba_longjmp to break out of
+ * the pager early and to attempt to recover from kdb errors.
+ */
+ KDB_STATE_CLEAR(LONGJMP);
+ if (kdbjmpbuf) {
+ if (kdba_setjmp(&kdbjmpbuf[smp_processor_id()])) {
+ /* Command aborted (usually in pager) */
+ continue;
+ }
+ else
+ KDB_STATE_SET(LONGJMP);
+ }
+#endif /* kdba_setjmp */
+
+ cmdbuf = cmd_cur;
+ *cmdbuf = '\0';
+ *(cmd_hist[cmd_head])='\0';
+
+ if (KDB_FLAG(ONLY_DO_DUMP)) {
+ /* kdb is off but a catastrophic error requires a dump.
+ * Take the dump and reboot.
+ * Turn on logging so the kdb output appears in the log
+ * buffer in the dump.
+ */
+ const char *setargs[] = { "set", "LOGGING", "1" };
+ kdb_set(2, setargs);
+ kdb_do_dump();
+ kdb_reboot(0, NULL);
+ /*NOTREACHED*/
+ }
+
+do_full_getstr:
+#if defined(CONFIG_SMP)
+ snprintf(kdb_prompt_str, CMD_BUFLEN, kdbgetenv("PROMPT"), smp_processor_id());
+#else
+ snprintf(kdb_prompt_str, CMD_BUFLEN, kdbgetenv("PROMPT"));
+#endif
+ if (defcmd_in_progress)
+ strncat(kdb_prompt_str, "[defcmd]", CMD_BUFLEN);
+
+ /*
+ * Fetch command from keyboard
+ */
+ cmdbuf = kdb_getstr(cmdbuf, CMD_BUFLEN, kdb_prompt_str);
+ if (*cmdbuf != '\n') {
+ if (*cmdbuf < 32) {
+ if(cmdptr == cmd_head) {
+ strncpy(cmd_hist[cmd_head], cmd_cur, CMD_BUFLEN);
+ *(cmd_hist[cmd_head]+strlen(cmd_hist[cmd_head])-1) = '\0';
+ }
+ if(!handle_ctrl_cmd(cmdbuf))
+ *(cmd_cur+strlen(cmd_cur)-1) = '\0';
+ cmdbuf = cmd_cur;
+ goto do_full_getstr;
+ }
+ else
+ strncpy(cmd_hist[cmd_head], cmd_cur, CMD_BUFLEN);
+
+ cmd_head = (cmd_head+1) % KDB_CMD_HISTORY_COUNT;
+ if (cmd_head == cmd_tail) cmd_tail = (cmd_tail+1) % KDB_CMD_HISTORY_COUNT;
+
+ }
+
+ cmdptr = cmd_head;
+ diag = kdb_parse(cmdbuf);
+ if (diag == KDB_NOTFOUND) {
+ kdb_printf("Unknown kdb command: '%s'\n", cmdbuf);
+ diag = 0;
+ }
+ if (diag == KDB_CMD_GO
+ || diag == KDB_CMD_CPU
+ || diag == KDB_CMD_SS
+ || diag == KDB_CMD_SSB)
+ break;
+
+ if (diag)
+ kdb_cmderror(diag);
+ }
+
+ kdba_local_arch_cleanup();
+
+ KDB_DEBUG_STATE("kdb_local 9", diag);
+ return diag;
+}
+
+
+/*
+ * kdb_print_state
+ *
+ * Print the state data for the current processor for debugging.
+ *
+ * Inputs:
+ * text Identifies the debug point
+ * value Any integer value to be printed, e.g. reason code.
+ * Returns:
+ * None.
+ * Locking:
+ * none
+ * Remarks:
+ * none
+ */
+
+void kdb_print_state(const char *text, int value)
+{
+ kdb_printf("state: %s cpu %d value %d initial %d state %x\n",
+ text, smp_processor_id(), value, kdb_initial_cpu, kdb_state[smp_processor_id()]);
+}
+
+/*
+ * kdb_previous_event
+ *
+ * Return a count of cpus that are leaving kdb, i.e. the number
+ * of processors that are still handling the previous kdb event.
+ *
+ * Inputs:
+ * None.
+ * Returns:
+ * Count of cpus in previous event.
+ * Locking:
+ * none
+ * Remarks:
+ * none
+ */
+
+static int
+kdb_previous_event(void)
+{
+ int i, leaving = 0;
+ for (i = 0; i < NR_CPUS; ++i) {
+ if (KDB_STATE_CPU(LEAVING, i))
+ ++leaving;
+ }
+ return leaving;
+}
+
+/*
+ * kdb_wait_for_cpus
+ *
+ * Invoked once at the start of a kdb event, from the controlling cpu. Wait a
+ * short period for the other cpus to enter kdb state.
+ *
+ * Inputs:
+ * none
+ * Returns:
+ * none
+ * Locking:
+ * none
+ * Remarks:
+ * none
+ */
+
+int kdb_wait_for_cpus_secs;
+
+static void
+kdb_wait_for_cpus(void)
+{
+#ifdef CONFIG_SMP
+ int online = 0, kdb_data = 0, prev_kdb_data = 0, c, time;
+ mdelay(100);
+ for (time = 0; time < kdb_wait_for_cpus_secs; ++time) {
+ online = 0;
+ kdb_data = 0;
+ for_each_online_cpu(c) {
+ ++online;
+ if (kdb_running_process[c].seqno >= kdb_seqno - 1)
+ ++kdb_data;
+ }
+ if (online == kdb_data)
+ break;
+ if (prev_kdb_data != kdb_data) {
+ kdb_nextline = 0; /* no prompt yet */
+ kdb_printf(" %d out of %d cpus in kdb, waiting for the rest, timeout in %d second(s)\n",
+ kdb_data, online, kdb_wait_for_cpus_secs - time);
+ prev_kdb_data = kdb_data;
+ }
+ touch_nmi_watchdog();
+ mdelay(1000);
+ /* Architectures may want to send a more forceful interrupt */
+ if (time == min(kdb_wait_for_cpus_secs / 2, 5))
+ kdba_wait_for_cpus();
+ if (time % 4 == 0)
+ kdb_printf(".");
+ }
+ if (time) {
+ int wait = online - kdb_data;
+ if (wait == 0)
+ kdb_printf("All cpus are now in kdb\n");
+ else
+ kdb_printf("%d cpu%s not in kdb, %s state is unknown\n",
+ wait,
+ wait == 1 ? " is" : "s are",
+ wait == 1 ? "its" : "their");
+ }
+#endif /* CONFIG_SMP */
+}
+
+/*
+ * kdb_main_loop
+ *
+ * The main kdb loop. After initial setup and assignment of the controlling
+ * cpu, all cpus are in this loop. One cpu is in control and will issue the kdb
+ * prompt, the others will spin until 'go' or cpu switch.
+ *
+ * To get a consistent view of the kernel stacks for all processes, this routine
+ * is invoked from the main kdb code via an architecture specific routine.
+ * kdba_main_loop is responsible for making the kernel stacks consistent for all
+ * processes, there should be no difference between a blocked process and a
+ * running process as far as kdb is concerned.
+ *
+ * Inputs:
+ * reason The reason KDB was invoked
+ * error The hardware-defined error code
+ * reason2 kdb's current reason code. Initially error but can change
+ * acording to kdb state.
+ * db_result Result code from break or debug point.
+ * regs The exception frame at time of fault/breakpoint. If reason
+ * is SILENT or CPU_UP then regs is NULL, otherwise it
+ * should always be valid.
+ * Returns:
+ * 0 KDB was invoked for an event which it wasn't responsible
+ * 1 KDB handled the event for which it was invoked.
+ * Locking:
+ * none
+ * Remarks:
+ * none
+ */
+
+int
+kdb_main_loop(kdb_reason_t reason, kdb_reason_t reason2, int error,
+ kdb_dbtrap_t db_result, struct pt_regs *regs)
+{
+ int result = 1;
+ /* Stay in kdb() until 'go', 'ss[b]' or an error */
+ while (1) {
+ /*
+ * All processors except the one that is in control
+ * will spin here.
+ */
+ KDB_DEBUG_STATE("kdb_main_loop 1", reason);
+ while (KDB_STATE(HOLD_CPU)) {
+ /* state KDB is turned off by kdb_cpu to see if the
+ * other cpus are still live, each cpu in this loop
+ * turns it back on.
+ */
+ if (!KDB_STATE(KDB)) {
+ KDB_STATE_SET(KDB);
+ }
+ }
+ KDB_STATE_CLEAR(SUPPRESS);
+ KDB_DEBUG_STATE("kdb_main_loop 2", reason);
+ if (KDB_STATE(LEAVING))
+ break; /* Another cpu said 'go' */
+
+ if (!kdb_quiet(reason))
+ kdb_wait_for_cpus();
+ /* Still using kdb, this processor is in control */
+ result = kdb_local(reason2, error, regs, db_result);
+ KDB_DEBUG_STATE("kdb_main_loop 3", result);
+
+ if (result == KDB_CMD_CPU) {
+ /* Cpu switch, hold the current cpu, release the target one. */
+ reason2 = KDB_REASON_SWITCH;
+ KDB_STATE_SET(HOLD_CPU);
+ KDB_STATE_CLEAR_CPU(HOLD_CPU, kdb_new_cpu);
+ continue;
+ }
+
+ if (result == KDB_CMD_SS) {
+ KDB_STATE_SET(DOING_SS);
+ break;
+ }
+
+ if (result == KDB_CMD_SSB) {
+ KDB_STATE_SET(DOING_SS);
+ KDB_STATE_SET(DOING_SSB);
+ break;
+ }
+
+ if (result && result != 1 && result != KDB_CMD_GO)
+ kdb_printf("\nUnexpected kdb_local return code %d\n", result);
+
+ KDB_DEBUG_STATE("kdb_main_loop 4", reason);
+ break;
+ }
+ if (KDB_STATE(DOING_SS))
+ KDB_STATE_CLEAR(SSBPT);
+ return result;
+}
+
+/* iapc_boot_arch was defined in ACPI 2.0, FADT revision 3 onwards. For any
+ * FADT prior to revision 3, we have to assume that we have an i8042 I/O
+ * device. ACPI initialises after KDB initialises but before using KDB, so
+ * check iapc_boot_arch on each entry to KDB.
+ */
+static void
+kdb_check_i8042(void)
+{
+ KDB_FLAG_CLEAR(NO_I8042);
+#ifdef CONFIG_ACPI
+ if (acpi_gbl_FADT.header.revision >= 3 &&
+ (acpi_gbl_FADT.boot_flags & BAF_8042_KEYBOARD_CONTROLLER) == 0)
+ KDB_FLAG_SET(NO_I8042);
+#endif /* CONFIG_ACPI */
+}
+
+/*
+ * kdb
+ *
+ * This function is the entry point for the kernel debugger. It
+ * provides a command parser and associated support functions to
+ * allow examination and control of an active kernel.
+ *
+ * The breakpoint trap code should invoke this function with
+ * one of KDB_REASON_BREAK (int 03) or KDB_REASON_DEBUG (debug register)
+ *
+ * the die_if_kernel function should invoke this function with
+ * KDB_REASON_OOPS.
+ *
+ * In single step mode, one cpu is released to run without
+ * breakpoints. Interrupts and NMI are reset to their original values,
+ * the cpu is allowed to do one instruction which causes a trap
+ * into kdb with KDB_REASON_DEBUG.
+ *
+ * Inputs:
+ * reason The reason KDB was invoked
+ * error The hardware-defined error code
+ * regs The exception frame at time of fault/breakpoint. If reason
+ * is SILENT or CPU_UP then regs is NULL, otherwise it
+ * should always be valid.
+ * Returns:
+ * 0 KDB was invoked for an event which it wasn't responsible
+ * 1 KDB handled the event for which it was invoked.
+ * Locking:
+ * none
+ * Remarks:
+ * No assumptions of system state. This function may be invoked
+ * with arbitrary locks held. It will stop all other processors
+ * in an SMP environment, disable all interrupts and does not use
+ * the operating systems keyboard driver.
+ *
+ * This code is reentrant but only for cpu switch. Any other
+ * reentrancy is an error, although kdb will attempt to recover.
+ *
+ * At the start of a kdb session the initial processor is running
+ * kdb() and the other processors can be doing anything. When the
+ * initial processor calls smp_kdb_stop() the other processors are
+ * driven through kdb_ipi which calls kdb() with reason SWITCH.
+ * That brings all processors into this routine, one with a "real"
+ * reason code, the other with SWITCH.
+ *
+ * Because the other processors are driven via smp_kdb_stop(),
+ * they enter here from the NMI handler. Until the other
+ * processors exit from here and exit from kdb_ipi, they will not
+ * take any more NMI requests. The initial cpu will still take NMI.
+ *
+ * Multiple race and reentrancy conditions, each with different
+ * advoidance mechanisms.
+ *
+ * Two cpus hit debug points at the same time.
+ *
+ * kdb_lock and kdb_initial_cpu ensure that only one cpu gets
+ * control of kdb. The others spin on kdb_initial_cpu until
+ * they are driven through NMI into kdb_ipi. When the initial
+ * cpu releases the others from NMI, they resume trying to get
+ * kdb_initial_cpu to start a new event.
+ *
+ * A cpu is released from kdb and starts a new event before the
+ * original event has completely ended.
+ *
+ * kdb_previous_event() prevents any cpu from entering
+ * kdb_initial_cpu state until the previous event has completely
+ * ended on all cpus.
+ *
+ * An exception occurs inside kdb.
+ *
+ * kdb_initial_cpu detects recursive entry to kdb and attempts
+ * to recover. The recovery uses longjmp() which means that
+ * recursive calls to kdb never return. Beware of assumptions
+ * like
+ *
+ * ++depth;
+ * kdb();
+ * --depth;
+ *
+ * If the kdb call is recursive then longjmp takes over and
+ * --depth is never executed.
+ *
+ * NMI handling.
+ *
+ * NMI handling is tricky. The initial cpu is invoked by some kdb event,
+ * this event could be NMI driven but usually is not. The other cpus are
+ * driven into kdb() via kdb_ipi which uses NMI so at the start the other
+ * cpus will not accept NMI. Some operations such as SS release one cpu
+ * but hold all the others. Releasing a cpu means it drops back to
+ * whatever it was doing before the kdb event, this means it drops out of
+ * kdb_ipi and hence out of NMI status. But the software watchdog uses
+ * NMI and we do not want spurious watchdog calls into kdb. kdba_read()
+ * resets the watchdog counters in its input polling loop, when a kdb
+ * command is running it is subject to NMI watchdog events.
+ *
+ * Another problem with NMI handling is the NMI used to drive the other
+ * cpus into kdb cannot be distinguished from the watchdog NMI. State
+ * flag WAIT_IPI indicates that a cpu is waiting for NMI via kdb_ipi,
+ * if not set then software NMI is ignored by kdb_ipi.
+ *
+ * Cpu switching.
+ *
+ * All cpus are in kdb (or they should be), all but one are
+ * spinning on KDB_STATE(HOLD_CPU). Only one cpu is not in
+ * HOLD_CPU state, only that cpu can handle commands.
+ *
+ * Go command entered.
+ *
+ * If necessary, go will switch to the initial cpu first. If the event
+ * was caused by a software breakpoint (assumed to be global) that
+ * requires single-step to get over the breakpoint then only release the
+ * initial cpu, after the initial cpu has single-stepped the breakpoint
+ * then release the rest of the cpus. If SSBPT is not required then
+ * release all the cpus at once.
+ */
+
+int
+kdb(kdb_reason_t reason, int error, struct pt_regs *regs)
+{
+ kdb_intstate_t int_state; /* Interrupt state */
+ kdb_reason_t reason2 = reason;
+ int result = 0; /* Default is kdb did not handle it */
+ int ss_event, old_regs_saved = 0;
+ struct pt_regs *old_regs = NULL;
+ kdb_dbtrap_t db_result=KDB_DB_NOBPT;
+ preempt_disable();
+ atomic_inc(&kdb_event);
+
+ switch(reason) {
+ case KDB_REASON_OOPS:
+ case KDB_REASON_NMI:
+ KDB_FLAG_SET(CATASTROPHIC); /* kernel state is dubious now */
+ break;
+ default:
+ break;
+ }
+ switch(reason) {
+ case KDB_REASON_ENTER:
+ case KDB_REASON_ENTER_SLAVE:
+ case KDB_REASON_BREAK:
+ case KDB_REASON_DEBUG:
+ case KDB_REASON_OOPS:
+ case KDB_REASON_SWITCH:
+ case KDB_REASON_KEYBOARD:
+ case KDB_REASON_NMI:
+ if (regs && regs != get_irq_regs()) {
+ old_regs = set_irq_regs(regs);
+ old_regs_saved = 1;
+ }
+ break;
+ default:
+ break;
+ }
+ if (kdb_continue_catastrophic > 2) {
+ kdb_printf("kdb_continue_catastrophic is out of range, setting to 2\n");
+ kdb_continue_catastrophic = 2;
+ }
+ if (!kdb_on && KDB_FLAG(CATASTROPHIC) && kdb_continue_catastrophic == 2) {
+ KDB_FLAG_SET(ONLY_DO_DUMP);
+ }
+ if (!kdb_on && !KDB_FLAG(ONLY_DO_DUMP))
+ goto out;
+
+ KDB_DEBUG_STATE("kdb 1", reason);
+ KDB_STATE_CLEAR(SUPPRESS);
+
+ /* Filter out userspace breakpoints first, no point in doing all
+ * the kdb smp fiddling when it is really a gdb trap.
+ * Save the single step status first, kdba_db_trap clears ss status.
+ * kdba_b[dp]_trap sets SSBPT if required.
+ */
+ ss_event = KDB_STATE(DOING_SS) || KDB_STATE(SSBPT);
+#ifdef CONFIG_CPU_XSCALE
+ if ( KDB_STATE(A_XSC_ICH) ) {
+ /* restore changed I_BIT */
+ KDB_STATE_CLEAR(A_XSC_ICH);
+ kdba_restore_retirq(regs, KDB_STATE(A_XSC_IRQ));
+ if ( !ss_event ) {
+ kdb_printf("Stranger!!! Why IRQ bit is changed====\n");
+ }
+ }
+#endif
+ if (reason == KDB_REASON_BREAK) {
+ db_result = kdba_bp_trap(regs, error); /* Only call this once */
+ }
+ if (reason == KDB_REASON_DEBUG) {
+ db_result = kdba_db_trap(regs, error); /* Only call this once */
+ }
+
+ if ((reason == KDB_REASON_BREAK || reason == KDB_REASON_DEBUG)
+ && db_result == KDB_DB_NOBPT) {
+ KDB_DEBUG_STATE("kdb 2", reason);
+ goto out; /* Not one of mine */
+ }
+
+ /* Turn off single step if it was being used */
+ if (ss_event) {
+ kdba_clearsinglestep(regs);
+ /* Single step after a breakpoint removes the need for a delayed reinstall */
+ if (reason == KDB_REASON_BREAK || reason == KDB_REASON_DEBUG)
+ KDB_STATE_CLEAR(SSBPT);
+ }
+
+ /* kdb can validly reenter but only for certain well defined conditions */
+ if (reason == KDB_REASON_DEBUG
+ && !KDB_STATE(HOLD_CPU)
+ && ss_event)
+ KDB_STATE_SET(REENTRY);
+ else
+ KDB_STATE_CLEAR(REENTRY);
+
+ /* Wait for previous kdb event to completely exit before starting
+ * a new event.
+ */
+ while (kdb_previous_event())
+ ;
+ KDB_DEBUG_STATE("kdb 3", reason);
+
+ /*
+ * If kdb is already active, print a message and try to recover.
+ * If recovery is not possible and recursion is allowed or
+ * forced recursion without recovery is set then try to recurse
+ * in kdb. Not guaranteed to work but it makes an attempt at
+ * debugging the debugger.
+ */
+ if (reason != KDB_REASON_SWITCH &&
+ reason != KDB_REASON_ENTER_SLAVE) {
+ if (KDB_IS_RUNNING() && !KDB_STATE(REENTRY)) {
+ int recover = 1;
+ unsigned long recurse = 0;
+ kdb_printf("kdb: Debugger re-entered on cpu %d, new reason = %d\n",
+ smp_processor_id(), reason);
+ /* Should only re-enter from released cpu */
+
+ if (KDB_STATE(HOLD_CPU)) {
+ kdb_printf(" Strange, cpu %d should not be running\n", smp_processor_id());
+ recover = 0;
+ }
+ if (!KDB_STATE(CMD)) {
+ kdb_printf(" Not executing a kdb command\n");
+ recover = 0;
+ }
+ if (!KDB_STATE(LONGJMP)) {
+ kdb_printf(" No longjmp available for recovery\n");
+ recover = 0;
+ }
+ kdbgetulenv("RECURSE", &recurse);
+ if (recurse > 1) {
+ kdb_printf(" Forced recursion is set\n");
+ recover = 0;
+ }
+ if (recover) {
+ kdb_printf(" Attempting to abort command and recover\n");
+#ifdef kdba_setjmp
+ kdba_longjmp(&kdbjmpbuf[smp_processor_id()], 0);
+#endif /* kdba_setjmp */
+ }
+ if (recurse) {
+ if (KDB_STATE(RECURSE)) {
+ kdb_printf(" Already in recursive mode\n");
+ } else {
+ kdb_printf(" Attempting recursive mode\n");
+ KDB_STATE_SET(RECURSE);
+ KDB_STATE_SET(REENTRY);
+ reason2 = KDB_REASON_RECURSE;
+ recover = 1;
+ }
+ }
+ if (!recover) {
+ kdb_printf(" Cannot recover, allowing event to proceed\n");
+ /*temp*/
+ while (KDB_IS_RUNNING())
+ cpu_relax();
+ goto out;
+ }
+ }
+ } else if (reason == KDB_REASON_SWITCH && !KDB_IS_RUNNING()) {
+ kdb_printf("kdb: CPU switch without kdb running, I'm confused\n");
+ goto out;
+ }
+
+ /*
+ * Disable interrupts, breakpoints etc. on this processor
+ * during kdb command processing
+ */
+ KDB_STATE_SET(KDB);
+ kdba_disableint(&int_state);
+ if (!KDB_STATE(KDB_CONTROL)) {
+ kdb_bp_remove_local();
+ KDB_STATE_SET(KDB_CONTROL);
+ }
+
+ /*
+ * If not entering the debugger due to CPU switch or single step
+ * reentry, serialize access here.
+ * The processors may race getting to this point - if,
+ * for example, more than one processor hits a breakpoint
+ * at the same time. We'll serialize access to kdb here -
+ * other processors will loop here, and the NMI from the stop
+ * IPI will take them into kdb as switch candidates. Once
+ * the initial processor releases the debugger, the rest of
+ * the processors will race for it.
+ *
+ * The above describes the normal state of affairs, where two or more
+ * cpus that are entering kdb at the "same" time are assumed to be for
+ * separate events. However some processes such as ia64 MCA/INIT will
+ * drive all the cpus into error processing at the same time. For that
+ * case, all of the cpus entering kdb at the "same" time are really a
+ * single event.
+ *
+ * That case is handled by the use of KDB_ENTER by one cpu (the
+ * monarch) and KDB_ENTER_SLAVE on the other cpus (the slaves).
+ * KDB_ENTER_SLAVE maps to KDB_REASON_ENTER_SLAVE. The slave events
+ * will be treated as if they had just responded to the kdb IPI, i.e.
+ * as if they were KDB_REASON_SWITCH.
+ *
+ * Because of races across multiple cpus, ENTER_SLAVE can occur before
+ * the main ENTER. Hold up ENTER_SLAVE here until the main ENTER
+ * arrives.
+ */
+
+ if (reason == KDB_REASON_ENTER_SLAVE) {
+ spin_lock(&kdb_lock);
+ while (!KDB_IS_RUNNING()) {
+ spin_unlock(&kdb_lock);
+ while (!KDB_IS_RUNNING())
+ cpu_relax();
+ spin_lock(&kdb_lock);
+ }
+ reason = KDB_REASON_SWITCH;
+ KDB_STATE_SET(HOLD_CPU);
+ spin_unlock(&kdb_lock);
+ }
+
+ if (reason == KDB_REASON_SWITCH || KDB_STATE(REENTRY))
+ ; /* drop through */
+ else {
+ KDB_DEBUG_STATE("kdb 4", reason);
+ spin_lock(&kdb_lock);
+ while (KDB_IS_RUNNING() || kdb_previous_event()) {
+ spin_unlock(&kdb_lock);
+ while (KDB_IS_RUNNING() || kdb_previous_event())
+ cpu_relax();
+ spin_lock(&kdb_lock);
+ }
+ KDB_DEBUG_STATE("kdb 5", reason);
+
+ kdb_initial_cpu = smp_processor_id();
+ ++kdb_seqno;
+ spin_unlock(&kdb_lock);
+ if (!kdb_quiet(reason))
+ notify_die(DIE_KDEBUG_ENTER, "KDEBUG ENTER", regs, error, 0, 0);
+ }
+
+ if (smp_processor_id() == kdb_initial_cpu
+ && !KDB_STATE(REENTRY)) {
+ KDB_STATE_CLEAR(HOLD_CPU);
+ KDB_STATE_CLEAR(WAIT_IPI);
+ kdb_check_i8042();
+ /*
+ * Remove the global breakpoints. This is only done
+ * once from the initial processor on initial entry.
+ */
+ if (!kdb_quiet(reason) || smp_processor_id() == 0)
+ kdb_bp_remove_global();
+
+ /*
+ * If SMP, stop other processors. The other processors
+ * will enter kdb() with KDB_REASON_SWITCH and spin in
+ * kdb_main_loop().
+ */
+ KDB_DEBUG_STATE("kdb 6", reason);
+ if (NR_CPUS > 1 && !kdb_quiet(reason)) {
+ int i;
+ for (i = 0; i < NR_CPUS; ++i) {
+ if (!cpu_online(i))
+ continue;
+ if (i != kdb_initial_cpu) {
+ KDB_STATE_SET_CPU(HOLD_CPU, i);
+ KDB_STATE_SET_CPU(WAIT_IPI, i);
+ }
+ }
+ KDB_DEBUG_STATE("kdb 7", reason);
+ smp_kdb_stop();
+ KDB_DEBUG_STATE("kdb 8", reason);
+ }
+ }
+
+ if (KDB_STATE(GO1)) {
+ kdb_bp_remove_global(); /* They were set for single-step purposes */
+ KDB_STATE_CLEAR(GO1);
+ reason = KDB_REASON_SILENT; /* Now silently go */
+ }
+
+ /* Set up a consistent set of process stacks before talking to the user */
+ KDB_DEBUG_STATE("kdb 9", result);
+ result = kdba_main_loop(reason, reason2, error, db_result, regs);
+ reason = reason2; /* back to original event type */
+
+ KDB_DEBUG_STATE("kdb 10", result);
+ kdba_adjust_ip(reason, error, regs);
+ KDB_STATE_CLEAR(LONGJMP);
+ KDB_DEBUG_STATE("kdb 11", result);
+ /* go which requires single-step over a breakpoint must only release
+ * one cpu.
+ */
+ if (result == KDB_CMD_GO && KDB_STATE(SSBPT))
+ KDB_STATE_SET(GO1);
+
+ if (smp_processor_id() == kdb_initial_cpu &&
+ !KDB_STATE(DOING_SS) &&
+ !KDB_STATE(RECURSE)) {
+ /*
+ * (Re)install the global breakpoints and cleanup the cached
+ * symbol table. This is only done once from the initial
+ * processor on go.
+ */
+ KDB_DEBUG_STATE("kdb 12", reason);
+ if (!kdb_quiet(reason) || smp_processor_id() == 0) {
+ kdb_bp_install_global(regs);
+ kdbnearsym_cleanup();
+ debug_kusage();
+ }
+ if (!KDB_STATE(GO1)) {
+ /*
+ * Release all other cpus which will see KDB_STATE(LEAVING) is set.
+ */
+ int i;
+ for (i = 0; i < NR_CPUS; ++i) {
+ if (KDB_STATE_CPU(KDB, i))
+ KDB_STATE_SET_CPU(LEAVING, i);
+ KDB_STATE_CLEAR_CPU(WAIT_IPI, i);
+ KDB_STATE_CLEAR_CPU(HOLD_CPU, i);
+ }
+ /* Wait until all the other processors leave kdb */
+ while (kdb_previous_event() != 1)
+ ;
+ if (!kdb_quiet(reason))
+ notify_die(DIE_KDEBUG_LEAVE, "KDEBUG LEAVE", regs, error, 0, 0);
+ kdb_initial_cpu = -1; /* release kdb control */
+ KDB_DEBUG_STATE("kdb 13", reason);
+ }
+ }
+
+ KDB_DEBUG_STATE("kdb 14", result);
+ kdba_restoreint(&int_state);
+#ifdef CONFIG_CPU_XSCALE
+ if ( smp_processor_id() == kdb_initial_cpu &&
+ ( KDB_STATE(SSBPT) | KDB_STATE(DOING_SS) )
+ ) {
+ kdba_setsinglestep(regs);
+ // disable IRQ in stack frame
+ KDB_STATE_SET(A_XSC_ICH);
+ if ( kdba_disable_retirq(regs) ) {
+ KDB_STATE_SET(A_XSC_IRQ);
+ }
+ else {
+ KDB_STATE_CLEAR(A_XSC_IRQ);
+ }
+ }
+#endif
+
+ /* Only do this work if we are really leaving kdb */
+ if (!(KDB_STATE(DOING_SS) || KDB_STATE(SSBPT) || KDB_STATE(RECURSE))) {
+ KDB_DEBUG_STATE("kdb 15", result);
+ kdb_bp_install_local(regs);
+ if (old_regs_saved)
+ set_irq_regs(old_regs);
+ KDB_STATE_CLEAR(KDB_CONTROL);
+ }
+
+ KDB_DEBUG_STATE("kdb 16", result);
+ KDB_FLAG_CLEAR(CATASTROPHIC);
+ KDB_STATE_CLEAR(IP_ADJUSTED); /* Re-adjust ip next time in */
+ KDB_STATE_CLEAR(KEYBOARD);
+ KDB_STATE_CLEAR(KDB); /* Main kdb state has been cleared */
+ KDB_STATE_CLEAR(RECURSE);
+ KDB_STATE_CLEAR(LEAVING); /* No more kdb work after this */
+ KDB_DEBUG_STATE("kdb 17", reason);
+out:
+ atomic_dec(&kdb_event);
+ preempt_enable();
+ return result != 0;
+}
+
+/*
+ * kdb_mdr
+ *
+ * This function implements the guts of the 'mdr' command.
+ *
+ * mdr <addr arg>,<byte count>
+ *
+ * Inputs:
+ * addr Start address
+ * count Number of bytes
+ * Outputs:
+ * None.
+ * Returns:
+ * Always 0. Any errors are detected and printed by kdb_getarea.
+ * Locking:
+ * none.
+ * Remarks:
+ */
+
+static int
+kdb_mdr(kdb_machreg_t addr, unsigned int count)
+{
+ unsigned char c;
+ while (count--) {
+ if (kdb_getarea(c, addr))
+ return 0;
+ kdb_printf("%02x", c);
+ addr++;
+ }
+ kdb_printf("\n");
+ return 0;
+}
+
+/*
+ * kdb_md
+ *
+ * This function implements the 'md', 'md1', 'md2', 'md4', 'md8'
+ * 'mdr' and 'mds' commands.
+ *
+ * md|mds [<addr arg> [<line count> [<radix>]]]
+ * mdWcN [<addr arg> [<line count> [<radix>]]]
+ * where W = is the width (1, 2, 4 or 8) and N is the count.
+ * for eg., md1c20 reads 20 bytes, 1 at a time.
+ * mdr <addr arg>,<byte count>
+ *
+ * Inputs:
+ * argc argument count
+ * argv argument vector
+ * Outputs:
+ * None.
+ * Returns:
+ * zero for success, a kdb diagnostic if error
+ * Locking:
+ * none.
+ * Remarks:
+ */
+
+static void
+kdb_md_line(const char *fmtstr, kdb_machreg_t addr,
+ int symbolic, int nosect, int bytesperword,
+ int num, int repeat, int phys)
+{
+ /* print just one line of data */
+ kdb_symtab_t symtab;
+ char cbuf[32];
+ char *c = cbuf;
+ int i;
+ unsigned long word;
+
+ memset(cbuf, '\0', sizeof(cbuf));
+ if (phys)
+ kdb_printf("phys " kdb_machreg_fmt0 " ", addr);
+ else
+ kdb_printf(kdb_machreg_fmt0 " ", addr);
+
+ for (i = 0; i < num && repeat--; i++) {
+ if (phys) {
+ if (kdb_getphysword(&word, addr, bytesperword))
+ break;
+ } else if (kdb_getword(&word, addr, bytesperword))
+ break;
+ kdb_printf(fmtstr, word);
+ if (symbolic)
+ kdbnearsym(word, &symtab);
+ else
+ memset(&symtab, 0, sizeof(symtab));
+ if (symtab.sym_name) {
+ kdb_symbol_print(word, &symtab, 0);
+ if (!nosect) {
+ kdb_printf("\n");
+ kdb_printf(" %s %s "
+ kdb_machreg_fmt " " kdb_machreg_fmt " " kdb_machreg_fmt,
+ symtab.mod_name,
+ symtab.sec_name,
+ symtab.sec_start,
+ symtab.sym_start,
+ symtab.sym_end);
+ }
+ addr += bytesperword;
+ } else {
+ union {
+ u64 word;
+ unsigned char c[8];
+ } wc;
+ unsigned char *cp;
+#ifdef __BIG_ENDIAN
+ cp = wc.c + 8 - bytesperword;
+#else
+ cp = wc.c;
+#endif
+ wc.word = word;
+#define printable_char(c) ({unsigned char __c = c; isascii(__c) && isprint(__c) ? __c : '.';})
+ switch (bytesperword) {
+ case 8:
+ *c++ = printable_char(*cp++);
+ *c++ = printable_char(*cp++);
+ *c++ = printable_char(*cp++);
+ *c++ = printable_char(*cp++);
+ addr += 4;
+ case 4:
+ *c++ = printable_char(*cp++);
+ *c++ = printable_char(*cp++);
+ addr += 2;
+ case 2:
+ *c++ = printable_char(*cp++);
+ addr++;
+ case 1:
+ *c++ = printable_char(*cp++);
+ addr++;
+ break;
+ }
+#undef printable_char
+ }
+ }
+ kdb_printf("%*s %s\n", (int)((num-i)*(2*bytesperword + 1)+1), " ", cbuf);
+}
+
+static int
+kdb_md(int argc, const char **argv)
+{
+ static kdb_machreg_t last_addr;
+ static int last_radix, last_bytesperword, last_repeat;
+ int radix = 16, mdcount = 8, bytesperword = KDB_WORD_SIZE, repeat;
+ int nosect = 0;
+ char fmtchar, fmtstr[64];
+ kdb_machreg_t addr;
+ unsigned long word;
+ long offset = 0;
+ int symbolic = 0;
+ int valid = 0;
+ int phys = 0;
+
+ kdbgetintenv("MDCOUNT", &mdcount);
+ kdbgetintenv("RADIX", &radix);
+ kdbgetintenv("BYTESPERWORD", &bytesperword);
+
+ /* Assume 'md <addr>' and start with environment values */
+ repeat = mdcount * 16 / bytesperword;
+
+ if (strcmp(argv[0], "mdr") == 0) {
+ if (argc != 2)
+ return KDB_ARGCOUNT;
+ valid = 1;
+ } else if (isdigit(argv[0][2])) {
+ bytesperword = (int)(argv[0][2] - '0');
+ if (bytesperword == 0) {
+ bytesperword = last_bytesperword;
+ if (bytesperword == 0) {
+ bytesperword = 4;
+ }
+ }
+ last_bytesperword = bytesperword;
+ repeat = mdcount * 16 / bytesperword;
+ if (!argv[0][3])
+ valid = 1;
+ else if (argv[0][3] == 'c' && argv[0][4]) {
+ char *p;
+ repeat = simple_strtoul(argv[0]+4, &p, 10);
+ mdcount = ((repeat * bytesperword) + 15) / 16;
+ valid = !*p;
+ }
+ last_repeat = repeat;
+ } else if (strcmp(argv[0], "md") == 0)
+ valid = 1;
+ else if (strcmp(argv[0], "mds") == 0)
+ valid = 1;
+ else if (strcmp(argv[0], "mdp") == 0) {
+ phys = valid = 1;
+ }
+ if (!valid)
+ return KDB_NOTFOUND;
+
+ if (argc == 0) {
+ if (last_addr == 0)
+ return KDB_ARGCOUNT;
+ addr = last_addr;
+ radix = last_radix;
+ bytesperword = last_bytesperword;
+ repeat = last_repeat;
+ mdcount = ((repeat * bytesperword) + 15) / 16;
+ }
+
+ if (argc) {
+ kdb_machreg_t val;
+ int diag, nextarg = 1;
+ diag = kdbgetaddrarg(argc, argv, &nextarg, &addr, &offset, NULL);
+ if (diag)
+ return diag;
+ if (argc > nextarg+2)
+ return KDB_ARGCOUNT;
+
+ if (argc >= nextarg) {
+ diag = kdbgetularg(argv[nextarg], &val);
+ if (!diag) {
+ mdcount = (int) val;
+ repeat = mdcount * 16 / bytesperword;
+ }
+ }
+ if (argc >= nextarg+1) {
+ diag = kdbgetularg(argv[nextarg+1], &val);
+ if (!diag)
+ radix = (int) val;
+ }
+ }
+
+ if (strcmp(argv[0], "mdr") == 0) {
+ return kdb_mdr(addr, mdcount);
+ }
+
+ switch (radix) {
+ case 10:
+ fmtchar = 'd';
+ break;
+ case 16:
+ fmtchar = 'x';
+ break;
+ case 8:
+ fmtchar = 'o';
+ break;
+ default:
+ return KDB_BADRADIX;
+ }
+
+ last_radix = radix;
+
+ if (bytesperword > KDB_WORD_SIZE)
+ return KDB_BADWIDTH;
+
+ switch (bytesperword) {
+ case 8:
+ sprintf(fmtstr, "%%16.16l%c ", fmtchar);
+ break;
+ case 4:
+ sprintf(fmtstr, "%%8.8l%c ", fmtchar);
+ break;
+ case 2:
+ sprintf(fmtstr, "%%4.4l%c ", fmtchar);
+ break;
+ case 1:
+ sprintf(fmtstr, "%%2.2l%c ", fmtchar);
+ break;
+ default:
+ return KDB_BADWIDTH;
+ }
+
+ last_repeat = repeat;
+ last_bytesperword = bytesperword;
+
+ if (strcmp(argv[0], "mds") == 0) {
+ symbolic = 1;
+ /* Do not save these changes as last_*, they are temporary mds
+ * overrides.
+ */
+ bytesperword = KDB_WORD_SIZE;
+ repeat = mdcount;
+ kdbgetintenv("NOSECT", &nosect);
+ }
+
+ /* Round address down modulo BYTESPERWORD */
+
+ addr &= ~(bytesperword-1);
+
+ while (repeat > 0) {
+ unsigned long a;
+ int n, z, num = (symbolic ? 1 : (16 / bytesperword));
+
+ for (a = addr, z = 0; z < repeat; a += bytesperword, ++z) {
+ if (phys) {
+ if (kdb_getphysword(&word, a, bytesperword)
+ || word)
+ break;
+ } else if (kdb_getword(&word, a, bytesperword) || word)
+ break;
+ }
+ n = min(num, repeat);
+ kdb_md_line(fmtstr, addr, symbolic, nosect, bytesperword, num, repeat, phys);
+ addr += bytesperword * n;
+ repeat -= n;
+ z = (z + num - 1) / num;
+ if (z > 2) {
+ int s = num * (z-2);
+ kdb_printf(kdb_machreg_fmt0 "-" kdb_machreg_fmt0 " zero suppressed\n",
+ addr, addr + bytesperword * s - 1);
+ addr += bytesperword * s;
+ repeat -= s;
+ }
+ }
+ last_addr = addr;
+
+ return 0;
+}
+
+/*
+ * kdb_mm
+ *
+ * This function implements the 'mm' command.
+ *
+ * mm address-expression new-value
+ *
+ * Inputs:
+ * argc argument count
+ * argv argument vector
+ * Outputs:
+ * None.
+ * Returns:
+ * zero for success, a kdb diagnostic if error
+ * Locking:
+ * none.
+ * Remarks:
+ * mm works on machine words, mmW works on bytes.
+ */
+
+static int
+kdb_mm(int argc, const char **argv)
+{
+ int diag;
+ kdb_machreg_t addr;
+ long offset = 0;
+ unsigned long contents;
+ int nextarg;
+ int width;
+
+ if (argv[0][2] && !isdigit(argv[0][2]))
+ return KDB_NOTFOUND;
+
+ if (argc < 2) {
+ return KDB_ARGCOUNT;
+ }
+
+ nextarg = 1;
+ if ((diag = kdbgetaddrarg(argc, argv, &nextarg, &addr, &offset, NULL)))
+ return diag;
+
+ if (nextarg > argc)
+ return KDB_ARGCOUNT;
+
+ if ((diag = kdbgetaddrarg(argc, argv, &nextarg, &contents, NULL, NULL)))
+ return diag;
+
+ if (nextarg != argc + 1)
+ return KDB_ARGCOUNT;
+
+ width = argv[0][2] ? (argv[0][2] - '0') : (KDB_WORD_SIZE);
+ if ((diag = kdb_putword(addr, contents, width)))
+ return diag;
+
+ kdb_printf(kdb_machreg_fmt " = " kdb_machreg_fmt "\n", addr, contents);
+
+ return 0;
+}
+
+/*
+ * kdb_go
+ *
+ * This function implements the 'go' command.
+ *
+ * go [address-expression]
+ *
+ * Inputs:
+ * argc argument count
+ * argv argument vector
+ * Outputs:
+ * None.
+ * Returns:
+ * KDB_CMD_GO for success, a kdb diagnostic if error
+ * Locking:
+ * none.
+ * Remarks:
+ */
+
+static int
+kdb_go(int argc, const char **argv)
+{
+ kdb_machreg_t addr;
+ int diag;
+ int nextarg;
+ long offset;
+ struct pt_regs *regs = get_irq_regs();
+
+ if (argc == 1) {
+ if (smp_processor_id() != kdb_initial_cpu) {
+ kdb_printf("go <address> must be issued from the initial cpu, do cpu %d first\n", kdb_initial_cpu);
+ return KDB_ARGCOUNT;
+ }
+ nextarg = 1;
+ diag = kdbgetaddrarg(argc, argv, &nextarg,
+ &addr, &offset, NULL);
+ if (diag)
+ return diag;
+
+ kdba_setpc(regs, addr);
+ } else if (argc)
+ return KDB_ARGCOUNT;
+
+ diag = KDB_CMD_GO;
+ if (KDB_FLAG(CATASTROPHIC)) {
+ kdb_printf("Catastrophic error detected\n");
+ kdb_printf("kdb_continue_catastrophic=%d, ",
+ kdb_continue_catastrophic);
+ if (kdb_continue_catastrophic == 0 && kdb_go_count++ == 0) {
+ kdb_printf("type go a second time if you really want to continue\n");
+ return 0;
+ }
+ if (kdb_continue_catastrophic == 2) {
+ kdb_do_dump();
+ kdb_printf("forcing reboot\n");
+ kdb_reboot(0, NULL);
+ }
+ kdb_printf("attempting to continue\n");
+ }
+ if (smp_processor_id() != kdb_initial_cpu) {
+ char buf[80];
+ kdb_printf("go was not issued from initial cpu, switching back to cpu %d\n", kdb_initial_cpu);
+ sprintf(buf, "cpu %d\n", kdb_initial_cpu);
+ /* Recursive use of kdb_parse, do not use argv after this point */
+ argv = NULL;
+ diag = kdb_parse(buf);
+ if (diag == KDB_CMD_CPU)
+ KDB_STATE_SET_CPU(GO_SWITCH, kdb_initial_cpu);
+ }
+ return diag;
+}
+
+/*
+ * kdb_rd
+ *
+ * This function implements the 'rd' command.
+ *
+ * rd display all general registers.
+ * rd c display all control registers.
+ * rd d display all debug registers.
+ *
+ * Inputs:
+ * argc argument count
+ * argv argument vector
+ * Outputs:
+ * None.
+ * Returns:
+ * zero for success, a kdb diagnostic if error
+ * Locking:
+ * none.
+ * Remarks:
+ */
+
+static int
+kdb_rd(int argc, const char **argv)
+{
+ int diag;
+ if (argc == 0) {
+ if ((diag = kdb_check_regs()))
+ return diag;
+ return kdba_dumpregs(kdb_current_regs, NULL, NULL);
+ }
+
+ if (argc > 2) {
+ return KDB_ARGCOUNT;
+ }
+
+ if ((diag = kdb_check_regs()))
+ return diag;
+ return kdba_dumpregs(kdb_current_regs, argv[1], argc==2 ? argv[2]: NULL);
+}
+
+/*
+ * kdb_rm
+ *
+ * This function implements the 'rm' (register modify) command.
+ *
+ * rm register-name new-contents
+ *
+ * Inputs:
+ * argc argument count
+ * argv argument vector
+ * Outputs:
+ * None.
+ * Returns:
+ * zero for success, a kdb diagnostic if error
+ * Locking:
+ * none.
+ * Remarks:
+ * Currently doesn't allow modification of control or
+ * debug registers.
+ */
+
+static int
+kdb_rm(int argc, const char **argv)
+{
+ int diag;
+ int ind = 0;
+ kdb_machreg_t contents;
+
+ if (argc != 2) {
+ return KDB_ARGCOUNT;
+ }
+
+ /*
+ * Allow presence or absence of leading '%' symbol.
+ */
+
+ if (argv[1][0] == '%')
+ ind = 1;
+
+ diag = kdbgetularg(argv[2], &contents);
+ if (diag)
+ return diag;
+
+ if ((diag = kdb_check_regs()))
+ return diag;
+ diag = kdba_setregcontents(&argv[1][ind], kdb_current_regs, contents);
+ if (diag)
+ return diag;
+
+ return 0;
+}
+
+#if defined(CONFIG_MAGIC_SYSRQ)
+/*
+ * kdb_sr
+ *
+ * This function implements the 'sr' (SYSRQ key) command which
+ * interfaces to the soi-disant MAGIC SYSRQ functionality.
+ *
+ * sr <magic-sysrq-code>
+ *
+ * Inputs:
+ * argc argument count
+ * argv argument vector
+ * Outputs:
+ * None.
+ * Returns:
+ * zero for success, a kdb diagnostic if error
+ * Locking:
+ * none.
+ * Remarks:
+ * None.
+ */
+static int
+kdb_sr(int argc, const char **argv)
+{
+ extern int __sysrq_enabled;
+ if (argc != 1) {
+ return KDB_ARGCOUNT;
+ }
+ if (!__sysrq_enabled) {
+ kdb_printf("Auto activating sysrq\n");
+ __sysrq_enabled = 1;
+ }
+
+ handle_sysrq(*argv[1], NULL);
+
+ return 0;
+}
+#endif /* CONFIG_MAGIC_SYSRQ */
+
+/*
+ * kdb_ef
+ *
+ * This function implements the 'regs' (display exception frame)
+ * command. This command takes an address and expects to find
+ * an exception frame at that address, formats and prints it.
+ *
+ * regs address-expression
+ *
+ * Inputs:
+ * argc argument count
+ * argv argument vector
+ * Outputs:
+ * None.
+ * Returns:
+ * zero for success, a kdb diagnostic if error
+ * Locking:
+ * none.
+ * Remarks:
+ * Not done yet.
+ */
+
+static int
+kdb_ef(int argc, const char **argv)
+{
+ int diag;
+ kdb_machreg_t addr;
+ long offset;
+ int nextarg;
+
+ if (argc == 1) {
+ nextarg = 1;
+ diag = kdbgetaddrarg(argc, argv, &nextarg, &addr, &offset, NULL);
+ if (diag)
+ return diag;
+
+ return kdba_dumpregs((struct pt_regs *)addr, NULL, NULL);
+ }
+
+ return KDB_ARGCOUNT;
+}
+
+#if defined(CONFIG_MODULES)
+extern struct list_head *kdb_modules;
+extern void free_module(struct module *);
+
+/* modules using other modules */
+struct module_use
+{
+ struct list_head list;
+ struct module *module_which_uses;
+};
+
+/*
+ * kdb_lsmod
+ *
+ * This function implements the 'lsmod' command. Lists currently
+ * loaded kernel modules.
+ *
+ * Mostly taken from userland lsmod.
+ *
+ * Inputs:
+ * argc argument count
+ * argv argument vector
+ * Outputs:
+ * None.
+ * Returns:
+ * zero for success, a kdb diagnostic if error
+ * Locking:
+ * none.
+ * Remarks:
+ *
+ */
+
+static int
+kdb_lsmod(int argc, const char **argv)
+{
+ struct module *mod;
+
+ if (argc != 0)
+ return KDB_ARGCOUNT;
+
+ kdb_printf("Module Size modstruct Used by\n");
+ list_for_each_entry(mod, kdb_modules, list) {
+
+ kdb_printf("%-20s%8lu 0x%p ", mod->name,
+ mod->core_size, (void *)mod);
+#ifdef CONFIG_MODULE_UNLOAD
+ kdb_printf("%4d ", module_refcount(mod));
+#endif
+ if (mod->state == MODULE_STATE_GOING)
+ kdb_printf(" (Unloading)");
+ else if (mod->state == MODULE_STATE_COMING)
+ kdb_printf(" (Loading)");
+ else
+ kdb_printf(" (Live)");
+
+#ifdef CONFIG_MODULE_UNLOAD
+ {
+ struct module_use *use;
+ kdb_printf(" [ ");
+ list_for_each_entry(use, &mod->modules_which_use_me, list)
+ kdb_printf("%s ", use->module_which_uses->name);
+ kdb_printf("]\n");
+ }
+#endif
+ }
+
+ return 0;
+}
+
+#endif /* CONFIG_MODULES */
+
+/*
+ * kdb_env
+ *
+ * This function implements the 'env' command. Display the current
+ * environment variables.
+ *
+ * Inputs:
+ * argc argument count
+ * argv argument vector
+ * Outputs:
+ * None.
+ * Returns:
+ * zero for success, a kdb diagnostic if error
+ * Locking:
+ * none.
+ * Remarks:
+ */
+
+static int
+kdb_env(int argc, const char **argv)
+{
+ int i;
+
+ for(i=0; i<__nenv; i++) {
+ if (__env[i]) {
+ kdb_printf("%s\n", __env[i]);
+ }
+ }
+
+ if (KDB_DEBUG(MASK))
+ kdb_printf("KDBFLAGS=0x%x\n", kdb_flags);
+
+ return 0;
+}
+
+/*
+ * kdb_dmesg
+ *
+ * This function implements the 'dmesg' command to display the contents
+ * of the syslog buffer.
+ *
+ * dmesg [lines] [adjust]
+ *
+ * Inputs:
+ * argc argument count
+ * argv argument vector
+ * Outputs:
+ * None.
+ * Returns:
+ * zero for success, a kdb diagnostic if error
+ * Locking:
+ * none.
+ * Remarks:
+ * None.
+ */
+
+static int
+kdb_dmesg(int argc, const char **argv)
+{
+ char *syslog_data[4], *start, *end, c = '\0', *p;
+ int diag, logging, logsize, lines = 0, adjust = 0, n;
+
+ if (argc > 2)
+ return KDB_ARGCOUNT;
+ if (argc) {
+ char *cp;
+ lines = simple_strtol(argv[1], &cp, 0);
+ if (*cp)
+ lines = 0;
+ if (argc > 1) {
+ adjust = simple_strtoul(argv[2], &cp, 0);
+ if (*cp || adjust < 0)
+ adjust = 0;
+ }
+ }
+
+ /* disable LOGGING if set */
+ diag = kdbgetintenv("LOGGING", &logging);
+ if (!diag && logging) {
+ const char *setargs[] = { "set", "LOGGING", "0" };
+ kdb_set(2, setargs);
+ }
+
+ /* syslog_data[0,1] physical start, end+1. syslog_data[2,3] logical start, end+1. */
+ kdb_syslog_data(syslog_data);
+ if (syslog_data[2] == syslog_data[3])
+ return 0;
+ logsize = syslog_data[1] - syslog_data[0];
+ start = syslog_data[2];
+ end = syslog_data[3];
+#define KDB_WRAP(p) (((p - syslog_data[0]) % logsize) + syslog_data[0])
+ for (n = 0, p = start; p < end; ++p) {
+ if ((c = *KDB_WRAP(p)) == '\n')
+ ++n;
+ }
+ if (c != '\n')
+ ++n;
+ if (lines < 0) {
+ if (adjust >= n)
+ kdb_printf("buffer only contains %d lines, nothing printed\n", n);
+ else if (adjust - lines >= n)
+ kdb_printf("buffer only contains %d lines, last %d lines printed\n",
+ n, n - adjust);
+ if (adjust) {
+ for (; start < end && adjust; ++start) {
+ if (*KDB_WRAP(start) == '\n')
+ --adjust;
+ }
+ if (start < end)
+ ++start;
+ }
+ for (p = start; p < end && lines; ++p) {
+ if (*KDB_WRAP(p) == '\n')
+ ++lines;
+ }
+ end = p;
+ } else if (lines > 0) {
+ int skip = n - (adjust + lines);
+ if (adjust >= n) {
+ kdb_printf("buffer only contains %d lines, nothing printed\n", n);
+ skip = n;
+ } else if (skip < 0) {
+ lines += skip;
+ skip = 0;
+ kdb_printf("buffer only contains %d lines, first %d lines printed\n",
+ n, lines);
+ }
+ for (; start < end && skip; ++start) {
+ if (*KDB_WRAP(start) == '\n')
+ --skip;
+ }
+ for (p = start; p < end && lines; ++p) {
+ if (*KDB_WRAP(p) == '\n')
+ --lines;
+ }
+ end = p;
+ }
+ /* Do a line at a time (max 200 chars) to reduce protocol overhead */
+ c = '\n';
+ while (start != end) {
+ char buf[201];
+ p = buf;
+ while (start < end && (c = *KDB_WRAP(start)) && (p - buf) < sizeof(buf)-1) {
+ ++start;
+ *p++ = c;
+ if (c == '\n')
+ break;
+ }
+ *p = '\0';
+ kdb_printf("%s", buf);
+ }
+ if (c != '\n')
+ kdb_printf("\n");
+
+ return 0;
+}
+
+/*
+ * kdb_cpu
+ *
+ * This function implements the 'cpu' command.
+ *
+ * cpu [<cpunum>]
+ *
+ * Inputs:
+ * argc argument count
+ * argv argument vector
+ * Outputs:
+ * None.
+ * Returns:
+ * KDB_CMD_CPU for success, a kdb diagnostic if error
+ * Locking:
+ * none.
+ * Remarks:
+ * All cpu's should be spinning in kdb(). However just in case
+ * a cpu did not take the smp_kdb_stop NMI, check that a cpu
+ * entered kdb() before passing control to it.
+ */
+
+static void
+kdb_cpu_status(void)
+{
+ int i, start_cpu, first_print = 1;
+ char state, prev_state = '?';
+
+ kdb_printf("Currently on cpu %d\n", smp_processor_id());
+ kdb_printf("Available cpus: ");
+ for (start_cpu = -1, i = 0; i < NR_CPUS; i++) {
+ if (!cpu_online(i))
+ state = 'F'; /* cpu is offline */
+ else {
+ struct kdb_running_process *krp = kdb_running_process+i;
+ if (KDB_STATE_CPU(KDB, i)) {
+ state = ' '; /* cpu is responding to kdb */
+ if (kdb_task_state_char(krp->p) == 'I')
+ state = 'I'; /* running the idle task */
+ } else if (krp->seqno && krp->p && krp->seqno >= kdb_seqno - 1)
+ state = '+'; /* some kdb data, but not responding */
+ else
+ state = '*'; /* no kdb data */
+ }
+ if (state != prev_state) {
+ if (prev_state != '?') {
+ if (!first_print)
+ kdb_printf(", ");
+ first_print = 0;
+ kdb_printf("%d", start_cpu);
+ if (start_cpu < i-1)
+ kdb_printf("-%d", i-1);
+ if (prev_state != ' ')
+ kdb_printf("(%c)", prev_state);
+ }
+ prev_state = state;
+ start_cpu = i;
+ }
+ }
+ /* print the trailing cpus, ignoring them if they are all offline */
+ if (prev_state != 'F') {
+ if (!first_print)
+ kdb_printf(", ");
+ kdb_printf("%d", start_cpu);
+ if (start_cpu < i-1)
+ kdb_printf("-%d", i-1);
+ if (prev_state != ' ')
+ kdb_printf("(%c)", prev_state);
+ }
+ kdb_printf("\n");
+}
+
+static int
+kdb_cpu(int argc, const char **argv)
+{
+ unsigned long cpunum;
+ int diag, i;
+
+ /* ask the other cpus if they are still active */
+ for (i=0; i<NR_CPUS; i++) {
+ if (cpu_online(i))
+ KDB_STATE_CLEAR_CPU(KDB, i);
+ }
+ KDB_STATE_SET(KDB);
+ barrier();
+ /* wait for the other cpus to notice and set state KDB again,
+ * see kdb_main_loop
+ */
+ udelay(1000);
+
+ if (argc == 0) {
+ kdb_cpu_status();
+ return 0;
+ }
+
+ if (argc != 1)
+ return KDB_ARGCOUNT;
+
+ diag = kdbgetularg(argv[1], &cpunum);
+ if (diag)
+ return diag;
+
+ /*
+ * Validate cpunum
+ */
+ if ((cpunum > NR_CPUS)
+ || !cpu_online(cpunum)
+ || !KDB_STATE_CPU(KDB, cpunum))
+ return KDB_BADCPUNUM;
+
+ kdb_new_cpu = cpunum;
+
+ /*
+ * Switch to other cpu
+ */
+ return KDB_CMD_CPU;
+}
+
+/* The user may not realize that ps/bta with no parameters does not print idle
+ * or sleeping system daemon processes, so tell them how many were suppressed.
+ */
+void
+kdb_ps_suppressed(void)
+{
+ int idle = 0, daemon = 0;
+ unsigned long mask_I = kdb_task_state_string("I"),
+ mask_M = kdb_task_state_string("M");
+ unsigned long cpu;
+ const struct task_struct *p, *g;
+ for (cpu = 0; cpu < NR_CPUS; ++cpu) {
+ if (!cpu_online(cpu))
+ continue;
+ p = kdb_curr_task(cpu);
+ if (kdb_task_state(p, mask_I))
+ ++idle;
+ }
+ kdb_do_each_thread(g, p) {
+ if (kdb_task_state(p, mask_M))
+ ++daemon;
+ } kdb_while_each_thread(g, p);
+ if (idle || daemon) {
+ if (idle)
+ kdb_printf("%d idle process%s (state I)%s",
+ idle, idle == 1 ? "" : "es",
+ daemon ? " and " : "");
+ if (daemon)
+ kdb_printf("%d sleeping system daemon (state M) process%s",
+ daemon, daemon == 1 ? "" : "es");
+ kdb_printf(" suppressed\n");
+ }
+}
+
+/*
+ * kdb_ps
+ *
+ * This function implements the 'ps' command which shows
+ * a list of the active processes.
+ *
+ * ps [DRSTCZEUIMA] All processes, optionally filtered by state
+ *
+ * Inputs:
+ * argc argument count
+ * argv argument vector
+ * Outputs:
+ * None.
+ * Returns:
+ * zero for success, a kdb diagnostic if error
+ * Locking:
+ * none.
+ * Remarks:
+ */
+
+void
+kdb_ps1(const struct task_struct *p)
+{
+ struct kdb_running_process *krp = kdb_running_process + kdb_process_cpu(p);
+ kdb_printf("0x%p %8d %8d %d %4d %c 0x%p %c%s\n",
+ (void *)p, p->pid, p->parent->pid,
+ kdb_task_has_cpu(p), kdb_process_cpu(p),
+ kdb_task_state_char(p),
+ (void *)(&p->thread),
+ p == kdb_curr_task(smp_processor_id()) ? '*': ' ',
+ p->comm);
+ if (kdb_task_has_cpu(p)) {
+ if (!krp->seqno || !krp->p)
+ kdb_printf(" Error: no saved data for this cpu\n");
+ else {
+ if (krp->seqno < kdb_seqno - 1)
+ kdb_printf(" Warning: process state is stale\n");
+ if (krp->p != p)
+ kdb_printf(" Error: does not match running process table (0x%p)\n", krp->p);
+ }
+ }
+}
+
+static int
+kdb_ps(int argc, const char **argv)
+{
+ struct task_struct *g, *p;
+ unsigned long mask, cpu;
+
+ if (argc == 0)
+ kdb_ps_suppressed();
+ kdb_printf("%-*s Pid Parent [*] cpu State %-*s Command\n",
+ (int)(2*sizeof(void *))+2, "Task Addr",
+ (int)(2*sizeof(void *))+2, "Thread");
+ mask = kdb_task_state_string(argc ? argv[1] : NULL);
+ /* Run the active tasks first */
+ for (cpu = 0; cpu < NR_CPUS; ++cpu) {
+ if (!cpu_online(cpu))
+ continue;
+ p = kdb_curr_task(cpu);
+ if (kdb_task_state(p, mask))
+ kdb_ps1(p);
+ }
+ kdb_printf("\n");
+ /* Now the real tasks */
+ kdb_do_each_thread(g, p) {
+ if (kdb_task_state(p, mask))
+ kdb_ps1(p);
+ } kdb_while_each_thread(g, p);
+
+ return 0;
+}
+
+/*
+ * kdb_pid
+ *
+ * This function implements the 'pid' command which switches
+ * the currently active process.
+ *
+ * pid [<pid> | R]
+ *
+ * Inputs:
+ * argc argument count
+ * argv argument vector
+ * Outputs:
+ * None.
+ * Returns:
+ * zero for success, a kdb diagnostic if error
+ * Locking:
+ * none.
+ * Remarks:
+ */
+
+
+static int
+kdb_pid(int argc, const char **argv)
+{
+ struct task_struct *p;
+ unsigned long val;
+ int diag;
+
+ if (argc > 1)
+ return KDB_ARGCOUNT;
+
+ if (argc) {
+ if (strcmp(argv[1], "R") == 0) {
+ p = KDB_RUNNING_PROCESS_ORIGINAL[kdb_initial_cpu].p;
+ } else {
+ diag = kdbgetularg(argv[1], &val);
+ if (diag)
+ return KDB_BADINT;
+
+ p = find_task_by_pid((pid_t)val);
+ if (!p) {
+ kdb_printf("No task with pid=%d\n", (pid_t)val);
+ return 0;
+ }
+ }
+
+ kdba_set_current_task(p);
+ }
+
+ kdb_printf("KDB current process is %s(pid=%d)\n", kdb_current_task->comm,
+ kdb_current_task->pid);
+
+ return 0;
+}
+
+/*
+ * kdb_ll
+ *
+ * This function implements the 'll' command which follows a linked
+ * list and executes an arbitrary command for each element.
+ *
+ * Inputs:
+ * argc argument count
+ * argv argument vector
+ * Outputs:
+ * None.
+ * Returns:
+ * zero for success, a kdb diagnostic if error
+ * Locking:
+ * none.
+ * Remarks:
+ */
+
+static int
+kdb_ll(int argc, const char **argv)
+{
+ int diag;
+ kdb_machreg_t addr;
+ long offset = 0;
+ kdb_machreg_t va;
+ unsigned long linkoffset;
+ int nextarg;
+ const char *command;
+
+ if (argc != 3) {
+ return KDB_ARGCOUNT;
+ }
+
+ nextarg = 1;
+ diag = kdbgetaddrarg(argc, argv, &nextarg, &addr, &offset, NULL);
+ if (diag)
+ return diag;
+
+ diag = kdbgetularg(argv[2], &linkoffset);
+ if (diag)
+ return diag;
+
+ /*
+ * Using the starting address as
+ * the first element in the list, and assuming that
+ * the list ends with a null pointer.
+ */
+
+ va = addr;
+ if (!(command = kdb_strdup(argv[3], GFP_KDB))) {
+ kdb_printf("%s: cannot duplicate command\n", __FUNCTION__);
+ return 0;
+ }
+ /* Recursive use of kdb_parse, do not use argv after this point */
+ argv = NULL;
+
+ while (va) {
+ char buf[80];
+
+ sprintf(buf, "%s " kdb_machreg_fmt "\n", command, va);
+ diag = kdb_parse(buf);
+ if (diag)
+ return diag;
+
+ addr = va + linkoffset;
+ if (kdb_getword(&va, addr, sizeof(va)))
+ return 0;
+ }
+ kfree(command);
+
+ return 0;
+}
+
+/*
+ * kdb_help
+ *
+ * This function implements the 'help' and '?' commands.
+ *
+ * Inputs:
+ * argc argument count
+ * argv argument vector
+ * Outputs:
+ * None.
+ * Returns:
+ * zero for success, a kdb diagnostic if error
+ * Locking:
+ * none.
+ * Remarks:
+ */
+
+static int
+kdb_help(int argc, const char **argv)
+{
+ kdbtab_t *kt;
+ int i;
+
+ kdb_printf("%-15.15s %-20.20s %s\n", "Command", "Usage", "Description");
+ kdb_printf("----------------------------------------------------------\n");
+ for(i=0, kt=kdb_commands; i<kdb_max_commands; i++, kt++) {
+ if (kt->cmd_name)
+ kdb_printf("%-15.15s %-20.20s %s\n", kt->cmd_name,
+ kt->cmd_usage, kt->cmd_help);
+ }
+ return 0;
+}
+
+extern int kdb_wake_up_process(struct task_struct * p);
+
+/*
+ * kdb_kill
+ *
+ * This function implements the 'kill' commands.
+ *
+ * Inputs:
+ * argc argument count
+ * argv argument vector
+ * Outputs:
+ * None.
+ * Returns:
+ * zero for success, a kdb diagnostic if error
+ * Locking:
+ * none.
+ * Remarks:
+ */
+
+static int
+kdb_kill(int argc, const char **argv)
+{
+ long sig, pid;
+ char *endp;
+ struct task_struct *p;
+ struct siginfo info;
+
+ if (argc!=2)
+ return KDB_ARGCOUNT;
+
+ sig = simple_strtol(argv[1], &endp, 0);
+ if (*endp)
+ return KDB_BADINT;
+ if (sig >= 0 ) {
+ kdb_printf("Invalid signal parameter.<-signal>\n");
+ return 0;
+ }
+ sig=-sig;
+
+ pid = simple_strtol(argv[2], &endp, 0);
+ if (*endp)
+ return KDB_BADINT;
+ if (pid <=0 ) {
+ kdb_printf("Process ID must be large than 0.\n");
+ return 0;
+ }
+
+ /* Find the process. */
+ if (!(p = find_task_by_pid(pid))) {
+ kdb_printf("The specified process isn't found.\n");
+ return 0;
+ }
+ p = p->group_leader;
+ info.si_signo = sig;
+ info.si_errno = 0;
+ info.si_code = SI_USER;
+ info.si_pid = pid; /* use same capabilities as process being signalled */
+ info.si_uid = 0; /* kdb has root authority */
+ kdb_send_sig_info(p, &info, kdb_seqno);
+ return 0;
+}
+
+struct kdb_tm {
+ int tm_sec; /* seconds */
+ int tm_min; /* minutes */
+ int tm_hour; /* hours */
+ int tm_mday; /* day of the month */
+ int tm_mon; /* month */
+ int tm_year; /* year */
+};
+
+static void
+kdb_gmtime(struct timespec *tv, struct kdb_tm *tm)
+{
+ /* This will work from 1970-2099, 2100 is not a leap year */
+ static int mon_day[] = { 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
+ memset(tm, 0, sizeof(*tm));
+ tm->tm_sec = tv->tv_sec % (24 * 60 * 60);
+ tm->tm_mday = tv->tv_sec / (24 * 60 * 60) + (2 * 365 + 1); /* shift base from 1970 to 1968 */
+ tm->tm_min = tm->tm_sec / 60 % 60;
+ tm->tm_hour = tm->tm_sec / 60 / 60;
+ tm->tm_sec = tm->tm_sec % 60;
+ tm->tm_year = 68 + 4*(tm->tm_mday / (4*365+1));
+ tm->tm_mday %= (4*365+1);
+ mon_day[1] = 29;
+ while (tm->tm_mday >= mon_day[tm->tm_mon]) {
+ tm->tm_mday -= mon_day[tm->tm_mon];
+ if (++tm->tm_mon == 12) {
+ tm->tm_mon = 0;
+ ++tm->tm_year;
+ mon_day[1] = 28;
+ }
+ }
+ ++tm->tm_mday;
+}
+
+/*
+ * Most of this code has been lifted from kernel/timer.c::sys_sysinfo().
+ * I cannot call that code directly from kdb, it has an unconditional
+ * cli()/sti() and calls routines that take locks which can stop the debugger.
+ */
+
+static void
+kdb_sysinfo(struct sysinfo *val)
+{
+ struct timespec uptime;
+ do_posix_clock_monotonic_gettime(&uptime);
+ memset(val, 0, sizeof(*val));
+ val->uptime = uptime.tv_sec;
+ val->loads[0] = avenrun[0];
+ val->loads[1] = avenrun[1];
+ val->loads[2] = avenrun[2];
+ val->procs = nr_threads-1;
+ si_meminfo(val);
+ kdb_si_swapinfo(val);
+
+ return;
+}
+
+/*
+ * kdb_summary
+ *
+ * This function implements the 'summary' command.
+ *
+ * Inputs:
+ * argc argument count
+ * argv argument vector
+ * Outputs:
+ * None.
+ * Returns:
+ * zero for success, a kdb diagnostic if error
+ * Locking:
+ * none.
+ * Remarks:
+ */
+
+static int
+kdb_summary(int argc, const char **argv)
+{
+ extern struct timespec xtime;
+ extern struct timezone sys_tz;
+ struct kdb_tm tm;
+ struct sysinfo val;
+
+ if (argc)
+ return KDB_ARGCOUNT;
+
+ kdb_printf("sysname %s\n", init_uts_ns.name.sysname);
+ kdb_printf("release %s\n", init_uts_ns.name.release);
+ kdb_printf("version %s\n", init_uts_ns.name.version);
+ kdb_printf("machine %s\n", init_uts_ns.name.machine);
+ kdb_printf("nodename %s\n", init_uts_ns.name.nodename);
+ kdb_printf("domainname %s\n", init_uts_ns.name.domainname);
+ kdb_printf("ccversion %s\n", __stringify(CCVERSION));
+
+ kdb_gmtime(&xtime, &tm);
+ kdb_printf("date %04d-%02d-%02d %02d:%02d:%02d tz_minuteswest %d\n",
+ 1900+tm.tm_year, tm.tm_mon+1, tm.tm_mday,
+ tm.tm_hour, tm.tm_min, tm.tm_sec,
+ sys_tz.tz_minuteswest);
+
+ kdb_sysinfo(&val);
+ kdb_printf("uptime ");
+ if (val.uptime > (24*60*60)) {
+ int days = val.uptime / (24*60*60);
+ val.uptime %= (24*60*60);
+ kdb_printf("%d day%s ", days, days == 1 ? "" : "s");
+ }
+ kdb_printf("%02ld:%02ld\n", val.uptime/(60*60), (val.uptime/60)%60);
+
+ /* lifted from fs/proc/proc_misc.c::loadavg_read_proc() */
+
+#define LOAD_INT(x) ((x) >> FSHIFT)
+#define LOAD_FRAC(x) LOAD_INT(((x) & (FIXED_1-1)) * 100)
+ kdb_printf("load avg %ld.%02ld %ld.%02ld %ld.%02ld\n",
+ LOAD_INT(val.loads[0]), LOAD_FRAC(val.loads[0]),
+ LOAD_INT(val.loads[1]), LOAD_FRAC(val.loads[1]),
+ LOAD_INT(val.loads[2]), LOAD_FRAC(val.loads[2]));
+ kdb_printf("\n");
+#undef LOAD_INT
+#undef LOAD_FRAC
+
+ kdb_meminfo_read_proc(); /* in fs/proc/proc_misc.c */
+
+ return 0;
+}
+
+/*
+ * kdb_per_cpu
+ *
+ * This function implements the 'per_cpu' command.
+ *
+ * Inputs:
+ * argc argument count
+ * argv argument vector
+ * Outputs:
+ * None.
+ * Returns:
+ * zero for success, a kdb diagnostic if error
+ * Locking:
+ * none.
+ * Remarks:
+ */
+
+static int
+kdb_per_cpu(int argc, const char **argv)
+{
+ char buf[256], fmtstr[64];
+ kdb_symtab_t symtab;
+ cpumask_t suppress = CPU_MASK_NONE;
+ int cpu, diag;
+ unsigned long addr, val, bytesperword = 0, whichcpu = ~0UL;
+
+ if (argc < 1 || argc > 3)
+ return KDB_ARGCOUNT;
+
+ snprintf(buf, sizeof(buf), "per_cpu__%s", argv[1]);
+ if (!kdbgetsymval(buf, &symtab)) {
+ kdb_printf("%s is not a per_cpu variable\n", argv[1]);
+ return KDB_BADADDR;
+ }
+ if (argc >=2 && (diag = kdbgetularg(argv[2], &bytesperword)))
+ return diag;
+ if (!bytesperword)
+ bytesperword = KDB_WORD_SIZE;
+ else if (bytesperword > KDB_WORD_SIZE)
+ return KDB_BADWIDTH;
+ sprintf(fmtstr, "%%0%dlx ", (int)(2*bytesperword));
+ if (argc >= 3) {
+ if ((diag = kdbgetularg(argv[3], &whichcpu)))
+ return diag;
+ if (!cpu_online(whichcpu)) {
+ kdb_printf("cpu %ld is not online\n", whichcpu);
+ return KDB_BADCPUNUM;
+ }
+ }
+
+ /* Most architectures use __per_cpu_offset[cpu], some use
+ * __per_cpu_offset(cpu), smp has no __per_cpu_offset.
+ */
+#ifdef __per_cpu_offset
+#define KDB_PCU(cpu) __per_cpu_offset(cpu)
+#else
+#ifdef CONFIG_SMP
+#define KDB_PCU(cpu) __per_cpu_offset[cpu]
+#else
+#define KDB_PCU(cpu) 0
+#endif
+#endif
+
+ for_each_online_cpu(cpu) {
+ if (whichcpu != ~0UL && whichcpu != cpu)
+ continue;
+ addr = symtab.sym_start + KDB_PCU(cpu);
+ if ((diag = kdb_getword(&val, addr, bytesperword))) {
+ kdb_printf("%5d " kdb_bfd_vma_fmt0 " - unable to read, diag=%d\n",
+ cpu, addr, diag);
+ continue;
+ }
+#ifdef CONFIG_SMP
+ if (!val) {
+ cpu_set(cpu, suppress);
+ continue;
+ }
+#endif /* CONFIG_SMP */
+ kdb_printf("%5d ", cpu);
+ kdb_md_line(fmtstr, addr,
+ bytesperword == KDB_WORD_SIZE,
+ 1, bytesperword, 1, 1, 0);
+ }
+ if (cpus_weight(suppress) == 0)
+ return 0;
+ kdb_printf("Zero suppressed cpu(s):");
+ for (cpu = first_cpu(suppress); cpu < NR_CPUS; cpu = next_cpu(cpu, suppress)) {
+ kdb_printf(" %d", cpu);
+ if (cpu == NR_CPUS-1 || next_cpu(cpu, suppress) != cpu + 1)
+ continue;
+ while (cpu < NR_CPUS && next_cpu(cpu, suppress) == cpu + 1)
+ ++cpu;
+ kdb_printf("-%d", cpu);
+ }
+ kdb_printf("\n");
+
+#undef KDB_PCU
+
+ return 0;
+}
+
+
+/*
+ * kdb_register_repeat
+ *
+ * This function is used to register a kernel debugger command.
+ *
+ * Inputs:
+ * cmd Command name
+ * func Function to execute the command
+ * usage A simple usage string showing arguments
+ * help A simple help string describing command
+ * repeat Does the command auto repeat on enter?
+ * Outputs:
+ * None.
+ * Returns:
+ * zero for success, one if a duplicate command.
+ * Locking:
+ * none.
+ * Remarks:
+ *
+ */
+
+#define kdb_command_extend 50 /* arbitrary */
+int
+kdb_register_repeat(char *cmd,
+ kdb_func_t func,
+ char *usage,
+ char *help,
+ short minlen,
+ kdb_repeat_t repeat)
+{
+ int i;
+ kdbtab_t *kp;
+
+ /*
+ * Brute force method to determine duplicates
+ */
+ for (i=0, kp=kdb_commands; i<kdb_max_commands; i++, kp++) {
+ if (kp->cmd_name && (strcmp(kp->cmd_name, cmd)==0)) {
+ kdb_printf("Duplicate kdb command registered: '%s'\n",
+ cmd);
+ return 1;
+ }
+ }
+
+ /*
+ * Insert command into first available location in table
+ */
+ for (i=0, kp=kdb_commands; i<kdb_max_commands; i++, kp++) {
+ if (kp->cmd_name == NULL) {
+ break;
+ }
+ }
+
+ if (i >= kdb_max_commands) {
+ kdbtab_t *new = kmalloc((kdb_max_commands + kdb_command_extend) * sizeof(*new), GFP_KDB);
+ if (!new) {
+ kdb_printf("Could not allocate new kdb_command table\n");
+ return 1;
+ }
+ if (kdb_commands) {
+ memcpy(new, kdb_commands, kdb_max_commands * sizeof(*new));
+ kfree(kdb_commands);
+ }
+ memset(new + kdb_max_commands, 0, kdb_command_extend * sizeof(*new));
+ kdb_commands = new;
+ kp = kdb_commands + kdb_max_commands;
+ kdb_max_commands += kdb_command_extend;
+ }
+
+ kp->cmd_name = cmd;
+ kp->cmd_func = func;
+ kp->cmd_usage = usage;
+ kp->cmd_help = help;
+ kp->cmd_flags = 0;
+ kp->cmd_minlen = minlen;
+ kp->cmd_repeat = repeat;
+
+ return 0;
+}
+
+/*
+ * kdb_register
+ *
+ * Compatibility register function for commands that do not need to
+ * specify a repeat state. Equivalent to kdb_register_repeat with
+ * KDB_REPEAT_NONE.
+ *
+ * Inputs:
+ * cmd Command name
+ * func Function to execute the command
+ * usage A simple usage string showing arguments
+ * help A simple help string describing command
+ * Outputs:
+ * None.
+ * Returns:
+ * zero for success, one if a duplicate command.
+ * Locking:
+ * none.
+ * Remarks:
+ *
+ */
+
+int
+kdb_register(char *cmd,
+ kdb_func_t func,
+ char *usage,
+ char *help,
+ short minlen)
+{
+ return kdb_register_repeat(cmd, func, usage, help, minlen, KDB_REPEAT_NONE);
+}
+
+/*
+ * kdb_unregister
+ *
+ * This function is used to unregister a kernel debugger command.
+ * It is generally called when a module which implements kdb
+ * commands is unloaded.
+ *
+ * Inputs:
+ * cmd Command name
+ * Outputs:
+ * None.
+ * Returns:
+ * zero for success, one command not registered.
+ * Locking:
+ * none.
+ * Remarks:
+ *
+ */
+
+int
+kdb_unregister(char *cmd)
+{
+ int i;
+ kdbtab_t *kp;
+
+ /*
+ * find the command.
+ */
+ for (i=0, kp=kdb_commands; i<kdb_max_commands; i++, kp++) {
+ if (kp->cmd_name && (strcmp(kp->cmd_name, cmd)==0)) {
+ kp->cmd_name = NULL;
+ return 0;
+ }
+ }
+
+ /*
+ * Couldn't find it.
+ */
+ return 1;
+}
+
+/*
+ * kdb_inittab
+ *
+ * This function is called by the kdb_init function to initialize
+ * the kdb command table. It must be called prior to any other
+ * call to kdb_register_repeat.
+ *
+ * Inputs:
+ * None.
+ * Outputs:
+ * None.
+ * Returns:
+ * None.
+ * Locking:
+ * None.
+ * Remarks:
+ *
+ */
+
+static void __init
+kdb_inittab(void)
+{
+ int i;
+ kdbtab_t *kp;
+
+ for(i=0, kp=kdb_commands; i < kdb_max_commands; i++,kp++) {
+ kp->cmd_name = NULL;
+ }
+
+ kdb_register_repeat("md", kdb_md, "<vaddr>", "Display Memory Contents, also mdWcN, e.g. md8c1", 1, KDB_REPEAT_NO_ARGS);
+ kdb_register_repeat("mdr", kdb_md, "<vaddr> <bytes>", "Display Raw Memory", 0, KDB_REPEAT_NO_ARGS);
+ kdb_register_repeat("mdp", kdb_md, "<paddr> <bytes>", "Display Physical Memory", 0, KDB_REPEAT_NO_ARGS);
+ kdb_register_repeat("mds", kdb_md, "<vaddr>", "Display Memory Symbolically", 0, KDB_REPEAT_NO_ARGS);
+ kdb_register_repeat("mm", kdb_mm, "<vaddr> <contents>", "Modify Memory Contents", 0, KDB_REPEAT_NO_ARGS);
+ kdb_register_repeat("id", kdb_id, "<vaddr>", "Display Instructions", 1, KDB_REPEAT_NO_ARGS);
+ kdb_register_repeat("go", kdb_go, "[<vaddr>]", "Continue Execution", 1, KDB_REPEAT_NONE);
+ kdb_register_repeat("rd", kdb_rd, "", "Display Registers", 1, KDB_REPEAT_NONE);
+ kdb_register_repeat("rm", kdb_rm, "<reg> <contents>", "Modify Registers", 0, KDB_REPEAT_NONE);
+ kdb_register_repeat("ef", kdb_ef, "<vaddr>", "Display exception frame", 0, KDB_REPEAT_NONE);
+ kdb_register_repeat("bt", kdb_bt, "[<vaddr>]", "Stack traceback", 1, KDB_REPEAT_NONE);
+ kdb_register_repeat("btp", kdb_bt, "<pid>", "Display stack for process <pid>", 0, KDB_REPEAT_NONE);
+ kdb_register_repeat("bta", kdb_bt, "[DRSTCZEUIMA]", "Display stack all processes", 0, KDB_REPEAT_NONE);
+ kdb_register_repeat("btc", kdb_bt, "", "Backtrace current process on each cpu", 0, KDB_REPEAT_NONE);
+ kdb_register_repeat("btt", kdb_bt, "<vaddr>", "Backtrace process given its struct task address", 0, KDB_REPEAT_NONE);
+ kdb_register_repeat("ll", kdb_ll, "<first-element> <linkoffset> <cmd>", "Execute cmd for each element in linked list", 0, KDB_REPEAT_NONE);
+ kdb_register_repeat("env", kdb_env, "", "Show environment variables", 0, KDB_REPEAT_NONE);
+ kdb_register_repeat("set", kdb_set, "", "Set environment variables", 0, KDB_REPEAT_NONE);
+ kdb_register_repeat("help", kdb_help, "", "Display Help Message", 1, KDB_REPEAT_NONE);
+ kdb_register_repeat("?", kdb_help, "", "Display Help Message", 0, KDB_REPEAT_NONE);
+ kdb_register_repeat("cpu", kdb_cpu, "<cpunum>","Switch to new cpu", 0, KDB_REPEAT_NONE);
+ kdb_register_repeat("ps", kdb_ps, "", "Display active task list", 0, KDB_REPEAT_NONE);
+ kdb_register_repeat("pid", kdb_pid, "<pidnum>", "Switch to another task", 0, KDB_REPEAT_NONE);
+ kdb_register_repeat("reboot", kdb_reboot, "", "Reboot the machine immediately", 0, KDB_REPEAT_NONE);
+#if defined(CONFIG_MODULES)
+ kdb_register_repeat("lsmod", kdb_lsmod, "", "List loaded kernel modules", 0, KDB_REPEAT_NONE);
+#endif
+#if defined(CONFIG_MAGIC_SYSRQ)
+ kdb_register_repeat("sr", kdb_sr, "<key>", "Magic SysRq key", 0, KDB_REPEAT_NONE);
+#endif
+ kdb_register_repeat("dmesg", kdb_dmesg, "[lines]", "Display syslog buffer", 0, KDB_REPEAT_NONE);
+ kdb_register_repeat("defcmd", kdb_defcmd, "name \"usage\" \"help\"", "Define a set of commands, down to endefcmd", 0, KDB_REPEAT_NONE);
+ kdb_register_repeat("kill", kdb_kill, "<-signal> <pid>", "Send a signal to a process", 0, KDB_REPEAT_NONE);
+ kdb_register_repeat("summary", kdb_summary, "", "Summarize the system", 4, KDB_REPEAT_NONE);
+ kdb_register_repeat("per_cpu", kdb_per_cpu, "", "Display per_cpu variables", 3, KDB_REPEAT_NONE);
+}
+
+/*
+ * kdb_cmd_init
+ *
+ * This function is called by the kdb_init function to execute any
+ * commands defined in kdb_cmds.
+ *
+ * Inputs:
+ * Commands in *kdb_cmds[];
+ * Outputs:
+ * None.
+ * Returns:
+ * None.
+ * Locking:
+ * None.
+ * Remarks:
+ *
+ */
+
+static void __init
+kdb_cmd_init(void)
+{
+ int i, diag;
+ for (i = 0; kdb_cmds[i]; ++i) {
+ if (!defcmd_in_progress)
+ kdb_printf("kdb_cmd[%d]: %s", i, kdb_cmds[i]);
+ diag = kdb_parse(kdb_cmds[i]);
+ if (diag)
+ kdb_printf("command failed, kdb diag %d\n", diag);
+ }
+ if (defcmd_in_progress) {
+ kdb_printf("Incomplete 'defcmd' set, forcing endefcmd\n");
+ kdb_parse("endefcmd");
+ }
+}
+
+/*
+ * kdb_panic
+ *
+ * Invoked via the panic_notifier_list.
+ *
+ * Inputs:
+ * None.
+ * Outputs:
+ * None.
+ * Returns:
+ * Zero.
+ * Locking:
+ * None.
+ * Remarks:
+ * When this function is called from panic(), the other cpus have already
+ * been stopped.
+ *
+ */
+
+static int
+kdb_panic(struct notifier_block *self, unsigned long command, void *ptr)
+{
+ KDB_FLAG_SET(CATASTROPHIC); /* kernel state is dubious now */
+ KDB_ENTER();
+ return 0;
+}
+
+static struct notifier_block kdb_block = { kdb_panic, NULL, 0 };
+
+#ifdef CONFIG_SYSCTL
+static int proc_do_kdb(ctl_table *table, int write, struct file *filp,
+ void __user *buffer, size_t *lenp, loff_t *ppos)
+{
+ if (KDB_FLAG(NO_CONSOLE) && write) {
+ printk(KERN_ERR "kdb has no working console and has switched itself off\n");
+ return -EINVAL;
+ }
+ return proc_dointvec(table, write, filp, buffer, lenp, ppos);
+}
+
+static ctl_table kdb_kern_table[] = {
+ {
+ .ctl_name = KERN_KDB,
+ .procname = "kdb",
+ .data = &kdb_on,
+ .maxlen = sizeof(int),
+ .mode = 0644,
+ .proc_handler = &proc_do_kdb,
+ .strategy = &sysctl_intvec,
+ },
+ {}
+};
+
+static ctl_table kdb_root_table[] = {
+ {
+ .ctl_name = CTL_KERN,
+ .procname = "kernel",
+ .mode = 0555,
+ .child = kdb_kern_table,
+ },
+ {}
+};
+#endif /* CONFIG_SYSCTL */
+
+static int
+kdb_cpu_callback(struct notifier_block *nfb, unsigned long action, void *hcpu)
+{
+ if (action == CPU_ONLINE) {
+ int cpu =(unsigned long)hcpu;
+ cpumask_t save_cpus_allowed = current->cpus_allowed;
+ cpumask_t new_cpus_allowed = cpumask_of_cpu(cpu);
+ set_cpus_allowed(current, new_cpus_allowed);
+ kdb(KDB_REASON_CPU_UP, 0, NULL); /* do kdb setup on this cpu */
+ set_cpus_allowed(current, save_cpus_allowed);
+ }
+ return NOTIFY_OK;
+}
+
+static struct notifier_block kdb_cpu_nfb = {
+ .notifier_call = kdb_cpu_callback
+};
+
+/*
+ * kdb_init
+ *
+ * Initialize the kernel debugger environment.
+ *
+ * Parameters:
+ * None.
+ * Returns:
+ * None.
+ * Locking:
+ * None.
+ * Remarks:
+ * None.
+ */
+
+void __init
+kdb_init(void)
+{
+ kdb_initial_cpu = smp_processor_id();
+ /*
+ * This must be called before any calls to kdb_printf.
+ */
+ kdb_io_init();
+
+ kdb_inittab(); /* Initialize Command Table */
+ kdb_initbptab(); /* Initialize Breakpoint Table */
+ kdb_id_init(); /* Initialize Disassembler */
+ kdba_init(); /* Architecture Dependent Initialization */
+
+ /*
+ * Use printk() to get message in log_buf[];
+ */
+ printk("kdb version %d.%d%s by Keith Owens, Scott Lurndal. "\
+ "Copyright SGI, All Rights Reserved\n",
+ KDB_MAJOR_VERSION, KDB_MINOR_VERSION, KDB_TEST_VERSION);
+
+ kdb_cmd_init(); /* Preset commands from kdb_cmds */
+ kdb_initial_cpu = -1; /* Avoid recursion problems */
+ kdb(KDB_REASON_CPU_UP, 0, NULL); /* do kdb setup on boot cpu */
+ kdb_initial_cpu = smp_processor_id();
+ atomic_notifier_chain_register(&panic_notifier_list, &kdb_block);
+ register_cpu_notifier(&kdb_cpu_nfb);
+
+#ifdef kdba_setjmp
+ kdbjmpbuf = vmalloc(NR_CPUS * sizeof(*kdbjmpbuf));
+ if (!kdbjmpbuf)
+ printk(KERN_ERR "Cannot allocate kdbjmpbuf, no kdb recovery will be possible\n");
+#endif /* kdba_setjmp */
+
+ kdb_initial_cpu = -1;
+ kdb_wait_for_cpus_secs = max(10, 2*num_online_cpus());
+}
+
+#ifdef CONFIG_SYSCTL
+static int __init
+kdb_late_init(void)
+{
+ register_sysctl_table(kdb_root_table);
+ return 0;
+}
+
+__initcall(kdb_late_init);
+#endif
+
+EXPORT_SYMBOL(kdb_register);
+EXPORT_SYMBOL(kdb_register_repeat);
+EXPORT_SYMBOL(kdb_unregister);
+EXPORT_SYMBOL(kdb_getarea_size);
+EXPORT_SYMBOL(kdb_putarea_size);
+EXPORT_SYMBOL(kdb_getuserarea_size);
+EXPORT_SYMBOL(kdb_putuserarea_size);
+EXPORT_SYMBOL(kdbgetularg);
+EXPORT_SYMBOL(kdbgetenv);
+EXPORT_SYMBOL(kdbgetintenv);
+EXPORT_SYMBOL(kdbgetaddrarg);
+EXPORT_SYMBOL(kdb);
+EXPORT_SYMBOL(kdb_on);
+EXPORT_SYMBOL(kdb_seqno);
+EXPORT_SYMBOL(kdb_initial_cpu);
+EXPORT_SYMBOL(kdbnearsym);
+EXPORT_SYMBOL(kdb_printf);
+EXPORT_SYMBOL(kdb_symbol_print);
+EXPORT_SYMBOL(kdb_running_process);
Index: linux/kdb/kdbsupport.c
===================================================================
--- /dev/null
+++ linux/kdb/kdbsupport.c
@@ -0,0 +1,1153 @@
+/*
+ * Kernel Debugger Architecture Independent Support Functions
+ *
+ * This file is subject to the terms and conditions of the GNU General Public
+ * License. See the file "COPYING" in the main directory of this archive
+ * for more details.
+ *
+ * Copyright (c) 1999-2004 Silicon Graphics, Inc. All Rights Reserved.
+ * 03/02/13 added new 2.5 kallsyms <xavier.bru@bull.net>
+ */
+
+#include <stdarg.h>
+#include <linux/types.h>
+#include <linux/sched.h>
+#include <linux/mm.h>
+#include <linux/kallsyms.h>
+#include <linux/stddef.h>
+#include <linux/vmalloc.h>
+#include <linux/ptrace.h>
+#include <linux/module.h>
+#include <linux/highmem.h>
+#include <linux/hardirq.h>
+#include <linux/delay.h>
+
+#include <asm/uaccess.h>
+
+#include <linux/kdb.h>
+#include <linux/kdbprivate.h>
+
+/*
+ * Symbol table functions.
+ */
+
+/*
+ * kdbgetsymval
+ *
+ * Return the address of the given symbol.
+ *
+ * Parameters:
+ * symname Character string containing symbol name
+ * symtab Structure to receive results
+ * Outputs:
+ * Returns:
+ * 0 Symbol not found, symtab zero filled
+ * 1 Symbol mapped to module/symbol/section, data in symtab
+ * Locking:
+ * None.
+ * Remarks:
+ */
+
+int
+kdbgetsymval(const char *symname, kdb_symtab_t *symtab)
+{
+ if (KDB_DEBUG(AR))
+ kdb_printf("kdbgetsymval: symname=%s, symtab=%p\n", symname, symtab);
+ memset(symtab, 0, sizeof(*symtab));
+
+ if ((symtab->sym_start = kallsyms_lookup_name(symname))) {
+ if (KDB_DEBUG(AR))
+ kdb_printf("kdbgetsymval: returns 1, symtab->sym_start=0x%lx\n", symtab->sym_start);
+ return 1;
+ }
+ if (KDB_DEBUG(AR))
+ kdb_printf("kdbgetsymval: returns 0\n");
+ return 0;
+}
+
+/*
+ * kdbnearsym
+ *
+ * Return the name of the symbol with the nearest address
+ * less than 'addr'.
+ *
+ * Parameters:
+ * addr Address to check for symbol near
+ * symtab Structure to receive results
+ * Outputs:
+ * Returns:
+ * 0 No sections contain this address, symtab zero filled
+ * 1 Address mapped to module/symbol/section, data in symtab
+ * Locking:
+ * None.
+ * Remarks:
+ * 2.6 kallsyms has a "feature" where it unpacks the name into a string.
+ * If that string is reused before the caller expects it then the caller
+ * sees its string change without warning. To avoid cluttering up the
+ * main kdb code with lots of kdb_strdup, tests and kfree calls, kdbnearsym
+ * maintains an LRU list of the last few unique strings. The list is sized
+ * large enough to hold active strings, no kdb caller of kdbnearsym makes
+ * more than ~20 later calls before using a saved value.
+ */
+
+static char *kdb_name_table[100]; /* arbitrary size */
+
+int
+kdbnearsym(unsigned long addr, kdb_symtab_t *symtab)
+{
+ int ret = 0;
+ unsigned long symbolsize;
+ unsigned long offset;
+#define knt1_size 128 /* must be >= kallsyms table size */
+ char *knt1 = NULL;
+
+ if (KDB_DEBUG(AR))
+ kdb_printf("kdbnearsym: addr=0x%lx, symtab=%p\n", addr, symtab);
+ memset(symtab, 0, sizeof(*symtab));
+
+ if (addr < 4096)
+ goto out;
+ knt1 = debug_kmalloc(knt1_size, GFP_ATOMIC);
+ if (!knt1) {
+ kdb_printf("kdbnearsym: addr=0x%lx cannot kmalloc knt1\n", addr);
+ goto out;
+ }
+ symtab->sym_name = kallsyms_lookup(addr, &symbolsize , &offset, (char **)(&symtab->mod_name), knt1);
+ if (offset > 8*1024*1024) {
+ symtab->sym_name = NULL;
+ addr = offset = symbolsize = 0;
+ }
+ symtab->sym_start = addr - offset;
+ symtab->sym_end = symtab->sym_start + symbolsize;
+ ret = symtab->sym_name != NULL && *(symtab->sym_name) != '\0';
+
+ if (ret) {
+ int i;
+ /* Another 2.6 kallsyms "feature". Sometimes the sym_name is
+ * set but the buffer passed into kallsyms_lookup is not used,
+ * so it contains garbage. The caller has to work out which
+ * buffer needs to be saved.
+ *
+ * What was Rusty smoking when he wrote that code?
+ */
+ if (symtab->sym_name != knt1) {
+ strncpy(knt1, symtab->sym_name, knt1_size);
+ knt1[knt1_size-1] = '\0';
+ }
+ for (i = 0; i < ARRAY_SIZE(kdb_name_table); ++i) {
+ if (kdb_name_table[i] && strcmp(kdb_name_table[i], knt1) == 0)
+ break;
+ }
+ if (i >= ARRAY_SIZE(kdb_name_table)) {
+ debug_kfree(kdb_name_table[0]);
+ memcpy(kdb_name_table, kdb_name_table+1,
+ sizeof(kdb_name_table[0])*(ARRAY_SIZE(kdb_name_table)-1));
+ } else {
+ debug_kfree(knt1);
+ knt1 = kdb_name_table[i];
+ memcpy(kdb_name_table+i, kdb_name_table+i+1,
+ sizeof(kdb_name_table[0])*(ARRAY_SIZE(kdb_name_table)-i-1));
+ }
+ i = ARRAY_SIZE(kdb_name_table) - 1;
+ kdb_name_table[i] = knt1;
+ symtab->sym_name = kdb_name_table[i];
+ knt1 = NULL;
+ }
+
+ if (symtab->mod_name == NULL)
+ symtab->mod_name = "kernel";
+ if (KDB_DEBUG(AR))
+ kdb_printf("kdbnearsym: returns %d symtab->sym_start=0x%lx, symtab->mod_name=%p, symtab->sym_name=%p (%s)\n", ret, symtab->sym_start, symtab->mod_name, symtab->sym_name, symtab->sym_name);
+
+out:
+ debug_kfree(knt1);
+ return ret;
+}
+
+void
+kdbnearsym_cleanup(void)
+{
+ int i;
+ for (i = 0; i < ARRAY_SIZE(kdb_name_table); ++i) {
+ if (kdb_name_table[i]) {
+ debug_kfree(kdb_name_table[i]);
+ kdb_name_table[i] = NULL;
+ }
+ }
+}
+
+/*
+ * kallsyms_symbol_complete
+ *
+ * Parameters:
+ * prefix_name prefix of a symbol name to lookup
+ * max_len maximum length that can be returned
+ * Returns:
+ * Number of symbols which match the given prefix.
+ * Notes:
+ * prefix_name is changed to contain the longest unique prefix that
+ * starts with this prefix (tab completion).
+ */
+
+static char ks_namebuf[KSYM_NAME_LEN+1], ks_namebuf_prev[KSYM_NAME_LEN+1];
+
+int kallsyms_symbol_complete(char *prefix_name, int max_len)
+{
+ loff_t pos = 0;
+ int prefix_len = strlen(prefix_name), prev_len = 0;
+ int i, number = 0;
+ const char *name;
+
+ while ((name = kdb_walk_kallsyms(&pos))) {
+ if (strncmp(name, prefix_name, prefix_len) == 0) {
+ strcpy(ks_namebuf, name);
+ /* Work out the longest name that matches the prefix */
+ if (++number == 1) {
+ prev_len = min_t(int, max_len-1, strlen(ks_namebuf));
+ memcpy(ks_namebuf_prev, ks_namebuf, prev_len);
+ ks_namebuf_prev[prev_len] = '\0';
+ } else for (i = 0; i < prev_len; ++i) {
+ if (ks_namebuf[i] != ks_namebuf_prev[i]) {
+ prev_len = i;
+ ks_namebuf_prev[i] = '\0';
+ break;
+ }
+ }
+ }
+ }
+ if (prev_len > prefix_len)
+ memcpy(prefix_name, ks_namebuf_prev, prev_len+1);
+ return number;
+}
+
+/*
+ * kallsyms_symbol_next
+ *
+ * Parameters:
+ * prefix_name prefix of a symbol name to lookup
+ * flag 0 means search from the head, 1 means continue search.
+ * Returns:
+ * 1 if a symbol matches the given prefix.
+ * 0 if no string found
+ */
+
+int kallsyms_symbol_next(char *prefix_name, int flag)
+{
+ int prefix_len = strlen(prefix_name);
+ static loff_t pos;
+ const char *name;
+
+ if (!flag)
+ pos = 0;
+
+ while ((name = kdb_walk_kallsyms(&pos))) {
+ if (strncmp(name, prefix_name, prefix_len) == 0) {
+ strncpy(prefix_name, name, strlen(name)+1);
+ return 1;
+ }
+ }
+ return 0;
+}
+
+#if defined(CONFIG_SMP)
+/*
+ * kdb_ipi
+ *
+ * This function is called from the non-maskable interrupt
+ * handler to handle a kdb IPI instruction.
+ *
+ * Inputs:
+ * regs = Exception frame pointer
+ * Outputs:
+ * None.
+ * Returns:
+ * 0 - Did not handle NMI
+ * 1 - Handled NMI
+ * Locking:
+ * None.
+ * Remarks:
+ * Initially one processor is invoked in the kdb() code. That
+ * processor sends an ipi which drives this routine on the other
+ * processors. All this does is call kdb() with reason SWITCH.
+ * This puts all processors into the kdb() routine and all the
+ * code for breakpoints etc. is in one place.
+ * One problem with the way the kdb NMI is sent, the NMI has no
+ * identification that says it came from kdb. If the cpu's kdb state is
+ * marked as "waiting for kdb_ipi" then the NMI is treated as coming from
+ * kdb, otherwise it is assumed to be for another reason and is ignored.
+ */
+
+int
+kdb_ipi(struct pt_regs *regs, void (*ack_interrupt)(void))
+{
+ /* Do not print before checking and clearing WAIT_IPI, IPIs are
+ * going all the time.
+ */
+ if (KDB_STATE(WAIT_IPI)) {
+ /*
+ * Stopping other processors via smp_kdb_stop().
+ */
+ if (ack_interrupt)
+ (*ack_interrupt)(); /* Acknowledge the interrupt */
+ KDB_STATE_CLEAR(WAIT_IPI);
+ KDB_DEBUG_STATE("kdb_ipi 1", 0);
+ kdb(KDB_REASON_SWITCH, 0, regs); /* Spin in kdb() */
+ KDB_DEBUG_STATE("kdb_ipi 2", 0);
+ return 1;
+ }
+ return 0;
+}
+#endif /* CONFIG_SMP */
+
+/*
+ * kdb_symbol_print
+ *
+ * Standard method for printing a symbol name and offset.
+ * Inputs:
+ * addr Address to be printed.
+ * symtab Address of symbol data, if NULL this routine does its
+ * own lookup.
+ * punc Punctuation for string, bit field.
+ * Outputs:
+ * None.
+ * Returns:
+ * Always 0.
+ * Locking:
+ * none.
+ * Remarks:
+ * The string and its punctuation is only printed if the address
+ * is inside the kernel, except that the value is always printed
+ * when requested.
+ */
+
+void
+kdb_symbol_print(kdb_machreg_t addr, const kdb_symtab_t *symtab_p, unsigned int punc)
+{
+ kdb_symtab_t symtab, *symtab_p2;
+ if (symtab_p) {
+ symtab_p2 = (kdb_symtab_t *)symtab_p;
+ }
+ else {
+ symtab_p2 = &symtab;
+ kdbnearsym(addr, symtab_p2);
+ }
+ if (symtab_p2->sym_name || (punc & KDB_SP_VALUE)) {
+ ; /* drop through */
+ }
+ else {
+ return;
+ }
+ if (punc & KDB_SP_SPACEB) {
+ kdb_printf(" ");
+ }
+ if (punc & KDB_SP_VALUE) {
+ kdb_printf(kdb_machreg_fmt0, addr);
+ }
+ if (symtab_p2->sym_name) {
+ if (punc & KDB_SP_VALUE) {
+ kdb_printf(" ");
+ }
+ if (punc & KDB_SP_PAREN) {
+ kdb_printf("(");
+ }
+ if (strcmp(symtab_p2->mod_name, "kernel")) {
+ kdb_printf("[%s]", symtab_p2->mod_name);
+ }
+ kdb_printf("%s", symtab_p2->sym_name);
+ if (addr != symtab_p2->sym_start) {
+ kdb_printf("+0x%lx", addr - symtab_p2->sym_start);
+ }
+ if (punc & KDB_SP_SYMSIZE) {
+ kdb_printf("/0x%lx", symtab_p2->sym_end - symtab_p2->sym_start);
+ }
+ if (punc & KDB_SP_PAREN) {
+ kdb_printf(")");
+ }
+ }
+ if (punc & KDB_SP_SPACEA) {
+ kdb_printf(" ");
+ }
+ if (punc & KDB_SP_NEWLINE) {
+ kdb_printf("\n");
+ }
+}
+
+/*
+ * kdb_strdup
+ *
+ * kdb equivalent of strdup, for disasm code.
+ * Inputs:
+ * str The string to duplicate.
+ * type Flags to kmalloc for the new string.
+ * Outputs:
+ * None.
+ * Returns:
+ * Address of the new string, NULL if storage could not be allocated.
+ * Locking:
+ * none.
+ * Remarks:
+ * This is not in lib/string.c because it uses kmalloc which is not
+ * available when string.o is used in boot loaders.
+ */
+
+char *kdb_strdup(const char *str, gfp_t type)
+{
+ int n = strlen(str)+1;
+ char *s = kmalloc(n, type);
+ if (!s) return NULL;
+ return strcpy(s, str);
+}
+
+/*
+ * kdb_getarea_size
+ *
+ * Read an area of data. The kdb equivalent of copy_from_user, with
+ * kdb messages for invalid addresses.
+ * Inputs:
+ * res Pointer to the area to receive the result.
+ * addr Address of the area to copy.
+ * size Size of the area.
+ * Outputs:
+ * none.
+ * Returns:
+ * 0 for success, < 0 for error.
+ * Locking:
+ * none.
+ */
+
+int kdb_getarea_size(void *res, unsigned long addr, size_t size)
+{
+ int ret = kdba_getarea_size(res, addr, size);
+ if (ret) {
+ if (!KDB_STATE(SUPPRESS)) {
+ kdb_printf("kdb_getarea: Bad address 0x%lx\n", addr);
+ KDB_STATE_SET(SUPPRESS);
+ }
+ ret = KDB_BADADDR;
+ }
+ else {
+ KDB_STATE_CLEAR(SUPPRESS);
+ }
+ return(ret);
+}
+
+/*
+ * kdb_putarea_size
+ *
+ * Write an area of data. The kdb equivalent of copy_to_user, with
+ * kdb messages for invalid addresses.
+ * Inputs:
+ * addr Address of the area to write to.
+ * res Pointer to the area holding the data.
+ * size Size of the area.
+ * Outputs:
+ * none.
+ * Returns:
+ * 0 for success, < 0 for error.
+ * Locking:
+ * none.
+ */
+
+int kdb_putarea_size(unsigned long addr, void *res, size_t size)
+{
+ int ret = kdba_putarea_size(addr, res, size);
+ if (ret) {
+ if (!KDB_STATE(SUPPRESS)) {
+ kdb_printf("kdb_putarea: Bad address 0x%lx\n", addr);
+ KDB_STATE_SET(SUPPRESS);
+ }
+ ret = KDB_BADADDR;
+ }
+ else {
+ KDB_STATE_CLEAR(SUPPRESS);
+ }
+ return(ret);
+}
+
+/*
+ * kdb_getphys
+ *
+ * Read data from a physical address. Validate the address is in range,
+ * use kmap_atomic() to get data
+ *
+ * Similar to kdb_getarea() - but for phys addresses
+ *
+ * Inputs:
+ * res Pointer to the word to receive the result
+ * addr Physical address of the area to copy
+ * size Size of the area
+ * Outputs:
+ * none.
+ * Returns:
+ * 0 for success, < 0 for error.
+ * Locking:
+ * none.
+ */
+static int kdb_getphys(void *res, unsigned long addr, size_t size)
+{
+ unsigned long pfn;
+ void *vaddr;
+ struct page *page;
+
+ pfn = (addr >> PAGE_SHIFT);
+ if (!pfn_valid(pfn))
+ return 1;
+ page = pfn_to_page(pfn);
+ vaddr = kmap_atomic(page, KM_KDB);
+ memcpy(res, vaddr + (addr & (PAGE_SIZE -1)), size);
+ kunmap_atomic(vaddr, KM_KDB);
+
+ return 0;
+}
+
+/*
+ * kdb_getphysword
+ *
+ * Inputs:
+ * word Pointer to the word to receive the result.
+ * addr Address of the area to copy.
+ * size Size of the area.
+ * Outputs:
+ * none.
+ * Returns:
+ * 0 for success, < 0 for error.
+ * Locking:
+ * none.
+ */
+int kdb_getphysword(unsigned long *word, unsigned long addr, size_t size)
+{
+ int diag;
+ __u8 w1;
+ __u16 w2;
+ __u32 w4;
+ __u64 w8;
+ *word = 0; /* Default value if addr or size is invalid */
+
+ switch (size) {
+ case 1:
+ if (!(diag = kdb_getphys(&w1, addr, sizeof(w1))))
+ *word = w1;
+ break;
+ case 2:
+ if (!(diag = kdb_getphys(&w2, addr, sizeof(w2))))
+ *word = w2;
+ break;
+ case 4:
+ if (!(diag = kdb_getphys(&w4, addr, sizeof(w4))))
+ *word = w4;
+ break;
+ case 8:
+ if (size <= sizeof(*word)) {
+ if (!(diag = kdb_getphys(&w8, addr, sizeof(w8))))
+ *word = w8;
+ break;
+ }
+ /* drop through */
+ default:
+ diag = KDB_BADWIDTH;
+ kdb_printf("kdb_getphysword: bad width %ld\n", (long) size);
+ }
+ return(diag);
+}
+
+/*
+ * kdb_getword
+ *
+ * Read a binary value. Unlike kdb_getarea, this treats data as numbers.
+ * Inputs:
+ * word Pointer to the word to receive the result.
+ * addr Address of the area to copy.
+ * size Size of the area.
+ * Outputs:
+ * none.
+ * Returns:
+ * 0 for success, < 0 for error.
+ * Locking:
+ * none.
+ */
+
+int kdb_getword(unsigned long *word, unsigned long addr, size_t size)
+{
+ int diag;
+ __u8 w1;
+ __u16 w2;
+ __u32 w4;
+ __u64 w8;
+ *word = 0; /* Default value if addr or size is invalid */
+ switch (size) {
+ case 1:
+ if (!(diag = kdb_getarea(w1, addr)))
+ *word = w1;
+ break;
+ case 2:
+ if (!(diag = kdb_getarea(w2, addr)))
+ *word = w2;
+ break;
+ case 4:
+ if (!(diag = kdb_getarea(w4, addr)))
+ *word = w4;
+ break;
+ case 8:
+ if (size <= sizeof(*word)) {
+ if (!(diag = kdb_getarea(w8, addr)))
+ *word = w8;
+ break;
+ }
+ /* drop through */
+ default:
+ diag = KDB_BADWIDTH;
+ kdb_printf("kdb_getword: bad width %ld\n", (long) size);
+ }
+ return(diag);
+}
+
+/*
+ * kdb_putword
+ *
+ * Write a binary value. Unlike kdb_putarea, this treats data as numbers.
+ * Inputs:
+ * addr Address of the area to write to..
+ * word The value to set.
+ * size Size of the area.
+ * Outputs:
+ * none.
+ * Returns:
+ * 0 for success, < 0 for error.
+ * Locking:
+ * none.
+ */
+
+int kdb_putword(unsigned long addr, unsigned long word, size_t size)
+{
+ int diag;
+ __u8 w1;
+ __u16 w2;
+ __u32 w4;
+ __u64 w8;
+ switch (size) {
+ case 1:
+ w1 = word;
+ diag = kdb_putarea(addr, w1);
+ break;
+ case 2:
+ w2 = word;
+ diag = kdb_putarea(addr, w2);
+ break;
+ case 4:
+ w4 = word;
+ diag = kdb_putarea(addr, w4);
+ break;
+ case 8:
+ if (size <= sizeof(word)) {
+ w8 = word;
+ diag = kdb_putarea(addr, w8);
+ break;
+ }
+ /* drop through */
+ default:
+ diag = KDB_BADWIDTH;
+ kdb_printf("kdb_putword: bad width %ld\n", (long) size);
+ }
+ return(diag);
+}
+
+/*
+ * kdb_task_state_string
+ *
+ * Convert a string containing any of the letters DRSTCZEUIMA to a mask
+ * for the process state field and return the value. If no argument is
+ * supplied, return the mask that corresponds to environment variable PS,
+ * DRSTCZEU by default.
+ * Inputs:
+ * s String to convert
+ * Outputs:
+ * none.
+ * Returns:
+ * Mask for process state.
+ * Locking:
+ * none.
+ * Notes:
+ * The mask folds data from several sources into a single long value, so
+ * be carefull not to overlap the bits. TASK_* bits are in the LSB,
+ * special cases like UNRUNNABLE are in the MSB. As of 2.6.10-rc1 there
+ * is no overlap between TASK_* and EXIT_* but that may not always be
+ * true, so EXIT_* bits are shifted left 16 bits before being stored in
+ * the mask.
+ */
+
+#define UNRUNNABLE (1UL << (8*sizeof(unsigned long) - 1)) /* unrunnable is < 0 */
+#define RUNNING (1UL << (8*sizeof(unsigned long) - 2))
+#define IDLE (1UL << (8*sizeof(unsigned long) - 3))
+#define DAEMON (1UL << (8*sizeof(unsigned long) - 4))
+
+unsigned long
+kdb_task_state_string(const char *s)
+{
+ long res = 0;
+ if (!s && !(s = kdbgetenv("PS"))) {
+ s = "DRSTCZEU"; /* default value for ps */
+ }
+ while (*s) {
+ switch (*s) {
+ case 'D': res |= TASK_UNINTERRUPTIBLE; break;
+ case 'R': res |= RUNNING; break;
+ case 'S': res |= TASK_INTERRUPTIBLE; break;
+ case 'T': res |= TASK_STOPPED; break;
+ case 'C': res |= TASK_TRACED; break;
+ case 'Z': res |= EXIT_ZOMBIE << 16; break;
+ case 'E': res |= EXIT_DEAD << 16; break;
+ case 'U': res |= UNRUNNABLE; break;
+ case 'I': res |= IDLE; break;
+ case 'M': res |= DAEMON; break;
+ case 'A': res = ~0UL; break;
+ default:
+ kdb_printf("%s: unknown flag '%c' ignored\n", __FUNCTION__, *s);
+ break;
+ }
+ ++s;
+ }
+ return res;
+}
+
+/*
+ * kdb_task_state_char
+ *
+ * Return the character that represents the task state.
+ * Inputs:
+ * p struct task for the process
+ * Outputs:
+ * none.
+ * Returns:
+ * One character to represent the task state.
+ * Locking:
+ * none.
+ */
+
+char
+kdb_task_state_char (const struct task_struct *p)
+{
+ int cpu = kdb_process_cpu(p);
+ struct kdb_running_process *krp = kdb_running_process + cpu;
+ char state = (p->state == 0) ? 'R' :
+ (p->state < 0) ? 'U' :
+ (p->state & TASK_UNINTERRUPTIBLE) ? 'D' :
+ (p->state & TASK_STOPPED) ? 'T' :
+ (p->state & TASK_TRACED) ? 'C' :
+ (p->exit_state & EXIT_ZOMBIE) ? 'Z' :
+ (p->exit_state & EXIT_DEAD) ? 'E' :
+ (p->state & TASK_INTERRUPTIBLE) ? 'S' : '?';
+ if (p->pid == 0) {
+ /* Idle task. Is it really idle, apart from the kdb interrupt? */
+ if (!kdb_task_has_cpu(p) || krp->irq_depth == 1) {
+ /* There is a corner case when the idle task takes an
+ * interrupt and dies in the interrupt code. It has an
+ * interrupt count of 1 but that did not come from kdb.
+ * This corner case can only occur on the initial cpu,
+ * all the others were entered via the kdb IPI.
+ */
+ if (cpu != kdb_initial_cpu || KDB_STATE_CPU(KEYBOARD, cpu))
+ state = 'I'; /* idle task */
+ }
+ }
+ else if (!p->mm && state == 'S') {
+ state = 'M'; /* sleeping system daemon */
+ }
+ return state;
+}
+
+/*
+ * kdb_task_state
+ *
+ * Return true if a process has the desired state given by the mask.
+ * Inputs:
+ * p struct task for the process
+ * mask mask from kdb_task_state_string to select processes
+ * Outputs:
+ * none.
+ * Returns:
+ * True if the process matches at least one criteria defined by the mask.
+ * Locking:
+ * none.
+ */
+
+unsigned long
+kdb_task_state(const struct task_struct *p, unsigned long mask)
+{
+ char state[] = { kdb_task_state_char(p), '\0' };
+ return (mask & kdb_task_state_string(state)) != 0;
+}
+
+struct kdb_running_process kdb_running_process[NR_CPUS];
+
+/* Save the state of a running process and invoke kdb_main_loop. This is
+ * invoked on the current process on each cpu (assuming the cpu is responding).
+ */
+
+int
+kdb_save_running(struct pt_regs *regs, kdb_reason_t reason,
+ kdb_reason_t reason2, int error, kdb_dbtrap_t db_result)
+{
+ struct kdb_running_process *krp = kdb_running_process + smp_processor_id();
+ krp->p = current;
+ krp->regs = regs;
+ krp->seqno = kdb_seqno;
+ krp->irq_depth = hardirq_count() >> HARDIRQ_SHIFT;
+ kdba_save_running(&(krp->arch), regs);
+ return kdb_main_loop(reason, reason2, error, db_result, regs);
+}
+
+/*
+ * kdb_unsave_running
+ *
+ * Reverse the effect of kdb_save_running.
+ * Inputs:
+ * regs struct pt_regs for the process
+ * Outputs:
+ * Updates kdb_running_process[] for this cpu.
+ * Returns:
+ * none.
+ * Locking:
+ * none.
+ */
+
+void
+kdb_unsave_running(struct pt_regs *regs)
+{
+ struct kdb_running_process *krp = kdb_running_process + smp_processor_id();
+ kdba_unsave_running(&(krp->arch), regs);
+ krp->seqno = 0;
+}
+
+
+/*
+ * kdb_print_nameval
+ *
+ * Print a name and its value, converting the value to a symbol lookup
+ * if possible.
+ * Inputs:
+ * name field name to print
+ * val value of field
+ * Outputs:
+ * none.
+ * Returns:
+ * none.
+ * Locking:
+ * none.
+ */
+
+void
+kdb_print_nameval(const char *name, unsigned long val)
+{
+ kdb_symtab_t symtab;
+ kdb_printf(" %-11.11s ", name);
+ if (kdbnearsym(val, &symtab))
+ kdb_symbol_print(val, &symtab, KDB_SP_VALUE|KDB_SP_SYMSIZE|KDB_SP_NEWLINE);
+ else
+ kdb_printf("0x%lx\n", val);
+}
+
+static struct page * kdb_get_one_user_page(const struct task_struct *tsk, unsigned long start,
+ int len, int write)
+{
+ struct mm_struct *mm = tsk->mm;
+ unsigned int flags;
+ struct vm_area_struct * vma;
+
+ /* shouldn't cross a page boundary. */
+ if ((start & PAGE_MASK) != ((start+len) & PAGE_MASK))
+ return NULL;
+
+ /* we need to align start address to the current page boundy, PAGE_ALIGN
+ * aligns to next page boundry.
+ * FIXME: What about hugetlb?
+ */
+ start = start & PAGE_MASK;
+ flags = write ? (VM_WRITE | VM_MAYWRITE) : (VM_READ | VM_MAYREAD);
+
+ vma = find_extend_vma(mm, start);
+
+ /* may be we can allow access to VM_IO pages inside KDB? */
+ if (!vma || (vma->vm_flags & VM_IO) || !(flags & vma->vm_flags))
+ return NULL;
+
+ return follow_page(vma, start, write ? FOLL_WRITE : 0);
+}
+
+int kdb_getuserarea_size(void *to, unsigned long from, size_t size)
+{
+ struct page *page;
+ void *vaddr;
+
+ page = kdb_get_one_user_page(kdb_current_task, from, size, 0);
+ if (!page)
+ return size;
+
+ vaddr = kmap_atomic(page, KM_KDB);
+ memcpy(to, vaddr+ (from & (PAGE_SIZE - 1)), size);
+ kunmap_atomic(vaddr, KM_KDB);
+
+ return 0;
+}
+
+int kdb_putuserarea_size(unsigned long to, void *from, size_t size)
+{
+ struct page *page;
+ void *vaddr;
+
+ page = kdb_get_one_user_page(kdb_current_task, to, size, 1);
+ if (!page)
+ return size;
+
+ vaddr = kmap_atomic(page, KM_KDB);
+ memcpy(vaddr+ (to & (PAGE_SIZE - 1)), from, size);
+ kunmap_atomic(vaddr, KM_KDB);
+
+ return 0;
+}
+
+/* Last ditch allocator for debugging, so we can still debug even when the
+ * GFP_ATOMIC pool has been exhausted. The algorithms are tuned for space
+ * usage, not for speed. One smallish memory pool, the free chain is always in
+ * ascending address order to allow coalescing, allocations are done in brute
+ * force best fit.
+ */
+
+struct debug_alloc_header {
+ u32 next; /* offset of next header from start of pool */
+ u32 size;
+ void *caller;
+};
+
+/* The memory returned by this allocator must be aligned, which means so must
+ * the header size. Do not assume that sizeof(struct debug_alloc_header) is a
+ * multiple of the alignment, explicitly calculate the overhead of this header,
+ * including the alignment. The rest of this code must not use sizeof() on any
+ * header or pointer to a header.
+ */
+#define dah_align 8
+#define dah_overhead ALIGN(sizeof(struct debug_alloc_header), dah_align)
+
+static u64 debug_alloc_pool_aligned[256*1024/dah_align]; /* 256K pool */
+static char *debug_alloc_pool = (char *)debug_alloc_pool_aligned;
+static u32 dah_first, dah_first_call = 1, dah_used = 0, dah_used_max = 0;
+
+/* Locking is awkward. The debug code is called from all contexts, including
+ * non maskable interrupts. A normal spinlock is not safe in NMI context. Try
+ * to get the debug allocator lock, if it cannot be obtained after a second
+ * then give up. If the lock could not be previously obtained on this cpu then
+ * only try once.
+ *
+ * sparse has no annotation for "this function _sometimes_ acquires a lock", so
+ * fudge the acquire/release notation.
+ */
+static DEFINE_SPINLOCK(dap_lock);
+static int
+get_dap_lock(void)
+ __acquires(dap_lock)
+{
+ static int dap_locked = -1;
+ int count;
+ if (dap_locked == smp_processor_id())
+ count = 1;
+ else
+ count = 1000;
+ while (1) {
+ if (spin_trylock(&dap_lock)) {
+ dap_locked = -1;
+ return 1;
+ }
+ if (!count--)
+ break;
+ udelay(1000);
+ }
+ dap_locked = smp_processor_id();
+ __acquire(dap_lock);
+ return 0;
+}
+
+void
+*debug_kmalloc(size_t size, gfp_t flags)
+{
+ unsigned int rem, h_offset;
+ struct debug_alloc_header *best, *bestprev, *prev, *h;
+ void *p = NULL;
+ if (!get_dap_lock()) {
+ __release(dap_lock); /* we never actually got it */
+ return NULL;
+ }
+ h = (struct debug_alloc_header *)(debug_alloc_pool + dah_first);
+ if (dah_first_call) {
+ h->size = sizeof(debug_alloc_pool_aligned) - dah_overhead;
+ dah_first_call = 0;
+ }
+ size = ALIGN(size, dah_align);
+ prev = best = bestprev = NULL;
+ while (1) {
+ if (h->size >= size && (!best || h->size < best->size)) {
+ best = h;
+ bestprev = prev;
+ if (h->size == size)
+ break;
+ }
+ if (!h->next)
+ break;
+ prev = h;
+ h = (struct debug_alloc_header *)(debug_alloc_pool + h->next);
+ }
+ if (!best)
+ goto out;
+ rem = best->size - size;
+ /* The pool must always contain at least one header */
+ if (best->next == 0 && bestprev == NULL && rem < dah_overhead)
+ goto out;
+ if (rem >= dah_overhead) {
+ best->size = size;
+ h_offset = ((char *)best - debug_alloc_pool) +
+ dah_overhead + best->size;
+ h = (struct debug_alloc_header *)(debug_alloc_pool + h_offset);
+ h->size = rem - dah_overhead;
+ h->next = best->next;
+ } else
+ h_offset = best->next;
+ best->caller = __builtin_return_address(0);
+ dah_used += best->size;
+ dah_used_max = max(dah_used, dah_used_max);
+ if (bestprev)
+ bestprev->next = h_offset;
+ else
+ dah_first = h_offset;
+ p = (char *)best + dah_overhead;
+ memset(p, POISON_INUSE, best->size - 1);
+ *((char *)p + best->size - 1) = POISON_END;
+out:
+ spin_unlock(&dap_lock);
+ return p;
+}
+
+void
+debug_kfree(void *p)
+{
+ struct debug_alloc_header *h;
+ unsigned int h_offset;
+ if (!p)
+ return;
+ if ((char *)p < debug_alloc_pool ||
+ (char *)p >= debug_alloc_pool + sizeof(debug_alloc_pool_aligned)) {
+ kfree(p);
+ return;
+ }
+ if (!get_dap_lock()) {
+ __release(dap_lock); /* we never actually got it */
+ return; /* memory leak, cannot be helped */
+ }
+ h = (struct debug_alloc_header *)((char *)p - dah_overhead);
+ memset(p, POISON_FREE, h->size - 1);
+ *((char *)p + h->size - 1) = POISON_END;
+ h->caller = NULL;
+ dah_used -= h->size;
+ h_offset = (char *)h - debug_alloc_pool;
+ if (h_offset < dah_first) {
+ h->next = dah_first;
+ dah_first = h_offset;
+ } else {
+ struct debug_alloc_header *prev;
+ unsigned int prev_offset;
+ prev = (struct debug_alloc_header *)(debug_alloc_pool + dah_first);
+ while (1) {
+ if (!prev->next || prev->next > h_offset)
+ break;
+ prev = (struct debug_alloc_header *)
+ (debug_alloc_pool + prev->next);
+ }
+ prev_offset = (char *)prev - debug_alloc_pool;
+ if (prev_offset + dah_overhead + prev->size == h_offset) {
+ prev->size += dah_overhead + h->size;
+ memset(h, POISON_FREE, dah_overhead - 1);
+ *((char *)h + dah_overhead - 1) = POISON_END;
+ h = prev;
+ h_offset = prev_offset;
+ } else {
+ h->next = prev->next;
+ prev->next = h_offset;
+ }
+ }
+ if (h_offset + dah_overhead + h->size == h->next) {
+ struct debug_alloc_header *next;
+ next = (struct debug_alloc_header *)
+ (debug_alloc_pool + h->next);
+ h->size += dah_overhead + next->size;
+ h->next = next->next;
+ memset(next, POISON_FREE, dah_overhead - 1);
+ *((char *)next + dah_overhead - 1) = POISON_END;
+ }
+ spin_unlock(&dap_lock);
+}
+
+void
+debug_kusage(void)
+{
+ struct debug_alloc_header *h_free, *h_used;
+#ifdef CONFIG_IA64
+ /* FIXME: using dah for ia64 unwind always results in a memory leak.
+ * Fix that memory leak first, then set debug_kusage_one_time = 1 for
+ * all architectures.
+ */
+ static int debug_kusage_one_time = 0;
+#else
+ static int debug_kusage_one_time = 1;
+#endif
+ if (!get_dap_lock()) {
+ __release(dap_lock); /* we never actually got it */
+ return;
+ }
+ h_free = (struct debug_alloc_header *)(debug_alloc_pool + dah_first);
+ if (dah_first == 0 &&
+ (h_free->size == sizeof(debug_alloc_pool_aligned) - dah_overhead ||
+ dah_first_call))
+ goto out;
+ if (!debug_kusage_one_time)
+ goto out;
+ debug_kusage_one_time = 0;
+ kdb_printf("%s: debug_kmalloc memory leak dah_first %d\n",
+ __FUNCTION__, dah_first);
+ if (dah_first) {
+ h_used = (struct debug_alloc_header *)debug_alloc_pool;
+ kdb_printf("%s: h_used %p size %d\n", __FUNCTION__, h_used, h_used->size);
+ }
+ do {
+ h_used = (struct debug_alloc_header *)
+ ((char *)h_free + dah_overhead + h_free->size);
+ kdb_printf("%s: h_used %p size %d caller %p\n",
+ __FUNCTION__, h_used, h_used->size, h_used->caller);
+ h_free = (struct debug_alloc_header *)
+ (debug_alloc_pool + h_free->next);
+ } while (h_free->next);
+ h_used = (struct debug_alloc_header *)
+ ((char *)h_free + dah_overhead + h_free->size);
+ if ((char *)h_used - debug_alloc_pool !=
+ sizeof(debug_alloc_pool_aligned))
+ kdb_printf("%s: h_used %p size %d caller %p\n",
+ __FUNCTION__, h_used, h_used->size, h_used->caller);
+out:
+ spin_unlock(&dap_lock);
+}
+
+/* Maintain a small stack of kdb_flags to allow recursion without disturbing
+ * the global kdb state.
+ */
+
+static int kdb_flags_stack[4], kdb_flags_index;
+
+void
+kdb_save_flags(void)
+{
+ BUG_ON(kdb_flags_index >= ARRAY_SIZE(kdb_flags_stack));
+ kdb_flags_stack[kdb_flags_index++] = kdb_flags;
+}
+
+void
+kdb_restore_flags(void)
+{
+ BUG_ON(kdb_flags_index <= 0);
+ kdb_flags = kdb_flags_stack[--kdb_flags_index];
+}
Index: linux/kdb/modules/Makefile
===================================================================
--- /dev/null
+++ linux/kdb/modules/Makefile
@@ -0,0 +1,14 @@
+#
+# This file is subject to the terms and conditions of the GNU General Public
+# License. See the file "COPYING" in the main directory of this archive
+# for more details.
+#
+# Copyright (c) 1999-2006 Silicon Graphics, Inc. All Rights Reserved.
+#
+
+obj-$(CONFIG_KDB_MODULES) += kdbm_pg.o kdbm_task.o kdbm_vm.o kdbm_sched.o
+ifdef CONFIG_X86
+obj-$(CONFIG_KDB_MODULES) += kdbm_x86.o
+endif
+obj-$(CONFIG_KDB_MODULES_XP) += kdbm_xpc.o
+CFLAGS_kdbm_vm.o += -I $(srctree)/drivers/scsi
Index: linux/kdb/modules/kdbm_pg.c
===================================================================
--- /dev/null
+++ linux/kdb/modules/kdbm_pg.c
@@ -0,0 +1,644 @@
+/*
+ * This file is subject to the terms and conditions of the GNU General Public
+ * License. See the file "COPYING" in the main directory of this archive
+ * for more details.
+ *
+ * Copyright (c) 1999-2004 Silicon Graphics, Inc. All Rights Reserved.
+ */
+
+#include <linux/module.h>
+#include <linux/init.h>
+#include <linux/mm.h>
+#include <linux/pagemap.h>
+#include <linux/fs.h>
+#include <linux/bio.h>
+#include <linux/buffer_head.h>
+#include <linux/kdb.h>
+#include <linux/kdbprivate.h>
+#include <linux/blkdev.h>
+#include <linux/ctype.h>
+
+MODULE_AUTHOR("SGI");
+MODULE_DESCRIPTION("Debug page information");
+MODULE_LICENSE("GPL");
+
+/* Standard Linux page stuff */
+
+#if !defined(CONFIG_DISCONTIGMEM) && !defined(CONFIG_NUMA)
+/* From include/linux/page-flags.h */
+static char *pg_flag_vals[] = {
+ "PG_locked", "PG_error", "PG_referenced", "PG_uptodate",
+ "PG_dirty", "PG_lru", "PG_active", "PG_slab",
+ "PG_owner_priv_1", "PG_arch_1", "PG_reserved", "PG_private",
+ "PG_writeback", "?? 13 ??", "PG_compound", "PG_swapcache",
+ "PG_mappedtodisk", "PG_reclaim", "?? 18 ??", "PG_buddy",
+ NULL };
+#endif
+
+/* From include/linux/buffer_head.h */
+static char *bh_state_vals[] = {
+ "Uptodate", "Dirty", "Lock", "Req",
+ "Uptodate_Lock", "Mapped", "New", "Async_read",
+ "Async_write", "Delay", "Boundary", "Write_EIO",
+ "Ordered", "Eopnotsupp", "Unwritten", "Priavate",
+ NULL };
+
+/* From include/linux/bio.h */
+static char *bio_flag_vals[] = {
+ "Uptodate", "RW_block", "EOF", "Seg_valid",
+ "Cloned", "Bounced", "User_mapped", "Eopnotsupp",
+ NULL };
+
+/* From include/linux/fs.h */
+static char *inode_flag_vals[] = {
+ "I_DIRTY_SYNC", "I_DIRTY_DATASYNC", "I_DIRTY_PAGES", "I_NEW",
+ "I_WILL_FREE", "I_FREEING", "I_CLEAR", "I_LOCK",
+ "I_SYNC", NULL };
+
+static char *map_flags(unsigned long flags, char *mapping[])
+{
+ static char buffer[256];
+ int index;
+ int offset = 12;
+
+ buffer[0] = '\0';
+
+ for (index = 0; flags && mapping[index]; flags >>= 1, index++) {
+ if (flags & 1) {
+ if ((offset + strlen(mapping[index]) + 1) >= 80) {
+ strcat(buffer, "\n ");
+ offset = 12;
+ } else if (offset > 12) {
+ strcat(buffer, " ");
+ offset++;
+ }
+ strcat(buffer, mapping[index]);
+ offset += strlen(mapping[index]);
+ }
+ }
+
+ return (buffer);
+}
+
+static int
+kdbm_buffers(int argc, const char **argv)
+{
+ struct buffer_head bh;
+ unsigned long addr;
+ long offset = 0;
+ int nextarg;
+ int diag;
+
+ if (argc != 1)
+ return KDB_ARGCOUNT;
+
+ nextarg = 1;
+ if ((diag = kdbgetaddrarg(argc, argv, &nextarg, &addr, &offset, NULL)) ||
+ (diag = kdb_getarea(bh, addr)))
+ return(diag);
+
+ kdb_printf("buffer_head at 0x%lx\n", addr);
+ kdb_printf(" bno %llu size %llu dev 0x%x\n",
+ (unsigned long long)bh.b_blocknr,
+ (unsigned long long)bh.b_size,
+ bh.b_bdev ? bh.b_bdev->bd_dev : 0);
+ kdb_printf(" count %d state 0x%lx [%s]\n",
+ bh.b_count.counter, bh.b_state,
+ map_flags(bh.b_state, bh_state_vals));
+ kdb_printf(" b_data 0x%p\n",
+ bh.b_data);
+ kdb_printf(" b_page 0x%p b_this_page 0x%p b_private 0x%p\n",
+ bh.b_page, bh.b_this_page, bh.b_private);
+ kdb_printf(" b_end_io ");
+ if (bh.b_end_io)
+ kdb_symbol_print(kdba_funcptr_value(bh.b_end_io), NULL, KDB_SP_VALUE);
+ else
+ kdb_printf("(NULL)");
+ kdb_printf("\n");
+
+ return 0;
+}
+
+static int
+print_biovec(struct bio_vec *vec, int vcount)
+{
+ struct bio_vec bvec;
+ unsigned long addr;
+ int diag;
+ int i;
+
+ if (vcount < 1 || vcount > BIO_MAX_PAGES) {
+ kdb_printf(" [skipped iovecs, vcnt is %d]\n", vcount);
+ return 0;
+ }
+
+ addr = (unsigned long)vec;
+ for (i = 0; i < vcount; i++) {
+ if ((diag = kdb_getarea(bvec, addr)))
+ return(diag);
+ addr += sizeof(bvec);
+ kdb_printf(" [%d] page 0x%p length=%u offset=%u\n",
+ i, bvec.bv_page, bvec.bv_len, bvec.bv_offset);
+ }
+ return 0;
+}
+
+static int
+kdbm_bio(int argc, const char **argv)
+{
+ struct bio bio;
+ unsigned long addr;
+ long offset = 0;
+ int nextarg;
+ int diag;
+
+ if (argc != 1)
+ return KDB_ARGCOUNT;
+
+ nextarg = 1;
+ if ((diag = kdbgetaddrarg(argc, argv, &nextarg, &addr, &offset, NULL)) ||
+ (diag = kdb_getarea(bio, addr)))
+ return(diag);
+
+ kdb_printf("bio at 0x%lx\n", addr);
+ kdb_printf(" bno %llu next 0x%p dev 0x%x\n",
+ (unsigned long long)bio.bi_sector,
+ bio.bi_next, bio.bi_bdev ? bio.bi_bdev->bd_dev : 0);
+ kdb_printf(" vcnt %u vec 0x%p rw 0x%lx flags 0x%lx [%s]\n",
+ bio.bi_vcnt, bio.bi_io_vec, bio.bi_rw, bio.bi_flags,
+ map_flags(bio.bi_flags, bio_flag_vals));
+ print_biovec(bio.bi_io_vec, bio.bi_vcnt);
+ kdb_printf(" count %d private 0x%p\n",
+ atomic_read(&bio.bi_cnt), bio.bi_private);
+ kdb_printf(" bi_end_io ");
+ if (bio.bi_end_io)
+ kdb_symbol_print(kdba_funcptr_value(bio.bi_end_io), NULL, KDB_SP_VALUE);
+ else
+ kdb_printf("(NULL)");
+ kdb_printf("\n");
+
+ return 0;
+}
+
+#if !defined(CONFIG_DISCONTIGMEM) && !defined(CONFIG_NUMA)
+static char *page_flags(unsigned long flags)
+{
+ return(map_flags(flags, pg_flag_vals));
+}
+
+static int
+kdbm_page(int argc, const char **argv)
+{
+ struct page page;
+ unsigned long addr;
+ long offset = 0;
+ int nextarg;
+ int diag;
+
+ if (argc != 1)
+ return KDB_ARGCOUNT;
+
+ nextarg = 1;
+ diag = kdbgetaddrarg(argc, argv, &nextarg, &addr, &offset, NULL);
+ if (diag)
+ return diag;
+
+#ifdef __ia64__
+ if (rgn_index(addr) == 0)
+ addr = (unsigned long) &mem_map[addr]; /* assume region 0 is a page index, not an address */
+#else
+ if (addr < PAGE_OFFSET)
+ addr = (unsigned long) &mem_map[addr];
+#endif
+
+ if ((diag = kdb_getarea(page, addr)))
+ return(diag);
+
+ kdb_printf("struct page at 0x%lx\n", addr);
+ kdb_printf(" addr space 0x%p index %lu (offset 0x%llx)\n",
+ page.mapping, page.index,
+ (unsigned long long)page.index << PAGE_CACHE_SHIFT);
+ kdb_printf(" count %d flags %s\n",
+ page._count.counter, page_flags(page.flags));
+ kdb_printf(" virtual 0x%p\n", page_address((struct page *)addr));
+ if (page_has_buffers(&page))
+ kdb_printf(" buffers 0x%p\n", page_buffers(&page));
+ else
+ kdb_printf(" private 0x%lx\n", page_private(&page));
+
+ return 0;
+}
+#endif /* !CONFIG_DISCONTIGMEM && !NUMA */
+
+static unsigned long
+print_request(unsigned long addr)
+{
+ struct request rq;
+
+ if (kdb_getarea(rq, addr))
+ return(0);
+
+ kdb_printf("struct request at 0x%lx\n", addr);
+ kdb_printf(" errors %d sector %llu nr_sectors %lu\n",
+ rq.errors,
+ (unsigned long long)rq.sector, rq.nr_sectors);
+
+ kdb_printf(" hsect %llu hnrsect %lu nrseg %u nrhwseg %u currnrsect %u\n",
+ (unsigned long long)rq.hard_sector, rq.hard_nr_sectors,
+ rq.nr_phys_segments, rq.nr_hw_segments,
+ rq.current_nr_sectors);
+
+ return (unsigned long) rq.queuelist.next;
+}
+
+static int
+kdbm_request(int argc, const char **argv)
+{
+ long offset = 0;
+ unsigned long addr;
+ int nextarg;
+ int diag;
+
+ if (argc != 1)
+ return KDB_ARGCOUNT;
+
+ nextarg = 1;
+ diag = kdbgetaddrarg(argc, argv, &nextarg, &addr, &offset, NULL);
+ if (diag)
+ return diag;
+
+ print_request(addr);
+ return 0;
+}
+
+
+static int
+kdbm_rqueue(int argc, const char **argv)
+{
+ struct request_queue rq;
+ unsigned long addr, head_addr, next;
+ long offset = 0;
+ int nextarg;
+ int i, diag;
+
+ if (argc != 1)
+ return KDB_ARGCOUNT;
+
+ nextarg = 1;
+ if ((diag = kdbgetaddrarg(argc, argv, &nextarg, &addr, &offset, NULL)) ||
+ (diag = kdb_getarea(rq, addr)))
+ return(diag);
+
+ kdb_printf("struct request_queue at 0x%lx\n", addr);
+ i = 0;
+ next = (unsigned long)rq.queue_head.next;
+ head_addr = addr + offsetof(struct request_queue, queue_head);
+ kdb_printf(" request queue: %s\n", next == head_addr ?
+ "empty" : "");
+ while (next != head_addr) {
+ i++;
+ next = print_request(next);
+ }
+
+ if (i)
+ kdb_printf("%d requests found\n", i);
+
+ return 0;
+}
+
+
+static void
+do_buffer(unsigned long addr)
+{
+ struct buffer_head bh;
+
+ if (kdb_getarea(bh, addr))
+ return;
+
+ kdb_printf("\tbh 0x%lx bno %8llu [%s]\n", addr,
+ (unsigned long long)bh.b_blocknr,
+ map_flags(bh.b_state, bh_state_vals));
+}
+
+static void
+kdbm_show_page(struct page *page, int first)
+{
+ if (first)
+ kdb_printf("page_struct index cnt zone nid flags\n");
+ kdb_printf("%p%s %6lu %5d %3d %3d 0x%lx",
+ page_address(page), sizeof(void *) == 4 ? " " : "",
+ page->index, atomic_read(&(page->_count)),
+ page_zonenum(page), page_to_nid(page),
+ page->flags & (~0UL >> ZONES_SHIFT));
+#define kdb_page_flags(page, type) if (Page ## type(page)) kdb_printf(" " #type);
+ kdb_page_flags(page, Locked);
+ kdb_page_flags(page, Error);
+ kdb_page_flags(page, Referenced);
+ kdb_page_flags(page, Uptodate);
+ kdb_page_flags(page, Dirty);
+ kdb_page_flags(page, LRU);
+ kdb_page_flags(page, Active);
+ kdb_page_flags(page, Slab);
+ kdb_page_flags(page, Checked);
+ if (page->flags & (1UL << PG_arch_1))
+ kdb_printf(" arch_1");
+ kdb_page_flags(page, Reserved);
+ kdb_page_flags(page, Private);
+ kdb_page_flags(page, Writeback);
+ kdb_page_flags(page, Compound);
+ kdb_page_flags(page, SwapCache);
+ kdb_page_flags(page, MappedToDisk);
+ kdb_page_flags(page, Reclaim);
+ kdb_page_flags(page, Buddy);
+
+ /* PageHighMem is not a flag any more, but treat it as one */
+ kdb_page_flags(page, HighMem);
+
+ if (page_has_buffers(page)) {
+ struct buffer_head *head, *bh;
+ kdb_printf("\n");
+ head = bh = page_buffers(page);
+ do {
+ do_buffer((unsigned long) bh);
+ } while ((bh = bh->b_this_page) != head);
+ } else if (page_private(page)) {
+ kdb_printf(" private= 0x%lx", page_private(page));
+ }
+ /* Cannot use page_mapping(page) here, it needs swapper_space which is
+ * not exported.
+ */
+ if (page->mapping)
+ kdb_printf(" mapping= %p", page->mapping);
+ kdb_printf("\n");
+#undef kdb_page_flags
+}
+
+static int
+kdbm_inode_pages(int argc, const char **argv)
+{
+ struct inode *inode = NULL;
+ struct address_space *ap = NULL;
+ unsigned long addr, addr1 = 0;
+ long offset = 0;
+ int nextarg;
+ int diag;
+ pgoff_t next = 0;
+ struct page *page;
+ int first;
+
+ nextarg = 1;
+ diag = kdbgetaddrarg(argc, argv, &nextarg, &addr, &offset, NULL);
+ if (diag)
+ goto out;
+
+ if (argc == 2) {
+ nextarg = 2;
+ diag = kdbgetaddrarg(argc, argv, &nextarg, &addr1,
+ &offset, NULL);
+ if (diag)
+ goto out;
+ kdb_printf("Looking for page index 0x%lx ... \n", addr1);
+ next = addr1;
+ }
+
+ if (!(inode = kmalloc(sizeof(*inode), GFP_ATOMIC))) {
+ kdb_printf("kdbm_inode_pages: cannot kmalloc inode\n");
+ goto out;
+ }
+ if (!(ap = kmalloc(sizeof(*ap), GFP_ATOMIC))) {
+ kdb_printf("kdbm_inode_pages: cannot kmalloc ap\n");
+ goto out;
+ }
+ if ((diag = kdb_getarea(*inode, addr)))
+ goto out;
+ if (!inode->i_mapping) {
+ kdb_printf("inode has no mapping\n");
+ goto out;
+ }
+ if ((diag = kdb_getarea(*ap, (unsigned long) inode->i_mapping)))
+ goto out;
+
+ /* Run the pages in the radix tree, printing the state of each page */
+ first = 1;
+ while (radix_tree_gang_lookup(&ap->page_tree, (void **)&page, next, 1)) {
+ kdbm_show_page(page, first);
+ if (addr1)
+ break;
+ first = 0;
+ next = page->index + 1;
+ }
+
+out:
+ if (inode)
+ kfree(inode);
+ if (ap)
+ kfree(ap);
+ return diag;
+}
+
+static int
+kdbm_inode(int argc, const char **argv)
+{
+ struct inode *inode = NULL;
+ unsigned long addr;
+ unsigned char *iaddr;
+ long offset = 0;
+ int nextarg;
+ int diag;
+
+ if (argc != 1)
+ return KDB_ARGCOUNT;
+
+ nextarg = 1;
+ if ((diag = kdbgetaddrarg(argc, argv, &nextarg, &addr, &offset, NULL)))
+ goto out;
+ if (!(inode = kmalloc(sizeof(*inode), GFP_ATOMIC))) {
+ kdb_printf("kdbm_inode: cannot kmalloc inode\n");
+ goto out;
+ }
+ if ((diag = kdb_getarea(*inode, addr)))
+ goto out;
+
+ kdb_printf("struct inode at 0x%lx\n", addr);
+
+ kdb_printf(" i_ino = %lu i_count = %u i_size %Ld\n",
+ inode->i_ino, atomic_read(&inode->i_count),
+ inode->i_size);
+
+ kdb_printf(" i_mode = 0%o i_nlink = %d i_rdev = 0x%x\n",
+ inode->i_mode, inode->i_nlink,
+ inode->i_rdev);
+
+ kdb_printf(" i_hash.nxt = 0x%p i_hash.pprev = 0x%p\n",
+ inode->i_hash.next,
+ inode->i_hash.pprev);
+
+ kdb_printf(" i_list.nxt = 0x%p i_list.prv = 0x%p\n",
+ list_entry(inode->i_list.next, struct inode, i_list),
+ list_entry(inode->i_list.prev, struct inode, i_list));
+
+ kdb_printf(" i_dentry.nxt = 0x%p i_dentry.prv = 0x%p\n",
+ list_entry(inode->i_dentry.next, struct dentry, d_alias),
+ list_entry(inode->i_dentry.prev, struct dentry, d_alias));
+
+ kdb_printf(" i_sb = 0x%p i_op = 0x%p i_data = 0x%lx nrpages = %lu\n",
+ inode->i_sb, inode->i_op,
+ addr + offsetof(struct inode, i_data),
+ inode->i_data.nrpages);
+ kdb_printf(" i_fop= 0x%p i_flock = 0x%p i_mapping = 0x%p\n",
+ inode->i_fop, inode->i_flock, inode->i_mapping);
+
+ kdb_printf(" i_flags 0x%x i_state 0x%lx [%s]",
+ inode->i_flags, inode->i_state,
+ map_flags(inode->i_state, inode_flag_vals));
+
+ iaddr = (char *)addr;
+ iaddr += offsetof(struct inode, i_private);
+
+ kdb_printf(" fs specific info @ 0x%p\n", iaddr);
+out:
+ if (inode)
+ kfree(inode);
+ return diag;
+}
+
+static int
+kdbm_sb(int argc, const char **argv)
+{
+ struct super_block *sb = NULL;
+ unsigned long addr;
+ long offset = 0;
+ int nextarg;
+ int diag;
+
+ if (argc != 1)
+ return KDB_ARGCOUNT;
+
+ nextarg = 1;
+ if ((diag = kdbgetaddrarg(argc, argv, &nextarg, &addr, &offset, NULL)))
+ goto out;
+ if (!(sb = kmalloc(sizeof(*sb), GFP_ATOMIC))) {
+ kdb_printf("kdbm_sb: cannot kmalloc sb\n");
+ goto out;
+ }
+ if ((diag = kdb_getarea(*sb, addr)))
+ goto out;
+
+ kdb_printf("struct super_block at 0x%lx\n", addr);
+ kdb_printf(" s_dev 0x%x blocksize 0x%lx\n", sb->s_dev, sb->s_blocksize);
+ kdb_printf(" s_flags 0x%lx s_root 0x%p\n", sb->s_flags, sb->s_root);
+ kdb_printf(" s_dirt %d s_dirty.next 0x%p s_dirty.prev 0x%p\n",
+ sb->s_dirt, sb->s_dirty.next, sb->s_dirty.prev);
+ kdb_printf(" s_frozen %d s_id [%s]\n", sb->s_frozen, sb->s_id);
+out:
+ if (sb)
+ kfree(sb);
+ return diag;
+}
+
+
+#if !defined(CONFIG_DISCONTIGMEM) && !defined(CONFIG_NUMA)
+/* According to Steve Lord, this code is ix86 specific. Patches to extend it to
+ * other architectures will be greatefully accepted.
+ */
+static int
+kdbm_memmap(int argc, const char **argv)
+{
+ struct page page;
+ int i, page_count;
+ int slab_count = 0;
+ int dirty_count = 0;
+ int locked_count = 0;
+ int page_counts[9];
+ int buffered_count = 0;
+#ifdef buffer_delay
+ int delay_count = 0;
+#endif
+ int diag;
+ unsigned long addr;
+
+ addr = (unsigned long)mem_map;
+ page_count = max_mapnr;
+ memset(page_counts, 0, sizeof(page_counts));
+
+ for (i = 0; i < page_count; i++) {
+ if ((diag = kdb_getarea(page, addr)))
+ return(diag);
+ addr += sizeof(page);
+
+ if (PageSlab(&page))
+ slab_count++;
+ if (PageDirty(&page))
+ dirty_count++;
+ if (PageLocked(&page))
+ locked_count++;
+ if (page._count.counter < 8)
+ page_counts[page._count.counter]++;
+ else
+ page_counts[8]++;
+ if (page_has_buffers(&page)) {
+ buffered_count++;
+#ifdef buffer_delay
+ if (buffer_delay(page.buffers))
+ delay_count++;
+#endif
+ }
+
+ }
+
+ kdb_printf(" Total pages: %6d\n", page_count);
+ kdb_printf(" Slab pages: %6d\n", slab_count);
+ kdb_printf(" Dirty pages: %6d\n", dirty_count);
+ kdb_printf(" Locked pages: %6d\n", locked_count);
+ kdb_printf(" Buffer pages: %6d\n", buffered_count);
+#ifdef buffer_delay
+ kdb_printf(" Delalloc pages: %6d\n", delay_count);
+#endif
+ for (i = 0; i < 8; i++) {
+ kdb_printf(" %d page count: %6d\n",
+ i, page_counts[i]);
+ }
+ kdb_printf(" high page count: %6d\n", page_counts[8]);
+ return 0;
+}
+#endif /* !CONFIG_DISCONTIGMEM && !NUMA */
+
+static int __init kdbm_pg_init(void)
+{
+#if !defined(CONFIG_DISCONTIGMEM) && !defined(CONFIG_NUMA)
+ kdb_register("page", kdbm_page, "<vaddr>", "Display page", 0);
+#endif
+ kdb_register("inode", kdbm_inode, "<vaddr>", "Display inode", 0);
+ kdb_register("sb", kdbm_sb, "<vaddr>", "Display super_block", 0);
+ kdb_register("bh", kdbm_buffers, "<buffer head address>", "Display buffer", 0);
+ kdb_register("bio", kdbm_bio, "<bio address>", "Display bio", 0);
+ kdb_register("inode_pages", kdbm_inode_pages, "<inode *>", "Display pages in an inode", 0);
+ kdb_register("req", kdbm_request, "<vaddr>", "dump request struct", 0);
+ kdb_register("rqueue", kdbm_rqueue, "<vaddr>", "dump request queue", 0);
+#if !defined(CONFIG_DISCONTIGMEM) && !defined(CONFIG_NUMA)
+ kdb_register("memmap", kdbm_memmap, "", "page table summary", 0);
+#endif
+
+ return 0;
+}
+
+
+static void __exit kdbm_pg_exit(void)
+{
+#if !defined(CONFIG_DISCONTIGMEM) && !defined(CONFIG_NUMA)
+ kdb_unregister("page");
+#endif
+ kdb_unregister("inode");
+ kdb_unregister("sb");
+ kdb_unregister("bh");
+ kdb_unregister("bio");
+ kdb_unregister("inode_pages");
+ kdb_unregister("req");
+ kdb_unregister("rqueue");
+#if !defined(CONFIG_DISCONTIGMEM) && !defined(CONFIG_NUMA)
+ kdb_unregister("memmap");
+#endif
+}
+
+module_init(kdbm_pg_init)
+module_exit(kdbm_pg_exit)
Index: linux/kdb/modules/kdbm_sched.c
===================================================================
--- /dev/null
+++ linux/kdb/modules/kdbm_sched.c
@@ -0,0 +1,57 @@
+/*
+ * This file is subject to the terms and conditions of the GNU General Public
+ * License. See the file "COPYING" in the main directory of this archive
+ * for more details.
+ *
+ * Copyright (c) 2005 Silicon Graphics, Inc. All Rights Reserved.
+ */
+
+#include <linux/kdb.h>
+#include <linux/kdbprivate.h>
+#include <linux/module.h>
+#include <linux/init.h>
+#include <linux/sched.h>
+
+MODULE_AUTHOR("SGI");
+MODULE_DESCRIPTION("Debug scheduler information");
+MODULE_LICENSE("GPL");
+
+static int
+kdbm_runqueues(int argc, const char **argv)
+{
+ unsigned long cpu;
+ int ret = 0;
+
+ if (argc == 1) {
+ ret = kdbgetularg((char *)argv[1], &cpu);
+ if (!ret) {
+ if (!cpu_online(cpu)) {
+ kdb_printf("Invalid cpu number\n");
+ } else
+ kdb_runqueue(cpu, kdb_printf);
+ }
+ } else if (argc == 0) {
+ for_each_online_cpu(cpu)
+ kdb_runqueue(cpu, kdb_printf);
+ } else {
+ /* More than one arg */
+ kdb_printf("Specify one cpu number\n");
+ }
+ return ret;
+}
+
+static int __init kdbm_sched_init(void)
+{
+ kdb_register("rq", kdbm_runqueues, "<cpunum>", "Display runqueue for <cpunum>", 0);
+ kdb_register("rqa", kdbm_runqueues, "", "Display all runqueues", 0);
+ return 0;
+}
+
+static void __exit kdbm_sched_exit(void)
+{
+ kdb_unregister("rq");
+ kdb_unregister("rqa");
+}
+
+module_init(kdbm_sched_init)
+module_exit(kdbm_sched_exit)
Index: linux/kdb/modules/kdbm_task.c
===================================================================
--- /dev/null
+++ linux/kdb/modules/kdbm_task.c
@@ -0,0 +1,199 @@
+/*
+ * This file is subject to the terms and conditions of the GNU General Public
+ * License. See the file "COPYING" in the main directory of this archive
+ * for more details.
+ *
+ * Copyright (c) 1999-2006 Silicon Graphics, Inc. All Rights Reserved.
+ */
+
+#include <linux/blkdev.h>
+#include <linux/types.h>
+#include <linux/kdb.h>
+#include <linux/kdbprivate.h>
+#include <linux/module.h>
+#include <linux/init.h>
+#include <linux/mm.h>
+#include <linux/sched.h>
+#include <asm/signal.h>
+
+MODULE_AUTHOR("SGI");
+MODULE_DESCRIPTION("Debug struct task and sigset information");
+MODULE_LICENSE("GPL");
+
+static char *
+kdb_cpus_allowed_string(struct task_struct *tp)
+{
+ static char maskbuf[NR_CPUS * 8];
+ if (cpus_equal(tp->cpus_allowed, cpu_online_map))
+ strcpy(maskbuf, "ALL");
+ else if (cpus_full(tp->cpus_allowed))
+ strcpy(maskbuf, "ALL(NR_CPUS)");
+ else if (cpus_empty(tp->cpus_allowed))
+ strcpy(maskbuf, "NONE");
+ else if (cpus_weight(tp->cpus_allowed) == 1)
+ snprintf(maskbuf, sizeof(maskbuf), "ONLY(%d)", first_cpu(tp->cpus_allowed));
+ else
+ cpulist_scnprintf(maskbuf, sizeof(maskbuf), tp->cpus_allowed);
+ return maskbuf;
+}
+
+static int
+kdbm_task(int argc, const char **argv)
+{
+ unsigned long addr;
+ long offset=0;
+ int nextarg;
+ int e = 0;
+ struct task_struct *tp = NULL, *tp1;
+
+ if (argc != 1)
+ return KDB_ARGCOUNT;
+
+ nextarg = 1;
+ if ((e = kdbgetaddrarg(argc, argv, &nextarg, &addr, &offset, NULL)) != 0)
+ return(e);
+
+ if (!(tp = kmalloc(sizeof(*tp), GFP_ATOMIC))) {
+ kdb_printf("%s: cannot kmalloc tp\n", __FUNCTION__);
+ goto out;
+ }
+ if ((e = kdb_getarea(*tp, addr))) {
+ kdb_printf("%s: invalid task address\n", __FUNCTION__);
+ goto out;
+ }
+
+ tp1 = (struct task_struct *)addr;
+ kdb_printf(
+ "struct task at 0x%lx, pid=%d flags=0x%x state=%ld comm=\"%s\"\n",
+ addr, tp->pid, tp->flags, tp->state, tp->comm);
+
+ kdb_printf(" cpu=%d policy=%u ", kdb_process_cpu(tp), tp->policy);
+ kdb_printf(
+ "prio=%d static_prio=%d cpus_allowed=",
+ tp->prio, tp->static_prio);
+ {
+ /* The cpus allowed string may be longer than kdb_printf() can
+ * handle. Print it in chunks.
+ */
+ char c, *p;
+ p = kdb_cpus_allowed_string(tp);
+ while (1) {
+ if (strlen(p) < 100) {
+ kdb_printf("%s", p);
+ break;
+ }
+ c = p[100];
+ p[100] = '\0';
+ kdb_printf("%s", p);
+ p[100] = c;
+ p += 100;
+ }
+ }
+ kdb_printf(" &thread=0x%p\n", &tp1->thread);
+
+ kdb_printf(" need_resched=%d ",
+ test_tsk_thread_flag(tp, TIF_NEED_RESCHED));
+ kdb_printf(
+ "time_slice=%u",
+ tp->rt.time_slice);
+ kdb_printf(" lock_depth=%d\n", tp->lock_depth);
+
+ kdb_printf(
+ " fs=0x%p files=0x%p mm=0x%p\n",
+ tp->fs, tp->files, tp->mm);
+
+ kdb_printf(
+ " uid=%d euid=%d suid=%d fsuid=%d gid=%d egid=%d sgid=%d fsgid=%d\n",
+ tp->uid, tp->euid, tp->suid, tp->fsuid, tp->gid, tp->egid, tp->sgid, tp->fsgid);
+
+ kdb_printf(
+ " user=0x%p\n",
+ tp->user);
+
+ if (tp->sysvsem.undo_list)
+ kdb_printf(
+ " sysvsem.sem_undo refcnt %d proc_list=0x%p\n",
+ atomic_read(&tp->sysvsem.undo_list->refcnt),
+ tp->sysvsem.undo_list->proc_list);
+
+ kdb_printf(
+ " signal=0x%p &blocked=0x%p &pending=0x%p\n",
+ tp->signal, &tp1->blocked, &tp1->pending);
+
+ kdb_printf(
+ " utime=%ld stime=%ld cutime=%ld cstime=%ld\n",
+ tp->utime, tp->stime,
+ tp->signal ? tp->signal->cutime : 0L,
+ tp->signal ? tp->signal->cstime : 0L);
+
+ kdb_printf(" thread_info=0x%p\n", task_thread_info(tp));
+ kdb_printf(" ti flags=0x%lx\n", (unsigned long)task_thread_info(tp)->flags);
+
+out:
+ if (tp)
+ kfree(tp);
+ return e;
+}
+
+static int
+kdbm_sigset(int argc, const char **argv)
+{
+ sigset_t *sp = NULL;
+ unsigned long addr;
+ long offset=0;
+ int nextarg;
+ int e = 0;
+ int i;
+ char fmt[32];
+
+ if (argc != 1)
+ return KDB_ARGCOUNT;
+
+#ifndef _NSIG_WORDS
+ kdb_printf("unavailable on this platform, _NSIG_WORDS not defined.\n");
+#else
+ nextarg = 1;
+ if ((e = kdbgetaddrarg(argc, argv, &nextarg, &addr, &offset, NULL)) != 0)
+ return(e);
+
+ if (!(sp = kmalloc(sizeof(*sp), GFP_ATOMIC))) {
+ kdb_printf("%s: cannot kmalloc sp\n", __FUNCTION__);
+ goto out;
+ }
+ if ((e = kdb_getarea(*sp, addr))) {
+ kdb_printf("%s: invalid sigset address\n", __FUNCTION__);
+ goto out;
+ }
+
+ sprintf(fmt, "[%%d]=0x%%0%dlx ", (int)sizeof(sp->sig[0])*2);
+ kdb_printf("sigset at 0x%p : ", sp);
+ for (i=_NSIG_WORDS-1; i >= 0; i--) {
+ if (i == 0 || sp->sig[i]) {
+ kdb_printf(fmt, i, sp->sig[i]);
+ }
+ }
+ kdb_printf("\n");
+#endif /* _NSIG_WORDS */
+
+out:
+ if (sp)
+ kfree(sp);
+ return e;
+}
+
+static int __init kdbm_task_init(void)
+{
+ kdb_register("task", kdbm_task, "<vaddr>", "Display task_struct", 0);
+ kdb_register("sigset", kdbm_sigset, "<vaddr>", "Display sigset_t", 0);
+
+ return 0;
+}
+
+static void __exit kdbm_task_exit(void)
+{
+ kdb_unregister("task");
+ kdb_unregister("sigset");
+}
+
+module_init(kdbm_task_init)
+module_exit(kdbm_task_exit)
Index: linux/kdb/modules/kdbm_vm.c
===================================================================
--- /dev/null
+++ linux/kdb/modules/kdbm_vm.c
@@ -0,0 +1,843 @@
+/*
+ * This file is subject to the terms and conditions of the GNU General Public
+ * License. See the file "COPYING" in the main directory of this archive
+ * for more details.
+ *
+ * Copyright (c) 1999-2006 Silicon Graphics, Inc. All Rights Reserved.
+ */
+
+#include <linux/blkdev.h>
+#include <linux/types.h>
+#include <linux/kdb.h>
+#include <linux/kdbprivate.h>
+#include <linux/module.h>
+#include <linux/init.h>
+#include <linux/mm.h>
+#include <linux/swap.h>
+#include <linux/swapops.h>
+
+#include <scsi.h>
+#include <scsi/scsi_host.h>
+
+MODULE_AUTHOR("SGI");
+MODULE_DESCRIPTION("Debug VM information");
+MODULE_LICENSE("GPL");
+
+struct __vmflags {
+ unsigned long mask;
+ char *name;
+};
+
+static struct __vmflags vmflags[] = {
+ { VM_READ, "VM_READ " },
+ { VM_WRITE, "VM_WRITE " },
+ { VM_EXEC, "VM_EXEC " },
+ { VM_SHARED, "VM_SHARED " },
+ { VM_MAYREAD, "VM_MAYREAD " },
+ { VM_MAYWRITE, "VM_MAYWRITE " },
+ { VM_MAYEXEC, "VM_MAYEXEC " },
+ { VM_MAYSHARE, "VM_MAYSHARE " },
+ { VM_GROWSDOWN, "VM_GROWSDOWN " },
+ { VM_GROWSUP, "VM_GROWSUP " },
+ { VM_PFNMAP, "VM_PFNMAP " },
+ { VM_DENYWRITE, "VM_DENYWRITE " },
+ { VM_EXECUTABLE, "VM_EXECUTABLE " },
+ { VM_LOCKED, "VM_LOCKED " },
+ { VM_IO, "VM_IO " },
+ { VM_SEQ_READ, "VM_SEQ_READ " },
+ { VM_RAND_READ, "VM_RAND_READ " },
+ { VM_DONTCOPY, "VM_DONTCOPY " },
+ { VM_DONTEXPAND, "VM_DONTEXPAND " },
+ { VM_RESERVED, "VM_RESERVED " },
+ { VM_ACCOUNT, "VM_ACCOUNT " },
+ { VM_HUGETLB, "VM_HUGETLB " },
+ { VM_NONLINEAR, "VM_NONLINEAR " },
+ { VM_MAPPED_COPY, "VM_MAPPED_COPY " },
+ { VM_INSERTPAGE, "VM_INSERTPAGE " },
+ { 0, "" }
+};
+
+static int
+kdbm_print_vm(struct vm_area_struct *vp, unsigned long addr, int verbose_flg)
+{
+ struct __vmflags *tp;
+
+ kdb_printf("struct vm_area_struct at 0x%lx for %d bytes\n",
+ addr, (int) sizeof (struct vm_area_struct));
+
+ kdb_printf("vm_start = 0x%p vm_end = 0x%p\n", (void *) vp->vm_start,
+ (void *) vp->vm_end);
+ kdb_printf("vm_page_prot = 0x%lx\n", pgprot_val(vp->vm_page_prot));
+
+ kdb_printf("vm_flags: ");
+ for (tp = vmflags; tp->mask; tp++) {
+ if (vp->vm_flags & tp->mask) {
+ kdb_printf(" %s", tp->name);
+ }
+ }
+ kdb_printf("\n");
+
+ if (!verbose_flg)
+ return 0;
+
+ kdb_printf("vm_mm = 0x%p\n", (void *) vp->vm_mm);
+ kdb_printf("vm_next = 0x%p\n", (void *) vp->vm_next);
+ kdb_printf("shared.vm_set.list.next = 0x%p\n", (void *) vp->shared.vm_set.list.next);
+ kdb_printf("shared.vm_set.list.prev = 0x%p\n", (void *) vp->shared.vm_set.list.prev);
+ kdb_printf("shared.vm_set.parent = 0x%p\n", (void *) vp->shared.vm_set.parent);
+ kdb_printf("shared.vm_set.head = 0x%p\n", (void *) vp->shared.vm_set.head);
+ kdb_printf("anon_vma_node.next = 0x%p\n", (void *) vp->anon_vma_node.next);
+ kdb_printf("anon_vma_node.prev = 0x%p\n", (void *) vp->anon_vma_node.prev);
+ kdb_printf("vm_ops = 0x%p\n", (void *) vp->vm_ops);
+ if (vp->vm_ops != NULL) {
+ kdb_printf("vm_ops->open = 0x%p\n", vp->vm_ops->open);
+ kdb_printf("vm_ops->close = 0x%p\n", vp->vm_ops->close);
+ kdb_printf("vm_ops->nopage = 0x%p\n", vp->vm_ops->nopage);
+#ifdef HAVE_VMOP_MPROTECT
+ kdb_printf("vm_ops->mprotect = 0x%p\n", vp->vm_ops->mprotect);
+#endif
+ }
+ kdb_printf("vm_pgoff = 0x%lx\n", vp->vm_pgoff);
+ kdb_printf("vm_file = 0x%p\n", (void *) vp->vm_file);
+ kdb_printf("vm_private_data = 0x%p\n", vp->vm_private_data);
+
+ return 0;
+}
+
+static int
+kdbm_print_vmp(struct vm_area_struct *vp, int verbose_flg)
+{
+ struct __vmflags *tp;
+
+ if (verbose_flg) {
+ kdb_printf("0x%lx: ", (unsigned long) vp);
+ }
+
+ kdb_printf("0x%p 0x%p ", (void *) vp->vm_start, (void *) vp->vm_end);
+
+ for (tp = vmflags; tp->mask; tp++) {
+ if (vp->vm_flags & tp->mask) {
+ kdb_printf(" %s", tp->name);
+ }
+ }
+ kdb_printf("\n");
+
+ return 0;
+}
+
+/*
+ * kdbm_vm
+ *
+ * This function implements the 'vm' command. Print a vm_area_struct.
+ *
+ * vm [-v] <address> Print vm_area_struct at <address>
+ * vmp [-v] <pid> Print all vm_area_structs for <pid>
+ */
+
+static int
+kdbm_vm(int argc, const char **argv)
+{
+ unsigned long addr;
+ long offset = 0;
+ int nextarg;
+ int diag;
+ int verbose_flg = 0;
+
+ if (argc == 2) {
+ if (strcmp(argv[1], "-v") != 0) {
+ return KDB_ARGCOUNT;
+ }
+ verbose_flg = 1;
+ } else if (argc != 1) {
+ return KDB_ARGCOUNT;
+ }
+
+ if (strcmp(argv[0], "vmp") == 0) {
+ struct task_struct *g, *tp;
+ struct vm_area_struct *vp;
+ pid_t pid;
+
+ if ((diag = kdbgetularg(argv[argc], (unsigned long *) &pid)))
+ return diag;
+
+ kdb_do_each_thread(g, tp) {
+ if (tp->pid == pid) {
+ if (tp->mm != NULL) {
+ if (verbose_flg)
+ kdb_printf
+ ("vm_area_struct ");
+ kdb_printf
+ ("vm_start vm_end vm_flags\n");
+ vp = tp->mm->mmap;
+ while (vp != NULL) {
+ kdbm_print_vmp(vp, verbose_flg);
+ vp = vp->vm_next;
+ }
+ }
+ return 0;
+ }
+ } kdb_while_each_thread(g, tp);
+
+ kdb_printf("No process with pid == %d found\n", pid);
+
+ } else {
+ struct vm_area_struct v;
+
+ nextarg = argc;
+ if ((diag = kdbgetaddrarg(argc, argv, &nextarg, &addr, &offset,
+ NULL))
+ || (diag = kdb_getarea(v, addr)))
+ return (diag);
+
+ kdbm_print_vm(&v, addr, verbose_flg);
+ }
+
+ return 0;
+}
+
+static int
+kdbm_print_pte(pte_t * pte)
+{
+ kdb_printf("0x%lx (", (unsigned long) pte_val(*pte));
+
+ if (pte_present(*pte)) {
+#ifdef pte_exec
+ if (pte_exec(*pte))
+ kdb_printf("X");
+#endif
+ if (pte_write(*pte))
+ kdb_printf("W");
+#ifdef pte_read
+ if (pte_read(*pte))
+ kdb_printf("R");
+#endif
+ if (pte_young(*pte))
+ kdb_printf("A");
+ if (pte_dirty(*pte))
+ kdb_printf("D");
+
+ } else {
+ kdb_printf("OFFSET=0x%lx ", swp_offset(pte_to_swp_entry(*pte)));
+ kdb_printf("TYPE=0x%ulx", swp_type(pte_to_swp_entry(*pte)));
+ }
+
+ kdb_printf(")");
+
+ /* final newline is output by caller of kdbm_print_pte() */
+
+ return 0;
+}
+
+/*
+ * kdbm_pte
+ *
+ * This function implements the 'pte' command. Print all pte_t structures
+ * that map to the given virtual address range (<address> through <address>
+ * plus <nbytes>) for the given process. The default value for nbytes is
+ * one.
+ *
+ * pte -m <mm> <address> [<nbytes>] Print all pte_t structures for
+ * virtual <address> in address space
+ * of <mm> which is a pointer to a
+ * mm_struct
+ * pte -p <pid> <address> [<nbytes>] Print all pte_t structures for
+ * virtual <address> in address space
+ * of <pid>
+ */
+
+static int
+kdbm_pte(int argc, const char **argv)
+{
+ unsigned long addr;
+ long offset = 0;
+ int nextarg;
+ unsigned long nbytes = 1;
+ long npgs;
+ int diag;
+ int found;
+ pid_t pid;
+ struct task_struct *tp;
+ struct mm_struct *mm, copy_of_mm;
+ pgd_t *pgd;
+ pud_t *pud;
+ pmd_t *pmd;
+ pte_t *pte;
+
+ if (argc < 3 || argc > 4) {
+ return KDB_ARGCOUNT;
+ }
+
+ if (strcmp(argv[1], "-p") == 0) {
+ if ((diag = kdbgetularg(argv[2], (unsigned long *) &pid))) {
+ return diag;
+ }
+
+ found = 0;
+ for_each_process(tp) {
+ if (tp->pid == pid) {
+ if (tp->mm != NULL) {
+ found = 1;
+ break;
+ }
+ kdb_printf("task structure's mm field is NULL\n");
+ return 0;
+ }
+ }
+
+ if (!found) {
+ kdb_printf("No process with pid == %d found\n", pid);
+ return 0;
+ }
+ mm = tp->mm;
+ } else if (strcmp(argv[1], "-m") == 0) {
+
+
+ nextarg = 2;
+ if ((diag = kdbgetaddrarg(argc, argv, &nextarg, &addr, &offset,
+ NULL))
+ || (diag = kdb_getarea(copy_of_mm, addr)))
+ return (diag);
+ mm = ©_of_mm;
+ } else {
+ return KDB_ARGCOUNT;
+ }
+
+ if ((diag = kdbgetularg(argv[3], &addr))) {
+ return diag;
+ }
+
+ if (argc == 4) {
+ if ((diag = kdbgetularg(argv[4], &nbytes))) {
+ return diag;
+ }
+ }
+
+ kdb_printf("vaddr pte\n");
+
+ npgs = ((((addr & ~PAGE_MASK) + nbytes) + ~PAGE_MASK) >> PAGE_SHIFT);
+ while (npgs-- > 0) {
+
+ kdb_printf("0x%p ", (void *) (addr & PAGE_MASK));
+
+ pgd = pgd_offset(mm, addr);
+ if (pgd_present(*pgd)) {
+ pud = pud_offset(pgd, addr);
+ if (pud_present(*pud)) {
+ pmd = pmd_offset(pud, addr);
+ if (pmd_present(*pmd)) {
+ pte = pte_offset_map(pmd, addr);
+ if (pte_present(*pte)) {
+ kdbm_print_pte(pte);
+ }
+ }
+ }
+ }
+
+ kdb_printf("\n");
+ addr += PAGE_SIZE;
+ }
+
+ return 0;
+}
+
+/*
+ * kdbm_rpte
+ *
+ * This function implements the 'rpte' command. Print all pte_t structures
+ * that contain the given physical page range (<pfn> through <pfn>
+ * plus <npages>) for the given process. The default value for npages is
+ * one.
+ *
+ * rpte -m <mm> <pfn> [<npages>] Print all pte_t structures for
+ * physical page <pfn> in address space
+ * of <mm> which is a pointer to a
+ * mm_struct
+ * rpte -p <pid> <pfn> [<npages>] Print all pte_t structures for
+ * physical page <pfn> in address space
+ * of <pid>
+ */
+
+static int
+kdbm_rpte(int argc, const char **argv)
+{
+ unsigned long addr;
+ unsigned long pfn;
+ long offset = 0;
+ int nextarg;
+ unsigned long npages = 1;
+ int diag;
+ int found;
+ pid_t pid;
+ struct task_struct *tp;
+ struct mm_struct *mm, copy_of_mm;
+ pgd_t *pgd;
+ pud_t *pud;
+ pmd_t *pmd;
+ pte_t *pte;
+ unsigned long g, u, m, t;
+
+ if (argc < 3 || argc > 4) {
+ return KDB_ARGCOUNT;
+ }
+
+ if (strcmp(argv[1], "-p") == 0) {
+ if ((diag = kdbgetularg(argv[2], (unsigned long *) &pid))) {
+ return diag;
+ }
+
+ found = 0;
+ for_each_process(tp) {
+ if (tp->pid == pid) {
+ if (tp->mm != NULL) {
+ found = 1;
+ break;
+ }
+ kdb_printf("task structure's mm field is NULL\n");
+ return 0;
+ }
+ }
+
+ if (!found) {
+ kdb_printf("No process with pid == %d found\n", pid);
+ return 0;
+ }
+ mm = tp->mm;
+ } else if (strcmp(argv[1], "-m") == 0) {
+
+
+ nextarg = 2;
+ if ((diag = kdbgetaddrarg(argc, argv, &nextarg, &addr, &offset,
+ NULL))
+ || (diag = kdb_getarea(copy_of_mm, addr)))
+ return (diag);
+ mm = ©_of_mm;
+ } else {
+ return KDB_ARGCOUNT;
+ }
+
+ if ((diag = kdbgetularg(argv[3], &pfn))) {
+ return diag;
+ }
+
+ if (argc == 4) {
+ if ((diag = kdbgetularg(argv[4], &npages))) {
+ return diag;
+ }
+ }
+
+ /* spaces after vaddr depends on sizeof(unsigned long) */
+ kdb_printf("pfn vaddr%*s pte\n",
+ (int)(2*sizeof(unsigned long) + 2 - 5), " ");
+
+ for (g = 0, pgd = pgd_offset(mm, 0UL); g < PTRS_PER_PGD; ++g, ++pgd) {
+ if (pgd_none(*pgd) || pgd_bad(*pgd))
+ continue;
+ for (u = 0, pud = pud_offset(pgd, 0UL); u < PTRS_PER_PUD; ++u, ++pud) {
+ if (pud_none(*pud) || pud_bad(*pud))
+ continue;
+ for (m = 0, pmd = pmd_offset(pud, 0UL); m < PTRS_PER_PMD; ++m, ++pmd) {
+ if (pmd_none(*pmd) || pmd_bad(*pmd))
+ continue;
+ for (t = 0, pte = pte_offset_map(pmd, 0UL); t < PTRS_PER_PTE; ++t, ++pte) {
+ if (pte_none(*pte))
+ continue;
+ if (pte_pfn(*pte) < pfn || pte_pfn(*pte) >= (pfn + npages))
+ continue;
+ addr = g << PGDIR_SHIFT;
+#ifdef __ia64__
+ /* IA64 plays tricks with the pgd mapping to save space.
+ * This reverses pgd_index().
+ */
+ {
+ unsigned long region = g >> (PAGE_SHIFT - 6);
+ unsigned long l1index = g - (region << (PAGE_SHIFT - 6));
+ addr = (region << 61) + (l1index << PGDIR_SHIFT);
+ }
+#endif
+ addr += (m << PMD_SHIFT) + (t << PAGE_SHIFT);
+ kdb_printf("0x%-14lx " kdb_bfd_vma_fmt0 " ",
+ pte_pfn(*pte), addr);
+ kdbm_print_pte(pte);
+ kdb_printf("\n");
+ }
+ }
+ }
+ }
+
+ return 0;
+}
+
+static int
+kdbm_print_dentry(unsigned long daddr)
+{
+ struct dentry d;
+ int diag;
+ char buf[256];
+
+ kdb_printf("Dentry at 0x%lx\n", daddr);
+ if ((diag = kdb_getarea(d, (unsigned long)daddr)))
+ return diag;
+
+ if ((d.d_name.len > sizeof(buf)) || (diag = kdb_getarea_size(buf, (unsigned long)(d.d_name.name), d.d_name.len)))
+ kdb_printf(" d_name.len = %d d_name.name = 0x%p\n",
+ d.d_name.len, d.d_name.name);
+ else
+ kdb_printf(" d_name.len = %d d_name.name = 0x%p <%.*s>\n",
+ d.d_name.len, d.d_name.name,
+ (int)(d.d_name.len), d.d_name.name);
+
+ kdb_printf(" d_count = %d d_flags = 0x%x d_inode = 0x%p\n",
+ atomic_read(&d.d_count), d.d_flags, d.d_inode);
+
+ kdb_printf(" d_parent = 0x%p\n", d.d_parent);
+
+ kdb_printf(" d_hash.nxt = 0x%p d_hash.prv = 0x%p\n",
+ d.d_hash.next, d.d_hash.pprev);
+
+ kdb_printf(" d_lru.nxt = 0x%p d_lru.prv = 0x%p\n",
+ d.d_lru.next, d.d_lru.prev);
+
+ kdb_printf(" d_child.nxt = 0x%p d_child.prv = 0x%p\n",
+ d.d_u.d_child.next, d.d_u.d_child.prev);
+
+ kdb_printf(" d_subdirs.nxt = 0x%p d_subdirs.prv = 0x%p\n",
+ d.d_subdirs.next, d.d_subdirs.prev);
+
+ kdb_printf(" d_alias.nxt = 0x%p d_alias.prv = 0x%p\n",
+ d.d_alias.next, d.d_alias.prev);
+
+ kdb_printf(" d_op = 0x%p d_sb = 0x%p d_fsdata = 0x%p\n",
+ d.d_op, d.d_sb, d.d_fsdata);
+
+ kdb_printf(" d_iname = %s\n",
+ d.d_iname);
+
+ if (d.d_inode) {
+ struct inode i;
+ kdb_printf("\nInode Entry at 0x%p\n", d.d_inode);
+ if ((diag = kdb_getarea(i, (unsigned long)d.d_inode)))
+ return diag;
+ kdb_printf(" i_mode = 0%o i_nlink = %d i_rdev = 0x%x\n",
+ i.i_mode, i.i_nlink, i.i_rdev);
+
+ kdb_printf(" i_ino = %ld i_count = %d\n",
+ i.i_ino, atomic_read(&i.i_count));
+
+ kdb_printf(" i_hash.nxt = 0x%p i_hash.prv = 0x%p\n",
+ i.i_hash.next, i.i_hash.pprev);
+
+ kdb_printf(" i_list.nxt = 0x%p i_list.prv = 0x%p\n",
+ i.i_list.next, i.i_list.prev);
+
+ kdb_printf(" i_dentry.nxt = 0x%p i_dentry.prv = 0x%p\n",
+ i.i_dentry.next, i.i_dentry.prev);
+
+ }
+ kdb_printf("\n");
+ return 0;
+}
+
+static int
+kdbm_filp(int argc, const char **argv)
+{
+ struct file f;
+ int nextarg;
+ unsigned long addr;
+ long offset;
+ int diag;
+
+ if (argc != 1)
+ return KDB_ARGCOUNT;
+
+ nextarg = 1;
+ if ((diag = kdbgetaddrarg(argc, argv, &nextarg, &addr, &offset, NULL)) ||
+ (diag = kdb_getarea(f, addr)))
+ return diag;
+
+ kdb_printf("File Pointer at 0x%lx\n", addr);
+
+ kdb_printf(" fu_list.nxt = 0x%p fu_list.prv = 0x%p\n",
+ f.f_u.fu_list.next, f.f_u.fu_list.prev);
+
+ kdb_printf(" f_dentry = 0x%p f_vfsmnt = 0x%p f_op = 0x%p\n",
+ f.f_dentry, f.f_vfsmnt, f.f_op);
+
+ kdb_printf(" f_count = %d f_flags = 0x%x f_mode = 0x%x\n",
+ atomic_read(&f.f_count), f.f_flags, f.f_mode);
+
+ kdb_printf(" f_pos = %Ld\n", f.f_pos);
+#ifdef CONFIG_SECURITY
+ kdb_printf(" security = 0x%p\n", f.f_security);
+#endif
+
+ kdb_printf(" private_data = 0x%p f_mapping = 0x%p\n\n",
+ f.private_data, f.f_mapping);
+
+ return kdbm_print_dentry((unsigned long)f.f_dentry);
+}
+
+static int
+kdbm_fl(int argc, const char **argv)
+{
+ struct file_lock fl;
+ int nextarg;
+ unsigned long addr;
+ long offset;
+ int diag;
+
+
+ if (argc != 1)
+ return KDB_ARGCOUNT;
+
+ nextarg = 1;
+ if ((diag = kdbgetaddrarg(argc, argv, &nextarg, &addr, &offset, NULL)) ||
+ (diag = kdb_getarea(fl, addr)))
+ return diag;
+
+ kdb_printf("File_lock at 0x%lx\n", addr);
+
+ kdb_printf(" fl_next = 0x%p fl_link.nxt = 0x%p fl_link.prv = 0x%p\n",
+ fl.fl_next, fl.fl_link.next, fl.fl_link.prev);
+ kdb_printf(" fl_block.nxt = 0x%p fl_block.prv = 0x%p\n",
+ fl.fl_block.next, fl.fl_block.prev);
+ kdb_printf(" fl_owner = 0x%p fl_pid = %d fl_wait = 0x%p\n",
+ fl.fl_owner, fl.fl_pid, &fl.fl_wait);
+ kdb_printf(" fl_file = 0x%p fl_flags = 0x%x\n",
+ fl.fl_file, fl.fl_flags);
+ kdb_printf(" fl_type = %d fl_start = 0x%llx fl_end = 0x%llx\n",
+ fl.fl_type, fl.fl_start, fl.fl_end);
+
+ kdb_printf(" file_lock_operations");
+ if (fl.fl_ops)
+ kdb_printf("\n fl_insert = 0x%p fl_remove = 0x%p fl_copy_lock = 0x%p fl_release_private = 0x%p\n",
+ fl.fl_ops->fl_insert, fl.fl_ops->fl_remove,
+ fl.fl_ops->fl_copy_lock, fl.fl_ops->fl_release_private);
+ else
+ kdb_printf(" empty\n");
+
+ kdb_printf(" lock_manager_operations");
+ if (fl.fl_lmops)
+ kdb_printf("\n fl_compare_owner = 0x%p fl_notify = 0x%p\n",
+ fl.fl_lmops->fl_compare_owner, fl.fl_lmops->fl_notify);
+ else
+ kdb_printf(" empty\n");
+
+ kdb_printf(" fl_fasync = 0x%p fl_break 0x%lx\n",
+ fl.fl_fasync, fl.fl_break_time);
+
+ return 0;
+}
+
+
+static int
+kdbm_dentry(int argc, const char **argv)
+{
+ int nextarg;
+ unsigned long addr;
+ long offset;
+ int diag;
+
+ if (argc != 1)
+ return KDB_ARGCOUNT;
+
+ nextarg = 1;
+ if ((diag = kdbgetaddrarg(argc, argv, &nextarg, &addr, &offset, NULL)))
+ return diag;
+
+ return kdbm_print_dentry(addr);
+}
+
+static int
+kdbm_kobject(int argc, const char **argv)
+{
+ struct kobject k;
+ int nextarg;
+ unsigned long addr;
+ long offset;
+ int diag;
+
+ if (argc != 1)
+ return KDB_ARGCOUNT;
+
+ nextarg = 1;
+ if ((diag = kdbgetaddrarg(argc, argv, &nextarg, &addr, &offset, NULL)) ||
+ (diag = kdb_getarea(k, addr)))
+ return diag;
+
+
+ kdb_printf("kobject at 0x%lx\n", addr);
+
+ if (k.name) {
+ char c;
+ kdb_printf(" name 0x%p", k.name);
+ if (kdb_getarea(c, (unsigned long)k.name) == 0)
+ kdb_printf(" '%s'", k.name);
+ kdb_printf("\n");
+ }
+
+ if (k.name != kobject_name((struct kobject *)addr))
+ kdb_printf(" name '%." __stringify(KOBJ_NAME_LEN) "s'\n", k.name);
+
+ kdb_printf(" kref.refcount %d'\n", atomic_read(&k.kref.refcount));
+
+ kdb_printf(" entry.next = 0x%p entry.prev = 0x%p\n",
+ k.entry.next, k.entry.prev);
+
+ kdb_printf(" parent = 0x%p kset = 0x%p ktype = 0x%p sd = 0x%p\n",
+ k.parent, k.kset, k.ktype, k.sd);
+
+ return 0;
+}
+
+static int
+kdbm_sh(int argc, const char **argv)
+{
+ int diag;
+ int nextarg;
+ unsigned long addr;
+ long offset = 0L;
+ struct Scsi_Host sh;
+
+ if (argc != 1)
+ return KDB_ARGCOUNT;
+
+ nextarg = 1;
+ if ((diag = kdbgetaddrarg(argc, argv, &nextarg, &addr, &offset, NULL)) ||
+ (diag = kdb_getarea(sh, addr)))
+ return diag;
+
+ kdb_printf("Scsi_Host at 0x%lx\n", addr);
+ kdb_printf("host_queue = 0x%p\n", sh.__devices.next);
+ kdb_printf("ehandler = 0x%p eh_action = 0x%p\n",
+ sh.ehandler, sh.eh_action);
+ kdb_printf("host_wait = 0x%p hostt = 0x%p\n",
+ &sh.host_wait, sh.hostt);
+ kdb_printf("host_failed = %d host_no = %d resetting = %d\n",
+ sh.host_failed, sh.host_no, sh.resetting);
+ kdb_printf("max id/lun/channel = [%d/%d/%d] this_id = %d\n",
+ sh.max_id, sh.max_lun, sh.max_channel, sh.this_id);
+ kdb_printf("can_queue = %d cmd_per_lun = %d sg_tablesize = %d u_isa_dma = %d\n",
+ sh.can_queue, sh.cmd_per_lun, sh.sg_tablesize, sh.unchecked_isa_dma);
+ kdb_printf("host_blocked = %d reverse_ordering = %d \n",
+ sh.host_blocked, sh.reverse_ordering);
+
+ return 0;
+}
+
+static int
+kdbm_sd(int argc, const char **argv)
+{
+ int diag;
+ int nextarg;
+ unsigned long addr;
+ long offset = 0L;
+ struct scsi_device *sd = NULL;
+
+ if (argc != 1)
+ return KDB_ARGCOUNT;
+
+ nextarg = 1;
+ if ((diag = kdbgetaddrarg(argc, argv, &nextarg, &addr, &offset, NULL)))
+ goto out;
+ if (!(sd = kmalloc(sizeof(*sd), GFP_ATOMIC))) {
+ kdb_printf("kdbm_sd: cannot kmalloc sd\n");
+ goto out;
+ }
+ if ((diag = kdb_getarea(*sd, addr)))
+ goto out;
+
+ kdb_printf("scsi_device at 0x%lx\n", addr);
+ kdb_printf("next = 0x%p prev = 0x%p host = 0x%p\n",
+ sd->siblings.next, sd->siblings.prev, sd->host);
+ kdb_printf("device_busy = %d current_cmnd 0x%p\n",
+ sd->device_busy, sd->current_cmnd);
+ kdb_printf("id/lun/chan = [%d/%d/%d] single_lun = %d device_blocked = %d\n",
+ sd->id, sd->lun, sd->channel, sd->sdev_target->single_lun, sd->device_blocked);
+ kdb_printf("queue_depth = %d current_tag = %d scsi_level = %d\n",
+ sd->queue_depth, sd->current_tag, sd->scsi_level);
+ kdb_printf("%8.8s %16.16s %4.4s\n", sd->vendor, sd->model, sd->rev);
+out:
+ if (sd)
+ kfree(sd);
+ return diag;
+}
+
+static int
+kdbm_sc(int argc, const char **argv)
+{
+ int diag;
+ int nextarg;
+ unsigned long addr;
+ long offset = 0L;
+ struct scsi_cmnd *sc = NULL;
+
+ if (argc != 1)
+ return KDB_ARGCOUNT;
+
+ nextarg = 1;
+ if ((diag = kdbgetaddrarg(argc, argv, &nextarg, &addr, &offset, NULL)))
+ goto out;
+ if (!(sc = kmalloc(sizeof(*sc), GFP_ATOMIC))) {
+ kdb_printf("kdbm_sc: cannot kmalloc sc\n");
+ goto out;
+ }
+ if ((diag = kdb_getarea(*sc, addr)))
+ goto out;
+
+ kdb_printf("scsi_cmnd at 0x%lx\n", addr);
+ kdb_printf("device = 0x%p next = 0x%p\n",
+ sc->device, sc->list.next);
+ kdb_printf("serial_number = %ld retries = %d\n",
+ sc->serial_number, sc->retries);
+ kdb_printf("cmd_len = %d\n", sc->cmd_len);
+ kdb_printf("cmnd = [%2.2x/%2.2x/%2.2x/%2.2x/%2.2x/%2.2x/%2.2x/%2.2x/%2.2x/%2.2x/%2.2x/%2.2x]\n",
+ sc->cmnd[0], sc->cmnd[1], sc->cmnd[2], sc->cmnd[3], sc->cmnd[4],
+ sc->cmnd[5], sc->cmnd[6], sc->cmnd[7], sc->cmnd[8], sc->cmnd[9],
+ sc->cmnd[10], sc->cmnd[11]);
+ kdb_printf("request_buffer = 0x%p request_bufflen = %d\n",
+ scsi_sglist(sc), scsi_bufflen(sc));
+ kdb_printf("use_sg = %d\n", scsi_sg_count(sc));
+ kdb_printf("underflow = %d transfersize = %d\n",
+ sc->underflow, sc->transfersize);
+ kdb_printf("tag = %d\n", sc->tag);
+
+out:
+ if (sc)
+ kfree(sc);
+ return diag;
+}
+
+static int __init kdbm_vm_init(void)
+{
+ kdb_register("vm", kdbm_vm, "[-v] <vaddr>", "Display vm_area_struct", 0);
+ kdb_register("vmp", kdbm_vm, "[-v] <pid>", "Display all vm_area_struct for <pid>", 0);
+ kdb_register("pte", kdbm_pte, "( -m <mm> | -p <pid> ) <vaddr> [<nbytes>]", "Display pte_t for mm_struct or pid", 0);
+ kdb_register("rpte", kdbm_rpte, "( -m <mm> | -p <pid> ) <pfn> [<npages>]", "Find pte_t containing pfn for mm_struct or pid", 0);
+ kdb_register("dentry", kdbm_dentry, "<dentry>", "Display interesting dentry stuff", 0);
+ kdb_register("kobject", kdbm_kobject, "<kobject>", "Display interesting kobject stuff", 0);
+ kdb_register("filp", kdbm_filp, "<filp>", "Display interesting filp stuff", 0);
+ kdb_register("fl", kdbm_fl, "<fl>", "Display interesting file_lock stuff", 0);
+ kdb_register("sh", kdbm_sh, "<vaddr>", "Show scsi_host", 0);
+ kdb_register("sd", kdbm_sd, "<vaddr>", "Show scsi_device", 0);
+ kdb_register("sc", kdbm_sc, "<vaddr>", "Show scsi_cmnd", 0);
+
+ return 0;
+}
+
+static void __exit kdbm_vm_exit(void)
+{
+ kdb_unregister("vm");
+ kdb_unregister("vmp");
+ kdb_unregister("pte");
+ kdb_unregister("rpte");
+ kdb_unregister("dentry");
+ kdb_unregister("kobject");
+ kdb_unregister("filp");
+ kdb_unregister("fl");
+ kdb_unregister("sh");
+ kdb_unregister("sd");
+ kdb_unregister("sc");
+}
+
+module_init(kdbm_vm_init)
+module_exit(kdbm_vm_exit)
Index: linux/kdb/modules/kdbm_x86.c
===================================================================
--- /dev/null
+++ linux/kdb/modules/kdbm_x86.c
@@ -0,0 +1,1094 @@
+/*
+ * This file is subject to the terms and conditions of the GNU General Public
+ * License. See the file "COPYING" in the main directory of this archive
+ * for more details.
+ *
+ * Author: Vamsi Krishna S. <vamsi_krishna@in.ibm.com>
+ * (C) 2003 IBM Corporation.
+ * 2006-10-10 Keith Owens
+ * Reworked to include x86_64 support
+ * Copyright (c) 2006 Silicon Graphics, Inc. All Rights Reserved.
+ */
+
+#include <linux/interrupt.h>
+#include <linux/types.h>
+#include <linux/kdb.h>
+#include <linux/kdbprivate.h>
+#include <linux/module.h>
+#include <linux/init.h>
+#include <linux/mm.h>
+
+#include <asm/processor.h>
+#include <asm/uaccess.h>
+#include <asm/desc.h>
+#include <asm/debugreg.h>
+#if 0
+#include <asm/pgtable.h>
+#endif
+
+MODULE_AUTHOR("Vamsi Krishna S./IBM");
+MODULE_DESCRIPTION("x86 specific information (gdt/idt/ldt/page tables)");
+MODULE_LICENSE("GPL");
+
+/* Isolate as many of the i386/x86_64 differences as possible in one spot */
+
+#ifdef CONFIG_X86_64
+
+#define KDB_X86_64 1
+#define MOVLQ "movq"
+
+typedef struct desc_struct kdb_desc_t;
+typedef struct gate_struct64 kdb_gate_desc_t;
+
+#define KDB_SYS_DESC_OFFSET(d) ((unsigned long)d->offset_high << 32 | d->offset_middle << 16 | d->offset_low)
+#define KDB_SYS_DESC_CALLG_COUNT(d) 0
+
+#else /* !CONFIG_X86_64 */
+
+#define KDB_X86_64 0
+#define desc_ptr Xgt_desc_struct
+#define MOVLQ "movl"
+
+/* i386 has no detailed mapping for the 8 byte segment descriptor, copy the
+ * x86_64 one and merge the l and avl bits.
+ */
+struct kdb_desc {
+ u16 limit0;
+ u16 base0;
+ unsigned base1 : 8, type : 4, s : 1, dpl : 2, p : 1;
+ unsigned limit : 4, avl : 2, d : 1, g : 1, base2 : 8;
+} __attribute__((packed));
+typedef struct kdb_desc kdb_desc_t;
+
+/* i386 has no detailed mapping for the 8 byte gate descriptor, base it on the
+ * x86_64 one.
+ */
+struct kdb_gate_desc {
+ u16 offset_low;
+ u16 segment;
+ unsigned res : 8, type : 4, s : 1, dpl : 2, p : 1;
+ u16 offset_middle;
+} __attribute__((packed));
+typedef struct kdb_gate_desc kdb_gate_desc_t;
+
+#define KDB_SYS_DESC_OFFSET(d) ((unsigned long)(d->offset_middle << 16 | d->offset_low))
+#define KDB_SYS_DESC_CALLG_COUNT(d) ((unsigned int)(d->res & 0x0F))
+
+#endif /* CONFIG_X86_64 */
+
+#define KDB_SEL_MAX 0x2000
+#define KDB_IDT_MAX 0x100
+#define KDB_SYS_DESC_TYPE_TSS16 0x01
+#define KDB_SYS_DESC_TYPE_LDT 0x02
+#define KDB_SYS_DESC_TYPE_TSSB16 0x03
+#define KDB_SYS_DESC_TYPE_CALLG16 0x04
+#define KDB_SYS_DESC_TYPE_TASKG 0x05
+#define KDB_SYS_DESC_TYPE_INTG16 0x06
+#define KDB_SYS_DESC_TYPE_TRAP16 0x07
+
+#define KDB_SYS_DESC_TYPE_TSS 0x09
+#define KDB_SYS_DESC_TYPE_TSSB 0x0b
+#define KDB_SYS_DESC_TYPE_CALLG 0x0c
+#define KDB_SYS_DESC_TYPE_INTG 0x0e
+#define KDB_SYS_DESC_TYPE_TRAPG 0x0f
+
+#define KDB_SEG_DESC_TYPE_CODE 0x08
+#define KDB_SEG_DESC_TYPE_CODE_R 0x02
+#define KDB_SEG_DESC_TYPE_DATA_W 0x02
+#define KDB_SEG_DESC_TYPE_CODE_C 0x02 /* conforming */
+#define KDB_SEG_DESC_TYPE_DATA_D 0x02 /* expand-down */
+#define KDB_SEG_DESC_TYPE_A 0x01 /* accessed */
+
+#define _LIMIT(d) ((unsigned long)((d)->limit << 16 | (d)->limit0))
+#define KDB_SEG_DESC_LIMIT(d) ((d)->g ? ((_LIMIT(d)+1) << 12) -1 : _LIMIT(d))
+
+static unsigned long kdb_seg_desc_base(kdb_desc_t *d)
+{
+ unsigned long base = d->base2 << 24 | d->base1 << 16 | d->base0;
+#ifdef CONFIG_X86_64
+ switch (d->type) {
+ case KDB_SYS_DESC_TYPE_TSS:
+ case KDB_SYS_DESC_TYPE_TSSB:
+ case KDB_SYS_DESC_TYPE_LDT:
+ base += (unsigned long)(((struct ldttss_desc64 *)d)->base3) << 32;
+ break;
+ }
+#endif
+ return base;
+}
+
+/* helper functions to display system registers in verbose mode */
+static void display_gdtr(void)
+{
+ struct desc_ptr gdtr;
+
+ __asm__ __volatile__ ("sgdt %0\n\t" : "=m"(gdtr));
+ kdb_printf("gdtr.address = " kdb_machreg_fmt0 ", gdtr.size = 0x%x\n",
+ gdtr.address, gdtr.size);
+
+ return;
+}
+
+static void display_ldtr(void)
+{
+ struct desc_ptr gdtr;
+ unsigned long ldtr;
+
+ __asm__ __volatile__ ("sgdt %0\n\t" : "=m"(gdtr));
+ __asm__ __volatile__ ("sldt %0\n\t" : "=m"(ldtr));
+ ldtr &= 0xfff8; /* extract the index */
+
+ kdb_printf("ldtr = " kdb_machreg_fmt0 " ", ldtr);
+
+ if (ldtr < gdtr.size) {
+ kdb_desc_t *ldt_desc =
+ (kdb_desc_t *)(gdtr.address + ldtr);
+ kdb_printf("base=" kdb_machreg_fmt0
+ ", limit=" kdb_machreg_fmt "\n",
+ kdb_seg_desc_base(ldt_desc),
+ KDB_SEG_DESC_LIMIT(ldt_desc));
+ } else {
+ kdb_printf("invalid\n");
+ }
+
+ return;
+}
+
+static void display_idtr(void)
+{
+ struct desc_ptr idtr;
+ __asm__ __volatile__ ("sidt %0\n\t" : "=m"(idtr));
+ kdb_printf("idtr.address = " kdb_machreg_fmt0 ", idtr.size = 0x%x\n",
+ idtr.address, idtr.size);
+ return;
+}
+
+static const char *cr0_flags[] = {
+ "pe", "mp", "em", "ts", "et", "ne", NULL, NULL,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
+ "wp", NULL, "am", NULL, NULL, NULL, NULL, NULL,
+ NULL, NULL, NULL, NULL, NULL, "nw", "cd", "pg"};
+
+static void display_cr0(void)
+{
+ kdb_machreg_t cr0;
+ int i;
+ __asm__ (MOVLQ " %%cr0,%0\n\t":"=r"(cr0));
+ kdb_printf("cr0 = " kdb_machreg_fmt0, cr0);
+ for (i = 0; i < ARRAY_SIZE(cr0_flags); i++) {
+ if (test_bit(i, &cr0) && cr0_flags[i])
+ kdb_printf(" %s", cr0_flags[i]);
+ }
+ kdb_printf("\n");
+ return;
+}
+
+static void display_cr3(void)
+{
+ kdb_machreg_t cr3;
+ __asm__ (MOVLQ " %%cr3,%0\n\t":"=r"(cr3));
+ kdb_printf("cr3 = " kdb_machreg_fmt0 " ", cr3);
+ if (cr3 & 0x08)
+ kdb_printf("pwt ");
+ if (cr3 & 0x10)
+ kdb_printf("pcd ");
+ kdb_printf("%s=" kdb_machreg_fmt0 "\n",
+ KDB_X86_64 ? "pml4" : "pgdir", cr3 & PAGE_MASK);
+ return;
+}
+
+static const char *cr4_flags[] = {
+ "vme", "pvi", "tsd", "de",
+ "pse", "pae", "mce", "pge",
+ "pce", "osfxsr" "osxmmexcpt"};
+
+static void display_cr4(void)
+{
+ kdb_machreg_t cr4;
+ int i;
+ __asm__ (MOVLQ " %%cr4,%0\n\t":"=r"(cr4));
+ kdb_printf("cr4 = " kdb_machreg_fmt0, cr4);
+ for (i = 0; i < ARRAY_SIZE(cr4_flags); i++) {
+ if (test_bit(i, &cr4))
+ kdb_printf(" %s", cr4_flags[i]);
+ }
+ kdb_printf("\n");
+ return;
+}
+
+static void display_cr8(void)
+{
+#ifdef CONFIG_X86_64
+ kdb_machreg_t cr8;
+ __asm__ (MOVLQ " %%cr8,%0\n\t":"=r"(cr8));
+ kdb_printf("cr8 = " kdb_machreg_fmt0 "\n", cr8);
+ return;
+#endif /* CONFIG_X86_64 */
+}
+
+static char *dr_type_name[] = { "exec", "write", "io", "rw" };
+
+static void display_dr_status(int nr, int enabled, int local, int len, int type)
+{
+ if (!enabled) {
+ kdb_printf("\tdebug register %d: not enabled\n", nr);
+ return;
+ }
+
+ kdb_printf(" debug register %d: %s, len = %d, type = %s\n",
+ nr,
+ local? " local":"global",
+ len,
+ dr_type_name[type]);
+}
+
+static void display_dr(void)
+{
+ kdb_machreg_t dr0, dr1, dr2, dr3, dr6, dr7;
+ int dbnr, set;
+
+ __asm__ (MOVLQ " %%db0,%0\n\t":"=r"(dr0));
+ __asm__ (MOVLQ " %%db1,%0\n\t":"=r"(dr1));
+ __asm__ (MOVLQ " %%db2,%0\n\t":"=r"(dr2));
+ __asm__ (MOVLQ " %%db3,%0\n\t":"=r"(dr3));
+ __asm__ (MOVLQ " %%db6,%0\n\t":"=r"(dr6));
+ __asm__ (MOVLQ " %%db7,%0\n\t":"=r"(dr7));
+
+ kdb_printf("dr0 = " kdb_machreg_fmt0 " dr1 = " kdb_machreg_fmt0
+ " dr2 = " kdb_machreg_fmt0 " dr3 = " kdb_machreg_fmt0 "\n",
+ dr0, dr1, dr2, dr3);
+ kdb_printf("dr6 = " kdb_machreg_fmt0 " ", dr6);
+ dbnr = dr6 & DR6_DR_MASK;
+ if (dbnr) {
+ int nr;
+ switch(dbnr) {
+ case 1:
+ nr = 0; break;
+ case 2:
+ nr = 1; break;
+ case 4:
+ nr = 2; break;
+ default:
+ nr = 3; break;
+ }
+ kdb_printf("debug register hit = %d", nr);
+ } else if (dr6 & DR_STEP) {
+ kdb_printf("single step");
+ } else if (dr6 & DR_SWITCH) {
+ kdb_printf("task switch");
+ }
+ kdb_printf("\n");
+
+ kdb_printf("dr7 = " kdb_machreg_fmt0 "\n", dr7);
+ set = DR7_L0(dr7) || DR7_G0(dr7);
+ display_dr_status(0, set, DR7_L0(dr7), DR7_LEN0(dr7), DR7_RW0(dr7));
+ set = DR7_L1(dr7) || DR7_G1(dr7);
+ display_dr_status(1, set, DR7_L1(dr7), DR7_LEN1(dr7), DR7_RW1(dr7));
+ set = DR7_L2(dr7) || DR7_G2(dr7);
+ display_dr_status(2, set, DR7_L2(dr7), DR7_LEN2(dr7), DR7_RW2(dr7));
+ set = DR7_L3(dr7) || DR7_G3(dr7);
+ display_dr_status(3, set, DR7_L3(dr7), DR7_LEN3(dr7), DR7_RW3(dr7));
+}
+
+static char *set_eflags[] = {
+ "carry", NULL, "parity", NULL, "adjust", NULL, "zero", "sign",
+ "trace", "intr-on", "dir", "overflow", NULL, NULL, "nestedtask", NULL,
+ "resume", "vm", "align", "vif", "vip", "id"};
+
+static void display_eflags(unsigned long ef)
+{
+ int i, iopl;
+ kdb_printf("eflags = " kdb_machreg_fmt0 " ", ef);
+ for (i = 0; i < ARRAY_SIZE(set_eflags); i++) {
+ if (test_bit(i, &ef) && set_eflags[i])
+ kdb_printf("%s ", set_eflags[i]);
+ }
+
+ iopl = (ef & 0x00003000) >> 12;
+ kdb_printf("iopl=%d\n", iopl);
+ return;
+}
+
+static void display_tss(struct tss_struct *t)
+{
+#ifdef CONFIG_X86_64
+ int i;
+ kdb_printf(" sp0 = 0x%016Lx, sp1 = 0x%016Lx\n",
+ t->x86_tss.sp0, t->x86_tss.sp1);
+ kdb_printf(" sp2 = 0x%016Lx\n", t->x86_tss.sp2);
+ for (i = 0; i < ARRAY_SIZE(t->x86_tss.ist); ++i)
+ kdb_printf(" ist[%d] = 0x%016Lx\n",
+ i, t->x86_tss.ist[i]);
+ kdb_printf(" iomap = 0x%04x\n", t->x86_tss.io_bitmap_base);
+#else /* !CONFIG_X86_64 */
+ kdb_printf(" cs = %04x, ip = " kdb_machreg_fmt0 "\n",
+ t->x86_tss.es, t->x86_tss.ip);
+ kdb_printf(" ss = %04x, sp = " kdb_machreg_fmt0 "\n",
+ t->x86_tss.ss, t->x86_tss.sp);
+ kdb_printf(" ss0 = %04x, sp0 = " kdb_machreg_fmt0 "\n",
+ t->x86_tss.ss0, t->x86_tss.sp0);
+ kdb_printf(" ss1 = %04x, sp1 = " kdb_machreg_fmt0 "\n",
+ t->x86_tss.ss1, t->x86_tss.sp1);
+ kdb_printf(" ss2 = %04x, sp2 = " kdb_machreg_fmt0 "\n",
+ t->x86_tss.ss2, t->x86_tss.sp2);
+ kdb_printf(" ldt = %04x, cr3 = " kdb_machreg_fmt0 "\n",
+ t->x86_tss.ldt, t->x86_tss.__cr3);
+ kdb_printf(" ds = %04x, es = %04x fs = %04x gs = %04x\n",
+ t->x86_tss.ds, t->x86_tss.es, t->x86_tss.fs, t->x86_tss.gs);
+ kdb_printf(" ax = " kdb_machreg_fmt0 ", bx = " kdb_machreg_fmt0
+ " cx = " kdb_machreg_fmt0 " dx = " kdb_machreg_fmt0 "\n",
+ t->x86_tss.ax, t->x86_tss.bx, t->x86_tss.cx, t->x86_tss.dx);
+ kdb_printf(" si = " kdb_machreg_fmt0 ", di = " kdb_machreg_fmt0
+ " bp = " kdb_machreg_fmt0 "\n",
+ t->x86_tss.si, t->x86_tss.di, t->x86_tss.bp);
+ kdb_printf(" trace = %d, iomap = 0x%04x\n", t->x86_tss.trace, t->x86_tss.io_bitmap_base);
+#endif /* CONFIG_X86_64 */
+}
+
+static char *gate_desc_types[] = {
+#ifdef CONFIG_X86_64
+ "reserved-0", "reserved-1", "ldt", "reserved-3",
+ "reserved-4", "reserved-5", "reserved-6", "reserved-7",
+ "reserved-8", "tss-avlb", "reserved-10", "tss-busy",
+ "callgate", "reserved-13", "intgate", "trapgate",
+#else /* CONFIG_X86_64 */
+ "reserved-0", "tss16-avlb", "ldt", "tss16-busy",
+ "callgate16", "taskgate", "intgate16", "trapgate16",
+ "reserved-8", "tss-avlb", "reserved-10", "tss-busy",
+ "callgate", "reserved-13", "intgate", "trapgate",
+#endif /* CONFIG_X86_64 */
+};
+
+static void
+display_gate_desc(kdb_gate_desc_t *d)
+{
+ kdb_printf("%-11s ", gate_desc_types[d->type]);
+
+ switch(d->type) {
+ case KDB_SYS_DESC_TYPE_LDT:
+ kdb_printf("base=");
+ kdb_symbol_print(kdb_seg_desc_base((kdb_desc_t *)d), NULL,
+ KDB_SP_DEFAULT);
+ kdb_printf(" limit=" kdb_machreg_fmt " dpl=%d\n",
+ KDB_SEG_DESC_LIMIT((kdb_desc_t *)d), d->dpl);
+ break;
+ case KDB_SYS_DESC_TYPE_TSS:
+ case KDB_SYS_DESC_TYPE_TSS16:
+ case KDB_SYS_DESC_TYPE_TSSB:
+ case KDB_SYS_DESC_TYPE_TSSB16:
+ {
+ struct tss_struct *tss =
+ (struct tss_struct *)
+ kdb_seg_desc_base((kdb_desc_t *)d);
+ kdb_printf("base=");
+ kdb_symbol_print((unsigned long)tss, NULL, KDB_SP_DEFAULT);
+ kdb_printf(" limit=" kdb_machreg_fmt " dpl=%d\n",
+ KDB_SEG_DESC_LIMIT((kdb_desc_t *)d), d->dpl);
+ display_tss(tss);
+ break;
+ }
+ case KDB_SYS_DESC_TYPE_CALLG16:
+ kdb_printf("segment=0x%4.4x off=", d->segment);
+ kdb_symbol_print(KDB_SYS_DESC_OFFSET(d), NULL, KDB_SP_DEFAULT);
+ kdb_printf(" dpl=%d wc=%d\n",
+ d->dpl, KDB_SYS_DESC_CALLG_COUNT(d));
+ break;
+ case KDB_SYS_DESC_TYPE_CALLG:
+ kdb_printf("segment=0x%4.4x off=", d->segment);
+ kdb_symbol_print(KDB_SYS_DESC_OFFSET(d), NULL, KDB_SP_DEFAULT);
+ kdb_printf(" dpl=%d\n", d->dpl);
+ break;
+ default:
+ kdb_printf("segment=0x%4.4x off=", d->segment);
+ if (KDB_SYS_DESC_OFFSET(d))
+ kdb_symbol_print(KDB_SYS_DESC_OFFSET(d), NULL,
+ KDB_SP_DEFAULT);
+ else
+ kdb_printf(kdb_machreg_fmt0, KDB_SYS_DESC_OFFSET(d));
+ kdb_printf(" dpl=%d", d->dpl);
+#ifdef CONFIG_X86_64
+ if (d->ist)
+ kdb_printf(" ist=%d", d->ist);
+#endif /* CONFIG_X86_64 */
+ kdb_printf("\n");
+ break;
+ }
+}
+
+static void
+display_seg_desc(kdb_desc_t *d)
+{
+ unsigned char type = d->type;
+
+ if (type & KDB_SEG_DESC_TYPE_CODE) {
+ kdb_printf("%-11s base=" kdb_machreg_fmt0 " limit="
+ kdb_machreg_fmt " dpl=%d %c%c%c %s %s %s \n",
+ "code",
+ kdb_seg_desc_base(d), KDB_SEG_DESC_LIMIT(d),
+ d->dpl,
+ (type & KDB_SEG_DESC_TYPE_CODE_R)?'r':'-',
+ '-', 'x',
+#ifdef CONFIG_X86_64
+ d->l ? "64b" : d->d ? "32b" : "16b",
+#else /* !CONFIG_X86_64 */
+ d->d ? "32b" : "16b",
+#endif /* CONFIG_X86_64 */
+ (type & KDB_SEG_DESC_TYPE_A)?"ac":"",
+ (type & KDB_SEG_DESC_TYPE_CODE_C)?"conf":"");
+ } else {
+ kdb_printf("%-11s base=" kdb_machreg_fmt0 " limit="
+ kdb_machreg_fmt " dpl=%d %c%c%c %s %s %s \n",
+ "data",
+ kdb_seg_desc_base(d), KDB_SEG_DESC_LIMIT(d),
+ d->dpl,
+ 'r',
+ (type & KDB_SEG_DESC_TYPE_DATA_W)?'w':'-',
+ '-',
+ d->d ? "32b" : "16b",
+ (type & KDB_SEG_DESC_TYPE_A)?"ac":"",
+ (type & KDB_SEG_DESC_TYPE_DATA_D)?"down":"");
+ }
+}
+
+static int
+kdb_parse_two_numbers(int argc, const char **argv, int *sel, int *count,
+ int *last_sel, int *last_count)
+{
+ int diag;
+
+ if (argc > 2)
+ return KDB_ARGCOUNT;
+
+ kdbgetintenv("MDCOUNT", count);
+
+ if (argc == 0) {
+ *sel = *last_sel;
+ if (*last_count)
+ *count = *last_count;
+ } else {
+ unsigned long val;
+
+ if (argc >= 1) {
+ diag = kdbgetularg(argv[1], &val);
+ if (diag)
+ return diag;
+ *sel = val;
+ }
+ if (argc >= 2) {
+ diag = kdbgetularg(argv[2], &val);
+ if (diag)
+ return diag;
+ *count = (int) val;
+ *last_count = (int) val;
+ } else if (*last_count) {
+ *count = *last_count;
+ }
+ }
+ return 0;
+}
+
+/*
+ * kdb_gdt
+ *
+ * This function implements the 'gdt' command.
+ *
+ * gdt [<selector> [<line count>]]
+ *
+ * Inputs:
+ * argc argument count
+ * argv argument vector
+ * Outputs:
+ * None.
+ * Returns:
+ * zero for success, a kdb diagnostic if error
+ * Locking:
+ * none.
+ * Remarks:
+ */
+static int
+kdb_gdt(int argc, const char **argv)
+{
+ int sel = 0;
+ struct desc_ptr gdtr;
+ int diag, count = 8;
+ kdb_desc_t *gdt;
+ unsigned int max_sel;
+ static int last_sel = 0, last_count = 0;
+
+ diag = kdb_parse_two_numbers(argc, argv, &sel, &count,
+ &last_sel, &last_count);
+ if (diag)
+ return diag;
+
+ __asm__ __volatile__ ("sgdt %0\n\t" : "=m"(gdtr));
+ gdt = (kdb_desc_t *) gdtr.address;
+
+ max_sel = (gdtr.size + 1) / sizeof(kdb_desc_t);
+ if (sel >= max_sel) {
+ kdb_printf("Maximum selector (%d) reached\n", max_sel);
+ return 0;
+ }
+
+ if (sel + count > max_sel)
+ count = max_sel - sel;
+
+ while (count--) {
+ kdb_desc_t *d = &gdt[sel];
+ kdb_printf("0x%4.4x ", sel++);
+
+ if (!d->p) {
+ kdb_printf("not present\n");
+ continue;
+ }
+ if (d->s) {
+ display_seg_desc(d);
+ } else {
+ display_gate_desc((kdb_gate_desc_t *)d);
+ if (KDB_X86_64 && count) {
+ ++sel; /* this descriptor occupies two slots */
+ --count;
+ }
+ }
+ }
+
+ last_sel = sel;
+ return 0;
+}
+
+/*
+ * kdb_ldt
+ *
+ * This function implements the 'ldt' command.
+ *
+ * ldt [<selector> [<line count>]]
+ *
+ * Inputs:
+ * argc argument count
+ * argv argument vector
+ * Outputs:
+ * None.
+ * Returns:
+ * zero for success, a kdb diagnostic if error
+ * Locking:
+ * none.
+ * Remarks:
+ */
+static int
+kdb_ldt(int argc, const char **argv)
+{
+ int sel = 0;
+ struct desc_ptr gdtr;
+ unsigned long ldtr = 0;
+ int diag, count = 8;
+ kdb_desc_t *ldt, *ldt_desc;
+ unsigned int max_sel;
+ static int last_sel = 0, last_count = 0;
+
+ diag = kdb_parse_two_numbers(argc, argv, &sel, &count,
+ &last_sel, &last_count);
+ if (diag)
+ return diag;
+
+ if (strcmp(argv[0], "ldtp") == 0) {
+ kdb_printf("pid=%d, process=%s\n",
+ kdb_current_task->pid, kdb_current_task->comm);
+ if (!kdb_current_task->mm ||
+ !kdb_current_task->mm->context.ldt) {
+ kdb_printf("no special LDT for this process\n");
+ return 0;
+ }
+ ldt = kdb_current_task->mm->context.ldt;
+ max_sel = kdb_current_task->mm->context.size;
+ } else {
+
+ /* sldt gives the GDT selector for the segment containing LDT */
+ __asm__ __volatile__ ("sgdt %0\n\t" : "=m"(gdtr));
+ __asm__ __volatile__ ("sldt %0\n\t" : "=m"(ldtr));
+ ldtr &= 0xfff8; /* extract the index */
+
+ if (ldtr > gdtr.size+1) {
+ kdb_printf("invalid ldtr\n");
+ return 0;
+ }
+
+ ldt_desc = (kdb_desc_t *)(gdtr.address + ldtr);
+ ldt = (kdb_desc_t *)kdb_seg_desc_base(ldt_desc);
+ max_sel = (KDB_SEG_DESC_LIMIT(ldt_desc)+1) / sizeof(kdb_desc_t);
+ }
+
+ if (sel >= max_sel) {
+ kdb_printf("Maximum selector (%d) reached\n", max_sel);
+ return 0;
+ }
+
+ if (sel + count > max_sel)
+ count = max_sel - sel;
+
+ while (count--) {
+ kdb_desc_t *d = &ldt[sel];
+ kdb_printf("0x%4.4x ", sel++);
+
+ if (!d->p) {
+ kdb_printf("not present\n");
+ continue;
+ }
+ if (d->s) {
+ display_seg_desc(d);
+ } else {
+ display_gate_desc((kdb_gate_desc_t *)d);
+ if (KDB_X86_64 && count) {
+ ++sel; /* this descriptor occupies two slots */
+ --count;
+ }
+ }
+ }
+
+ last_sel = sel;
+ return 0;
+}
+
+/*
+ * kdb_idt
+ *
+ * This function implements the 'idt' command.
+ *
+ * idt [<vector> [<line count>]]
+ *
+ * Inputs:
+ * argc argument count
+ * argv argument vector
+ * Outputs:
+ * None.
+ * Returns:
+ * zero for success, a kdb diagnostic if error
+ * Locking:
+ * none.
+ * Remarks:
+ */
+static int
+kdb_idt(int argc, const char **argv)
+{
+ int vec = 0;
+ struct desc_ptr idtr;
+ int diag, count = 8;
+ kdb_gate_desc_t *idt;
+ unsigned int max_entries;
+ static int last_vec = 0, last_count = 0;
+
+ diag = kdb_parse_two_numbers(argc, argv, &vec, &count,
+ &last_vec, &last_count);
+ if (diag)
+ return diag;
+
+ __asm__ __volatile__ ("sidt %0\n\t" : "=m"(idtr));
+ idt = (kdb_gate_desc_t *)idtr.address;
+
+ max_entries = (idtr.size+1) / sizeof(kdb_gate_desc_t);
+ if (vec >= max_entries) {
+ kdb_printf("Maximum vector (%d) reached\n", max_entries);
+ return 0;
+ }
+
+ if (vec + count > max_entries)
+ count = max_entries - vec;
+
+ while (count--) {
+ kdb_gate_desc_t *d = &idt[vec];
+ kdb_printf("0x%4.4x ", vec++);
+ if (!d->p) {
+ kdb_printf("not present\n");
+ continue;
+ }
+#ifndef CONFIG_X86_64
+ if (d->s) {
+ kdb_printf("invalid\n");
+ continue;
+ }
+#endif /* CONFIG_X86_64 */
+ display_gate_desc(d);
+ }
+
+ last_vec = vec;
+
+ return 0;
+}
+
+#if 0
+static int
+get_pagetables(unsigned long addr, pgd_t **pgdir, pmd_t **pgmiddle, pte_t **pte)
+{
+ pgd_t *d;
+ pmd_t *m;
+ pte_t *t;
+
+ if (addr > PAGE_OFFSET) {
+ d = pgd_offset_k(addr);
+ } else {
+ kdb_printf("pid=%d, process=%s\n", kdb_current_task->pid, kdb_current_task->comm);
+ d = pgd_offset(kdb_current_task->mm, addr);
+ }
+
+ if (pgd_none(*d) || pgd_bad(*d)) {
+ *pgdir = NULL;
+ *pgmiddle = NULL;
+ *pte = NULL;
+ return 0;
+ } else {
+ *pgdir = d;
+ }
+
+ /* if _PAGE_PSE is set, pgdir points directly to the page. */
+ if (pgd_val(*d) & _PAGE_PSE) {
+ *pgmiddle = NULL;
+ *pte = NULL;
+ return 0;
+ }
+
+ m = pmd_offset(d, addr);
+ if (pmd_none(*m) || pmd_bad(*m)) {
+ *pgmiddle = NULL;
+ *pte = NULL;
+ return 0;
+ } else {
+ *pgmiddle = m;
+ }
+
+ t = pte_offset(m, addr);
+ if (pte_none(*t)) {
+ *pte = NULL;
+ return 0;
+ } else {
+ *pte = t;
+ }
+ kdb_printf("\naddr=%08lx, pgd=%08lx, pmd=%08lx, pte=%08lx\n",
+ addr,
+ (unsigned long) pgd_val(*d),
+ (unsigned long) pmd_val(*m),
+ (unsigned long) pte_val(*t));
+ return 0;
+}
+#endif
+
+#define FORMAT_PGDIR(entry) \
+ kdb_printf("frame=%05lx %c %s %c %c %c %s %c %s %s \n",\
+ (entry >> PAGE_SHIFT), \
+ (entry & _PAGE_PRESENT)?'p':'n', \
+ (entry & _PAGE_RW)?"rw":"ro", \
+ (entry & _PAGE_USER)?'u':'s', \
+ (entry & _PAGE_ACCESSED)?'a':' ', \
+ ' ', \
+ (entry & _PAGE_PSE)?"4M":"4K", \
+ (entry & _PAGE_GLOBAL)?'g':' ', \
+ (entry & _PAGE_PWT)?"wt":"wb", \
+ (entry & _PAGE_PCD)?"cd":" ");
+
+#define FORMAT_PTE(p, entry) \
+ kdb_printf("frame=%05lx %c%c%c %c %c %c %s %c %s %s\n", \
+ (entry >> PAGE_SHIFT), \
+ (pte_read(p))? 'r':'-', \
+ (pte_write(p))? 'w':'-', \
+ (pte_exec(p))? 'x':'-', \
+ (pte_dirty(p))? 'd':' ', \
+ (pte_young(p))? 'a':' ', \
+ (entry & _PAGE_USER)? 'u':'s', \
+ " ", \
+ (entry & _PAGE_GLOBAL)? 'g':' ', \
+ (entry & _PAGE_PWT)? "wt":"wb", \
+ (entry & _PAGE_PCD)? "cd":" ");
+#if 0
+static int
+display_pgdir(unsigned long addr, pgd_t *pgdir, int count)
+{
+ unsigned long entry;
+ int i;
+ int index = pgdir - ((pgd_t *)(((unsigned long)pgdir) & PAGE_MASK));
+
+ count = min(count, PTRS_PER_PGD - index);
+ addr &= ~(PGDIR_SIZE-1);
+
+ for (i = 0; i < count; i++, pgdir++) {
+ entry = pgd_val(*pgdir);
+ kdb_printf("pgd: addr=%08lx ", addr);
+ if (pgd_none(*pgdir)) {
+ kdb_printf("pgdir not present\n");
+ } else {
+ FORMAT_PGDIR(entry);
+ }
+ addr += PGDIR_SIZE;
+ }
+ return i;
+}
+#endif
+
+#if 0 /* for now, let's not print pgmiddle. */
+static int
+display_pgmiddle(unsigned long addr, pmd_t *pgmiddle, int count)
+{
+ unsigned long entry;
+ int i;
+ int index = pgmiddle - ((pmd_t *)(((unsigned long)pgmiddle) & PAGE_MASK));
+
+ count = min(count, PTRS_PER_PMD - index);
+ addr &= ~(PMD_SIZE-1);
+
+ for (i = 0; i < count; i++, pgmiddle++) {
+ entry = pmd_val(*pgmiddle);
+ kdb_printf("pmd: addr=%08lx ", addr);
+ if (pmd_none(*pgmiddle)) {
+ kdb_printf("pgmiddle not present\n");
+ } else {
+ FORMAT_PGDIR(entry);
+ }
+ addr += PMD_SIZE;
+ }
+ return i;
+}
+#endif
+
+#if 0
+static int
+display_pte(unsigned long addr, pte_t *pte, int count)
+{
+ unsigned long entry;
+ int i;
+ int index = pte - ((pte_t *)(((unsigned long)pte) & PAGE_MASK));
+
+ count = min(count, PTRS_PER_PTE - index);
+ addr &= PAGE_MASK;
+
+ for (i = 0; i < count; i++, pte++) {
+ entry = pte_val(*pte);
+ kdb_printf("pte: addr=%08lx ", addr);
+ if (pte_none(*pte)) {
+ kdb_printf("pte not present\n");
+ } else if (!pte_present(*pte)) {
+ kdb_printf("page swapped out. swp_offset=%08lx ", SWP_OFFSET(pte_to_swp_entry(*pte)));
+ kdb_printf("swp_type=%8lx", SWP_TYPE(pte_to_swp_entry(*pte)));
+ } else {
+ FORMAT_PTE(*pte, entry);
+ }
+ addr += PAGE_SIZE;
+ }
+ return i;
+}
+
+
+/*
+ * kdb_pte
+ *
+ * This function implements the 'pte' command.
+ *
+ * pte <addr arg> [<line count>]
+ *
+ * Inputs:
+ * argc argument count
+ * argv argument vector
+ * Outputs:
+ * None.
+ * Returns:
+ * zero for success, a kdb diagnostic if error
+ * Locking:
+ * none.
+ * Remarks:
+ */
+static int
+kdb_pte(int argc, const char **argv)
+{
+ static unsigned long last_addr = 0, last_count = 0;
+ int count = 8;
+ unsigned long addr;
+ long offset = 0;
+ pgd_t *pgdir;
+ pmd_t *pgmiddle;
+ pte_t *pte;
+
+#ifdef CONFIG_X86_PAE
+ kdb_printf("This kernel is compiled with PAE support.");
+ return KDB_NOTIMP;
+#endif
+ kdbgetintenv("MDCOUNT", &count);
+
+ if (argc == 0) {
+ if (last_addr == 0)
+ return KDB_ARGCOUNT;
+ addr = last_addr;
+ if (last_count)
+ count = last_count;
+ } else {
+ kdb_machreg_t val;
+ int diag, nextarg = 1;
+ diag = kdbgetaddrarg(argc, argv, &nextarg, &addr, &offset, NULL);
+ if (diag)
+ return diag;
+ if (argc > nextarg+1)
+ return KDB_ARGCOUNT;
+
+ if (argc >= nextarg) {
+ diag = kdbgetularg(argv[nextarg], &val);
+ if (!diag) {
+ count = (int) val;
+ last_count = count;
+ } else if (last_count) {
+ count = last_count;
+ }
+ }
+ }
+
+ /*
+ * round off the addr to a page boundary.
+ */
+ addr &= PAGE_MASK;
+
+ get_pagetables(addr, &pgdir, &pgmiddle, &pte);
+
+ if (pgdir)
+ display_pgdir(addr, pgdir, 1);
+#if 0 /* for now, let's not print pgmiddle. */
+ if (pgmiddle)
+ display_pgmiddle(addr, pgmiddle, 1);
+#endif
+ if (pte) {
+ int displayed;
+ displayed = display_pte(addr, pte, count);
+ addr += (displayed << PAGE_SHIFT);
+ }
+ last_addr = addr;
+ return 0;
+}
+#else
+/*
+ * Todo - In 2.5 the pte_offset macro in asm/pgtable.h seems to be
+ * renamed to pte_offset_kernel.
+ */
+static int
+kdb_pte(int argc, const char **argv)
+{
+ kdb_printf("not supported.");
+ return KDB_NOTIMP;
+}
+#endif
+
+/*
+ * kdb_rdv
+ *
+ * This function implements the 'rdv' command.
+ * It displays all registers of the current processor
+ * included control registers in verbose mode.
+ *
+ * Inputs:
+ * argc argument count
+ * argv argument vector
+ * Outputs:
+ * None.
+ * Returns:
+ * zero for success, a kdb diagnostic if error
+ * Locking:
+ * none.
+ * Remarks:
+ * This should have been an option to rd command say "rd v",
+ * but it is here as it is a non-essential x86-only command,
+ * that need not clutter arch/i386/kdb/kdbasupport.c.
+ */
+static int
+kdb_rdv(int argc, const char **argv)
+{
+ struct pt_regs *regs = get_irq_regs();
+ kdba_dumpregs(regs, NULL, NULL);
+ kdb_printf("\n");
+ display_eflags(regs->flags);
+ kdb_printf("\n");
+ display_gdtr();
+ display_idtr();
+ display_ldtr();
+ kdb_printf("\n");
+ display_cr0();
+ display_cr3();
+ display_cr4();
+ display_cr8();
+ kdb_printf("\n");
+ display_dr();
+ return 0;
+}
+
+static int
+kdb_rdmsr(int argc, const char **argv)
+{
+ unsigned long addr;
+ uint32_t l, h;
+ int diag;
+ struct cpuinfo_x86 *c = &cpu_data(smp_processor_id());
+
+ if (argc != 1)
+ return KDB_ARGCOUNT;
+
+ if ((diag = kdbgetularg(argv[1], &addr)))
+ return diag;
+
+ if (!cpu_has(c, X86_FEATURE_MSR))
+ return KDB_NOTIMP;
+
+ kdb_printf("msr(0x%lx) = ", addr);
+ if ((diag = rdmsr_safe(addr, &l, &h))) {
+ kdb_printf("error %d\n", diag);
+ return KDB_BADINT;
+ } else {
+ kdb_printf("0x%08x_%08x\n", h, l);
+ }
+
+ return 0;
+}
+
+static int
+kdb_wrmsr(int argc, const char **argv)
+{
+ unsigned long addr;
+ unsigned long l, h;
+ int diag;
+ struct cpuinfo_x86 *c = &cpu_data(smp_processor_id());
+
+ if (argc != 3)
+ return KDB_ARGCOUNT;
+
+ if ((diag = kdbgetularg(argv[1], &addr))
+ || (diag = kdbgetularg(argv[2], &h))
+ || (diag = kdbgetularg(argv[3], &l)))
+ return diag;
+
+ if (!cpu_has(c, X86_FEATURE_MSR))
+ return KDB_NOTIMP;
+
+ if ((diag = wrmsr_safe(addr, l, h))) {
+ kdb_printf("error %d\n", diag);
+ return KDB_BADINT;
+ }
+
+ return 0;
+}
+
+static int __init kdbm_x86_init(void)
+{
+ kdb_register("rdv", kdb_rdv, NULL, "Display registers in verbose mode", 0);
+ kdb_register_repeat("gdt", kdb_gdt, "<sel> [<count>]", "Display GDT", 0, KDB_REPEAT_NO_ARGS);
+ kdb_register_repeat("idt", kdb_idt, "<int> [<count>]", "Display IDT", 0, KDB_REPEAT_NO_ARGS);
+ kdb_register_repeat("ldt", kdb_ldt, "<sel> [<count>]", "Display LDT", 0, KDB_REPEAT_NO_ARGS);
+ kdb_register_repeat("ptex", kdb_pte, "<addr> [<count>]", "Display pagetables", 0, KDB_REPEAT_NO_ARGS);
+ kdb_register_repeat("ldtp", kdb_ldt, "<sel> [<count>]", "Display Process LDT", 0, KDB_REPEAT_NO_ARGS);
+ kdb_register("rdmsr", kdb_rdmsr, "<maddr>", "Display Model Specific Register", 0);
+ kdb_register("wrmsr", kdb_wrmsr, "<maddr> <h> <l>", "Modify Model Specific Register", 0);
+ return 0;
+}
+
+static void __exit kdbm_x86_exit(void)
+{
+ kdb_unregister("rdv");
+ kdb_unregister("gdt");
+ kdb_unregister("ldt");
+ kdb_unregister("idt");
+ kdb_unregister("ptex");
+ kdb_unregister("ldtp");
+ kdb_unregister("rdmsr");
+ kdb_unregister("wrmsr");
+}
+
+module_init(kdbm_x86_init)
+module_exit(kdbm_x86_exit)
Index: linux/kdb/modules/kdbm_xpc.c
===================================================================
--- /dev/null
+++ linux/kdb/modules/kdbm_xpc.c
@@ -0,0 +1,1105 @@
+/*
+ * This file is subject to the terms and conditions of the GNU General Public
+ * License. See the file "COPYING" in the main directory of this archive
+ * for more details.
+ *
+ * Copyright (c) 2006 Silicon Graphics, Inc. All Rights Reserved.
+ */
+
+
+/*
+ * Cross Partition Communication (XPC) kdb support.
+ *
+ * This provides kdb commands for debugging XPC.
+ */
+
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/kdb.h>
+#include <linux/kdbprivate.h>
+#include <asm/sn/sn_sal.h>
+#include <asm/sn/xpc.h>
+
+
+MODULE_AUTHOR("SGI");
+MODULE_DESCRIPTION("Debug XPC information");
+MODULE_LICENSE("GPL");
+
+
+static int
+kdbm_xpc_down(int argc, const char **argv)
+{
+ if (xpc_rsvd_page == NULL) {
+ kdb_printf("Reserved Page has not been initialized.\n");
+
+ } else if (xpc_kdebug_force_disengage()) {
+ kdb_printf("Unable to force XPC disengage.\n");
+ }
+ return 0;
+}
+
+
+static char *
+kdbm_xpc_get_ascii_reason_code(enum xpc_retval reason)
+{
+ switch (reason) {
+ case xpcSuccess: return "";
+ case xpcNotConnected: return "xpcNotConnected";
+ case xpcConnected: return "xpcConnected";
+ case xpcRETIRED1: return "xpcRETIRED1";
+ case xpcMsgReceived: return "xpcMsgReceived";
+ case xpcMsgDelivered: return "xpcMsgDelivered";
+ case xpcRETIRED2: return "xpcRETIRED2";
+ case xpcNoWait: return "xpcNoWait";
+ case xpcRetry: return "xpcRetry";
+ case xpcTimeout: return "xpcTimeout";
+ case xpcInterrupted: return "xpcInterrupted";
+ case xpcUnequalMsgSizes: return "xpcUnequalMsgSizes";
+ case xpcInvalidAddress: return "xpcInvalidAddress";
+ case xpcNoMemory: return "xpcNoMemory";
+ case xpcLackOfResources: return "xpcLackOfResources";
+ case xpcUnregistered: return "xpcUnregistered";
+ case xpcAlreadyRegistered: return "xpcAlreadyRegistered";
+ case xpcPartitionDown: return "xpcPartitionDown";
+ case xpcNotLoaded: return "xpcNotLoaded";
+ case xpcUnloading: return "xpcUnloading";
+ case xpcBadMagic: return "xpcBadMagic";
+ case xpcReactivating: return "xpcReactivating";
+ case xpcUnregistering: return "xpcUnregistering";
+ case xpcOtherUnregistering: return "xpcOtherUnregistering";
+ case xpcCloneKThread: return "xpcCloneKThread";
+ case xpcCloneKThreadFailed: return "xpcCloneKThreadFailed";
+ case xpcNoHeartbeat: return "xpcNoHeartbeat";
+ case xpcPioReadError: return "xpcPioReadError";
+ case xpcPhysAddrRegFailed: return "xpcPhysAddrRegFailed";
+ case xpcBteDirectoryError: return "xpcBteDirectoryError";
+ case xpcBtePoisonError: return "xpcBtePoisonError";
+ case xpcBteWriteError: return "xpcBteWriteError";
+ case xpcBteAccessError: return "xpcBteAccessError";
+ case xpcBtePWriteError: return "xpcBtePWriteError";
+ case xpcBtePReadError: return "xpcBtePReadError";
+ case xpcBteTimeOutError: return "xpcBteTimeOutError";
+ case xpcBteXtalkError: return "xpcBteXtalkError";
+ case xpcBteNotAvailable: return "xpcBteNotAvailable";
+ case xpcBteUnmappedError: return "xpcBteUnmappedError";
+ case xpcBadVersion: return "xpcBadVersion";
+ case xpcVarsNotSet: return "xpcVarsNotSet";
+ case xpcNoRsvdPageAddr: return "xpcNoRsvdPageAddr";
+ case xpcInvalidPartid: return "xpcInvalidPartid";
+ case xpcLocalPartid: return "xpcLocalPartid";
+ case xpcOtherGoingDown: return "xpcOtherGoingDown";
+ case xpcSystemGoingDown: return "xpcSystemGoingDown";
+ case xpcSystemHalt: return "xpcSystemHalt";
+ case xpcSystemReboot: return "xpcSystemReboot";
+ case xpcSystemPoweroff: return "xpcSystemPoweroff";
+ case xpcDisconnecting: return "xpcDisconnecting";
+ case xpcOpenCloseError: return "xpcOpenCloseError";
+ case xpcUnknownReason: return "xpcUnknownReason";
+ default: return "undefined reason code";
+ }
+}
+
+
+/*
+ * Display the reserved page used by XPC.
+ *
+ * xpcrp
+ */
+static int
+kdbm_xpc_rsvd_page(int argc, const char **argv)
+{
+ struct xpc_rsvd_page *rp = (struct xpc_rsvd_page *) xpc_rsvd_page;
+
+
+ if (argc > 0) {
+ return KDB_ARGCOUNT;
+ }
+
+ if (rp == NULL) {
+ kdb_printf("Reserved Page has not been initialized.\n");
+ return 0;
+ }
+
+ kdb_printf("struct xpc_rsvd_page @ (0x%p):\n", (void *) rp);
+ kdb_printf("\tSAL_signature=0x%lx\n", rp->SAL_signature);
+ kdb_printf("\tSAL_version=0x%lx\n", rp->SAL_version);
+ kdb_printf("\tpartid=%d\n", rp->partid);
+ kdb_printf("\tversion=0x%x %d.%d\n", rp->version,
+ XPC_VERSION_MAJOR(rp->version),
+ XPC_VERSION_MINOR(rp->version));
+ kdb_printf("\tvars_pa=0x%lx\n", rp->vars_pa);
+ kdb_printf("\tstamp=0x%lx:0x%lx\n",
+ rp->stamp.tv_sec, rp->stamp.tv_nsec);
+ kdb_printf("\tnasids_size=%ld\n", rp->nasids_size);
+
+ return 0;
+}
+
+
+static void
+kdbm_xpc_print_vars_part(struct xpc_vars_part *vars_part, partid_t partid)
+{
+ kdb_printf("struct xpc_vars_part @ (0x%p) [partid=%d]:\n",
+ (void *) vars_part, partid);
+ kdb_printf("\tmagic=0x%lx ", vars_part->magic);
+ if (vars_part->magic != 0) {
+ kdb_printf("%s", (char *) &vars_part->magic);
+ }
+ kdb_printf("\n");
+ kdb_printf("\tGPs_pa=0x%lx\n", vars_part->GPs_pa);
+ kdb_printf("\topenclose_args_pa=0x%lx\n",
+ vars_part->openclose_args_pa);
+ kdb_printf("\tIPI_amo_pa=0x%lx\n", vars_part->IPI_amo_pa);
+ kdb_printf("\tIPI_nasid=0x%x\n", vars_part->IPI_nasid);
+ kdb_printf("\tIPI_phys_cpuid=0x%x\n", vars_part->IPI_phys_cpuid);
+ kdb_printf("\tnchannels=%d\n", vars_part->nchannels);
+}
+
+
+/*
+ * Display XPC variables.
+ *
+ * xpcvars [ <partid> ]
+ *
+ * no partid - displays xpc_vars structure
+ * partid=0 - displays all initialized xpc_vars_part structures
+ * partid=i - displays xpc_vars_part structure for specified
+ * partition, if initialized
+ */
+static int
+kdbm_xpc_variables(int argc, const char **argv)
+{
+ int ret;
+ unsigned long ulong_partid;
+ partid_t partid;
+ struct xpc_vars_part *vars_part;
+
+
+ if (xpc_rsvd_page == NULL) {
+ kdb_printf("Reserved Page has not been initialized.\n");
+ return 0;
+ }
+ DBUG_ON(xpc_vars == NULL);
+
+ if (argc == 0) {
+
+ /* just display the xpc_vars structure */
+
+ kdb_printf("struct xpc_vars @ (0x%p):\n", (void *) xpc_vars);
+ kdb_printf("\tversion=0x%x %d.%d\n", xpc_vars->version,
+ XPC_VERSION_MAJOR(xpc_vars->version),
+ XPC_VERSION_MINOR(xpc_vars->version));
+ kdb_printf("\theartbeat=%ld\n", xpc_vars->heartbeat);
+ kdb_printf("\theartbeating_to_mask=0x%lx",
+ xpc_vars->heartbeating_to_mask);
+ for (partid = 1; partid < XP_MAX_PARTITIONS; partid++) {
+ if (xpc_hb_allowed(partid, xpc_vars)) {
+ kdb_printf(" %d", partid);
+ }
+ }
+ kdb_printf("\n");
+ kdb_printf("\theartbeat_offline=0x%lx\n",
+ xpc_vars->heartbeat_offline);
+ kdb_printf("\tact_nasid=0x%x\n", xpc_vars->act_nasid);
+ kdb_printf("\tact_phys_cpuid=0x%x\n",
+ xpc_vars->act_phys_cpuid);
+ kdb_printf("\tvars_part_pa=0x%lx\n", xpc_vars->vars_part_pa);
+ kdb_printf("\tamos_page_pa=0x%lx\n", xpc_vars->amos_page_pa);
+ kdb_printf("\tamos_page=0x%p\n", (void *) xpc_vars->amos_page);
+ return 0;
+
+ } else if (argc != 1) {
+ return KDB_ARGCOUNT;
+ }
+
+ ret = kdbgetularg(argv[1], (unsigned long *) &ulong_partid);
+ if (ret) {
+ return ret;
+ }
+ partid = (partid_t) ulong_partid;
+ if (partid < 0 || partid >= XP_MAX_PARTITIONS) {
+ kdb_printf("invalid partid\n");
+ return KDB_BADINT;
+ }
+
+ vars_part = (struct xpc_vars_part *) __va(xpc_vars->vars_part_pa);
+ DBUG_ON(vars_part == NULL);
+
+ if (partid == 0) {
+
+ /* display all initialized xpc_vars_part structure */
+
+ for (partid = 1; partid < XP_MAX_PARTITIONS; partid++) {
+ if (vars_part[partid].magic == 0) {
+ continue;
+ }
+ kdbm_xpc_print_vars_part(&vars_part[partid], partid);
+ }
+
+ } else {
+
+ /* display specified xpc_vars_part structure */
+
+ if (vars_part[partid].magic != 0) {
+ kdbm_xpc_print_vars_part(&vars_part[partid], partid);
+ } else {
+ kdb_printf("struct xpc_vars_part for partid %d not "
+ "initialized\n", partid);
+ }
+ }
+
+ return 0;
+}
+
+
+static void
+kdbm_xpc_print_engaged(char *string, u64 mask, int verbose)
+{
+ partid_t partid;
+
+
+ kdb_printf("%s=0x%lx", string, mask);
+
+ if (verbose) {
+ partid = 0;
+ while (mask != 0) {
+ if (mask & 1UL) {
+ kdb_printf(" %d", partid);
+ }
+ partid++;
+ mask >>= 1;
+ }
+ }
+ kdb_printf("\n");
+}
+
+
+/*
+ * Display XPC's 'engaged partitions' and 'disengage request' AMOs.
+ *
+ * xpcengaged [ -v ]
+ *
+ * -v - verbose mode, displays partition numbers.
+ */
+static int
+kdbm_xpc_engaged(int argc, const char **argv)
+{
+ int nextarg = 1;
+ int verbose = 0;
+ u64 mask;
+
+
+ if (argc > 1) {
+ return KDB_ARGCOUNT;
+ }
+ if (argc == 1) {
+ if (strcmp(argv[nextarg], "-v") != 0) {
+ return KDB_ARGCOUNT;
+ }
+ verbose = 1;
+ }
+
+ mask = xpc_partition_engaged(-1UL);
+ kdbm_xpc_print_engaged("engaged partitions", mask, verbose);
+
+ mask = xpc_partition_disengage_requested(-1UL);
+ kdbm_xpc_print_engaged("disengage request", mask, verbose);
+
+ return 0;
+}
+
+
+static void
+kdbm_xpc_print_IPI_flags_for_channel(u8 IPI_flags)
+{
+ if (IPI_flags & XPC_IPI_MSGREQUEST) kdb_printf(" MSGREQUEST");
+ if (IPI_flags & XPC_IPI_OPENREPLY) kdb_printf(" OPENREPLY");
+ if (IPI_flags & XPC_IPI_OPENREQUEST) kdb_printf(" OPENREQUEST");
+ if (IPI_flags & XPC_IPI_CLOSEREPLY) kdb_printf(" CLOSEREPLY");
+ if (IPI_flags & XPC_IPI_CLOSEREQUEST) kdb_printf(" CLOSEREQUEST");
+}
+
+
+static void
+kdbm_xpc_print_IPI_flags(u64 IPI_amo)
+{
+ int ch_number;
+ u8 IPI_flags;
+
+
+ for (ch_number = 0; ch_number < XPC_NCHANNELS; ch_number++) {
+
+ /* get the IPI flags for the specific channel */
+ IPI_flags = XPC_GET_IPI_FLAGS(IPI_amo, ch_number);
+ if (IPI_flags == 0) {
+ continue;
+ }
+
+ kdb_printf("\t channel_%d=0x%x", ch_number, IPI_flags);
+ kdbm_xpc_print_IPI_flags_for_channel(IPI_flags);
+ kdb_printf("\n");
+ }
+}
+
+
+static void
+kdbm_xpc_print_part(struct xpc_partition *part, partid_t partid)
+{
+ kdb_printf("xpc_partitions[partid=%d] (0x%p):\n", partid,
+ (void *) part);
+ kdb_printf("\tremote_rp_version=0x%x %d.%d\n", part->remote_rp_version,
+ XPC_VERSION_MAJOR(part->remote_rp_version),
+ XPC_VERSION_MINOR(part->remote_rp_version));
+ kdb_printf("\tremote_rp_stamp=0x%lx:0x%lx\n",
+ part->remote_rp_stamp.tv_sec, part->remote_rp_stamp.tv_nsec);
+ kdb_printf("\tremote_rp_pa=0x%lx\n", part->remote_rp_pa);
+ kdb_printf("\tremote_vars_pa=0x%lx\n", part->remote_vars_pa);
+ kdb_printf("\tremote_vars_part_pa=0x%lx\n", part->remote_vars_part_pa);
+ kdb_printf("\tlast_heartbeat=%ld\n", part->last_heartbeat);
+ kdb_printf("\tremote_amos_page_pa=0x%lx\n", part->remote_amos_page_pa);
+ kdb_printf("\tremote_act_nasid=0x%x\n", part->remote_act_nasid);
+ kdb_printf("\tremote_act_phys_cpuid=0x%x\n",
+ part->remote_act_phys_cpuid);
+ kdb_printf("\tact_IRQ_rcvd=%d\n", part->act_IRQ_rcvd);
+ kdb_printf("\tact_state=%d", part->act_state);
+ switch (part->act_state) {
+ case XPC_P_INACTIVE: kdb_printf(" INACTIVE\n"); break;
+ case XPC_P_ACTIVATION_REQ: kdb_printf(" ACTIVATION_REQ\n"); break;
+ case XPC_P_ACTIVATING: kdb_printf(" ACTIVATING\n"); break;
+ case XPC_P_ACTIVE: kdb_printf(" ACTIVE\n"); break;
+ case XPC_P_DEACTIVATING: kdb_printf(" DEACTIVATING\n"); break;
+ default: kdb_printf(" unknown\n");
+ }
+ kdb_printf("\tremote_vars_version=0x%x %d.%d\n",
+ part->remote_vars_version,
+ XPC_VERSION_MAJOR(part->remote_vars_version),
+ XPC_VERSION_MINOR(part->remote_vars_version));
+ kdb_printf("\treactivate_nasid=%d\n", part->reactivate_nasid);
+ kdb_printf("\treason=%d %s\n", part->reason,
+ kdbm_xpc_get_ascii_reason_code(part->reason));
+ kdb_printf("\treason_line=%d\n", part->reason_line);
+
+ kdb_printf("\tdisengage_request_timeout=0x%lx\n",
+ part->disengage_request_timeout);
+ kdb_printf("\t&disengage_request_timer=0x%p\n",
+ (void *) &part->disengage_request_timer);
+
+ kdb_printf("\tsetup_state=%d", part->setup_state);
+ switch (part->setup_state) {
+ case XPC_P_UNSET: kdb_printf(" UNSET\n"); break;
+ case XPC_P_SETUP: kdb_printf(" SETUP\n"); break;
+ case XPC_P_WTEARDOWN: kdb_printf(" WTEARDOWN\n"); break;
+ case XPC_P_TORNDOWN: kdb_printf(" TORNDOWN\n"); break;
+ default: kdb_printf(" unknown\n");
+ }
+ kdb_printf("\treferences=%d\n", atomic_read(&part->references));
+ kdb_printf("\tnchannels=%d\n", part->nchannels);
+ kdb_printf("\tnchannels_active=%d\n",
+ atomic_read(&part->nchannels_active));
+ kdb_printf("\tnchannels_engaged=%d\n",
+ atomic_read(&part->nchannels_engaged));
+ kdb_printf("\tchannels=0x%p\n", (void *) part->channels);
+ kdb_printf("\tlocal_GPs=0x%p\n", (void *) part->local_GPs);
+ kdb_printf("\tremote_GPs=0x%p\n", (void *) part->remote_GPs);
+ kdb_printf("\tremote_GPs_pa=0x%lx\n", part->remote_GPs_pa);
+ kdb_printf("\tlocal_openclose_args=0x%p\n",
+ (void *) part->local_openclose_args);
+ kdb_printf("\tremote_openclose_args=0x%p\n",
+ (void *) part->remote_openclose_args);
+ kdb_printf("\tremote_openclose_args_pa=0x%lx\n",
+ part->remote_openclose_args_pa);
+ kdb_printf("\tremote_IPI_nasid=0x%x\n", part->remote_IPI_nasid);
+ kdb_printf("\tremote_IPI_phys_cpuid=0x%x\n",
+ part->remote_IPI_phys_cpuid);
+ kdb_printf("\tremote_IPI_amo_va=0x%p\n",
+ (void *) part->remote_IPI_amo_va);
+ kdb_printf("\tlocal_IPI_amo_va=0x%p\n",
+ (void *) part->local_IPI_amo_va);
+ kdb_printf("\tlocal_IPI_amo=0x%lx\n", part->local_IPI_amo);
+ kdbm_xpc_print_IPI_flags(part->local_IPI_amo);
+ kdb_printf("\tIPI_owner=%s\n", part->IPI_owner);
+ kdb_printf("\t&dropped_IPI_timer=0x%p\n",
+ (void *) &part->dropped_IPI_timer);
+
+ kdb_printf("\tchannel_mgr_requests=%d\n", atomic_read(&part->
+ channel_mgr_requests));
+}
+
+
+/*
+ * Display XPC partitions.
+ *
+ * xpcpart [ <vaddr> | <partid> ]
+ */
+static int
+kdbm_xpc_partitions(int argc, const char **argv)
+{
+ int ret;
+ int nextarg = 1;
+ long offset = 0;
+ unsigned long addr;
+ struct xpc_partition *part;
+ partid_t partid;
+
+
+ if (argc > 1) {
+ return KDB_ARGCOUNT;
+
+ } else if (argc == 1) {
+ ret = kdbgetaddrarg(argc, argv, &nextarg, &addr, &offset,
+ NULL);
+ if (ret) {
+ return ret;
+ }
+ if (addr > 0 && addr < XP_MAX_PARTITIONS) {
+ partid = (partid_t) addr;
+ part = &xpc_partitions[partid];
+ } else {
+ part = (struct xpc_partition *) addr;
+ partid = part - &xpc_partitions[0];
+ if (partid <= 0 || partid >= XP_MAX_PARTITIONS ||
+ part != &xpc_partitions[partid]) {
+ kdb_printf("invalid partition entry address\n");
+ return KDB_BADADDR;
+ }
+ }
+ kdbm_xpc_print_part(part, partid);
+
+ } else {
+ for (partid = 1; partid < XP_MAX_PARTITIONS; partid++) {
+ part = &xpc_partitions[partid];
+ if (part->setup_state == XPC_P_UNSET &&
+ part->reason == 0) {
+ continue;
+ }
+ kdbm_xpc_print_part(part, partid);
+ }
+ }
+ return 0;
+}
+
+
+static void
+kdbm_xpc_print_channel_flags(u32 flags)
+{
+ kdb_printf("\tflags=0x%x", flags);
+
+ if (flags & XPC_C_WDISCONNECT) kdb_printf(" WDISCONNECT");
+ if (flags & XPC_C_DISCONNECTINGCALLOUT_MADE) kdb_printf(" DISCONNECTINGCALLOUT_MADE");
+ if (flags & XPC_C_DISCONNECTINGCALLOUT) kdb_printf(" DISCONNECTINGCALLOUT");
+ if (flags & XPC_C_DISCONNECTING) kdb_printf(" DISCONNECTING");
+ if (flags & XPC_C_DISCONNECTED) kdb_printf(" DISCONNECTED");
+
+ if (flags & XPC_C_CLOSEREQUEST) kdb_printf(" CLOSEREQUEST");
+ if (flags & XPC_C_RCLOSEREQUEST) kdb_printf(" RCLOSEREQUEST");
+ if (flags & XPC_C_CLOSEREPLY) kdb_printf(" CLOSEREPLY");
+ if (flags & XPC_C_RCLOSEREPLY) kdb_printf(" RCLOSEREPLY");
+
+ if (flags & XPC_C_CONNECTING) kdb_printf(" CONNECTING");
+ if (flags & XPC_C_CONNECTED) kdb_printf(" CONNECTED");
+ if (flags & XPC_C_CONNECTEDCALLOUT_MADE) kdb_printf(" CONNECTEDCALLOUT_MADE");
+ if (flags & XPC_C_CONNECTEDCALLOUT) kdb_printf(" CONNECTEDCALLOUT");
+ if (flags & XPC_C_SETUP) kdb_printf(" SETUP");
+
+ if (flags & XPC_C_OPENREQUEST) kdb_printf(" OPENREQUEST");
+ if (flags & XPC_C_ROPENREQUEST) kdb_printf(" ROPENREQUEST");
+ if (flags & XPC_C_OPENREPLY) kdb_printf(" OPENREPLY");
+ if (flags & XPC_C_ROPENREPLY) kdb_printf(" ROPENREPLY");
+
+ if (flags & XPC_C_WASCONNECTED) kdb_printf(" WASCONNECTED");
+
+ kdb_printf("\n");
+}
+
+
+static void
+kdbm_xpc_print_channel(struct xpc_channel *ch)
+{
+ kdb_printf("channel %d (0x%p):\n", ch->number, (void *) ch);
+ kdb_printf("\tpartid=%d\n", ch->partid);
+
+ kdbm_xpc_print_channel_flags(ch->flags);
+
+ kdb_printf("\treason=%d %s\n", ch->reason,
+ kdbm_xpc_get_ascii_reason_code(ch->reason));
+ kdb_printf("\treason_line=%d\n", ch->reason_line);
+ kdb_printf("\tnumber=%d\n", ch->number);
+ kdb_printf("\tmsg_size=%d\n", ch->msg_size);
+ kdb_printf("\tlocal_nentries=%d\n", ch->local_nentries);
+ kdb_printf("\tremote_nentries=%d\n", ch->remote_nentries);
+ kdb_printf("\tlocal_msgqueue=0x%p\n", (void *) ch->local_msgqueue);
+ kdb_printf("\tremote_msgqueue_pa=0x%lx\n", ch->remote_msgqueue_pa);
+ kdb_printf("\tremote_msgqueue=0x%p\n",
+ (void *) ch->remote_msgqueue);
+ kdb_printf("\treferences=%d\n", atomic_read(&ch->references));
+ kdb_printf("\tn_on_msg_allocate_wq=%d\n",
+ atomic_read(&ch->n_on_msg_allocate_wq));
+ kdb_printf("\t&msg_allocate_wq=0x%p\n",
+ (void *) &ch->msg_allocate_wq);
+
+ kdb_printf("\tdelayed_IPI_flags=0x%x", ch->delayed_IPI_flags);
+ kdbm_xpc_print_IPI_flags_for_channel(ch->delayed_IPI_flags);
+ kdb_printf("\n");
+
+ kdb_printf("\tn_to_notify=%d\n", atomic_read(&ch->n_to_notify));
+ kdb_printf("\tnotify_queue=0x%p\n", (void *) ch->notify_queue);
+ kdb_printf("\tfunc=0x%p\n", (void *) ch->func);
+ kdb_printf("\tkey=0x%p\n", ch->key);
+ kdb_printf("\t&msg_to_pull_mutex=0x%p\n",
+ (void *) &ch->msg_to_pull_mutex);
+ kdb_printf("\t&wdisconnect_wait=0x%p\n",
+ (void *) &ch->wdisconnect_wait);
+ kdb_printf("\tlocal_GP=0x%p (%ld:%ld)\n", (void *) ch->local_GP,
+ ch->local_GP->get,
+ ch->local_GP->put);
+ kdb_printf("\tremote_GP=%ld:%ld\n", ch->remote_GP.get,
+ ch->remote_GP.put);
+ kdb_printf("\tw_local_GP=%ld:%ld\n", ch->w_local_GP.get,
+ ch->w_local_GP.put);
+ kdb_printf("\tw_remote_GP=%ld:%ld\n", ch->w_remote_GP.get,
+ ch->w_remote_GP.put);
+ kdb_printf("\tnext_msg_to_pull=%ld\n", ch->next_msg_to_pull);
+ kdb_printf("\tkthreads_assigned=%d\n",
+ atomic_read(&ch->kthreads_assigned));
+ kdb_printf("\tkthreads_assigned_limit=%d\n",
+ ch->kthreads_assigned_limit);
+ kdb_printf("\tkthreads_idle=%d\n",
+ atomic_read(&ch->kthreads_idle));
+ kdb_printf("\tkthreads_idle_limit=%d\n", ch->kthreads_idle_limit);
+ kdb_printf("\tkthreads_active=%d\n",
+ atomic_read(&ch->kthreads_active));
+ kdb_printf("\tkthreads_created=%d\n", ch->kthreads_created);
+ kdb_printf("\t&idle_wq=0x%p\n", (void *) &ch->idle_wq);
+
+ if (ch->flags & XPC_C_CONNECTED) {
+ kdb_printf("\n\t#of local msg queue entries available =%ld\n",
+ ch->local_nentries - (ch->w_local_GP.put -
+ ch->w_remote_GP.get));
+
+ kdb_printf("\t#of local msgs allocated !sent =%ld\n",
+ ch->w_local_GP.put - ch->local_GP->put);
+ kdb_printf("\t#of local msgs allocated sent !ACK'd =%ld\n",
+ ch->local_GP->put - ch->remote_GP.get);
+ kdb_printf("\t#of local msgs allocated sent ACK'd !notified ="
+ "%ld\n", ch->remote_GP.get - ch->w_remote_GP.get);
+
+ kdb_printf("\t#of remote msgs sent !pulled =%ld\n",
+ ch->w_remote_GP.put - ch->next_msg_to_pull);
+ kdb_printf("\t#of remote msgs sent !delivered =%ld\n",
+ ch->next_msg_to_pull - ch->w_local_GP.get);
+ kdb_printf("\t#of remote msgs sent delivered !received =%ld\n",
+ ch->w_local_GP.get - ch->local_GP->get);
+ }
+}
+
+
+/*
+ * Display a XPC partition's channels.
+ *
+ * xpcchan <vaddr> | <partid> [ <channel> ]
+ */
+static int
+kdbm_xpc_channels(int argc, const char **argv)
+{
+ int ret;
+ int nextarg = 1;
+ long offset = 0;
+ unsigned long addr;
+ partid_t partid;
+ struct xpc_partition *part;
+ int ch_number;
+ struct xpc_channel *ch;
+
+
+ if (argc < 1 || argc > 2) {
+ return KDB_ARGCOUNT;
+ }
+
+ ret = kdbgetaddrarg(argc, argv, &nextarg, &addr, &offset, NULL);
+ if (ret) {
+ return ret;
+ }
+ if (addr > 0 && addr < XP_MAX_PARTITIONS) {
+ partid = (partid_t) addr;
+ part = &xpc_partitions[partid];
+ if (part->setup_state == XPC_P_UNSET) {
+ kdb_printf("partition is UNSET\n");
+ return 0;
+ }
+ if (part->setup_state == XPC_P_TORNDOWN) {
+ kdb_printf("partition is TORNDOWN\n");
+ return 0;
+ }
+
+ if (argc == 2) {
+ ret = kdbgetularg(argv[2],
+ (unsigned long *) &ch_number);
+ if (ret) {
+ return ret;
+ }
+ if (ch_number < 0 || ch_number >= part->nchannels) {
+ kdb_printf("invalid channel #\n");
+ return KDB_BADINT;
+ }
+ kdbm_xpc_print_channel(&part->channels[ch_number]);
+ } else {
+ for (ch_number = 0; ch_number < part->nchannels;
+ ch_number++) {
+ kdbm_xpc_print_channel(&part->
+ channels[ch_number]);
+ }
+ }
+
+ } else {
+ ch = (struct xpc_channel *) addr;
+
+ for (partid = 1; partid < XP_MAX_PARTITIONS; partid++) {
+ part = &xpc_partitions[partid];
+ if (part->setup_state != XPC_P_UNSET &&
+ part->setup_state != XPC_P_TORNDOWN &&
+ ch >= part->channels) {
+ ch_number = ch - part->channels;
+ if (ch_number < part->nchannels &&
+ ch == &part->channels[ch_number]) {
+ break;
+ }
+ }
+ }
+ if (partid == XP_MAX_PARTITIONS) {
+ kdb_printf("invalid channel address\n");
+ return KDB_BADADDR;
+ }
+ kdbm_xpc_print_channel(ch);
+ }
+
+ return 0;
+}
+
+
+static void
+kdbm_xpc_print_local_msgqueue(struct xpc_channel *ch)
+{
+ int i;
+ char *prefix;
+ struct xpc_msg *msg = ch->local_msgqueue;
+ s64 w_remote_GP_get = ch->w_remote_GP.get % ch->local_nentries;
+ s64 remote_GP_get = ch->remote_GP.get % ch->local_nentries;
+ s64 local_GP_put = ch->local_GP->put % ch->local_nentries;
+ s64 w_local_GP_put = ch->w_local_GP.put % ch->local_nentries;
+
+
+ kdb_printf("local message queue (0x%p):\n\n", (void *) msg);
+
+ for (i = 0; i < ch->local_nentries; i++) {
+ kdb_printf("0x%p: flags=0x%x number=%ld", (void *) msg,
+ msg->flags, msg->number);
+
+ prefix = " <--";
+
+ if (i == w_remote_GP_get) {
+ kdb_printf("%s w_remote_GP.get", prefix);
+ prefix = ",";
+ }
+ if (i == remote_GP_get) {
+ kdb_printf("%s remote_GP.get", prefix);
+ prefix = ",";
+ }
+ if (i == local_GP_put) {
+ kdb_printf("%s local_GP->put", prefix);
+ prefix = ",";
+ }
+ if (i == w_local_GP_put) {
+ kdb_printf("%s w_local_GP.put", prefix);
+ }
+ kdb_printf("\n");
+
+ msg = (struct xpc_msg *) ((u64) msg + ch->msg_size);
+ }
+}
+
+
+static void
+kdbm_xpc_print_remote_msgqueue(struct xpc_channel *ch)
+{
+ int i;
+ char *prefix;
+ struct xpc_msg *msg = ch->remote_msgqueue;
+ s64 local_GP_get = ch->local_GP->get % ch->remote_nentries;
+ s64 w_local_GP_get = ch->w_local_GP.get % ch->remote_nentries;
+ s64 next_msg_to_pull = ch->next_msg_to_pull % ch->remote_nentries;
+ s64 w_remote_GP_put = ch->w_remote_GP.put % ch->remote_nentries;
+ s64 remote_GP_put = ch->remote_GP.put % ch->remote_nentries;
+
+
+ kdb_printf("cached remote message queue (0x%p):\n\n", (void *) msg);
+
+ for (i = 0; i < ch->remote_nentries; i++) {
+ kdb_printf("0x%p: flags=0x%x number=%ld", (void *) msg,
+ msg->flags, msg->number);
+
+ prefix = " <--";
+
+ if (i == local_GP_get) {
+ kdb_printf("%s local_GP->get", prefix);
+ prefix = ",";
+ }
+ if (i == w_local_GP_get) {
+ kdb_printf("%s w_local_GP.get", prefix);
+ prefix = ",";
+ }
+ if (i == next_msg_to_pull) {
+ kdb_printf("%s next_msg_to_pull", prefix);
+ prefix = ",";
+ }
+ if (i == w_remote_GP_put) {
+ kdb_printf("%s w_remote_GP.put", prefix);
+ prefix = ",";
+ }
+ if (i == remote_GP_put) {
+ kdb_printf("%s remote_GP.put", prefix);
+ }
+ kdb_printf("\n");
+
+ msg = (struct xpc_msg *) ((u64) msg + ch->msg_size);
+ }
+}
+
+
+/*
+ * Display XPC specified message queue.
+ *
+ * xpcmque <partid> <channel> local|remote
+ */
+static int
+kdbm_xpc_msgqueue(int argc, const char **argv)
+{
+ int ret, ch_number;
+ unsigned long ulong_partid;
+ partid_t partid;
+ struct xpc_partition *part;
+ struct xpc_channel *ch;
+
+
+ if (argc != 3) {
+ return KDB_ARGCOUNT;
+ }
+
+ ret = kdbgetularg(argv[1], (unsigned long *) &ulong_partid);
+ if (ret) {
+ return ret;
+ }
+ partid = (partid_t) ulong_partid;
+ if (partid <= 0 || partid >= XP_MAX_PARTITIONS) {
+ kdb_printf("invalid partid\n");
+ return KDB_BADINT;
+ }
+
+ ret = kdbgetularg(argv[2], (unsigned long *) &ch_number);
+ if (ret) {
+ return ret;
+ }
+ if (ch_number < 0 || ch_number >= XPC_NCHANNELS) {
+ kdb_printf("invalid channel #\n");
+ return KDB_BADINT;
+ }
+
+ part = &xpc_partitions[partid];
+
+ if (part->setup_state == XPC_P_UNSET) {
+ kdb_printf("partition is UNSET\n");
+ return 0;
+ }
+ if (part->setup_state == XPC_P_TORNDOWN) {
+ kdb_printf("partition is TORNDOWN\n");
+ return 0;
+ }
+
+ if (ch_number >= part->nchannels) {
+ kdb_printf("unsupported channel #\n");
+ return KDB_BADINT;
+ }
+
+ ch = &part->channels[ch_number];
+
+ if (!(ch->flags & XPC_C_SETUP)) {
+ kdb_printf("message queues are not SETUP\n");
+ return 0;
+ }
+
+ if (strcmp(argv[3], "r") == 0 || strcmp(argv[3], "remote") == 0) {
+ kdbm_xpc_print_remote_msgqueue(ch);
+ } else if (strcmp(argv[3], "l") == 0 || strcmp(argv[3], "local") == 0) {
+ kdbm_xpc_print_local_msgqueue(ch);
+ } else {
+ kdb_printf("unknown msg queue selected\n");
+ return KDB_BADINT;
+ }
+
+ return 0;
+}
+
+
+static void
+kdbm_xpc_print_msg_flags(u8 flags)
+{
+ kdb_printf("\tflags=0x%x", flags);
+
+ if (flags & XPC_M_INTERRUPT) kdb_printf(" INTERRUPT");
+ if (flags & XPC_M_READY) kdb_printf(" READY");
+ if (flags & XPC_M_DONE) kdb_printf(" DONE");
+
+ kdb_printf("\n");
+}
+
+
+/*
+ * Display XPC message.
+ *
+ * xpcmsg <vaddr>
+ */
+static int
+kdbm_xpc_msg(int argc, const char **argv)
+{
+ int ret, nextarg = argc;
+ long offset = 0;
+ unsigned long addr;
+ struct xpc_msg *msg;
+
+
+ if (argc != 1) {
+ return KDB_ARGCOUNT;
+ }
+
+ ret = kdbgetaddrarg(argc, argv, &nextarg, &addr, &offset, NULL);
+ if (ret) {
+ return ret;
+ }
+
+ msg = (struct xpc_msg *) addr;
+ kdb_printf("msg (0x%p):\n", (void *) msg);
+ kdbm_xpc_print_msg_flags(msg->flags);
+ kdb_printf("\tnumber=%ld\n", msg->number);
+ kdb_printf("\t&payload=0x%p\n", (void *) &msg->payload);
+
+ return 0;
+}
+
+
+static void
+kdbm_xpc_print_notify_queue(struct xpc_channel *ch)
+{
+ int i;
+ char *prefix;
+ struct xpc_notify *notify = ch->notify_queue;
+ s64 w_remote_GP_get = ch->w_remote_GP.get % ch->local_nentries;
+ s64 remote_GP_get = ch->remote_GP.get % ch->local_nentries;
+ s64 local_GP_put = ch->local_GP->put % ch->local_nentries;
+ s64 w_local_GP_put = ch->w_local_GP.put % ch->local_nentries;
+
+
+ kdb_printf("notify queue (0x%p):\n\n", (void *) notify);
+
+ for (i = 0; i < ch->local_nentries; i++) {
+ kdb_printf("0x%p: type=0x%x", (void *) notify, notify->type);
+
+ if (notify->type == XPC_N_CALL) {
+ kdb_printf(" CALL func=0x%p key=0x%p",
+ (void *) notify->func, notify->key);
+ }
+
+ prefix = " <--";
+
+ if (i == w_remote_GP_get) {
+ kdb_printf("%s w_remote_GP.get", prefix);
+ prefix = ",";
+ }
+ if (i == remote_GP_get) {
+ kdb_printf("%s remote_GP.get", prefix);
+ prefix = ",";
+ }
+ if (i == local_GP_put) {
+ kdb_printf("%s local_GP->put", prefix);
+ prefix = ",";
+ }
+ if (i == w_local_GP_put) {
+ kdb_printf("%s w_local_GP.put", prefix);
+ }
+ kdb_printf("\n");
+
+ notify++;
+ }
+}
+
+
+/*
+ * Display XPC specified notify queue.
+ *
+ * xpcnque <partid> <channel>
+ */
+static int
+kdbm_xpc_notify_queue(int argc, const char **argv)
+{
+ int ret, ch_number;
+ unsigned long ulong_partid;
+ partid_t partid;
+ struct xpc_partition *part;
+ struct xpc_channel *ch;
+
+
+ if (argc != 2) {
+ return KDB_ARGCOUNT;
+ }
+
+ ret = kdbgetularg(argv[1], (unsigned long *) &ulong_partid);
+ if (ret) {
+ return ret;
+ }
+ partid = (partid_t) ulong_partid;
+ if (partid <= 0 || partid >= XP_MAX_PARTITIONS) {
+ kdb_printf("invalid partid\n");
+ return KDB_BADINT;
+ }
+
+ ret = kdbgetularg(argv[2], (unsigned long *) &ch_number);
+ if (ret) {
+ return ret;
+ }
+ if (ch_number < 0 || ch_number >= XPC_NCHANNELS) {
+ kdb_printf("invalid channel #\n");
+ return KDB_BADINT;
+ }
+
+ part = &xpc_partitions[partid];
+
+ if (part->setup_state == XPC_P_UNSET) {
+ kdb_printf("partition is UNSET\n");
+ return 0;
+ }
+ if (part->setup_state == XPC_P_TORNDOWN) {
+ kdb_printf("partition is TORNDOWN\n");
+ return 0;
+ }
+
+ if (ch_number >= part->nchannels) {
+ kdb_printf("unsupported channel #\n");
+ return KDB_BADINT;
+ }
+
+ ch = &part->channels[ch_number];
+
+ if (!(ch->flags & XPC_C_SETUP)) {
+ kdb_printf("notify queue is not SETUP\n");
+ return 0;
+ }
+
+ kdbm_xpc_print_notify_queue(ch);
+
+ return 0;
+}
+
+
+static void
+kdbm_xpc_print_users(struct xpc_registration *registration, int ch_number)
+{
+ kdb_printf("xpc_registrations[channel=%d] (0x%p):\n", ch_number,
+ (void *) registration);
+
+ kdb_printf("\t&mutex=0x%p\n", (void *) ®istration->mutex);
+ kdb_printf("\tfunc=0x%p\n", (void *) registration->func);
+ kdb_printf("\tkey=0x%p\n", registration->key);
+ kdb_printf("\tnentries=%d\n", registration->nentries);
+ kdb_printf("\tmsg_size=%d\n", registration->msg_size);
+ kdb_printf("\tassigned_limit=%d\n", registration->assigned_limit);
+ kdb_printf("\tidle_limit=%d\n", registration->idle_limit);
+}
+
+
+/*
+ * Display current XPC users who have registered via xpc_connect().
+ *
+ * xpcusers [ <channel> ]
+ */
+static int
+kdbm_xpc_users(int argc, const char **argv)
+{
+ int ret;
+ struct xpc_registration *registration;
+ int ch_number;
+
+
+ if (argc > 1) {
+ return KDB_ARGCOUNT;
+
+ } else if (argc == 1) {
+ ret = kdbgetularg(argv[1], (unsigned long *) &ch_number);
+ if (ret) {
+ return ret;
+ }
+ if (ch_number < 0 || ch_number >= XPC_NCHANNELS) {
+ kdb_printf("invalid channel #\n");
+ return KDB_BADINT;
+ }
+ registration = &xpc_registrations[ch_number];
+ kdbm_xpc_print_users(registration, ch_number);
+
+ } else {
+ for (ch_number = 0; ch_number < XPC_NCHANNELS; ch_number++) {
+ registration = &xpc_registrations[ch_number];
+
+ /* if !XPC_CHANNEL_REGISTERED(ch_number) */
+ if (registration->func == NULL) {
+ continue;
+ }
+ kdbm_xpc_print_users(registration, ch_number);
+ }
+ }
+ return 0;
+}
+
+
+static int __init
+kdbm_xpc_register(void)
+{
+ (void) kdb_register("xpcdown", kdbm_xpc_down, "",
+ "Mark this partition as being down", 0);
+ (void) kdb_register("xpcrp", kdbm_xpc_rsvd_page, "",
+ "Display XPC reserved page", 0);
+ (void) kdb_register("xpcvars", kdbm_xpc_variables, "[<partid>]",
+ "Display XPC variables", 0);
+ (void) kdb_register("xpcengaged", kdbm_xpc_engaged, "[-v]",
+ "Display XPC engaged partitions AMOs", 0);
+ (void) kdb_register("xpcpart", kdbm_xpc_partitions, "[<vaddr>|"
+ "<partid>]", "Display struct xpc_partition entries", 0);
+ (void) kdb_register("xpcchan", kdbm_xpc_channels, "<vaddr> | <partid> "
+ "[<channel>]", "Display struct xpc_channel entries", 0);
+ (void) kdb_register("xpcmque", kdbm_xpc_msgqueue, "<partid> <channel> "
+ "local|remote", "Display local or remote msg queue", 0);
+ (void) kdb_register("xpcmsg", kdbm_xpc_msg, "<vaddr>",
+ "Display struct xpc_msg", 0);
+ (void) kdb_register("xpcnque", kdbm_xpc_notify_queue, "<partid> "
+ "<channel>", "Display notify queue", 0);
+ (void) kdb_register("xpcusers", kdbm_xpc_users, "[ <channel> ]",
+ "Display struct xpc_registration entries", 0);
+ return 0;
+}
+
+
+static void __exit
+kdbm_xpc_unregister(void)
+{
+ (void) kdb_unregister("xpcdown");
+ (void) kdb_unregister("xpcrp");
+ (void) kdb_unregister("xpcvars");
+ (void) kdb_unregister("xpcengaged");
+ (void) kdb_unregister("xpcpart");
+ (void) kdb_unregister("xpcchan");
+ (void) kdb_unregister("xpcmque");
+ (void) kdb_unregister("xpcmsg");
+ (void) kdb_unregister("xpcnque");
+ (void) kdb_unregister("xpcusers");
+}
+
+
+module_init(kdbm_xpc_register);
+module_exit(kdbm_xpc_unregister);
+
Index: linux/kernel/exit.c
===================================================================
--- linux.orig/kernel/exit.c
+++ linux/kernel/exit.c
@@ -4,6 +4,9 @@
* Copyright (C) 1991, 1992 Linus Torvalds
*/
+#ifdef CONFIG_KDB
+#include <linux/kdb.h>
+#endif
#include <linux/mm.h>
#include <linux/slab.h>
#include <linux/interrupt.h>
Index: linux/kernel/kallsyms.c
===================================================================
--- linux.orig/kernel/kallsyms.c
+++ linux/kernel/kallsyms.c
@@ -483,3 +483,25 @@ __initcall(kallsyms_init);
EXPORT_SYMBOL(__print_symbol);
EXPORT_SYMBOL_GPL(sprint_symbol);
+
+#ifdef CONFIG_KDB
+#include <linux/kdb.h>
+#include <linux/kdbprivate.h>
+
+const char *kdb_walk_kallsyms(loff_t *pos)
+{
+ static struct kallsym_iter kdb_walk_kallsyms_iter;
+ if (*pos == 0) {
+ memset(&kdb_walk_kallsyms_iter, 0, sizeof(kdb_walk_kallsyms_iter));
+ reset_iter(&kdb_walk_kallsyms_iter, 0);
+ }
+ while (1) {
+ if (!update_iter(&kdb_walk_kallsyms_iter, *pos))
+ return NULL;
+ ++*pos;
+ /* Some debugging symbols have no name. Ignore them. */
+ if (kdb_walk_kallsyms_iter.name[0])
+ return kdb_walk_kallsyms_iter.name;
+ }
+}
+#endif /* CONFIG_KDB */
Index: linux/kernel/module.c
===================================================================
--- linux.orig/kernel/module.c
+++ linux/kernel/module.c
@@ -2344,12 +2344,23 @@ out:
return -ERANGE;
}
+#ifdef CONFIG_KDB
+#include <linux/kdb.h>
+struct list_head *kdb_modules = &modules; /* kdb needs the list of modules */
+#endif /* CONFIG_KDB */
+
int module_get_kallsym(unsigned int symnum, unsigned long *value, char *type,
char *name, char *module_name, int *exported)
{
struct module *mod;
+#ifdef CONFIG_KDB
+ int get_lock = !KDB_IS_RUNNING();
+#else
+#define get_lock 1
+#endif
- preempt_disable();
+ if (get_lock)
+ preempt_disable();
list_for_each_entry(mod, &modules, list) {
if (symnum < mod->num_symtab) {
*value = mod->symtab[symnum].st_value;
@@ -2358,12 +2369,14 @@ int module_get_kallsym(unsigned int symn
KSYM_NAME_LEN);
strlcpy(module_name, mod->name, MODULE_NAME_LEN);
*exported = is_exported(name, mod);
- preempt_enable();
+ if (get_lock)
+ preempt_enable();
return 0;
}
symnum -= mod->num_symtab;
}
- preempt_enable();
+ if (get_lock)
+ preempt_enable();
return -ERANGE;
}
Index: linux/kernel/printk.c
===================================================================
--- linux.orig/kernel/printk.c
+++ linux/kernel/printk.c
@@ -432,6 +432,20 @@ asmlinkage long sys_syslog(int type, cha
return do_syslog(type, buf, len);
}
+#ifdef CONFIG_KDB
+/* kdb dmesg command needs access to the syslog buffer. do_syslog() uses locks
+ * so it cannot be used during debugging. Just tell kdb where the start and
+ * end of the physical and logical logs are. This is equivalent to do_syslog(3).
+ */
+void kdb_syslog_data(char *syslog_data[4])
+{
+ syslog_data[0] = log_buf;
+ syslog_data[1] = log_buf + log_buf_len;
+ syslog_data[2] = log_buf + log_end - (logged_chars < log_buf_len ? logged_chars : log_buf_len);
+ syslog_data[3] = log_buf + log_end;
+}
+#endif /* CONFIG_KDB */
+
/*
* Call the console drivers on a range of log_buf
*/
Index: linux/kernel/sched.c
===================================================================
--- linux.orig/kernel/sched.c
+++ linux/kernel/sched.c
@@ -7375,7 +7375,7 @@ void normalize_rt_tasks(void)
#endif /* CONFIG_MAGIC_SYSRQ */
-#ifdef CONFIG_IA64
+#if defined(CONFIG_IA64) || defined(CONFIG_KDB)
/*
* These functions are only useful for the IA64 MCA handling.
*
@@ -8138,3 +8138,79 @@ struct cgroup_subsys cpuacct_subsys = {
.subsys_id = cpuacct_subsys_id,
};
#endif /* CONFIG_CGROUP_CPUACCT */
+
+#ifdef CONFIG_KDB
+
+#include <linux/kdb.h>
+
+static void
+kdb_prio(char *name, struct rt_prio_array *array, kdb_printf_t xxx_printf)
+{
+ int pri;
+
+ xxx_printf(" %s bitmap: 0x%lx 0x%lx 0x%lx\n",
+ name,
+ array->bitmap[0], array->bitmap[1], array->bitmap[2]);
+
+ pri = sched_find_first_bit(array->bitmap);
+ if (pri != MAX_PRIO) {
+ xxx_printf(" bitmap priorities:");
+ while (pri != MAX_PRIO) {
+ xxx_printf(" %d", pri);
+ pri++;
+ pri = find_next_bit(array->bitmap, MAX_PRIO, pri);
+ }
+ xxx_printf("\n");
+ }
+
+ for (pri = 0; pri < MAX_PRIO; pri++) {
+ int printed_hdr = 0;
+ struct list_head *head, *curr;
+
+ head = array->queue + pri;
+ curr = head->next;
+ while(curr != head) {
+ struct task_struct *task;
+ if (!printed_hdr) {
+ xxx_printf(" queue at priority=%d\n", pri);
+ printed_hdr = 1;
+ }
+ task = list_entry(curr, struct task_struct, rt.run_list);
+ xxx_printf(" 0x%p %d %s time_slice:%d\n",
+ task, task->pid, task->comm,
+ task->rt.time_slice);
+ curr = curr->next;
+ }
+ }
+}
+
+/* This code must be in sched.c because struct rq is only defined in this
+ * source. To allow most of kdb to be modular, this code cannot call any kdb
+ * functions directly, any external functions that it needs must be passed in
+ * as parameters.
+ */
+
+void
+kdb_runqueue(unsigned long cpu, kdb_printf_t xxx_printf)
+{
+ struct rq *rq;
+
+ rq = cpu_rq(cpu);
+
+ xxx_printf("CPU%ld lock:%s curr:0x%p(%d)(%s)",
+ cpu, (spin_is_locked(&rq->lock))?"LOCKED":"free",
+ rq->curr, rq->curr->pid, rq->curr->comm);
+ if (rq->curr == rq->idle)
+ xxx_printf(" is idle");
+ xxx_printf("\n ");
+#ifdef CONFIG_SMP
+ xxx_printf(" cpu_load:%lu %lu %lu",
+ rq->cpu_load[0], rq->cpu_load[1], rq->cpu_load[2]);
+#endif
+ xxx_printf(" nr_running:%lu nr_switches:%llu\n",
+ rq->nr_running, (long long)rq->nr_switches);
+ kdb_prio("active", &rq->rt.active, xxx_printf);
+}
+EXPORT_SYMBOL(kdb_runqueue);
+
+#endif /* CONFIG_KDB */
Index: linux/kernel/signal.c
===================================================================
--- linux.orig/kernel/signal.c
+++ linux/kernel/signal.c
@@ -2624,3 +2624,52 @@ void __init signals_init(void)
{
sigqueue_cachep = KMEM_CACHE(sigqueue, SLAB_PANIC);
}
+
+#ifdef CONFIG_KDB
+#include <linux/kdb.h>
+/*
+ * kdb_send_sig_info
+ *
+ * Allows kdb to send signals without exposing signal internals.
+ *
+ * Inputs:
+ * t task
+ * siginfo signal information
+ * seqno current kdb sequence number (avoid including kdbprivate.h)
+ * Outputs:
+ * None.
+ * Returns:
+ * None.
+ * Locking:
+ * Checks if the required locks are available before calling the main
+ * signal code, to avoid kdb deadlocks.
+ * Remarks:
+ */
+void
+kdb_send_sig_info(struct task_struct *t, struct siginfo *info, int seqno)
+{
+ static struct task_struct *kdb_prev_t;
+ static int kdb_prev_seqno;
+ int sig, new_t;
+ if (!spin_trylock(&t->sighand->siglock)) {
+ kdb_printf("Can't do kill command now.\n"
+ "The sigmask lock is held somewhere else in kernel, try again later\n");
+ return;
+ }
+ spin_unlock(&t->sighand->siglock);
+ new_t = kdb_prev_t != t || kdb_prev_seqno != seqno;
+ kdb_prev_t = t;
+ kdb_prev_seqno = seqno;
+ if (t->state != TASK_RUNNING && new_t) {
+ kdb_printf("Process is not RUNNING, sending a signal from kdb risks deadlock\n"
+ "on the run queue locks. The signal has _not_ been sent.\n"
+ "Reissue the kill command if you want to risk the deadlock.\n");
+ return;
+ }
+ sig = info->si_signo;
+ if (send_sig_info(sig, info, t))
+ kdb_printf("Fail to deliver Signal %d to process %d.\n", sig, t->pid);
+ else
+ kdb_printf("Signal %d is sent to process %d.\n", sig, t->pid);
+}
+#endif /* CONFIG_KDB */
Index: linux/mm/hugetlb.c
===================================================================
--- linux.orig/mm/hugetlb.c
+++ linux/mm/hugetlb.c
@@ -661,6 +661,25 @@ int hugetlb_overcommit_handler(struct ct
#endif /* CONFIG_SYSCTL */
+#ifdef CONFIG_KDB
+#include <linux/kdb.h>
+#include <linux/kdbprivate.h>
+/* Like hugetlb_report_meminfo() but using kdb_printf() */
+void
+kdb_hugetlb_report_meminfo(void)
+{
+ kdb_printf(
+ "HugePages_Total: %5lu\n"
+ "HugePages_Free: %5lu\n"
+ "HugePages_Rsvd: %5lu\n"
+ "Hugepagesize: %5lu kB\n",
+ nr_huge_pages,
+ free_huge_pages,
+ resv_huge_pages,
+ HPAGE_SIZE/1024);
+}
+#endif /* CONFIG_KDB */
+
int hugetlb_report_meminfo(char *buf)
{
return sprintf(buf,
Index: linux/mm/swapfile.c
===================================================================
--- linux.orig/mm/swapfile.c
+++ linux/mm/swapfile.c
@@ -13,6 +13,10 @@
#include <linux/swap.h>
#include <linux/vmalloc.h>
#include <linux/pagemap.h>
+#ifdef CONFIG_KDB
+#include <linux/kdb.h>
+#include <linux/kdbprivate.h>
+#endif /* CONFIG_KDB */
#include <linux/namei.h>
#include <linux/shm.h>
#include <linux/blkdev.h>
@@ -1745,6 +1749,24 @@ void si_swapinfo(struct sysinfo *val)
spin_unlock(&swap_lock);
}
+#ifdef CONFIG_KDB
+/* Like si_swapinfo() but without the locks */
+void kdb_si_swapinfo(struct sysinfo *val)
+{
+ unsigned int i;
+ unsigned long nr_to_be_unused = 0;
+
+ for (i = 0; i < nr_swapfiles; i++) {
+ if (!(swap_info[i].flags & SWP_USED) ||
+ (swap_info[i].flags & SWP_WRITEOK))
+ continue;
+ nr_to_be_unused += swap_info[i].inuse_pages;
+ }
+ val->freeswap = nr_swap_pages + nr_to_be_unused;
+ val->totalswap = total_swap_pages + nr_to_be_unused;
+}
+#endif /* CONFIG_KDB */
+
/*
* Verify that a swap entry is valid and increment its swap map count.
*
Index: linux/drivers/usb/core/hcd.c
===================================================================
--- linux.orig/drivers/usb/core/hcd.c
+++ linux/drivers/usb/core/hcd.c
@@ -1976,6 +1976,20 @@ usb_hcd_platform_shutdown(struct platfor
}
EXPORT_SYMBOL_GPL(usb_hcd_platform_shutdown);
+#ifdef CONFIG_KDB_USB
+void *
+usb_hcd_get_kdb_poll_func(struct usb_device *udev)
+{
+ struct usb_hcd *hcd = bus_to_hcd(udev->bus);
+
+ if (hcd && hcd->driver)
+ return (void *)(hcd->driver->kdb_poll_char);
+
+ return NULL;
+}
+EXPORT_SYMBOL_GPL (usb_hcd_get_kdb_poll_func);
+#endif /* CONFIG_KDB_USB */
+
/*-------------------------------------------------------------------------*/
#if defined(CONFIG_USB_MON)
Index: linux/drivers/usb/core/hcd.h
===================================================================
--- linux.orig/drivers/usb/core/hcd.h
+++ linux/drivers/usb/core/hcd.h
@@ -214,6 +214,10 @@ struct hc_driver {
/* force handover of high-speed port to full-speed companion */
void (*relinquish_port)(struct usb_hcd *, int);
+#ifdef CONFIG_KDB_USB
+ /* KDB poll function for this HC */
+ int (*kdb_poll_char)(struct urb *urb);
+#endif /* CONFIG_KDB_USB */
};
extern int usb_hcd_link_urb_to_ep(struct usb_hcd *hcd, struct urb *urb);
Index: linux/drivers/usb/host/ehci-hcd.c
===================================================================
--- linux.orig/drivers/usb/host/ehci-hcd.c
+++ linux/drivers/usb/host/ehci-hcd.c
@@ -995,6 +995,48 @@ static int ehci_get_frame (struct usb_hc
ehci->periodic_size;
}
+#ifdef CONFIG_KDB_USB
+
+int
+ehci_kdb_poll_char(struct urb *urb)
+{
+ struct ehci_hcd *ehci;
+
+ /* just to make sure */
+ if (!urb || !urb->dev || !urb->dev->bus)
+ return -1;
+
+ ehci = (struct ehci_hcd *) hcd_to_ehci(bus_to_hcd(urb->dev->bus));
+
+ /* make sure */
+ if (!ehci)
+ return -1;
+
+ if (!HC_IS_RUNNING (ehci_to_hcd(ehci)->state))
+ return -1;
+
+ /*
+ * If ehci->lock is held coming into this routine, it could
+ * mean KDB was entered while the HC driver was in the midst
+ * of processing URBs. Therefore it could be dangerous to
+ * processes URBs from this poll routine. And, we can't wait on
+ * the lock since we are in KDB and kernel threads (including the
+ * one holding the lock) are suspended.
+ * So, we punt and return an error. Keyboards attached to this
+ * HC will not be useable from KDB at this time.
+ */
+ if (spin_is_locked(&ehci->lock))
+ return -EBUSY;
+
+ /* processes the URB */
+ if (qh_completions_kdb(ehci, urb->hcpriv, urb))
+ return 0;
+
+ return -1;
+}
+
+#endif /* CONFIG_KDB_USB */
+
/*-------------------------------------------------------------------------*/
#define DRIVER_INFO DRIVER_VERSION " " DRIVER_DESC
Index: linux/drivers/usb/host/ehci-pci.c
===================================================================
--- linux.orig/drivers/usb/host/ehci-pci.c
+++ linux/drivers/usb/host/ehci-pci.c
@@ -22,6 +22,10 @@
#error "This file is PCI bus glue. CONFIG_PCI must be defined."
#endif
+#ifdef CONFIG_KDB_USB
+#include <linux/kdb.h>
+#endif
+
/*-------------------------------------------------------------------------*/
/* called after powerup, by probe or system-pm "wakeup" */
@@ -379,6 +383,10 @@ static const struct hc_driver ehci_pci_h
.bus_suspend = ehci_bus_suspend,
.bus_resume = ehci_bus_resume,
.relinquish_port = ehci_relinquish_port,
+
+#ifdef CONFIG_KDB_USB
+ .kdb_poll_char = ehci_kdb_poll_char,
+#endif
};
/*-------------------------------------------------------------------------*/
Index: linux/kernel/sysctl_check.c
===================================================================
--- linux.orig/kernel/sysctl_check.c
+++ linux/kernel/sysctl_check.c
@@ -104,6 +104,7 @@ static const struct trans_ctl_table tran
{ KERN_MAX_LOCK_DEPTH, "max_lock_depth" },
{ KERN_NMI_WATCHDOG, "nmi_watchdog" },
{ KERN_PANIC_ON_NMI, "panic_on_unrecovered_nmi" },
+ { KERN_KDB, "kdb" },
{}
};
Index: linux/drivers/usb/host/ehci-q.c
===================================================================
--- linux.orig/drivers/usb/host/ehci-q.c
+++ linux/drivers/usb/host/ehci-q.c
@@ -448,6 +448,228 @@ halt:
return count;
}
+#ifdef CONFIG_KDB_USB
+/*
+ * This routine is basically a copy of qh_completions() for use by KDB.
+ * It is modified to only work on qtds which are associated
+ * with 'kdburb'. Also, there are some fixups related to locking.
+ */
+unsigned
+qh_completions_kdb(struct ehci_hcd *ehci, struct ehci_qh *qh, struct urb *kdburb)
+{
+ struct ehci_qtd *last = NULL, *end = qh->dummy;
+ struct list_head *entry, *tmp;
+ int last_status = -EINPROGRESS;
+ int stopped;
+ unsigned count = 0;
+ int do_status = 0;
+ u8 state;
+ u32 halt = HALT_BIT(ehci);
+
+ /* verify params are valid */
+ if (!qh || !kdburb)
+ return 0;
+
+ if (unlikely (list_empty (&qh->qtd_list)))
+ return count;
+
+ /* completions (or tasks on other cpus) must never clobber HALT
+ * till we've gone through and cleaned everything up, even when
+ * they add urbs to this qh's queue or mark them for unlinking.
+ *
+ * NOTE: unlinking expects to be done in queue order.
+ */
+ state = qh->qh_state;
+ qh->qh_state = QH_STATE_COMPLETING;
+ stopped = (state == QH_STATE_IDLE);
+
+ /* remove de-activated QTDs from front of queue.
+ * after faults (including short reads), cleanup this urb
+ * then let the queue advance.
+ * if queue is stopped, handles unlinks.
+ */
+ list_for_each_safe (entry, tmp, &qh->qtd_list) {
+ struct ehci_qtd *qtd;
+ struct urb *urb;
+ u32 token = 0;
+ int qtd_status;
+
+ qtd = list_entry (entry, struct ehci_qtd, qtd_list);
+ urb = qtd->urb;
+
+ if (urb != kdburb)
+ continue;
+
+ /* clean up any state from previous QTD ...*/
+ if (last) {
+ if (likely (last->urb != urb)) {
+ /*
+ * Lock hackery here...
+ * ehci_urb_done() makes the assumption
+ * that it's called with ehci->lock held.
+ * So, lock it if it isn't already.
+ */
+ if (!spin_is_locked(&ehci->lock))
+ spin_lock(&ehci->lock);
+
+ ehci_urb_done(ehci, last->urb, last_status);
+
+ /*
+ * ehci_urb_done() releases and reacquires
+ * ehci->lock, so release it here.
+ */
+ if (spin_is_locked(&ehci->lock))
+ spin_unlock (&ehci->lock);
+
+ count++;
+ }
+ ehci_qtd_free (ehci, last);
+ last = NULL;
+ last_status = -EINPROGRESS;
+ }
+
+ /* ignore urbs submitted during completions we reported */
+ if (qtd == end)
+ break;
+
+ /* hardware copies qtd out of qh overlay */
+ rmb ();
+ token = hc32_to_cpu(ehci, qtd->hw_token);
+
+ /* always clean up qtds the hc de-activated */
+ if ((token & QTD_STS_ACTIVE) == 0) {
+
+ if ((token & QTD_STS_HALT) != 0) {
+ stopped = 1;
+
+ /* magic dummy for some short reads; qh won't advance.
+ * that silicon quirk can kick in with this dummy too.
+ */
+ } else if (IS_SHORT_READ (token)
+ && !(qtd->hw_alt_next
+ & EHCI_LIST_END(ehci))) {
+ stopped = 1;
+ goto halt;
+ }
+
+ /* stop scanning when we reach qtds the hc is using */
+ } else if (likely (!stopped
+ && HC_IS_RUNNING (ehci_to_hcd(ehci)->state))) {
+ break;
+
+ } else {
+ stopped = 1;
+
+ if (unlikely (!HC_IS_RUNNING (ehci_to_hcd(ehci)->state)))
+ last_status = -ESHUTDOWN;
+
+ /* ignore active urbs unless some previous qtd
+ * for the urb faulted (including short read) or
+ * its urb was canceled. we may patch qh or qtds.
+ */
+ if (likely(last_status == -EINPROGRESS &&
+ !urb->unlinked))
+ continue;
+
+ /* issue status after short control reads */
+ if (unlikely (do_status != 0)
+ && QTD_PID (token) == 0 /* OUT */) {
+ do_status = 0;
+ continue;
+ }
+
+ /* token in overlay may be most current */
+ if (state == QH_STATE_IDLE
+ && cpu_to_hc32(ehci, qtd->qtd_dma)
+ == qh->hw_current)
+ token = hc32_to_cpu(ehci, qh->hw_token);
+
+ /* force halt for unlinked or blocked qh, so we'll
+ * patch the qh later and so that completions can't
+ * activate it while we "know" it's stopped.
+ */
+ if ((halt & qh->hw_token) == 0) {
+halt:
+ qh->hw_token |= halt;
+ wmb ();
+ }
+ }
+
+ /* remove it from the queue */
+ qtd_status = qtd_copy_status(ehci, urb, qtd->length, token);
+ if (unlikely(qtd_status == -EREMOTEIO)) {
+ do_status = (!urb->unlinked &&
+ usb_pipecontrol(urb->pipe));
+ qtd_status = 0;
+ }
+ if (likely(last_status == -EINPROGRESS))
+ last_status = qtd_status;
+
+ if (stopped && qtd->qtd_list.prev != &qh->qtd_list) {
+ last = list_entry (qtd->qtd_list.prev,
+ struct ehci_qtd, qtd_list);
+ last->hw_next = qtd->hw_next;
+ }
+ list_del (&qtd->qtd_list);
+ last = qtd;
+ }
+
+ /* last urb's completion might still need calling */
+ if (likely (last != NULL)) {
+ /*
+ * Lock hackery here...
+ * ehci_urb_done() makes the assumption
+ * that it's called with ehci->lock held.
+ * So, lock it if it isn't already.
+ */
+ if (!spin_is_locked(&ehci->lock))
+ spin_lock(&ehci->lock);
+
+ ehci_urb_done(ehci, last->urb, last_status);
+
+ /*
+ * ehci_urb_done() releases and reacquires
+ * ehci->lock, so release it here.
+ */
+ if (spin_is_locked(&ehci->lock))
+ spin_unlock (&ehci->lock);
+
+ count++;
+ ehci_qtd_free (ehci, last);
+ }
+
+ /* restore original state; caller must unlink or relink */
+ qh->qh_state = state;
+
+ /* be sure the hardware's done with the qh before refreshing
+ * it after fault cleanup, or recovering from silicon wrongly
+ * overlaying the dummy qtd (which reduces DMA chatter).
+ */
+ if (stopped != 0 || qh->hw_qtd_next == EHCI_LIST_END(ehci)) {
+ switch (state) {
+ case QH_STATE_IDLE:
+ qh_refresh(ehci, qh);
+ break;
+ case QH_STATE_LINKED:
+ /* should be rare for periodic transfers,
+ * except maybe high bandwidth ...
+ */
+ if ((cpu_to_hc32(ehci, QH_SMASK)
+ & qh->hw_info2) != 0) {
+ intr_deschedule (ehci, qh);
+ (void) qh_schedule (ehci, qh);
+ } else
+ unlink_async (ehci, qh);
+ break;
+ /* otherwise, unlink already started */
+ }
+ }
+
+ return count;
+}
+
+#endif /* CONFIG_KDB_USB */
+
/*-------------------------------------------------------------------------*/
// high bandwidth multiplier, as encoded in highspeed endpoint descriptors
|