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
|
/*
EventGraph.c : Event graph engine.
Copyright (C) 1999, 2000, 2001, 2002 Karim Yaghmour (karym@opersys.com).
Portions contributed by T. Halloran: (C) Copyright 2002 IBM Poughkeepsie, IBM Corporation
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; version 2 of the License.
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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
History :
K.Y., 15/03/2002, Fixed RTAI display for fast drawing.
ROC., 01/01/2001, Optimized drawing and added selective icon suppression
JAL, 05/12/2000, Added support for cross-platform trace decoding.
(andy_lowe@mvista.com)
K.Y., 19/06/2000, Added RTAI traces support.
K.Y., 10/05/2000, Scroll functions have been added to respond to
the user playing with the Up, Down, Left, Right and
Page Up, Page Down keys.
K.Y., 10/02/2000, EGIDrawEvents() has undergone another major rewrite
because of the changes in the way the trace is read.
The event structure not holding the same information
it had, details are fetched dynamically using the
corresponding DBEventXXX() functions.
K.Y., 20/10/1999, EGIDrawEvents() has gone a major rewrite. Now, it uses
IRQ entries and exits and has been corrected for some
nuissances and complexities it has. It is still complex
though, but there's no way around this if Linux' behavior
is to be presented as it really is.
K.Y., 19/07/1999, Adding detail to the graph after separating EGIDrawTrace()
in smaller pieces.
K.Y., 07/07/1999, Using a pixmap the size of drawable area. Initially
drawing was done using a "true" size pixmap containing
all the trace. This took too much memory.
K.Y., 28/06/1999, Initial typing.
*/
#include <sys/time.h>
#include <unistd.h>
#include <math.h> /* This is for fmod */
#include <gdk/gdkkeysyms.h>
#include <EventOptions.h>
#include <Tables.h>
#include <EventDB.h>
#if SUPP_RTAI
#include <RTAIDB.h>
#endif
#include "MainWindow.h"
#include "EventGraph.h"
const gchar* gProcessItemData = "Process Item Data";
/**********************************************************************************/
/******************************* Internal functions *******************************/
/**********************************************************************************/
/******************************************************************
* Macro : EGIFindEventDistance()
* Description :
* Parameters :
* Return values :
* History :
* Note :
******************************************************************/
#if 1
#define EGIFindEventDistance(EGraph, EventDesc, DrawStart, DrawEnd) \
(guint) ((((gdouble) EGraph->HDrawSize) * \
(DBGetTimeInDouble(EventDesc.Time) - DrawStart)) / (DrawEnd - DrawStart))
#else /* This is for debugging only */
guint EGIFindEventDistance(eventGraph* pmEventGraph,
eventDescription pmEventDesc,
gdouble pmDrawStart,
gdouble pmDrawEnd)
{
guint lRetValue;
gdouble lDistance;
lDistance = (DBGetTimeInDouble(pmEventDesc.Time) - pmDrawStart) * ((gdouble) pmEventGraph->HDrawSize);
lDistance /= pmDrawEnd - pmDrawStart;
g_print("lDistance = %lf \n", lDistance);
lRetValue = (guint) lDistance;
g_print("lRetValue = %d \n", lRetValue);
return lRetValue;
}
#endif
/******************************************************************
* Macro : EGIFindProcessHeight()
* Description :
* Parameters :
* Return values :
* History :
* Note :
******************************************************************/
#define EGIFindProcessHeight(EGraph, Process) \
EGraph->VTrueSize - \
(EGraph->NbProc - Process->ListPos) * EGraph->LabelHeight + \
EGraph->LabelHeight / 3
/******************************************************************
* Macro : EGIFindKernelHeight()
* Description :
* Parameters :
* Return values :
* History :
* Note :
******************************************************************/
#define EGIFindKernelHeight(EGraph) \
EGraph->VTrueSize - \
(EGraph->NbTask + 1) * EGraph->LabelHeight + \
EGraph->LabelHeight / 3
/******************************************************************
* Macro : EGIFindTaskHeight()
* Description :
* Parameters :
* Return values :
* History :
* Note :
******************************************************************/
#if SUPP_RTAI
#if 0
#define EGIFindTaskHeight(EGraph, Task) \
EGraph->VTrueSize - \
(EGraph->NbProc - Task->ListPos) * EGraph->LabelHeight + \
EGraph->LabelHeight / 3
#else
inline guint EGIFindTaskHeight(eventGraph* pmEventGraph, RTAItask* pmTask)
{
if(pmTask != NULL)
return (pmEventGraph->VTrueSize - \
(pmEventGraph->NbProc - pmTask->ListPos) * pmEventGraph->LabelHeight + \
pmEventGraph->LabelHeight / 3);
else
return EGIFindKernelHeight(pmEventGraph);
}
#endif
#endif /* SUPP_RTAI */
/******************************************************************
* Macro : EGIFindRTAIHeight()
* Description :
* Parameters :
* Return values :
* History :
* Note :
******************************************************************/
#if SUPP_RTAI
#define EGIFindRTAIHeight(EGraph) \
EGraph->VTrueSize - EGraph->LabelHeight + EGraph->LabelHeight / 3
#endif /* SUPP_RTAI */
/******************************************************************
* Function : EGIDrawVLine()
* Description :
* Accept a vertical line draw request. Defer it as long as possible
* (notably when the current X position has finally changed). This
* prevents needless overdraws in expanded time scales when USecPerPixel
* gets big (draw count is reduced by 10x). Update the deferred request
* when the current request is for a longer line. This preserves
* the visual display of the original version of LTT.
* Parameters :
* pmEGraph, The event graph where to draw line.
* pmGC, The graphic context in which to draw the line.
* pmX, The X coordinate where to draw.
* pmY1, The Y coordinate where to start drawing.
* pmY2, The Y coordinate where to stop drawing.
* Return values :
* NONE
* History :
* 01/01, ROC Initial typing
* Note :
******************************************************************/
void EGIDrawVLine(eventGraph* pmEGraph, GdkGC* pmGC, guint pmX, guint pmY1, guint pmY2)
{
deferredLine* pDefLine = &(pmEGraph->VDef); /* Block invariant */
/* Should we draw fast vertical lines */
if(pmEGraph->FastVLines == TRUE)
{
/* If X has changed, either draw the deferral or flag an error. In either
case, store the current request as a completely new deferral. */
if(pDefLine->Same != pmX)
{
/* Draw and defer */
if(pDefLine->Same > pmX) /* idiot check */
g_print("Visualizer: Current VLine X < deferral point!!!\n");
/* First time check */
if(pDefLine->Same != 0)
{
/* Draw a line */
gdk_draw_line(pmEGraph->PixMap, pDefLine->GC,
pDefLine->Same, pDefLine->Start,
pDefLine->Same, pDefLine->End);
pmEGraph->NbVLines++;
}
/* Keep track of the request details to differ it */
pDefLine->GC = pmGC;
pDefLine->Same = pmX;
pDefLine->Start = pmY1;
pDefLine->End = pmY2;
}
else
{
/* same == x: Is the current request larger than the deferral?
Don't update on delta GC cuz that's not what the original
LTT did; it just drew the latest request which means
the longest, latest line always won. Yes there might
have been some inadvertent two-GC lines but too bad.
The test is <= instead of just < so that the "latest"
line is drawn. This more closely preserves visual
accuracy at high zoom out when the last control transfer
from a process to kernel has a different color. */
if(abs(pDefLine->End - pDefLine->Start) <= abs(pmY2 - pmY1))
{
pDefLine->Start = pmY1;
pDefLine->End = pmY2;
pDefLine->GC = pmGC; /* Might be different */
}
}
}
else
{
/* Slow behavior, draw EVERY request, even overdraws */
gdk_draw_line(pmEGraph->PixMap, pmGC, pmX, pmY1, pmX, pmY2);
pmEGraph->NbVLines++;
}
}
/******************************************************************
* Function : EGIDrawThickHLine()
* Description :
* Accept a horizontal line draw request. First, only draw the thick
* line at high enough zoom in; it's a 2/3 reduction in gdk_draw_line
* calls and does not affect the displayed info noticeably.
* As with vertical lines, defer the request as long as possible:
* when the current Y position GC (line type) has changed. Thus the
* "last line" drawn in a spot will always be the proper color/style.
* Update the deferred request by extending it when X changes but
* Y and GC do not. This accumulation also saves on gdk calls.
* The combined savings can be a factor of 100 drop in gdk_draw_line
* calls. Theoretically this may not duplicate the original look
* of LTT at high zoomout but I got over it :-)
* Parameters :
* pmEGraph, The event graph where to draw line.
* pmGC, The graphic context in which to draw the line.
* pmY, The Y coordinate where to draw.
* pmX1, The X coordinate where to start drawing.
* pmX2, The X coordinate where to stop drawing.
* Return values :
* NONE
* History :
* 01/01, ROC change from macro to function and enhance
* mm/yy K.Y. Initial typing
* Note :
* This used to be a macro.
******************************************************************/
void EGIDrawThickHLine(eventGraph* pmEGraph, GdkGC* pmGC, guint pmY, guint pmX1, guint pmX2)
{
deferredLine* pDefLine = &(pmEGraph->HDef); /* Block invariant */
/* Should we draw fast horizontal lines */
if(pmEGraph->FastHLines == TRUE)
{
/* If Y OR GC has changed, either draw the deferral or flag an error.
In either case, store the current request as a new deferral.
Note that the start case of DeferY == 0 comes through here
without a draw but makes the first deferral. BTW, don't draw
zero-length lines, either :-) */
if((pDefLine->Same != pmY) || (pDefLine->GC != pmGC))
{
if((pDefLine->Same != 0) && (pDefLine->End > pDefLine->Start))
{
gdk_draw_line(pmEGraph->PixMap, pDefLine->GC,
pDefLine->Start, pDefLine->Same,
pDefLine->End, pDefLine->Same);
pmEGraph->NbHLines++;
/* Thick lines? */
if(pmEGraph->NbIntervalEvents < 200)
{
gdk_draw_line(pmEGraph->PixMap, pDefLine->GC,
pDefLine->Start, pDefLine->Same + 1,
pDefLine->End, pDefLine->Same + 1);
gdk_draw_line(pmEGraph->PixMap, pDefLine->GC,
pDefLine->Start, pDefLine->Same + 2,
pDefLine->End, pDefLine->Same + 2);
pmEGraph->NbHLines += 2;
}
}
/* Keep record of request */
pDefLine->GC = pmGC;
pDefLine->Same = pmY;
pDefLine->Start = pmX1;
pDefLine->End = pmX2;
}
else
{
/* Same Y and GC; should I extend the current deferral? */
if(pDefLine->End > pmX2)
g_print("Visualizer: Current HLine x2 < deferral point!!!\n");
else
/* Also assigns on ==, I don't care */
pDefLine->End = pmX2;
}
}
else
{
/* Slow behavior, draw them now */
gdk_draw_line(pmEGraph->PixMap, pmGC, pmX1, pmY, pmX2, pmY);
gdk_draw_line(pmEGraph->PixMap, pmGC, pmX1, pmY + 1, pmX2, pmY + 1);
gdk_draw_line(pmEGraph->PixMap, pmGC, pmX1, pmY + 2, pmX2, pmY + 2);
pmEGraph->NbHLines += 3;
}
}
/******************************************************************
* Function : EGICreateColor()
* Description :
* Parameters :
* Return values :
* History :
* Note :
******************************************************************/
GdkColor* EGICreateColor(long pmRed, long pmGreen, long pmBlue)
{
GdkColor* pColor; /* The color */
/* Allocate space for color */
pColor = (GdkColor*) g_malloc(sizeof(GdkColor));
/* Set the color's attributes */
pColor->red = pmRed;
pColor->green = pmGreen;
pColor->blue = pmBlue;
/* Allocate the color in the colormap */
gdk_color_alloc(gdk_colormap_get_system(), pColor);
/* Give the color to the caller */
return pColor;
}
/******************************************************************
* Function : EGICreateGC()
* Description :
* Parameters :
* Return values :
* History :
* Note :
******************************************************************/
GdkGC* EGICreateGC(GdkPixmap* pmPixMap,
GdkColor* pmForegroundColor,
GdkColor* pmBackgroundColor,
GdkLineStyle pmLineType)
{
GdkGC* pGC; /* The graphic context */
/* Allocate space for GC */
pGC = gdk_gc_new(pmPixMap);
/* Set the forground and background colors */
gdk_gc_set_foreground(pGC, pmForegroundColor);
gdk_gc_set_background(pGC, pmBackgroundColor);
/* Set the Line Type */
gdk_gc_set_line_attributes(pGC,
1,
pmLineType,
GDK_CAP_NOT_LAST,
GDK_JOIN_MITER);
/* Return the graphic contex to the caller */
return pGC;
}
/******************************************************************
* Function : EGIFindDrawLimits()
* Description :
* Parameters :
* Return values :
* History :
* Note :
******************************************************************/
void EGIFindDrawLimits(eventGraph* pmEventGraph,
gfloat pmValue, gfloat pmPageSize,
gfloat pmMinValue, gfloat pmMaxValue,
gdouble* pmDrawStart, gdouble* pmDrawEnd)
{
/* Are we drawing the last page */
if(pmValue > (pmMaxValue - pmPageSize))
{
/* Set drawing times */
*pmDrawStart = pmEventGraph->StartTime + pmEventGraph->Duration - pmEventGraph->Interval;
*pmDrawEnd = pmEventGraph->StartTime + pmEventGraph->Duration;
}
else if(pmValue == pmMinValue)
{
/* Set drawing times */
*pmDrawStart = pmEventGraph->StartTime;
*pmDrawEnd = pmEventGraph->StartTime + pmEventGraph->Interval;
}
else
{
/* Set drawing times */
*pmDrawStart = pmEventGraph->StartTime +
(pmEventGraph->Duration *
(gdouble) ((pmValue - pmMinValue)) / (gdouble) (pmMaxValue - pmMinValue));
*pmDrawEnd = *pmDrawStart + pmEventGraph->Interval;
}
}
/******************************************************************
* Function : EGIFindLimitEvents()
* Description :
* Find the events at the limits of the draw area.
* Parameters :
* pmEventGraph, The event graph for which the search is carried
* out
* pmDrawStart, The time at which we start drawing.
* pmDrawEnd, The time at which we end drawing.
* pmFirstEvent, The pointer to the first event to be drawn.
* pmLastEvent, The pointer to the last event to be drawn.
* Return values :
* TRUE, We found drawing limits.
* FALSE, We failed to find draw limits.
* History :
* 01/01 ROC Count events in the interval.
* mm/yy K.Y. Initial typing
* Note :
* ROC, Earlier I had needed this calculated before the main event loop.
* That's not true anymore and perhaps it should be moved back there.
******************************************************************/
int EGIFindLimitEvents(eventGraph* pmEventGraph,
gdouble pmDrawStart, gdouble pmDrawEnd,
event* pmFirstEvent, event* pmLastEvent)
{
event lEvent; /* Generic event pointer */
event lEventNext; /* Next event */
event lEventPrev; /* Previous event */
event lFirstEvent = {0, 0}; /* First event drawn */
event lLastEvent = {0, 0}; /* Last event drawn */
struct timeval lEventTime; /* An event time */
struct timeval lEventNextTime; /* Next event's time */
struct timeval lEventPrevTime; /* Previous event's time */
/* Were we dealing with the first event in the event list */
if(pmDrawStart == pmEventGraph->StartTime)
lFirstEvent = pmEventGraph->EventDB->FirstEventWithProc;
else
{
/* Are we starting at the same time as the already draw event */
if(pmDrawStart == pmEventGraph->DrawStartTime)
/* Start at the same event as last time */
lFirstEvent = pmEventGraph->DrawStartEvent;
else
{
/* Start at the current draw start event */
lEventPrev = lEventNext = lEvent = pmEventGraph->DrawStartEvent;
/* Are we moving forward */
if(pmDrawStart >= pmEventGraph->DrawStartTime)
{
/* Keep going on forward in the trace */
while(DBEventNext(pmEventGraph->EventDB, &lEventNext) == TRUE)
{
/* Get the event time */
DBEventTime(pmEventGraph->EventDB, &lEvent, &lEventTime);
DBEventTime(pmEventGraph->EventDB, &lEventNext, &lEventNextTime);
/* Is the next event past the draw start time and the current one before */
if((DBGetTimeInDouble(lEventNextTime) >= pmDrawStart)
&&(DBGetTimeInDouble(lEventTime) < pmDrawStart))
{
/* We found the first event */
lFirstEvent = lEvent;
break;
}
/* Go to the next event */
lEvent = lEventNext;
}
}
else
{
/* Start at the next event since the current event could be the draw start event */
DBEventNext(pmEventGraph->EventDB, &lEvent);
/* Keep going on backwards in the trace */
do
{
/* Get the event time */
DBEventTime(pmEventGraph->EventDB, &lEvent, &lEventTime);
DBEventTime(pmEventGraph->EventDB, &lEventPrev, &lEventPrevTime);
/* Is the current event past the draw start time and the previous one before */
if((DBGetTimeInDouble(lEventTime) >= pmDrawStart)
&&(DBGetTimeInDouble(lEventPrevTime) < pmDrawStart))
{
/* We found the first event */
lFirstEvent = lEventPrev;
break;
}
/* Go to the previous event */
lEvent = lEventPrev;
/* Is this the first event drawable */
if(DBEventsEqual(lEvent, pmEventGraph->EventDB->FirstEventWithProc))
{
lFirstEvent = lEvent;
break;
}
} while(DBEventPrev(pmEventGraph->EventDB, &lEventPrev) == TRUE);
} /* End of else */
} /* End of else */
} /* End of else */
/* Just in case of early return... */
pmEventGraph->NbIntervalEvents = 0;
/* Did we find anything (Both are initialized as zero, so test if lFirstEvent remained zero) */
if(DBEventsEqual(lFirstEvent, lLastEvent))
return FALSE;
/* Loop around the rest of the events start from the first event */
lEventNext = lEvent = lFirstEvent;
do
{
/* Count operation (perhaps off by 2?) */
pmEventGraph->NbIntervalEvents++;
/* Get the event time */
DBEventTime(pmEventGraph->EventDB, &lEvent, &lEventTime);
DBEventTime(pmEventGraph->EventDB, &lEventNext, &lEventNextTime);
/* Is the next event past the draw end time and the current one before it */
if((DBGetTimeInDouble(lEventNextTime) > pmDrawEnd)
&& (DBGetTimeInDouble(lEventTime) <= pmDrawEnd))
/* We found the last event */
break;
/* Go to the next event */
lEvent = lEventNext;
} while(DBEventNext(pmEventGraph->EventDB, &lEventNext) == TRUE);
/* Set the last event drawn */
lLastEvent = lEventNext;
/* Are the last events and first events the same */
if(DBEventsEqual(lFirstEvent, lLastEvent))
return FALSE;
/* Update draw start time */
pmEventGraph->DrawStartTime = pmDrawStart;
/* Set and update the limit events found */
*pmFirstEvent = pmEventGraph->DrawStartEvent = lFirstEvent;
*pmLastEvent = pmEventGraph->DrawEndEvent = lLastEvent;
/* Tell the caller that the search was successfull */
return TRUE;
}
/******************************************************************
* Function : EGICommitEventDrawRequest()
* Description :
* Commits a draw event info request. This means that the information
* gets drawn to the trace pixmap.
* Parameters :
* pmEventInfo, The event info to be commited.
* pmEventGraph, The event graph where to commit the request.
* Return values :
* NONE
* History :
* 01/01 ROC, initial typing
* Note :
******************************************************************/
void EGICommitEventDrawRequest(eventInfo* pmEventInfo, eventGraph* pmEventGraph)
{
/* Set Clipping information */
gdk_gc_set_clip_mask (pmEventGraph->BackgroundGC,
pmEventInfo->EventIcon.Mask);
gdk_gc_set_clip_origin (pmEventGraph->BackgroundGC,
pmEventInfo->x,
pmEventInfo->y - EGRAPH_TEXT_TO_LINE_DIST - EGRAPH_ICONS_HEIGHT);
/* Draw an icon that represents the event */
gdk_draw_pixmap(pmEventGraph->PixMap,
pmEventGraph->BackgroundGC,
pmEventInfo->EventIcon.Pixmap,
0, 0,
pmEventInfo->x,
pmEventInfo->y - EGRAPH_TEXT_TO_LINE_DIST - EGRAPH_ICONS_HEIGHT,
EGRAPH_ICONS_WIDTH,
EGRAPH_ICONS_HEIGHT);
/* Stop clipping */
gdk_gc_set_clip_mask(pmEventGraph->BackgroundGC, NULL);
/* Suppressing text on icons saves less than 5% of the time of
drawing the icons. Calculated suppression is therefore not
worth it, especially considering the risk of misinterpretation.
Let the user decide for itself. */
if(GTK_TOGGLE_BUTTON(((mainWindow*)pmEventGraph->MainWindow)->tlbHideIconText)->active != TRUE)
gdk_draw_string(pmEventGraph->PixMap,
pmEventGraph->TextFont,
pmEventGraph->TextGC,
pmEventInfo->x + EGRAPH_ICONS_WIDTH,
pmEventInfo->y - EGRAPH_TEXT_TO_LINE_DIST,
pmEventInfo->EventText);
}
/******************************************************************
* Function :
* EGIPendDrawEventInfoReq()
* Description :
* This function pends a draw request for a clipped icon and
* text information on a pixmap.
* Description :
* Not every event gets an icon but many do (average about 40%).
* Accept an icon draw request. Only draw a new icon when it
* is far enough away from any other icon (where "far enough" is
* an evolving concept). This prevents useless overdraws in
* expanded time scales when USecPerPixel gets big. This has
* shown a factor of 10 drop in actual icon calls. Furthermore,
* suppress the text string until the graph is expanded "enough".
* ALWAYS update the deferred request (pixmap or label or Y may
* change).
* Parameters :
* pmEventGraph, The event graph being drawn.
* pmEventIcon, The icon to be drawn.
* pmX, The X position of the icon.
* pmY, The Y position of the icon.
* pmEventText, The text to be drawn beside the icon.
* pmEvent, The event for which the icon is being drawn.
* Return values :
* NONE.
* History : 01/01, ROC Deferral rewrite
* Note :
******************************************************************/
void EGIPendDrawEventInfoReq(eventGraph* pmEventGraph,
pixAndMask pmEventIcon,
guint pmX,
guint pmY,
gchar* pmEventText,
event* pmEvent)
{
guint dx; /* X distance */
guint dy; /* Y distance */
guint lOverlapRange; /* Range used to determine whether icons overlap */
GSList* pNextEventIcon; /* Next icon in event list */
eventInfo* pEventInfo; /* Pointer to event info */
mainWindow* pMainWindow; /* Pointer to main window */
/* Get main window */
pMainWindow = pmEventGraph->MainWindow;
/* A great philosophical argument could follow about the proper location
for these tests but the bottom line(s) are:
1. All tests are done here
2. It's only two lines per icon
3. I don't need to understand the logic of the calling routines.
I don't know how gcc does partial evals so these are separate "if"s */
if(GTK_TOGGLE_BUTTON(pMainWindow->tlbHideSysCalls)->active)
if(EGRAPH_PAM_EQUAL(pmEventIcon, pmEventGraph->SysCall))
return;
if(GTK_TOGGLE_BUTTON(pMainWindow->tlbHideIRQs)->active)
if(EGRAPH_PAM_EQUAL(pmEventIcon, pmEventGraph->IRQ))
return;
if(GTK_TOGGLE_BUTTON(pMainWindow->tlbHideTraps)->active)
if(EGRAPH_PAM_EQUAL(pmEventIcon, pmEventGraph->Trap))
return;
if(GTK_TOGGLE_BUTTON(pMainWindow->tlbHideSoftIRQs)->active)
if(EGRAPH_PAM_EQUAL(pmEventIcon, pmEventGraph->BottomHalf))
return;
if(GTK_TOGGLE_BUTTON(pMainWindow->tlbHideSchedChange)->active)
if(EGRAPH_PAM_EQUAL(pmEventIcon, pmEventGraph->SchedChange))
return;
if(GTK_TOGGLE_BUTTON(pMainWindow->tlbHideKernelTimer)->active)
if(EGRAPH_PAM_EQUAL(pmEventIcon, pmEventGraph->KernelTimer))
return;
/* Should we draw icons rapidly */
if(pmEventGraph->FastIcons)
{
/* Walk the list of already deferred icons, checking the distance
from the most recent ones. Stop when:
1. Looked far enough back in the list (add to the list)
2. An icon is too close (return)
3. End of list (add to the list) */
/* Determine overlap range */
lOverlapRange = pmX - EGRAPH_ICON_FAR_ENOUGH;
/* Start from the begining of the list of icons pending */
pNextEventIcon = pmEventGraph->EventIcons;
/* 'Til the last entry in the list */
while(pNextEventIcon != NULL)
{
/* Get the event information to be drawn */
pEventInfo = (eventInfo*) pNextEventIcon->data;
/* Get the location of the icon */
dx = pEventInfo->x;
/* Is this icon far enough from the current icon */
if(dx < lOverlapRange)
break; /* Rest of icons are further than this */
/* What's the difference between that icon and the requested draw location */
dx = dx - pmX;
dy = pEventInfo->y - pmY;
/* Do the icons overlap */
if((dx * dx + dy * dy) < EGRAPH_ICON_CLEARANCE)
/* The caller's request is refused since it overlaps with another request */
return;
/* Go to the next icon in the list */
pNextEventIcon = pNextEventIcon->next;
}
}
/* Are we drawing a process event (THIS IS UGLY CODE. K.Y.) */
if(pmY < (EGIFindKernelHeight(pmEventGraph) - EGRAPH_TEXT_TO_LINE_DIST))
pmEventGraph->NbUserIcons++;
else
pmEventGraph->NbKernelIcons++;
/* Allocate a new event coordinate item and prepend it to the list so
the most recent icons will be searched first next time through. */
pEventInfo = (eventInfo*) g_malloc(sizeof(eventInfo));
pEventInfo->EventIcon = pmEventIcon;
pEventInfo->x = pmX;
pEventInfo->y = pmY;
strcpy(pEventInfo->EventText, pmEventText); /* Copy dynamic data */
pEventInfo->Event = *pmEvent; /* Here, too */
/* The prepend call returns a new head of list so update it */
pmEventGraph->EventIcons = g_slist_prepend(pmEventGraph->EventIcons,
(gpointer) pEventInfo);
}
/******************************************************************
* Function :
* EGIDrawLinuxEvents()
* Description :
* Draws the event graph for Linux.
* Parameters :
* pmEventGraph, The event graph in which trace is drawn.
* pmEventDB, The event database of events to be drawn.
* pmSystem, The system to which the database belongs.
* pmDrawStart, The draw start time.
* pmDrawEnd, The draw end time.
* pmFirstEvent, The first event to be drawn.
* pmLastEvent, The last event to be drawn.
* Return values :
* NONE
* History :
* K.Y., 06/06/2000, This function is largely what EGIDrawEvents()
* used to be. I've taken the code out of there
* in order to implement support for multiple
* trace types.
* Note :
******************************************************************/
void EGIDrawLinuxEvents(eventGraph* pmEventGraph,
db* pmEventDB,
systemInfo* pmSystem,
gdouble pmDrawStart, gdouble pmDrawEnd,
event* pmFirstEvent, event* pmLastEvent)
{
gint lPID = -1; /* PID of event owner */
gint lLastCtrlEventID; /* The event ID of the last control event */
guint x1, y1, x2, y2; /* Origin and destination points for drawing */
gchar lString[30]; /* String used to display information on graph */
gdouble lDrawLinesTime = 0; /* Time taken to draw the lines */
gdouble lDrawIconsTime; /* Time taken to draw the icons */
gboolean lFirstCtrlEvent = TRUE; /* We are currently dealing with the first control% event */
event lEvent; /* Generic event */
event lLastCtrlEvent; /* Last event that generated a change of control */
GdkGC* pTempGC; /* Temporary graphic context */
process* pEventProcess = NULL; /* Process associated with event */
process* pLastCtrlEventProcess; /* Process to which last control event belongs */
struct timeval lDrawBeginTime; /* Time at which we began drawing */
struct timeval lDrawDoneTime; /* Time at which we were done drawing */
struct timeval lLastCtrlEventTime; /* The time of occurence of the last control event */
eventDescription lEventDesc; /* Generic event decription */
/* Go to the first significant event */
lLastCtrlEvent = lEvent = *pmFirstEvent;
/* Set last x and y */
x2 = 0;
y2 = EGIFindKernelHeight(pmEventGraph);
/* Is this the first schedule-in */
if(!DBEventsEqual(pmEventDB->FirstEventWithProc, lLastCtrlEvent))
/* Go back to the last control event */
while((DBEventControl(pmEventDB, &lLastCtrlEvent, pmSystem) != TRUE)
&&(DBEventPrev(pmEventDB, &lLastCtrlEvent) == TRUE));
/* Get the last control event's ID and it's process */
lLastCtrlEventID = DBEventID(pmEventDB, &lLastCtrlEvent);
pLastCtrlEventProcess = DBEventProcess(pmEventDB, &lLastCtrlEvent, pmSystem, FALSE);
/* Get the current event's ID and it's process */
pEventProcess = DBEventProcess(pmEventDB, &lEvent, pmSystem, FALSE);
lPID = pEventProcess->PID;
/* Initialize the last deferred event (ie, doesn't really exist) */
pmEventGraph->HDef.Same = 0;
pmEventGraph->VDef.Same = 0;
/* Initialize benchmark counters and stats even if they're never printed */
pmEventGraph->NbHLines = 1; /* Start at 1 to account for the final flush */
pmEventGraph->NbVLines = 1;
pmEventGraph->NbUserIcons = 0; /* But not icons as they are batch-delayed */
pmEventGraph->NbKernelIcons = 0;
gettimeofday(&lDrawBeginTime, NULL);
/* Draw the events */
while((DBEventNext(pmEventDB, &lEvent) == TRUE)
&& (!DBEventsEqual(lEvent, (*pmLastEvent))))
{
/* Get the event's description */
DBEventDescription(pmEventGraph->EventDB, &lEvent, FALSE, &lEventDesc);
/* If the trace contains many CPUs only draw the first one */
if((pmEventGraph->EventDB->LogCPUID == TRUE)
&&(lEventDesc.CPUID != 0))
continue;
#if 0
printf("X1 = %u; X2 = %u; Y1 = %u; Y2 = %u \n", x1, x2, y1, y2);
#endif
/* Depending on the event */
switch(lEventDesc.ID)
{
/* Entry (syscall / trap / irq) */
case TRACE_SYSCALL_ENTRY :
case TRACE_TRAP_ENTRY :
case TRACE_IRQ_ENTRY :
/* Is this an IRQ entry while we were in the kernel */
if((lEventDesc.ID == TRACE_IRQ_ENTRY)
&&(RFT8(pmEventDB, IRQ_EVENT(lEventDesc.Struct)->kernel)))
{
/* Display the IRQ information */
sprintf(lString, "%d:%s",
RFT8(pmEventDB, IRQ_EVENT(lEventDesc.Struct)->irq_id),
pmSystem->Interrupts[RFT8(pmEventDB, IRQ_EVENT(lEventDesc.Struct)->irq_id)]);
/* Draw the IRQ details */
EGIPendDrawEventInfoReq(pmEventGraph,
pmEventGraph->IRQ,
EGIFindEventDistance(pmEventGraph, lEventDesc, pmDrawStart, pmDrawEnd),
y2 - EGRAPH_TEXT_TO_LINE_DIST,
lString,
&lEvent);
/* Don't go any further */
continue;
}
/* Is this a trap while idle task was running. On PPC, the system timer is a trap and not an interrupt */
if((lEventDesc.ID == TRACE_TRAP_ENTRY)
&&(pEventProcess->PID == 0))
{
/* Display the trap entry information */
switch(pmEventDB->ArchType)
{
case TRACE_ARCH_TYPE_I386 :
case TRACE_ARCH_TYPE_PPC :
case TRACE_ARCH_TYPE_SH :
case TRACE_ARCH_TYPE_MIPS :
sprintf(lString, "%s", pmEventDB->TrapString(pmEventDB,
RFT16(pmEventDB, TRAP_EVENT(lEventDesc.Struct)->trap_id)));
break;
case TRACE_ARCH_TYPE_S390 :
sprintf(lString, "%s", pmEventDB->TrapString(pmEventDB,
RFT64(pmEventDB, TRAP_EVENT_S390(lEventDesc.Struct)->trap_id)));
break;
}
/* Draw the text and its icon */
EGIPendDrawEventInfoReq(pmEventGraph,
pmEventGraph->Trap,
EGIFindEventDistance(pmEventGraph, lEventDesc, pmDrawStart, pmDrawEnd),
y2 - EGRAPH_TEXT_TO_LINE_DIST,
lString,
&lEvent);
/* Don't go any further */
continue;
}
/* Are we at the begining of the graph */
if(lFirstCtrlEvent == TRUE)
{
/* Was the last control event an exit */
if(DBEventControlExit(pmEventDB, &lLastCtrlEvent, pEventProcess->PID) == TRUE)
{
/* Find the height of the process */
y2 = EGIFindProcessHeight(pmEventGraph, pEventProcess);
/* Use the process GC to draw the next horizontal line */
pTempGC = pmEventGraph->ProcessGC;
}
else
{
/* Find the height of the kernel */
y2 = EGIFindKernelHeight(pmEventGraph);
/* Use the process GC to draw the next horizontal line */
pTempGC = pmEventGraph->KernelGC;
}
}
else /* Not at beginning of graph */
{
/* Was the last control event an exit */
if(DBEventControlExit(pmEventDB, &lLastCtrlEvent, lPID) == TRUE)
{
/* Draw a line from the irq exit or trap exit to the process */
x1 = x2;
y1 = y2;
x2 = x1;
y2 = EGIFindProcessHeight(pmEventGraph, pEventProcess);
switch(lLastCtrlEventID)
{
case TRACE_SYSCALL_EXIT :
pTempGC = pmEventGraph->SysCallGC;
break;
case TRACE_TRAP_EXIT :
pTempGC = pmEventGraph->TrapGC;
break;
default :
pTempGC = pmEventGraph->InterruptGC;
break;
}
EGIDrawVLine(pmEventGraph, pTempGC, x1, y1, y2);
/* Does this event belong to a process or to the kernel */
if((pEventProcess != NULL)
&&(pEventProcess->PID != 0))
/* Use the process GC to draw the next horizontal line */
pTempGC = pmEventGraph->ProcessGC;
else
/* Use the kernel GC to draw the next horizontal line */
pTempGC = pmEventGraph->KernelGC;
} /* end of else-if */
/* The previous control event was NOT an exit */
else
/* Use the kernel GC to draw the next horizontal line */
pTempGC = pmEventGraph->KernelGC;
} /* Not at beginning of graph */
/* Draw a line from the last exit to now */
x1 = x2;
y1 = y2;
x2 = EGIFindEventDistance(pmEventGraph, lEventDesc, pmDrawStart, pmDrawEnd);
y2 = y1;
EGIDrawThickHLine(pmEventGraph, pTempGC, y2, x1, x2);
/* Display the event information, depending on it's type */
switch(lEventDesc.ID)
{
case TRACE_SYSCALL_ENTRY :
/* Display the syscall entry information */
sprintf(lString, "%s", pmEventDB->SyscallString(pmEventDB,
RFT8(pmEventDB, SYSCALL_EVENT(lEventDesc.Struct)->syscall_id)));
/* Draw the text and its icon */
EGIPendDrawEventInfoReq(pmEventGraph,
pmEventGraph->SysCall,
x2,
y2,
lString,
&lEvent);
/* Set temp GC */
pTempGC = pmEventGraph->SysCallGC;
break;
case TRACE_TRAP_ENTRY :
/* Display the trap entry information */
switch(pmEventDB->ArchType)
{
case TRACE_ARCH_TYPE_I386 :
case TRACE_ARCH_TYPE_PPC :
case TRACE_ARCH_TYPE_SH :
case TRACE_ARCH_TYPE_MIPS :
sprintf(lString, "%s", pmEventDB->TrapString(pmEventDB,
RFT16(pmEventDB, TRAP_EVENT(lEventDesc.Struct)->trap_id)));
break;
case TRACE_ARCH_TYPE_S390 :
sprintf(lString, "%s", pmEventDB->TrapString(pmEventDB,
RFT64(pmEventDB, TRAP_EVENT_S390(lEventDesc.Struct)->trap_id)));
break;
}
/* Draw the text and its icon */
EGIPendDrawEventInfoReq(pmEventGraph,
pmEventGraph->Trap,
x2,
y2,
lString,
&lEvent);
/* Set temp GC */
pTempGC = pmEventGraph->TrapGC;
break;
case TRACE_IRQ_ENTRY :
/* Display the IRQ information */
sprintf(lString, "%d:%s",
RFT8(pmEventDB, IRQ_EVENT(lEventDesc.Struct)->irq_id),
pmSystem->Interrupts[RFT8(pmEventDB, IRQ_EVENT(lEventDesc.Struct)->irq_id)]);
/* If we're at kernel height, then back up a little */
if(y2 == EGIFindKernelHeight(pmEventGraph))
/* Draw the string */
EGIPendDrawEventInfoReq(pmEventGraph,
pmEventGraph->IRQ,
x2,
y2 - EGRAPH_TEXT_TO_LINE_DIST,
lString,
&lEvent);
else
/* Draw the string */
EGIPendDrawEventInfoReq(pmEventGraph,
pmEventGraph->IRQ,
x2,
y2,
lString,
&lEvent);
/* Set current GC */
pTempGC = pmEventGraph->InterruptGC;
break;
}
/* Draw a line from the process to the kernel */
x1 = x2;
y1 = y2;
x2 = x1;
y2 = EGIFindKernelHeight(pmEventGraph);
EGIDrawVLine(pmEventGraph, pTempGC, x1, y1, y2);
/* Is this a control event */
if(DBEventControlEntry(pmEventDB, &lEvent, lPID) == TRUE)
{
/* The first control event has been processed */
lFirstCtrlEvent = FALSE;
/* Set last control event */
lLastCtrlEvent = lEvent;
/* Get a pointer to the process to which this event belongs and the event's description */
pLastCtrlEventProcess = pEventProcess;
lLastCtrlEventID = lEventDesc.ID;
}
break;
/* Exit (syscall / trap /irq) */
case TRACE_SYSCALL_EXIT :
case TRACE_TRAP_EXIT :
case TRACE_IRQ_EXIT :
/* Draw a line from the last event to now */
x1 = x2;
y1 = y2;
x2 = EGIFindEventDistance(pmEventGraph, lEventDesc, pmDrawStart, pmDrawEnd);
y2 = y1;
EGIDrawThickHLine(pmEventGraph, pmEventGraph->KernelGC, y2, x1, x2);
/* Is this a control event */
if(DBEventControlExit(pmEventDB, &lEvent, lPID) == TRUE)
{
/* The first control event has been processed */
lFirstCtrlEvent = FALSE;
/* Set last control event */
lLastCtrlEvent = lEvent;
/* Get a pointer to the process to which this event belongs and the event's description */
pLastCtrlEventProcess = pEventProcess;
lLastCtrlEventID = lEventDesc.ID;
}
break;
/* Scheduling change / Kernel timer / Bottom Half / Process / Network */
case TRACE_SCHEDCHANGE :
case TRACE_KERNEL_TIMER :
case TRACE_SOFT_IRQ :
case TRACE_PROCESS :
case TRACE_NETWORK :
/* Display information according to event */
switch(lEventDesc.ID)
{
/* Scheduling change */
case TRACE_SCHEDCHANGE :
/* Get the PID of the incoming process */
lPID = RFT32(pmEventDB, SCHED_EVENT(lEventDesc.Struct)->in);
/* Get a pointer to this process */
pEventProcess = DBGetProcByPID(lPID, pmSystem);
/* Display the PID of the incoming process */
sprintf(lString, "%d", lPID);
/* Draw the text and its icon */
EGIPendDrawEventInfoReq(pmEventGraph,
pmEventGraph->SchedChange,
EGIFindEventDistance(pmEventGraph, lEventDesc, pmDrawStart, pmDrawEnd),
EGIFindKernelHeight(pmEventGraph),
lString,
&lEvent);
break;
/* Kernel timer */
case TRACE_KERNEL_TIMER :
/* Display the kernel timer information */
lString[0] = '\0';
/* Draw the text and its icon */
EGIPendDrawEventInfoReq(pmEventGraph, pmEventGraph->KernelTimer,
EGIFindEventDistance(pmEventGraph, lEventDesc, pmDrawStart, pmDrawEnd),
EGIFindKernelHeight(pmEventGraph),
lString,
&lEvent);
break;
/* Bottom Half */
case TRACE_SOFT_IRQ :
/* Is this the kernel timer */
if((RFT8(pmEventDB, SOFT_IRQ_EVENT(lEventDesc.Struct)->event_sub_id) == TRACE_SOFT_IRQ_BOTTOM_HALF)
&&(RFT32(pmEventDB, SOFT_IRQ_EVENT(lEventDesc.Struct)->event_data) == 0))
break;
/* Display the bottom half information */
switch(RFT8(pmEventDB, SOFT_IRQ_EVENT(lEventDesc.Struct)->event_sub_id))
{
/* TRACE_SOFT_IRQ_BOTTOM_HALF */
case TRACE_SOFT_IRQ_BOTTOM_HALF :
sprintf(lString,
"BH:%d",
RFT32(pmEventDB, SOFT_IRQ_EVENT(lEventDesc.Struct)->event_data));
break;
/* TRACE_SOFT_IRQ_SOFT_IRQ */
case TRACE_SOFT_IRQ_SOFT_IRQ :
sprintf(lString,
"SIRQ:%d",
RFT32(pmEventDB, SOFT_IRQ_EVENT(lEventDesc.Struct)->event_data));
break;
/* TRACE_SOFT_IRQ_TASKLET_ACTION */
case TRACE_SOFT_IRQ_TASKLET_ACTION :
sprintf(lString,
"TA: 0x%08X",
RFT32(pmEventDB, SOFT_IRQ_EVENT(lEventDesc.Struct)->event_data));
break;
/* TRACE_SOFT_IRQ_TASKLET_HI_ACTION */
case TRACE_SOFT_IRQ_TASKLET_HI_ACTION :
sprintf(lString,
"THA: 0x%08X",
RFT32(pmEventDB, SOFT_IRQ_EVENT(lEventDesc.Struct)->event_data));
break;
}
/* Draw the text and its icon */
EGIPendDrawEventInfoReq(pmEventGraph, pmEventGraph->BottomHalf,
EGIFindEventDistance(pmEventGraph, lEventDesc, pmDrawStart, pmDrawEnd),
EGIFindKernelHeight(pmEventGraph),
lString,
&lEvent);
break;
/* Process */
case TRACE_PROCESS :
break;
/* Network */
case TRACE_NETWORK :
break;
}
/* Is this a control event resulting in a return to a process */
if(DBEventControlExit(pmEventDB, &lEvent, lPID) == TRUE)
{
/* Draw a line from the entry to the event */
x1 = x2;
y1 = y2;
x2 = EGIFindEventDistance(pmEventGraph, lEventDesc, pmDrawStart, pmDrawEnd);
y2 = y1;
EGIDrawThickHLine(pmEventGraph, pmEventGraph->KernelGC, y2, x1, x2);
/* Draw a line from the event change to the process */
x1 = x2;
y1 = y2;
x2 = x1;
y2 = EGIFindProcessHeight(pmEventGraph, pEventProcess);
EGIDrawVLine(pmEventGraph, pmEventGraph->InterruptGC, x1, y1, y2);
/* The first control event has been processed */
lFirstCtrlEvent = FALSE;
/* Set last control event */
lLastCtrlEvent = lEvent;
/* Get a pointer to the process to which this event belongs and the event's description */
pLastCtrlEventProcess = pEventProcess;
lLastCtrlEventID = lEventDesc.ID;
}
break;
/* File system */
case TRACE_FILE_SYSTEM :
/* Are we starting to wait for I/O */
if(RFT8(pmEventDB, FS_EVENT(lEventDesc.Struct)->event_sub_id) == TRACE_FILE_SYSTEM_BUF_WAIT_START)
{
sprintf(lString, "I/O:START");
EGIPendDrawEventInfoReq(pmEventGraph, pmEventGraph->IOStart,
EGIFindEventDistance(pmEventGraph, lEventDesc, pmDrawStart, pmDrawEnd),
EGIFindKernelHeight(pmEventGraph),
lString,
&lEvent);
}
/* Are we ending wait for I/O */
if(RFT8(pmEventDB, FS_EVENT(lEventDesc.Struct)->event_sub_id) == TRACE_FILE_SYSTEM_BUF_WAIT_END)
{
sprintf(lString, "I/O:END");
EGIPendDrawEventInfoReq(pmEventGraph, pmEventGraph->IOEnd,
EGIFindEventDistance(pmEventGraph, lEventDesc, pmDrawStart, pmDrawEnd),
EGIFindKernelHeight(pmEventGraph),
lString,
&lEvent);
}
break;
/* Timer */
case TRACE_TIMER :
break;
/* Memory */
case TRACE_MEMORY :
break;
/* Socket */
case TRACE_SOCKET :
break;
/* IPC */
case TRACE_IPC :
break;
/* Otherwise */
default :
break;
g_print("Encountered unknow event \n");
exit(1);
break;
} /* End switch type of the event to draw */
} /* End drawing loop */
/* Did we draw all the events in the window */
if(DBEventsEqual((*pmFirstEvent), pmEventDB->FirstEvent)
&&DBEventsEqual((*pmLastEvent), pmEventDB->LastEvent))
goto DoneDrawing;
/* Get the last control event's time */
DBEventTime(pmEventDB, &lLastCtrlEvent, &lLastCtrlEventTime);
#if 0
printf("Last control event was %s \n", EventID[lLastCtrlEventID]);
#endif
/* Was the last control event really a control event */
if(DBEventControl(pmEventDB, &lLastCtrlEvent, pmSystem) == TRUE)
{
/* Was the last control event an exit */
if(DBEventControlExit(pmEventDB, &lLastCtrlEvent, pEventProcess->PID) == TRUE)
{
/* Choose the right GC to draw */
switch(lLastCtrlEventID)
{
case TRACE_SYSCALL_EXIT :
pTempGC = pmEventGraph->SysCallGC;
break;
case TRACE_TRAP_EXIT :
pTempGC = pmEventGraph->TrapGC;
break;
default :
pTempGC = pmEventGraph->InterruptGC;
break;
}
/* Draw a vertical line to the process */
x1 = x2;
y1 = y2 - 1;
x2 = x1;
y2 = EGIFindProcessHeight(pmEventGraph, pLastCtrlEventProcess);
/* Is the event visible */
if(DBGetTimeInDouble(lLastCtrlEventTime) >= pmDrawStart)
EGIDrawVLine(pmEventGraph, pTempGC, x1, y1, y2);
/* Draw a horizontal line to the end */
x1 = x2;
y1 = y2;
x2 = pmEventGraph->HDrawSize;
y2 = y1;
EGIDrawThickHLine(pmEventGraph, pmEventGraph->ProcessGC, y2, x1, x2);
}
else /* Last control event was an entry into the kernel */
{
/* Draw a horizontal line to the end */
x1 = x2;
y1 = y2;
x2 = pmEventGraph->HDrawSize;
y2 = y1;
EGIDrawThickHLine(pmEventGraph, pmEventGraph->KernelGC, y2, x1, x2);
}
}
else /* This wasn't a control event */
{
/* Draw a horizontal line through the screen */
x1 = 0;
/* Were we idle all this time or is this the first control event */
if((pLastCtrlEventProcess != NULL)
&&(pLastCtrlEventProcess != 0)
&&(!DBEventsEqual(lLastCtrlEvent, pmEventDB->FirstEventWithProc)))
{
/* This was a process */
y1 = EGIFindProcessHeight(pmEventGraph, pLastCtrlEventProcess);
pTempGC = pmEventGraph->ProcessGC;
}
else
{
/* This was in the kernel */
y1 = EGIFindKernelHeight(pmEventGraph);
pTempGC = pmEventGraph->KernelGC;
}
/* Draw t'ill the end */
x2 = pmEventGraph->HDrawSize;
y2 = y1;
/* Draw the thick line */
EGIDrawThickHLine(pmEventGraph, pTempGC, y2, x1, x2);
}
DoneDrawing: /* OK, this doesn't look clean, but IT IS (try doing without ... you'll see) */
/* Are we drawing horizontal lines fast */
if(pmEventGraph->FastHLines)
/* Flush any deferred lines by asking for a last line that is out of limits */
EGIDrawThickHLine(pmEventGraph, NULL, 32000, 32000, 32000);
/* Are we drawing vertical lines fast */
if(pmEventGraph->FastVLines)
/* Flush any deferred lines by asking for a last line that is out of limits */
EGIDrawVLine(pmEventGraph, NULL, 32000, 32000, 32000);
/* Are we benchmarking our operations */
if(pmEventGraph->Benchmark)
{
/* We're done drawing the lines, get the current time */
gettimeofday(&lDrawDoneTime, NULL);
/* Compute the time it took to draw the lines (add 1 to avoid divide by zero) */
lDrawLinesTime = (DBGetTimeInDouble(lDrawDoneTime) - DBGetTimeInDouble(lDrawBeginTime) + 1) / 1000000.0;
/* Print out the benchmarks */
printf("\n%6ld Hor + %6ld Vert = %6ld lines in %6.3f s: %8.0f lines/sec\n",
pmEventGraph->NbHLines,
pmEventGraph->NbVLines,
pmEventGraph->NbHLines + pmEventGraph->NbVLines,
lDrawLinesTime,
(float)(pmEventGraph->NbVLines + pmEventGraph->NbHLines) / lDrawLinesTime);
/* Print out the begining of the icon draw information time */
printf("%6ld User + %6ld Kern = %6ld icons in ",
pmEventGraph->NbUserIcons,
pmEventGraph->NbKernelIcons,
pmEventGraph->NbUserIcons + pmEventGraph->NbKernelIcons);
/* Flush out any pending output */
fflush(stdout);
/* Get the current time to see how much time it will take to draw the icons */
gettimeofday(&lDrawBeginTime, NULL);
}
/* Now draw the deferred icons so they come out on top */
g_slist_foreach(pmEventGraph->EventIcons,
(GFunc) EGICommitEventDrawRequest,
pmEventGraph);
/* Are we benchmarking our operations */
if(pmEventGraph->Benchmark)
{
/* We're done drawing the icons, get the current time */
gettimeofday(&lDrawDoneTime, NULL);
/* Compute the time it took to draw the icons (add 1 to avoid divide by zero) */
lDrawIconsTime = (DBGetTimeInDouble(lDrawDoneTime) - DBGetTimeInDouble(lDrawBeginTime) + 1) / 1000000.0;
/* Print out the icon drawing information */
printf("%6.3f s: %8.0f icons/sec\n",
lDrawIconsTime,
(float)(pmEventGraph->NbUserIcons + pmEventGraph->NbKernelIcons) / lDrawIconsTime);
printf("\t Total DB traversal + draw time: %6.3f s: %8.0f events/sec\n",
(lDrawLinesTime + lDrawIconsTime),
(float)pmEventGraph->NbIntervalEvents / (lDrawLinesTime + lDrawIconsTime));
}
}
/******************************************************************
* Function :
* EGIDrawEventInfo()
* Description :
* Draws the information and icon for the given event at the
* given position.
* Parameters :
* pmEventGraph, The event graph in which info is drawn.
* pmEventDesc, The event description of event to be drawn.
* pmX, The X position where to draw.
* pmY, The Y position where to draw.
* Return values :
* NONE
* History :
* K.Y., 06/07/2000, Initial typing.
******************************************************************/
void EGIDrawEventInfo(eventGraph* pmEventGraph,
event* pmEvent,
eventDescription* pmEventDesc,
guint pmX,
guint pmY)
{
db* pEventDB; /* The event database to which events belong */
gchar lString[30]; /* String used to display information on graph */
/* Get the event database to which events belongs */
pEventDB = pmEventGraph->EventDB;
/* Depending on the event */
switch(pmEventDesc->ID)
{
/* Syscall entry */
case TRACE_SYSCALL_ENTRY :
/* Display the syscall entry information */
sprintf(lString, "%s", pmEventGraph->EventDB->SyscallString(pmEventGraph->EventDB,
RFT8(pEventDB, SYSCALL_EVENT(pmEventDesc->Struct)->syscall_id)));
/* Draw the text and its icon */
EGIPendDrawEventInfoReq(pmEventGraph,
pmEventGraph->SysCall,
pmX,
pmY,
lString,
pmEvent);
break;
/* Trap entry */
case TRACE_TRAP_ENTRY :
/* Display the syscall entry information */
switch(pmEventGraph->EventDB->ArchType)
{
case TRACE_ARCH_TYPE_I386 :
case TRACE_ARCH_TYPE_PPC :
case TRACE_ARCH_TYPE_SH :
case TRACE_ARCH_TYPE_MIPS :
sprintf(lString, "%s", pmEventGraph->EventDB->TrapString(pmEventGraph->EventDB,
RFT16(pEventDB, TRAP_EVENT(pmEventDesc->Struct)->trap_id)));
break;
case TRACE_ARCH_TYPE_S390 :
sprintf(lString, "%s", pmEventGraph->EventDB->TrapString(pmEventGraph->EventDB,
RFT64(pEventDB, TRAP_EVENT_S390(pmEventDesc->Struct)->trap_id)));
}
/* Draw the text and its icon */
EGIPendDrawEventInfoReq(pmEventGraph,
pmEventGraph->Trap,
pmX,
pmY,
lString,
pmEvent);
break;
/* IRQ entry */
case TRACE_IRQ_ENTRY :
/* Display the syscall entry information */
sprintf(lString, "%d:%s", RFT8(pEventDB, IRQ_EVENT(pmEventDesc->Struct)->irq_id),
pmEventGraph->System->Interrupts[RFT8(pEventDB, IRQ_EVENT(pmEventDesc->Struct)->irq_id)]);
/* If we're at kernel height, then back up a little */
if(pmY == EGIFindKernelHeight(pmEventGraph))
/* Draw the string */
EGIPendDrawEventInfoReq(pmEventGraph,
pmEventGraph->IRQ,
pmX,
pmY - EGRAPH_TEXT_TO_LINE_DIST,
lString,
pmEvent);
else
/* Draw the string */
EGIPendDrawEventInfoReq(pmEventGraph,
pmEventGraph->IRQ,
pmX,
pmY,
lString,
pmEvent);
break;
/* Syscall exit */
case TRACE_SYSCALL_EXIT :
break;
/* Trap exit */
case TRACE_TRAP_EXIT :
break;
/* IRQ exit */
case TRACE_IRQ_EXIT :
break;
/* Scheduling change */
case TRACE_SCHEDCHANGE :
/* Display the PID of the incoming process */
sprintf(lString, "%d", RFT32(pEventDB, SCHED_EVENT(pmEventDesc->Struct)->in));
/* Draw the text and its icon */
EGIPendDrawEventInfoReq(pmEventGraph,
pmEventGraph->SchedChange,
pmX,
pmY,
lString,
pmEvent);
break;
/* Kernel timer */
case TRACE_KERNEL_TIMER :
/* Display the kernel timer information */
lString[0] = '\0';
/* Draw the text and its icon */
EGIPendDrawEventInfoReq(pmEventGraph,
pmEventGraph->KernelTimer,
pmX,
pmY,
lString,
pmEvent);
break;
/* Soft irq */
case TRACE_SOFT_IRQ :
/* Is this the kernel timer */
if((RFT8(pEventDB, SOFT_IRQ_EVENT(pmEventDesc->Struct)->event_sub_id) == TRACE_SOFT_IRQ_BOTTOM_HALF)
&&(RFT32(pEventDB, SOFT_IRQ_EVENT(pmEventDesc->Struct)->event_data) == 0))
break;
/* Display the bottom half information */
switch(RFT8(pEventDB, SOFT_IRQ_EVENT(pmEventDesc->Struct)->event_sub_id))
{
/* TRACE_SOFT_IRQ_BOTTOM_HALF */
case TRACE_SOFT_IRQ_BOTTOM_HALF :
sprintf(lString,
"BH:%d",
RFT32(pEventDB, SOFT_IRQ_EVENT(pmEventDesc->Struct)->event_data));
break;
/* TRACE_SOFT_IRQ_SOFT_IRQ */
case TRACE_SOFT_IRQ_SOFT_IRQ :
sprintf(lString,
"SIRQ:%d",
RFT32(pEventDB, SOFT_IRQ_EVENT(pmEventDesc->Struct)->event_data));
break;
/* TRACE_SOFT_IRQ_TASKLET_ACTION */
case TRACE_SOFT_IRQ_TASKLET_ACTION :
sprintf(lString,
"TA: 0x%08X",
RFT32(pEventDB, SOFT_IRQ_EVENT(pmEventDesc->Struct)->event_data));
break;
/* TRACE_SOFT_IRQ_TASKLET_HI_ACTION */
case TRACE_SOFT_IRQ_TASKLET_HI_ACTION :
sprintf(lString,
"THA: 0x%08X",
RFT32(pEventDB, SOFT_IRQ_EVENT(pmEventDesc->Struct)->event_data));
break;
}
/* Draw the text and its icon */
EGIPendDrawEventInfoReq(pmEventGraph,
pmEventGraph->BottomHalf,
pmX,
pmY,
lString,
pmEvent);
break;
/* Process */
case TRACE_PROCESS :
break;
/* Network */
case TRACE_NETWORK :
break;
/* File system */
case TRACE_FILE_SYSTEM :
/* Are we starting to wait for I/O */
if(RFT8(pEventDB, FS_EVENT(pmEventDesc->Struct)->event_sub_id) == TRACE_FILE_SYSTEM_BUF_WAIT_START)
{
sprintf(lString, "I/O:START");
EGIPendDrawEventInfoReq(pmEventGraph,
pmEventGraph->IOStart,
pmX,
pmY,
lString,
pmEvent);
}
/* Are we ending wait for I/O */
if(RFT8(pEventDB, FS_EVENT(pmEventDesc->Struct)->event_sub_id) == TRACE_FILE_SYSTEM_BUF_WAIT_END)
{
sprintf(lString, "I/O:END");
EGIPendDrawEventInfoReq(pmEventGraph,
pmEventGraph->IOEnd,
pmX,
pmY,
lString,
pmEvent);
}
break;
/* Timer */
case TRACE_TIMER :
break;
/* Memory */
case TRACE_MEMORY :
break;
/* Socket */
case TRACE_SOCKET :
break;
/* IPC */
case TRACE_IPC :
break;
#if SUPP_RTAI
/* RTAI has been mounted */
case TRACE_RTAI_MOUNT :
/* Set string to empty */
lString[0] = '\0';
/* Draw the string */
EGIPendDrawEventInfoReq(pmEventGraph,
pmEventGraph->RTAIMount,
pmX,
pmY,
lString,
pmEvent);
break;
/* RTAI has been unmounted */
case TRACE_RTAI_UMOUNT :
/* Set string to empty */
lString[0] = '\0';
/* Draw the string */
EGIPendDrawEventInfoReq(pmEventGraph,
pmEventGraph->RTAIUmount,
pmX,
pmY,
lString,
pmEvent);
break;
/* Global IRQ entry */
case TRACE_RTAI_GLOBAL_IRQ_ENTRY :
/* Display the syscall entry information */
sprintf(lString, "G:%d", RFT8(pEventDB, IRQ_EVENT(pmEventDesc->Struct)->irq_id));
/* Draw the string */
EGIPendDrawEventInfoReq(pmEventGraph,
pmEventGraph->RTAIIrq,
pmX,
pmY,
lString,
pmEvent);
break;
/* Global IRQ exit */
case TRACE_RTAI_GLOBAL_IRQ_EXIT :
break;
/* CPU own IRQ entry */
case TRACE_RTAI_OWN_IRQ_ENTRY :
/* Display the syscall entry information */
sprintf(lString, "C:%d", RFT8(pEventDB, IRQ_EVENT(pmEventDesc->Struct)->irq_id));
/* Draw the string */
EGIPendDrawEventInfoReq(pmEventGraph,
pmEventGraph->RTAIIrq,
pmX,
pmY,
lString,
pmEvent);
break;
/* CPU own IRQ exit */
case TRACE_RTAI_OWN_IRQ_EXIT :
break;
/* Trap entry */
case TRACE_RTAI_TRAP_ENTRY :
break;
/* Trap exit */
case TRACE_RTAI_TRAP_EXIT :
break;
/* System ReQuest entry */
case TRACE_RTAI_SRQ_ENTRY :
/* Display the SRQ entry information */
sprintf(lString, "SRQ: %d", RFT8(pEventDB, RTAI_SRQ_ENTRY_EVENT(pmEventDesc->Struct)->srq_id));
/* Draw the text and its icon */
EGIPendDrawEventInfoReq(pmEventGraph,
pmEventGraph->SysCall,
pmX,
pmY,
lString,
pmEvent);
break;
/* System ReQuest exit */
case TRACE_RTAI_SRQ_EXIT :
break;
/* Switch to Linux */
case TRACE_RTAI_SWITCHTO_LINUX :
break;
/* Switch to RTAI */
case TRACE_RTAI_SWITCHTO_RT :
break;
/* Scheduling change */
case TRACE_RTAI_SCHED_CHANGE :
/* Display the PID of the incoming process */
if(RFT32(pEventDB, RTAI_SCHED_CHANGE_EVENT(pmEventDesc->Struct)->out_state) != 0)
sprintf(lString, "RT:%d", RFT32(pEventDB, RTAI_SCHED_CHANGE_EVENT(pmEventDesc->Struct)->in));
else
sprintf(lString, "RT:%d", RFT32(pEventDB, RTAI_SCHED_CHANGE_EVENT(pmEventDesc->Struct)->out));
/* Draw the text and its icon */
EGIPendDrawEventInfoReq(pmEventGraph,
pmEventGraph->SchedChange,
pmX,
pmY,
lString,
pmEvent);
break;
/* Hit key part of task services */
case TRACE_RTAI_TASK :
switch(RFT8(pEventDB, RTAI_TASK_EVENT(pmEventDesc->Struct)->event_sub_id))
{
case TRACE_RTAI_TASK_INIT :
sprintf(lString,
"INIT %d",
RFT32(pEventDB, RTAI_TASK_EVENT(pmEventDesc->Struct)->event_data1));
break;
case TRACE_RTAI_TASK_DELETE :
sprintf(lString,
"DELETE %d",
RFT32(pEventDB, RTAI_TASK_EVENT(pmEventDesc->Struct)->event_data1));
break;
case TRACE_RTAI_TASK_SIG_HANDLER :
sprintf(lString,
"SIGHDL %d",
RFT32(pEventDB, RTAI_TASK_EVENT(pmEventDesc->Struct)->event_data1));
break;
case TRACE_RTAI_TASK_YIELD :
sprintf(lString,
"YIELD");
break;
case TRACE_RTAI_TASK_SUSPEND :
sprintf(lString,
"SUSPEND %d",
RFT32(pEventDB, RTAI_TASK_EVENT(pmEventDesc->Struct)->event_data1));
break;
case TRACE_RTAI_TASK_RESUME :
sprintf(lString,
"RESUME %d",
RFT32(pEventDB, RTAI_TASK_EVENT(pmEventDesc->Struct)->event_data1));
break;
case TRACE_RTAI_TASK_MAKE_PERIOD_RELATIVE :
sprintf(lString,
"PERIODREL %d",
RFT32(pEventDB, RTAI_TASK_EVENT(pmEventDesc->Struct)->event_data1));
break;
case TRACE_RTAI_TASK_MAKE_PERIOD :
sprintf(lString,
"PERIOD %d",
RFT32(pEventDB, RTAI_TASK_EVENT(pmEventDesc->Struct)->event_data1));
break;
case TRACE_RTAI_TASK_WAIT_PERIOD :
sprintf(lString,
"WPERIOD");
break;
case TRACE_RTAI_TASK_BUSY_SLEEP :
sprintf(lString,
"BSLEEP");
break;
case TRACE_RTAI_TASK_SLEEP :
sprintf(lString,
"SLEEP %d",
RFT32(pEventDB, RTAI_TASK_EVENT(pmEventDesc->Struct)->event_data1));
break;
case TRACE_RTAI_TASK_SLEEP_UNTIL :
sprintf(lString,
"SLEEPU %Ld",
RFT32(pEventDB, RTAI_TASK_EVENT(pmEventDesc->Struct)->event_data2));
break;
}
/* Draw the text and its icon */
EGIPendDrawEventInfoReq(pmEventGraph,
pmEventGraph->RTAITask,
pmX,
pmY,
lString,
pmEvent);
break;
/* Hit key part of timer services */
case TRACE_RTAI_TIMER :
switch(RFT8(pEventDB, RTAI_TIMER_EVENT(pmEventDesc->Struct)->event_sub_id))
{
case TRACE_RTAI_TIMER_REQUEST :
sprintf(lString,
"REQUEST %08X",
RFT32(pEventDB, RTAI_TASK_EVENT(pmEventDesc->Struct)->event_data1));
break;
case TRACE_RTAI_TIMER_FREE :
sprintf(lString,
"FREE");
break;
case TRACE_RTAI_TIMER_REQUEST_APIC :
sprintf(lString,
"RAPIC %08X",
RFT32(pEventDB, RTAI_TASK_EVENT(pmEventDesc->Struct)->event_data1));
break;
case TRACE_RTAI_TIMER_APIC_FREE :
sprintf(lString,
"APICFREE");
break;
case TRACE_RTAI_TIMER_HANDLE_EXPIRY :
sprintf(lString,
"EXPIRY");
break;
}
/* Draw the text and its icon */
EGIPendDrawEventInfoReq(pmEventGraph,
pmEventGraph->RTAITimer,
pmX,
pmY,
lString,
pmEvent);
break;
/* Hit key part of semaphore services */
case TRACE_RTAI_SEM :
switch(RFT8(pEventDB, RTAI_SEM_EVENT(pmEventDesc->Struct)->event_sub_id))
{
case TRACE_RTAI_SEM_INIT :
sprintf(lString,
"INIT %08X",
RFT32(pEventDB, RTAI_TASK_EVENT(pmEventDesc->Struct)->event_data1));
break;
case TRACE_RTAI_SEM_DELETE :
sprintf(lString,
"DELETE %08X",
RFT32(pEventDB, RTAI_TASK_EVENT(pmEventDesc->Struct)->event_data1));
break;
case TRACE_RTAI_SEM_SIGNAL :
sprintf(lString,
"SIGNAL %08X",
RFT32(pEventDB, RTAI_TASK_EVENT(pmEventDesc->Struct)->event_data1));
break;
case TRACE_RTAI_SEM_WAIT :
sprintf(lString,
"WAIT %08X",
RFT32(pEventDB, RTAI_TASK_EVENT(pmEventDesc->Struct)->event_data1));
break;
case TRACE_RTAI_SEM_WAIT_IF :
sprintf(lString,
"WAITIF %08X",
RFT32(pEventDB, RTAI_TASK_EVENT(pmEventDesc->Struct)->event_data1));
break;
case TRACE_RTAI_SEM_WAIT_UNTIL :
sprintf(lString,
"WAITU %08X",
RFT32(pEventDB, RTAI_TASK_EVENT(pmEventDesc->Struct)->event_data1));
break;
}
/* Draw the text and its icon */
EGIPendDrawEventInfoReq(pmEventGraph,
pmEventGraph->RTAISem,
pmX,
pmY,
lString,
pmEvent);
break;
/* Hit key part of message services */
case TRACE_RTAI_MSG :
switch(RFT8(pEventDB, RTAI_MSG_EVENT(pmEventDesc->Struct)->event_sub_id))
{
case TRACE_RTAI_MSG_SEND :
sprintf(lString,
"SEND %d",
RFT32(pEventDB, RTAI_MSG_EVENT(pmEventDesc->Struct)->event_data1));
break;
case TRACE_RTAI_MSG_SEND_IF :
sprintf(lString,
"SENDIF %d",
RFT32(pEventDB, RTAI_MSG_EVENT(pmEventDesc->Struct)->event_data1));
break;
case TRACE_RTAI_MSG_SEND_UNTIL :
sprintf(lString,
"SENDU %d",
RFT32(pEventDB, RTAI_MSG_EVENT(pmEventDesc->Struct)->event_data1));
break;
case TRACE_RTAI_MSG_RECV :
sprintf(lString,
"RECEIVE %d",
RFT32(pEventDB, RTAI_MSG_EVENT(pmEventDesc->Struct)->event_data1));
break;
case TRACE_RTAI_MSG_RECV_IF :
sprintf(lString,
"RECEIVEIF %d",
RFT32(pEventDB, RTAI_MSG_EVENT(pmEventDesc->Struct)->event_data1));
break;
case TRACE_RTAI_MSG_RECV_UNTIL :
sprintf(lString,
"RECEIVEU %d",
RFT32(pEventDB, RTAI_MSG_EVENT(pmEventDesc->Struct)->event_data1));
break;
}
/* Draw the text and its icon */
EGIPendDrawEventInfoReq(pmEventGraph,
pmEventGraph->RTAIMsg,
pmX,
pmY,
lString,
pmEvent);
break;
/* Hit key part of RPC services */
case TRACE_RTAI_RPC :
switch(RFT8(pEventDB, RTAI_RPC_EVENT(pmEventDesc->Struct)->event_sub_id))
{
case TRACE_RTAI_RPC_MAKE :
sprintf(lString,
"MAKE %d",
RFT32(pEventDB, RTAI_RPC_EVENT(pmEventDesc->Struct)->event_data1));
break;
case TRACE_RTAI_RPC_MAKE_IF :
sprintf(lString,
"MAKEIF %d",
RFT32(pEventDB, RTAI_RPC_EVENT(pmEventDesc->Struct)->event_data1));
break;
case TRACE_RTAI_RPC_MAKE_UNTIL :
sprintf(lString,
"MAKEU %d",
RFT32(pEventDB, RTAI_RPC_EVENT(pmEventDesc->Struct)->event_data1));
break;
case TRACE_RTAI_RPC_RETURN :
sprintf(lString,
"RETURN %d",
RFT32(pEventDB, RTAI_RPC_EVENT(pmEventDesc->Struct)->event_data1));
break;
}
/* Draw the text and its icon */
EGIPendDrawEventInfoReq(pmEventGraph,
pmEventGraph->RTAIRPC,
pmX,
pmY,
lString,
pmEvent);
break;
/* Hit key part of mail box services */
case TRACE_RTAI_MBX :
switch(RFT8(pEventDB, RTAI_MBX_EVENT(pmEventDesc->Struct)->event_sub_id))
{
case TRACE_RTAI_MBX_INIT :
sprintf(lString,
"INIT %08X",
RFT32(pEventDB, RTAI_MBX_EVENT(pmEventDesc->Struct)->event_data1));
break;
case TRACE_RTAI_MBX_DELETE :
sprintf(lString,
"DELETE %08X",
RFT32(pEventDB, RTAI_MBX_EVENT(pmEventDesc->Struct)->event_data1));
break;
case TRACE_RTAI_MBX_SEND :
sprintf(lString,
"SEND %08X",
RFT32(pEventDB, RTAI_MBX_EVENT(pmEventDesc->Struct)->event_data1));
break;
case TRACE_RTAI_MBX_SEND_WP :
sprintf(lString,
"SENDWP %08X",
RFT32(pEventDB, RTAI_MBX_EVENT(pmEventDesc->Struct)->event_data1));
break;
case TRACE_RTAI_MBX_SEND_IF :
sprintf(lString,
"SENDIF %08X",
RFT32(pEventDB, RTAI_MBX_EVENT(pmEventDesc->Struct)->event_data1));
break;
case TRACE_RTAI_MBX_SEND_UNTIL :
sprintf(lString,
"SENDU %08X",
RFT32(pEventDB, RTAI_MBX_EVENT(pmEventDesc->Struct)->event_data1));
break;
case TRACE_RTAI_MBX_RECV :
sprintf(lString,
"RECEIVE %08X",
RFT32(pEventDB, RTAI_MBX_EVENT(pmEventDesc->Struct)->event_data1));
break;
case TRACE_RTAI_MBX_RECV_WP :
sprintf(lString,
"RECEIVEWP %08X",
RFT32(pEventDB, RTAI_MBX_EVENT(pmEventDesc->Struct)->event_data1));
break;
case TRACE_RTAI_MBX_RECV_IF :
sprintf(lString,
"RECEIVEIF %08X",
RFT32(pEventDB, RTAI_MBX_EVENT(pmEventDesc->Struct)->event_data1));
break;
case TRACE_RTAI_MBX_RECV_UNTIL :
sprintf(lString,
"RECEIVEU %08X",
RFT32(pEventDB, RTAI_MBX_EVENT(pmEventDesc->Struct)->event_data1));
break;
}
/* Draw the text and its icon */
EGIPendDrawEventInfoReq(pmEventGraph,
pmEventGraph->RTAIMbx,
pmX,
pmY,
lString,
pmEvent);
break;
/* Hit key part of FIFO services */
case TRACE_RTAI_FIFO :
switch(RFT8(pEventDB, RTAI_SEM_EVENT(pmEventDesc->Struct)->event_sub_id))
{
case TRACE_RTAI_FIFO_CREATE :
sprintf(lString,
"CREATE %d",
RFT32(pEventDB, RTAI_TASK_EVENT(pmEventDesc->Struct)->event_data1));
break;
case TRACE_RTAI_FIFO_DESTROY :
sprintf(lString,
"DESTROY %d",
RFT32(pEventDB, RTAI_TASK_EVENT(pmEventDesc->Struct)->event_data1));
break;
case TRACE_RTAI_FIFO_RESET :
sprintf(lString,
"RESET %d",
RFT32(pEventDB, RTAI_TASK_EVENT(pmEventDesc->Struct)->event_data1));
break;
case TRACE_RTAI_FIFO_RESIZE :
sprintf(lString,
"RESIZE %d",
RFT32(pEventDB, RTAI_TASK_EVENT(pmEventDesc->Struct)->event_data1));
break;
case TRACE_RTAI_FIFO_PUT :
sprintf(lString,
"PUT %d",
RFT32(pEventDB, RTAI_TASK_EVENT(pmEventDesc->Struct)->event_data1));
break;
case TRACE_RTAI_FIFO_GET :
sprintf(lString,
"GET %d",
RFT32(pEventDB, RTAI_TASK_EVENT(pmEventDesc->Struct)->event_data1));
break;
case TRACE_RTAI_FIFO_CREATE_HANDLER :
sprintf(lString,
"CRHDLR %d",
RFT32(pEventDB, RTAI_TASK_EVENT(pmEventDesc->Struct)->event_data1));
break;
case TRACE_RTAI_FIFO_OPEN :
sprintf(lString,
"OPEN %d",
RFT32(pEventDB, RTAI_TASK_EVENT(pmEventDesc->Struct)->event_data1));
break;
case TRACE_RTAI_FIFO_RELEASE :
sprintf(lString,
"RELEASE %d",
RFT32(pEventDB, RTAI_TASK_EVENT(pmEventDesc->Struct)->event_data1));
break;
case TRACE_RTAI_FIFO_READ :
sprintf(lString,
"READ %d",
RFT32(pEventDB, RTAI_TASK_EVENT(pmEventDesc->Struct)->event_data1));
break;
case TRACE_RTAI_FIFO_WRITE :
sprintf(lString,
"WRITE %d",
RFT32(pEventDB, RTAI_TASK_EVENT(pmEventDesc->Struct)->event_data1));
break;
case TRACE_RTAI_FIFO_READ_TIMED :
sprintf(lString,
"READTIMED %d",
RFT32(pEventDB, RTAI_TASK_EVENT(pmEventDesc->Struct)->event_data1));
break;
case TRACE_RTAI_FIFO_WRITE_TIMED :
sprintf(lString,
"WRITETIMED %d",
RFT32(pEventDB, RTAI_TASK_EVENT(pmEventDesc->Struct)->event_data1));
break;
case TRACE_RTAI_FIFO_READ_ALLATONCE :
sprintf(lString,
"READ ALL");
break;
case TRACE_RTAI_FIFO_LLSEEK :
sprintf(lString,
"LSEEK %d",
RFT32(pEventDB, RTAI_TASK_EVENT(pmEventDesc->Struct)->event_data1));
break;
case TRACE_RTAI_FIFO_FASYNC :
sprintf(lString,
"FAYSNC %d",
RFT32(pEventDB, RTAI_TASK_EVENT(pmEventDesc->Struct)->event_data1));
break;
case TRACE_RTAI_FIFO_IOCTL :
sprintf(lString,
"IOCTL %d",
RFT32(pEventDB, RTAI_TASK_EVENT(pmEventDesc->Struct)->event_data1));
break;
case TRACE_RTAI_FIFO_POLL :
sprintf(lString,
"POLL %d",
RFT32(pEventDB, RTAI_TASK_EVENT(pmEventDesc->Struct)->event_data1));
break;
case TRACE_RTAI_FIFO_SUSPEND_TIMED :
sprintf(lString,
"SUSPTIMED %d",
RFT32(pEventDB, RTAI_TASK_EVENT(pmEventDesc->Struct)->event_data1));
break;
case TRACE_RTAI_FIFO_SET_ASYNC_SIG :
sprintf(lString,
"ASYNCSIG %d",
RFT32(pEventDB, RTAI_TASK_EVENT(pmEventDesc->Struct)->event_data1));
break;
case TRACE_RTAI_FIFO_SEM_INIT :
sprintf(lString,
"SEMINIT %d",
RFT32(pEventDB, RTAI_TASK_EVENT(pmEventDesc->Struct)->event_data1));
break;
case TRACE_RTAI_FIFO_SEM_POST :
sprintf(lString,
"SEMPOST %d",
RFT32(pEventDB, RTAI_TASK_EVENT(pmEventDesc->Struct)->event_data1));
break;
case TRACE_RTAI_FIFO_SEM_WAIT :
sprintf(lString,
"SEMWAIT %d",
RFT32(pEventDB, RTAI_TASK_EVENT(pmEventDesc->Struct)->event_data1));
break;
case TRACE_RTAI_FIFO_SEM_TRY_WAIT :
sprintf(lString,
"SEMTRYWAIT %d",
RFT32(pEventDB, RTAI_TASK_EVENT(pmEventDesc->Struct)->event_data1));
break;
case TRACE_RTAI_FIFO_SEM_TIMED_WAIT :
sprintf(lString,
"SEMTIMWAIT %d",
RFT32(pEventDB, RTAI_TASK_EVENT(pmEventDesc->Struct)->event_data1));
break;
case TRACE_RTAI_FIFO_SEM_DESTROY :
sprintf(lString,
"SEMDESTROY %d",
RFT32(pEventDB, RTAI_TASK_EVENT(pmEventDesc->Struct)->event_data1));
break;
}
/* Draw the text and its icon */
EGIPendDrawEventInfoReq(pmEventGraph,
pmEventGraph->RTAIFifo,
pmX,
pmY,
lString,
pmEvent);
break;
/* Hit key part of shared memory services */
case TRACE_RTAI_SHM :
switch(RFT8(pEventDB, RTAI_SHM_EVENT(pmEventDesc->Struct)->event_sub_id))
{
case TRACE_RTAI_SHM_MALLOC :
sprintf(lString,
"MALLOC %d",
RFT32(pEventDB, RTAI_SHM_EVENT(pmEventDesc->Struct)->event_data1));
break;
case TRACE_RTAI_SHM_KMALLOC :
sprintf(lString,
"KMALLOC %d",
RFT32(pEventDB, RTAI_SHM_EVENT(pmEventDesc->Struct)->event_data1));
break;
case TRACE_RTAI_SHM_GET_SIZE :
sprintf(lString,
"GETSIZE %d",
RFT32(pEventDB, RTAI_SHM_EVENT(pmEventDesc->Struct)->event_data1));
break;
case TRACE_RTAI_SHM_FREE :
sprintf(lString,
"FREE %d",
RFT32(pEventDB, RTAI_SHM_EVENT(pmEventDesc->Struct)->event_data1));
break;
case TRACE_RTAI_SHM_KFREE :
sprintf(lString,
"KFREE %d",
RFT32(pEventDB, RTAI_SHM_EVENT(pmEventDesc->Struct)->event_data1));
break;
}
/* Draw the text and its icon */
EGIPendDrawEventInfoReq(pmEventGraph,
pmEventGraph->RTAIShm,
pmX,
pmY,
lString,
pmEvent);
break;
/* Hit key part of Posix services */
case TRACE_RTAI_POSIX :
switch(RFT8(pEventDB, RTAI_POSIX_EVENT(pmEventDesc->Struct)->event_sub_id))
{
case TRACE_RTAI_POSIX_MQ_OPEN :
sprintf(lString,
"MQOPEN %d",
RFT32(pEventDB, RTAI_POSIX_EVENT(pmEventDesc->Struct)->event_data1));
break;
case TRACE_RTAI_POSIX_MQ_CLOSE :
sprintf(lString,
"MQCLOSE %u",
RFT32(pEventDB, RTAI_POSIX_EVENT(pmEventDesc->Struct)->event_data1));
break;
case TRACE_RTAI_POSIX_MQ_SEND :
sprintf(lString,
"MQSEND %u",
RFT32(pEventDB, RTAI_POSIX_EVENT(pmEventDesc->Struct)->event_data1));
break;
case TRACE_RTAI_POSIX_MQ_RECV :
sprintf(lString,
"MQRECEIVE %u",
RFT32(pEventDB, RTAI_POSIX_EVENT(pmEventDesc->Struct)->event_data1));
break;
case TRACE_RTAI_POSIX_MQ_GET_ATTR :
sprintf(lString,
"MQGETATTR %u",
RFT32(pEventDB, RTAI_POSIX_EVENT(pmEventDesc->Struct)->event_data1));
break;
case TRACE_RTAI_POSIX_MQ_SET_ATTR :
sprintf(lString,
"MQSETATTR %u",
RFT32(pEventDB, RTAI_POSIX_EVENT(pmEventDesc->Struct)->event_data1));
break;
case TRACE_RTAI_POSIX_MQ_NOTIFY :
sprintf(lString,
"MQNOTIFY %u",
RFT32(pEventDB, RTAI_POSIX_EVENT(pmEventDesc->Struct)->event_data1));
break;
case TRACE_RTAI_POSIX_MQ_UNLINK :
sprintf(lString,
"MQUNLINK %u",
RFT32(pEventDB, RTAI_POSIX_EVENT(pmEventDesc->Struct)->event_data1));
break;
case TRACE_RTAI_POSIX_PTHREAD_CREATE :
sprintf(lString,
"PTHREAD-CREATE %08X",
RFT32(pEventDB, RTAI_POSIX_EVENT(pmEventDesc->Struct)->event_data1));
break;
case TRACE_RTAI_POSIX_PTHREAD_EXIT :
sprintf(lString,
"PTHREAD-EXIT");
break;
case TRACE_RTAI_POSIX_PTHREAD_SELF :
sprintf(lString,
"PTHREAD-SELF %d",
RFT32(pEventDB, RTAI_POSIX_EVENT(pmEventDesc->Struct)->event_data1));
break;
case TRACE_RTAI_POSIX_PTHREAD_ATTR_INIT :
sprintf(lString,
"PTHREADATTR-INIT %08X",
RFT32(pEventDB, RTAI_POSIX_EVENT(pmEventDesc->Struct)->event_data1));
break;
case TRACE_RTAI_POSIX_PTHREAD_ATTR_DESTROY :
sprintf(lString,
"PTHREADATTR-DESTROY %08X",
RFT32(pEventDB, RTAI_POSIX_EVENT(pmEventDesc->Struct)->event_data1));
break;
case TRACE_RTAI_POSIX_PTHREAD_ATTR_SETDETACHSTATE :
sprintf(lString,
"PTHREADATTR-SETD-STATE %08X",
RFT32(pEventDB, RTAI_POSIX_EVENT(pmEventDesc->Struct)->event_data1));
break;
case TRACE_RTAI_POSIX_PTHREAD_ATTR_GETDETACHSTATE :
sprintf(lString,
"PTHREADATTR-GETD-STATE %08X",
RFT32(pEventDB, RTAI_POSIX_EVENT(pmEventDesc->Struct)->event_data1));
break;
case TRACE_RTAI_POSIX_PTHREAD_ATTR_SETSCHEDPARAM :
sprintf(lString,
"PTHREADATTR-SETS-PARAM %08X",
RFT32(pEventDB, RTAI_POSIX_EVENT(pmEventDesc->Struct)->event_data1));
break;
case TRACE_RTAI_POSIX_PTHREAD_ATTR_GETSCHEDPARAM :
sprintf(lString,
"PTHREADATTR-GETS-PARAM %08X",
RFT32(pEventDB, RTAI_POSIX_EVENT(pmEventDesc->Struct)->event_data1));
break;
case TRACE_RTAI_POSIX_PTHREAD_ATTR_SETSCHEDPOLICY :
sprintf(lString,
"PTHREADATTR-SETS-POLICY %08X",
RFT32(pEventDB, RTAI_POSIX_EVENT(pmEventDesc->Struct)->event_data1));
break;
case TRACE_RTAI_POSIX_PTHREAD_ATTR_GETSCHEDPOLICY :
sprintf(lString,
"PTHREADATTR-GETS-POLICY %08X",
RFT32(pEventDB, RTAI_POSIX_EVENT(pmEventDesc->Struct)->event_data1));
break;
case TRACE_RTAI_POSIX_PTHREAD_ATTR_SETINHERITSCHED :
sprintf(lString,
"PTHREADATTR-SETI-SCHED %08X",
RFT32(pEventDB, RTAI_POSIX_EVENT(pmEventDesc->Struct)->event_data1));
break;
case TRACE_RTAI_POSIX_PTHREAD_ATTR_GETINHERITSCHED :
sprintf(lString,
"PTHREADATTR-GETI-SCHED %08X",
RFT32(pEventDB, RTAI_POSIX_EVENT(pmEventDesc->Struct)->event_data1));
break;
case TRACE_RTAI_POSIX_PTHREAD_ATTR_SETSCOPE :
sprintf(lString,
"PTHREADATTR-SET-SCOPE %08X",
RFT32(pEventDB, RTAI_POSIX_EVENT(pmEventDesc->Struct)->event_data1));
break;
case TRACE_RTAI_POSIX_PTHREAD_ATTR_GETSCOPE :
sprintf(lString,
"PTHREADATTR-GET-SCOPE %08X",
RFT32(pEventDB, RTAI_POSIX_EVENT(pmEventDesc->Struct)->event_data1));
break;
case TRACE_RTAI_POSIX_PTHREAD_SCHED_YIELD :
sprintf(lString,
"PTHREAD SCHED YIELD");
break;
case TRACE_RTAI_POSIX_PTHREAD_CLOCK_GETTIME :
sprintf(lString,
"PTHREADCLOCK-GETT %d",
RFT32(pEventDB, RTAI_POSIX_EVENT(pmEventDesc->Struct)->event_data1));
break;
case TRACE_RTAI_POSIX_PTHREAD_MUTEX_INIT :
sprintf(lString,
"PTHREADMUTEX-INIT %08X",
RFT32(pEventDB, RTAI_POSIX_EVENT(pmEventDesc->Struct)->event_data1));
break;
case TRACE_RTAI_POSIX_PTHREAD_MUTEX_DESTROY :
sprintf(lString,
"PTHREADMUTEX-DESTROY %08X",
RFT32(pEventDB, RTAI_POSIX_EVENT(pmEventDesc->Struct)->event_data1));
break;
case TRACE_RTAI_POSIX_PTHREAD_MUTEXATTR_INIT :
sprintf(lString,
"PTHREADMUTEX-ATTRINIT %08X",
RFT32(pEventDB, RTAI_POSIX_EVENT(pmEventDesc->Struct)->event_data1));
break;
case TRACE_RTAI_POSIX_PTHREAD_MUTEXATTR_DESTROY :
sprintf(lString,
"PTHREADMUTEX-ATTRDESTROY %08X",
RFT32(pEventDB, RTAI_POSIX_EVENT(pmEventDesc->Struct)->event_data1));
break;
case TRACE_RTAI_POSIX_PTHREAD_MUTEXATTR_SETKIND_NP :
sprintf(lString,
"PTHREADMUTEX-SETK-NP %08X",
RFT32(pEventDB, RTAI_POSIX_EVENT(pmEventDesc->Struct)->event_data1));
break;
case TRACE_RTAI_POSIX_PTHREAD_MUTEXATTR_GETKIND_NP :
sprintf(lString,
"PTHREADMUTEX-GETK-NP %08X",
RFT32(pEventDB, RTAI_POSIX_EVENT(pmEventDesc->Struct)->event_data1));
break;
case TRACE_RTAI_POSIX_PTHREAD_SETSCHEDPARAM :
sprintf(lString,
"PTHREAD-SETSCHEDPARM %d",
RFT32(pEventDB, RTAI_POSIX_EVENT(pmEventDesc->Struct)->event_data1));
break;
case TRACE_RTAI_POSIX_PTHREAD_GETSCHEDPARAM :
sprintf(lString,
"PTHREAD-GETSCHEDPARM %d",
RFT32(pEventDB, RTAI_POSIX_EVENT(pmEventDesc->Struct)->event_data1));
break;
case TRACE_RTAI_POSIX_PTHREAD_MUTEX_TRY_LOCK :
sprintf(lString,
"PTHREADMUTEX-TRYLOCK %08X",
RFT32(pEventDB, RTAI_POSIX_EVENT(pmEventDesc->Struct)->event_data1));
break;
case TRACE_RTAI_POSIX_PTHREAD_MUTEX_LOCK :
sprintf(lString,
"PTHREADMUTEX-LOCK %08X",
RFT32(pEventDB, RTAI_POSIX_EVENT(pmEventDesc->Struct)->event_data1));
break;
case TRACE_RTAI_POSIX_PTHREAD_MUTEX_UNLOCK :
sprintf(lString,
"PTHREADMUTEX-UNLOCK %08X",
RFT32(pEventDB, RTAI_POSIX_EVENT(pmEventDesc->Struct)->event_data1));
break;
case TRACE_RTAI_POSIX_PTHREAD_COND_INIT :
sprintf(lString,
"PTHREADCOND-INIT %08X",
RFT32(pEventDB, RTAI_POSIX_EVENT(pmEventDesc->Struct)->event_data1));
break;
case TRACE_RTAI_POSIX_PTHREAD_COND_DESTROY :
sprintf(lString,
"PTHREADCOND-DESTROY %08X",
RFT32(pEventDB, RTAI_POSIX_EVENT(pmEventDesc->Struct)->event_data1));
break;
case TRACE_RTAI_POSIX_PTHREAD_CONDATTR_INIT :
sprintf(lString,
"PTHREADCOND-ATTRINIT %08X",
RFT32(pEventDB, RTAI_POSIX_EVENT(pmEventDesc->Struct)->event_data1));
break;
case TRACE_RTAI_POSIX_PTHREAD_CONDATTR_DESTROY :
sprintf(lString,
"PTHREADCOND-ATTRDESTROY %08X",
RFT32(pEventDB, RTAI_POSIX_EVENT(pmEventDesc->Struct)->event_data1));
break;
case TRACE_RTAI_POSIX_PTHREAD_COND_WAIT :
sprintf(lString,
"PTHREADCOND-WAIT %08X",
RFT32(pEventDB, RTAI_POSIX_EVENT(pmEventDesc->Struct)->event_data1));
break;
case TRACE_RTAI_POSIX_PTHREAD_COND_TIMEDWAIT :
sprintf(lString,
"PTHREADCOND-TIMEDWAIT %08X",
RFT32(pEventDB, RTAI_POSIX_EVENT(pmEventDesc->Struct)->event_data1));
break;
case TRACE_RTAI_POSIX_PTHREAD_COND_SIGNAL :
sprintf(lString,
"PTHREADCOND-SIGNAL %08X",
RFT32(pEventDB, RTAI_POSIX_EVENT(pmEventDesc->Struct)->event_data1));
break;
case TRACE_RTAI_POSIX_PTHREAD_COND_BROADCAST :
sprintf(lString,
"PTHREADCOND-BROADCAST %08X",
RFT32(pEventDB, RTAI_POSIX_EVENT(pmEventDesc->Struct)->event_data1));
break;
}
/* Draw the text and its icon */
EGIPendDrawEventInfoReq(pmEventGraph,
pmEventGraph->RTAIPosix,
pmX,
pmY,
lString,
pmEvent);
break;
/* Hit key part of LXRT services */
case TRACE_RTAI_LXRT :
switch(RFT8(pEventDB, RTAI_LXRT_EVENT(pmEventDesc->Struct)->event_sub_id))
{
case TRACE_RTAI_LXRT_RTAI_SYSCALL_ENTRY :
sprintf(lString,
"LXRT-SYSCALL-ENTRY");
break;
case TRACE_RTAI_LXRT_RTAI_SYSCALL_EXIT :
sprintf(lString,
"LXRT-SYSCALL-EXIT");
break;
case TRACE_RTAI_LXRT_SCHED_CHANGE :
sprintf(lString,
"SCHEDCHANGE");
break;
case TRACE_RTAI_LXRT_STEAL_TASK :
sprintf(lString,
"STEAL %d",
RFT32(pEventDB, RTAI_LXRT_EVENT(pmEventDesc->Struct)->event_data1));
break;
case TRACE_RTAI_LXRT_GIVE_BACK_TASK :
sprintf(lString,
"GIVEBACK %d",
RFT32(pEventDB, RTAI_LXRT_EVENT(pmEventDesc->Struct)->event_data1));
break;
case TRACE_RTAI_LXRT_SUSPEND :
sprintf(lString,
"SUSPEND %d",
RFT32(pEventDB, RTAI_LXRT_EVENT(pmEventDesc->Struct)->event_data1));
break;
case TRACE_RTAI_LXRT_RESUME :
sprintf(lString,
"RESUME %d",
RFT32(pEventDB, RTAI_LXRT_EVENT(pmEventDesc->Struct)->event_data1));
break;
case TRACE_RTAI_LXRT_HANDLE :
sprintf(lString,
"HANDLESRQ %d",
RFT32(pEventDB, RTAI_LXRT_EVENT(pmEventDesc->Struct)->event_data1));
break;
}
/* Draw the text and its icon */
EGIPendDrawEventInfoReq(pmEventGraph,
pmEventGraph->RTAILXRT,
pmX,
pmY,
lString,
pmEvent);
break;
/* Hit key part of LXRT-Informed services */
case TRACE_RTAI_LXRTI :
switch(RFT8(pEventDB, RTAI_LXRTI_EVENT(pmEventDesc->Struct)->event_sub_id))
{
case TRACE_RTAI_LXRTI_NAME_ATTACH :
sprintf(lString,
"NAMEATTACH %u",
RFT32(pEventDB, RTAI_LXRTI_EVENT(pmEventDesc->Struct)->event_data1));
break;
case TRACE_RTAI_LXRTI_NAME_LOCATE :
sprintf(lString,
"NAMELOCATE %d",
RFT32(pEventDB, RTAI_LXRTI_EVENT(pmEventDesc->Struct)->event_data2));
break;
case TRACE_RTAI_LXRTI_NAME_DETACH :
sprintf(lString,
"NAMEDETACH %u",
RFT32(pEventDB, RTAI_LXRTI_EVENT(pmEventDesc->Struct)->event_data1));
break;
case TRACE_RTAI_LXRTI_SEND :
sprintf(lString,
"SEND %u",
RFT32(pEventDB, RTAI_LXRTI_EVENT(pmEventDesc->Struct)->event_data1));
break;
case TRACE_RTAI_LXRTI_RECV :
sprintf(lString,
"RECEIVE %u",
RFT32(pEventDB, RTAI_LXRTI_EVENT(pmEventDesc->Struct)->event_data1));
break;
case TRACE_RTAI_LXRTI_CRECV :
sprintf(lString,
"C-RECEIVE %u",
RFT32(pEventDB, RTAI_LXRTI_EVENT(pmEventDesc->Struct)->event_data1));
break;
case TRACE_RTAI_LXRTI_REPLY :
sprintf(lString,
"REPLY %u",
RFT32(pEventDB, RTAI_LXRTI_EVENT(pmEventDesc->Struct)->event_data1));
break;
case TRACE_RTAI_LXRTI_PROXY_ATTACH :
sprintf(lString,
"PROXYATTACH %u",
RFT32(pEventDB, RTAI_LXRTI_EVENT(pmEventDesc->Struct)->event_data1));
break;
case TRACE_RTAI_LXRTI_PROXY_DETACH :
sprintf(lString,
"PROXYDETACH %u",
RFT32(pEventDB, RTAI_LXRTI_EVENT(pmEventDesc->Struct)->event_data1));
break;
case TRACE_RTAI_LXRTI_TRIGGER :
sprintf(lString,
"TRIGGER %u",
RFT32(pEventDB, RTAI_LXRTI_EVENT(pmEventDesc->Struct)->event_data1));
break;
}
/* Draw the text and its icon */
EGIPendDrawEventInfoReq(pmEventGraph,
pmEventGraph->RTAILXRTI,
pmX,
pmY,
lString,
pmEvent);
break;
#endif /* SUPP_RTAI */
/* Otherwise */
default :
g_print("Encountered unknow event \n");
exit(1);
break;
} /* End switch type of the event to draw */
}
/******************************************************************
* Function :
* EGIDrawRTAIEvents()
* Description :
* Draws the event graph for RTAI modified Linux.
* Parameters :
* pmEventGraph, The event graph in which trace is drawn.
* pmEventDB, The event database of events to be drawn.
* pmSystem, The system to which the database belongs.
* pmDrawStart, The draw start time.
* pmDrawEnd, The draw end time.
* pmFirstEvent, The first event to be drawn.
* pmLastEvent, The last event to be drawn.
* Return values :
* NONE
* History :
* K.Y., 06/06/2000, This function is largely inspired by what
* EGIDrawEvents() used to be, but is the first
* implementation of graph drawing using the
* "state" concept.
******************************************************************/
#if SUPP_RTAI
void EGIDrawRTAIEvents(eventGraph* pmEventGraph,
db* pmEventDB,
systemInfo* pmSystem,
gdouble pmDrawStart, gdouble pmDrawEnd,
event* pmFirstEvent, event* pmLastEvent)
{
gint lPID = -1; /* PID of event owner */
gint lTID = -1; /* TID of event owner */
guint x1, y1, x2, y2; /* Origin and destination points for drawing */
event lEvent; /* Generic event */
event lFirstNextEvent; /* Event following first event */
GdkGC* pTempGC = NULL; /* Temporary graphic context */
gdouble lDrawLinesTime = 0; /* Time taken to draw the lines */
gdouble lDrawIconsTime; /* Time taken to draw the icons */
process* pEventProcess = NULL; /* Process associated with event */
RTAItask* pEventTask = NULL; /* Task associated with event */
struct timeval lDrawBeginTime; /* Time at which we began drawing */
struct timeval lDrawDoneTime; /* Time at which we were done drawing */
RTAIsystemState lCurrSysState; /* Current system state */
RTAIsystemState lNextSysState; /* Next system state */
eventDescription lEventDesc; /* Generic event decription */
/* Go to the first significant event */
lEvent = *pmFirstEvent;
/* Get the task to which this event belongs and it's TID */
pEventTask = RTAIDBEventTask(pmEventDB, &lEvent, pmSystem, TRUE);
if(pEventTask != NULL)
lTID = pEventTask->TID;
/* Get the process to which this event belongs and it's PID */
pEventProcess = DBEventProcess(pmEventDB, &lEvent, pmSystem, TRUE);
lPID = pEventProcess->PID;
/* Is the incoming task an RT buddy of a linux process */
if((pEventTask != NULL)
&&(pEventTask->TID != 0)
&&(pEventTask->IsProcessShadow == TRUE)
&&(DBGetTimeInDouble(pEventProcess->ReportedSwitchTime) < (DBGetTimeInDouble(pEventTask->ReportedSwitchTime))))
{
/* Get the process to which this event belongs and it's PID */
pEventProcess = pEventTask->ShadowProcess;
lPID = pEventProcess->PID;
}
/* Get the initial state */
lFirstNextEvent = lEvent;
DBEventNext(pmEventDB, &lFirstNextEvent);
lCurrSysState = RTAIDBGetCurrentState(pmEventDB, &lFirstNextEvent, pmSystem);
/* Initialize the last deferred event (ie, doesn't really exist) */
pmEventGraph->HDef.Same = 0;
pmEventGraph->VDef.Same = 0;
/* Initialize benchmark counters and stats even if they're never printed */
pmEventGraph->NbHLines = 1; /* Start at 1 to account for the final flush */
pmEventGraph->NbVLines = 1;
pmEventGraph->NbUserIcons = 0; /* But not icons as they are batch-delayed */
pmEventGraph->NbKernelIcons = 0;
gettimeofday(&lDrawBeginTime, NULL);
/* Set last x */
x2 = 0;
/* Set last y */
switch(lCurrSysState)
{
/* We are in RTAI's core */
case RTAI_CORE:
y2 = EGIFindRTAIHeight(pmEventGraph);
break;
/* We are in an RTAI task */
case RTAI_TASK:
y2 = EGIFindTaskHeight(pmEventGraph, pEventTask);
break;
/* We are in the Linux kernel */
case LINUX_KERNEL:
y2 = EGIFindKernelHeight(pmEventGraph);
break;
/* We are in a Linux process */
case LINUX_PROCESS:
y2 = EGIFindProcessHeight(pmEventGraph, pEventProcess);
break;
default:
g_print("Unable to find current system state (%d) \n", lCurrSysState);
exit(1);
}
/* Draw the events */
while((DBEventNext(pmEventDB, &lEvent) == TRUE)
&& (!DBEventsEqual(lEvent, (*pmLastEvent))))
{
/* Get the event's description */
DBEventDescription(pmEventDB, &lEvent, FALSE, &lEventDesc);
/* If the trace contains many CPUs only draw the first one, for now */
if((pmEventGraph->EventDB->LogCPUID == TRUE)
&&(lEventDesc.CPUID != 0))
continue;
/* Get the next system state */
lNextSysState = RTAIDBEventState(pmEventDB,
&lEvent,
pEventProcess,
lCurrSysState,
pEventTask);
/* Is this an RTAI scheduling change */
if(lEventDesc.ID == TRACE_RTAI_SCHED_CHANGE)
{
/* Get the task to which this event belongs and it's TID */
pEventTask = RTAIDBEventTask(pmEventDB, &lEvent, pmSystem, TRUE);
lTID = pEventTask->TID;
/* Is the incoming task an RT shadow of a linux process */
if(pEventTask->IsProcessShadow == TRUE)
{
pEventProcess = pEventTask->ShadowProcess;
lPID = pEventProcess->PID;
}
/* Is the incoming task Linux */
else if(pEventTask->TID == 0)
{
/* Get the process to which this event belongs and it's PID */
pEventProcess = DBEventProcess(pmEventDB, &lEvent, pmSystem, TRUE);
lPID = pEventProcess->PID;
}
}
/* Is this a scheduling change */
if((lEventDesc.ID == TRACE_SCHEDCHANGE)
#if 0
&&(((pEventTask != NULL)
&&((pEventTask->IsProcessShadow == FALSE)
||(pEventTask->TID == 0)))
||(pEventTask == NULL)))
#else
)
#endif
{
/* Get the process to which this event belongs and it's TID */
pEventProcess = DBEventProcess(pmEventDB, &lEvent, pmSystem, FALSE);
lPID = pEventProcess->PID;
}
/* Find current event's position */
x1 = x2;
y1 = y2;
x2 = EGIFindEventDistance(pmEventGraph, lEventDesc, pmDrawStart, pmDrawEnd);
y2 = y1;
/* Draw the event's information */
EGIDrawEventInfo(pmEventGraph,
&lEvent,
&lEventDesc,
x2,
y2);
/* Depending on the current state */
switch(lCurrSysState)
{
/* We are in RTAI's core */
case RTAI_CORE:
/* Draw a horizontal line since the last event */
EGIDrawThickHLine(pmEventGraph, pmEventGraph->RTAIGC, y2, x1, x2);
/* Depending on the next state */
switch(lNextSysState)
{
/* We are remaining in the same state */
case RTAI_CORE:
break;
/* We are going in an RTAI task */
case RTAI_TASK:
/* Update drawing height */
y2 = EGIFindTaskHeight(pmEventGraph, pEventTask);
break;
/* We are going in the Linux kernel */
case LINUX_KERNEL:
/* Update drawing height */
y2 = EGIFindKernelHeight(pmEventGraph);
break;
/* We are going in a Linux process */
case LINUX_PROCESS:
/* Update drawing height */
y2 = EGIFindProcessHeight(pmEventGraph, pEventProcess);
break;
default:
break;
}
break;
/* We are in an RTAI task */
case RTAI_TASK:
/* Draw a horizontal line since the last event */
EGIDrawThickHLine(pmEventGraph, pmEventGraph->TaskGC, y2, x1, x2);
/* Depending on the next state */
switch(lNextSysState)
{
/* We are going in RTAI's core */
case RTAI_CORE:
/* Update drawing height */
y2 = EGIFindRTAIHeight(pmEventGraph);
break;
/* We are remaining in the same state */
case RTAI_TASK:
/* Is the current event an RTAI scheduling change */
if(lEventDesc.ID == TRACE_RTAI_SCHED_CHANGE)
y2 = EGIFindTaskHeight(pmEventGraph, pEventTask);
break;
/* We are going in the Linux kernel */
case LINUX_KERNEL:
/* Update drawing height */
y2 = EGIFindKernelHeight(pmEventGraph);
break;
/* We are going in a Linux process */
case LINUX_PROCESS:
/* Update drawing height */
y2 = EGIFindProcessHeight(pmEventGraph, pEventProcess);
break;
default:
break;
}
break;
/* We are in the Linux kernel */
case LINUX_KERNEL:
/* Draw a horizontal line since the last event */
EGIDrawThickHLine(pmEventGraph, pmEventGraph->KernelGC, y2, x1, x2);
/* Depending on the next state */
switch(lNextSysState)
{
/* We are going in RTAI's core */
case RTAI_CORE:
/* Update drawing height */
y2 = EGIFindRTAIHeight(pmEventGraph);
break;
/* We are going in an RTAI task */
case RTAI_TASK:
/* Update drawing height */
y2 = EGIFindTaskHeight(pmEventGraph, pEventTask);
break;
/* We are remaining in the same state */
case LINUX_KERNEL:
break;
/* We are going in a Linux process */
case LINUX_PROCESS:
/* Update drawing height */
y2 = EGIFindProcessHeight(pmEventGraph, pEventProcess);
break;
default:
break;
}
break;
/* We are in a Linux process */
case LINUX_PROCESS:
/* Draw a horizontal line since the last event */
EGIDrawThickHLine(pmEventGraph, pmEventGraph->ProcessGC, y2, x1, x2);
/* Depending on the next state */
switch(lNextSysState)
{
/* We are going in RTAI's core */
case RTAI_CORE:
/* Update drawing height */
y2 = EGIFindRTAIHeight(pmEventGraph);
break;
/* We are going in an RTAI task */
case RTAI_TASK:
/* Update drawing height */
y2 = EGIFindTaskHeight(pmEventGraph, pEventTask);
break;
/* We are going in the Linux kernel */
case LINUX_KERNEL:
/* Update drawing height */
y2 = EGIFindKernelHeight(pmEventGraph);
break;
/* We are remaining in the same state */
case LINUX_PROCESS:
break;
default:
break;
}
break;
default:
break;
}
/* Was there a state change */
if((lCurrSysState != lNextSysState)
||((lCurrSysState == lNextSysState)
&&(lEventDesc.ID == TRACE_RTAI_SCHED_CHANGE)))
{
/* Depending on the type of event */
switch(lEventDesc.ID)
{
/* IRQ entries/exits */
case TRACE_IRQ_ENTRY:
case TRACE_IRQ_EXIT:
case TRACE_RTAI_GLOBAL_IRQ_ENTRY:
case TRACE_RTAI_GLOBAL_IRQ_EXIT:
case TRACE_RTAI_OWN_IRQ_ENTRY:
case TRACE_RTAI_OWN_IRQ_EXIT:
pTempGC = pmEventGraph->InterruptGC;
break;
/* Trap entries/exits */
case TRACE_TRAP_ENTRY:
case TRACE_TRAP_EXIT:
case TRACE_RTAI_TRAP_ENTRY:
case TRACE_RTAI_TRAP_EXIT:
pTempGC = pmEventGraph->TrapGC;
break;
/* Syscall entries/exits */
case TRACE_SYSCALL_ENTRY:
case TRACE_SYSCALL_EXIT:
pTempGC = pmEventGraph->SysCallGC;
break;
/* Anything else */
default:
pTempGC = pmEventGraph->InterruptGC;
break;
}
/* Draw line from initial state to final state */
x1 = x2;
x2 = x1;
gdk_draw_line(pmEventGraph->PixMap,
pTempGC,
x1,
y1,
x2,
y2);
/* Update the system's state */
lCurrSysState = lNextSysState;
} /* End state change handling */
} /* End drawing loop */
/* Did we draw all the events in the window */
if(DBEventsEqual((*pmFirstEvent), pmEventDB->FirstEvent)
&&DBEventsEqual((*pmLastEvent), pmEventDB->LastEvent))
/* Don't draw anything */
goto DoneDrawing;
/* Depending on the last state we are in */
switch(lCurrSysState)
{
/* We are in RTAI's core */
case RTAI_CORE:
pTempGC = pmEventGraph->RTAIGC;
break;
/* We are in an RTAI task */
case RTAI_TASK:
pTempGC = pmEventGraph->TaskGC;
break;
/* We are in the Linux kernel */
case LINUX_KERNEL:
pTempGC = pmEventGraph->KernelGC;
break;
/* We are in a Linux process */
case LINUX_PROCESS:
pTempGC = pmEventGraph->ProcessGC;
break;
default:
break;
}
/* Update line coordinates */
x1 = x2;
y1 = y2;
x2 = pmEventGraph->HDrawSize;
y2 = y1;
/* Draw last line */
EGIDrawThickHLine(pmEventGraph, pTempGC, y2, x1, x2);
DoneDrawing: /* OK, this doesn't look clean, but IT IS (try doing without ... you'll see) */
/* Are we drawing horizontal lines fast */
if(pmEventGraph->FastHLines)
/* Flush any deferred lines by asking for a last line that is out of limits */
EGIDrawThickHLine(pmEventGraph, NULL, 32000, 32000, 32000);
/* Are we drawing vertical lines fast */
if(pmEventGraph->FastVLines)
/* Flush any deferred lines by asking for a last line that is out of limits */
EGIDrawVLine(pmEventGraph, NULL, 32000, 32000, 32000);
/* Are we benchmarking our operations */
if(pmEventGraph->Benchmark)
{
/* We're done drawing the lines, get the current time */
gettimeofday(&lDrawDoneTime, NULL);
/* Compute the time it took to draw the lines (add 1 to avoid divide by zero) */
lDrawLinesTime = (DBGetTimeInDouble(lDrawDoneTime) - DBGetTimeInDouble(lDrawBeginTime) + 1) / 1000000.0;
/* Print out the benchmarks */
printf("\n%6ld Hor + %6ld Vert = %6ld lines in %6.3f s: %8.0f lines/sec\n",
pmEventGraph->NbHLines,
pmEventGraph->NbVLines,
pmEventGraph->NbHLines + pmEventGraph->NbVLines,
lDrawLinesTime,
(float)(pmEventGraph->NbVLines + pmEventGraph->NbHLines) / lDrawLinesTime);
/* Print out the begining of the icon draw information time */
printf("%6ld User + %6ld Kern = %6ld icons in ",
pmEventGraph->NbUserIcons,
pmEventGraph->NbKernelIcons,
pmEventGraph->NbUserIcons + pmEventGraph->NbKernelIcons);
/* Flush out any pending output */
fflush(stdout);
/* Get the current time to see how much time it will take to draw the icons */
gettimeofday(&lDrawBeginTime, NULL);
}
/* Now draw the deferred icons so they come out on top */
g_slist_foreach(pmEventGraph->EventIcons,
(GFunc) EGICommitEventDrawRequest,
pmEventGraph);
/* Are we benchmarking our operations */
if(pmEventGraph->Benchmark)
{
/* We're done drawing the icons, get the current time */
gettimeofday(&lDrawDoneTime, NULL);
/* Compute the time it took to draw the icons (add 1 to avoid divide by zero) */
lDrawIconsTime = (DBGetTimeInDouble(lDrawDoneTime) - DBGetTimeInDouble(lDrawBeginTime) + 1) / 1000000.0;
/* Print out the icon drawing information */
printf("%6.3f s: %8.0f icons/sec\n",
lDrawIconsTime,
(float)(pmEventGraph->NbUserIcons + pmEventGraph->NbKernelIcons) / lDrawIconsTime);
printf("\t Total DB traversal + draw time: %6.3f s: %8.0f events/sec\n",
(lDrawLinesTime + lDrawIconsTime),
(float)pmEventGraph->NbIntervalEvents / (lDrawLinesTime + lDrawIconsTime));
}
}
#endif /* SUPP_RTAI */
/******************************************************************
* Function :
* EGIDrawEvents()
* Description :
* Calls the correct drawing function depending on the type
* of trace.
* Parameters :
* pmEventGraph, The event graph in which trace is drawn.
* pmDrawStart, The draw start time.
* pmDrawEnd, The draw end time.
* pmFirstEvent, The first event to be drawn.
* pmLastEvent, The last event to be drawn.
* Return values :
* NONE.
* History :
* K.Y., 06/06/2000, Moved drawing code into trace type dependent
* functions.
* K.Y., ..., Multiple modifications (see header).
* K.Y., 28/06/1999, Initial typing.
* Note :
******************************************************************/
void EGIDrawEvents(eventGraph* pmEventGraph,
gdouble pmDrawStart, gdouble pmDrawEnd,
event* pmFirstEvent, event* pmLastEvent)
{
db* pEventDB; /* The event database */
systemInfo* pSystem; /* System pointer */
#if 0
struct timeval lTime; /* Generic timevalue */
printf("\n");
DBEventTime(pmEventGraph->EventDB, pmFirstEvent, &lTime);
printf("First event time : (%ld, %ld) \n", lTime.tv_sec, lTime.tv_usec);
DBEventTime(pmEventGraph->EventDB, pmLastEvent, &lTime);
printf("Last event time : (%ld, %ld) \n", lTime.tv_sec, lTime.tv_usec);
#endif
/* Initialize event database */
pEventDB = pmEventGraph->EventDB;
/* Initialize system pointer */
pSystem = pmEventGraph->System;
/* Make sure the event icon coordinates list is empty */
if(pmEventGraph->EventIcons != NULL)
{
/* Free all allocated coordinate items */
g_slist_foreach(pmEventGraph->EventIcons, (GFunc) g_free, NULL);
/* Free the GList list items */
g_slist_free(pmEventGraph->EventIcons);
/* Reset list pointer */
pmEventGraph->EventIcons = NULL;
}
/* Depending on the type of trace */
switch(pEventDB->SystemType)
{
/* Vanilla Linux */
case TRACE_SYS_TYPE_VANILLA_LINUX :
EGIDrawLinuxEvents(pmEventGraph,
pEventDB,
pSystem,
pmDrawStart, pmDrawEnd,
pmFirstEvent, pmLastEvent);
break;
#if SUPP_RTAI
/* RTAI modified Linux */
case TRACE_SYS_TYPE_RTAI_LINUX :
EGIDrawRTAIEvents(pmEventGraph,
pEventDB,
pSystem,
pmDrawStart, pmDrawEnd,
pmFirstEvent, pmLastEvent);
break;
#endif
/* Just in case */
default :
g_print("TraceVisualizer: Unknow trace type to draw \n");
return;
break;
}
}
/******************************************************************
* Function : EGIDrawHorizon()
* Description :
* Parameters :
* Return values :
* History :
* Note :
******************************************************************/
void EGIDrawHorizon(eventGraph* pmEventGraph)
{
process* pProc; /* Generic process pointer */
/* Go through all the processes in the process list */
for(pProc = pmEventGraph->System->Processes;
pProc != NULL;
pProc = pProc->Next)
{
/* Is this process zero */
if(pProc->PID != 0)
gdk_draw_line(pmEventGraph->PixMap,
pmEventGraph->HorizonGC,
0,
EGIFindProcessHeight(pmEventGraph, pProc),
pmEventGraph->HDrawSize,
EGIFindProcessHeight(pmEventGraph, pProc));
else
gdk_draw_line(pmEventGraph->PixMap,
pmEventGraph->HorizonGC,
0,
EGIFindKernelHeight(pmEventGraph),
pmEventGraph->HDrawSize,
EGIFindKernelHeight(pmEventGraph));
}
}
/******************************************************************
* Function : EGIDrawSelectionLine()
* Description :
* Parameters :
* Return values :
* History :
* Note :
******************************************************************/
void EGIDrawSelectionLine(eventGraph* pmEventGraph)
{
/* If a process is selected */
if(pmEventGraph->SelectedProc != NULL)
gdk_draw_line(pmEventGraph->PixMap,
pmEventGraph->SelectedGC,
0,
EGIFindProcessHeight(pmEventGraph, pmEventGraph->SelectedProc),
pmEventGraph->HDrawSize,
EGIFindProcessHeight(pmEventGraph, pmEventGraph->SelectedProc));
}
/******************************************************************
* Function : EGIDrawTrace()
* Description :
* Parameters :
* Return values :
* History :
* Note :
******************************************************************/
void EGIDrawTrace(eventGraph* pmEventGraph, gboolean pmForce)
{
event lFirstEvent; /* First event drawn */
event lLastEvent; /* Last event drawn */
gchar lUnits[80]; /* Memory span units */
glong lMemorySpan; /* Quantity of memory containing event data we have to go through */
gfloat lScrollDisplacement; /* Displacement between last and current scroll positions */
gfloat lValue; /* Current position of scrollbar */
gfloat lPageSize; /* Size of scroll page */
gfloat lMinValue; /* Minimum value of scroll bar position */
gfloat lMaxValue; /* Maximum value of scroll bar position */
gdouble lDrawStart; /* Time of first event drawn */
gdouble lDrawEnd; /* Time of last event drawn */
/* Set globals from options. This routine is essentially the entry point to the EG "module" */
pmEventGraph->Benchmark = ((systemView*)(((mainWindow*)(pmEventGraph->MainWindow))->SystemView))->Options->Benchmark;
pmEventGraph->FastHLines = !GTK_TOGGLE_BUTTON(((mainWindow*)pmEventGraph->MainWindow)->tlbSlowH)->active;
pmEventGraph->FastVLines = !GTK_TOGGLE_BUTTON(((mainWindow*)pmEventGraph->MainWindow)->tlbSlowV)->active;
pmEventGraph->FastIcons = !GTK_TOGGLE_BUTTON(((mainWindow*)pmEventGraph->MainWindow)->tlbSlowI)->active;
/* Get scrollbar parameters */
lValue = GTK_ADJUSTMENT(pmEventGraph->HAdjustment)->value;
lPageSize = GTK_ADJUSTMENT(pmEventGraph->HAdjustment)->page_size;
lMinValue = GTK_ADJUSTMENT(pmEventGraph->HAdjustment)->lower;
lMaxValue = GTK_ADJUSTMENT(pmEventGraph->HAdjustment)->upper;
/* Get displacement */
lScrollDisplacement = GTK_ADJUSTMENT(pmEventGraph->HAdjustment)->value - pmEventGraph->LastScrollVal;
#if 0
/* Print out the sizes */
g_print("\nHBar Value / Page Size\t: %.f / %.f\n", lValue, lPageSize);
g_print("Min / Max Value\t\t: %.f / %.f\n", lMinValue, lMaxValue);
g_print("Scroll Delta / Force Redraw : %.f / %s\n", lScrollDisplacement, pmForce ? "TRUE" : "FALSE");
#endif
/* Is it worth it to redraw */
if((lScrollDisplacement < 1) && (lScrollDisplacement > -1) && (pmForce != TRUE))
return;
/* Update the latest scroll value */
pmEventGraph->LastScrollVal = lValue;
/* Get the drawing interval */
EGIFindDrawLimits(pmEventGraph, lValue, lPageSize, lMinValue, lMaxValue, &lDrawStart, &lDrawEnd);
/* Print display interval in status bar */
WDTimeSBarDisplay(pmEventGraph->MainWindow, lDrawStart, lDrawEnd);
/* Don't go forward if there is nothing to draw */
if(pmEventGraph->Interval < 0)
return;
/* Find the first and last event drawable */
if(EGIFindLimitEvents(pmEventGraph, lDrawStart, lDrawEnd, &lFirstEvent, &lLastEvent) == FALSE)
{
/* Draw all the events */
lFirstEvent = pmEventGraph->EventDB->FirstEventWithProc;
lLastEvent = pmEventGraph->EventDB->LastEvent;
}
/* Are we benchmarking? */
if(pmEventGraph->Benchmark)
{
/* Compute the memory span we have to go through to draw the trace */
lMemorySpan = (lLastEvent.EventPos - lFirstEvent.EventPos)
+ pmEventGraph->EventDB->BufferSize * (lLastEvent.BufID - lFirstEvent.BufID);
/* Determine the memory span units */
if(lMemorySpan < 9999)
strcpy(lUnits, "bytes");
else
{
lMemorySpan /= 1024;
if(lMemorySpan < 9999)
strcpy(lUnits, "kilobytes");
else
{
lMemorySpan /= 1024;
strcpy(lUnits, "megabytes");
}
}
#if 0
g_print("\nDrawable Events Time Interval \t\t: %.2f \n", pmEventGraph->Interval);
g_print("Draw Start / End \t: %.f / %.f\n", lDrawStart, lDrawEnd);
g_print("Graph Start / Duration \t: %.f / %.f\n", pmEventGraph->StartTime, pmEventGraph->Duration);
#endif
g_print("\n-----------------------------------------------------------\n");
g_print("%ld events in %ld %s span %.0f uSec; drawn @ %0.3f us/pixel...\n",
pmEventGraph->NbIntervalEvents, lMemorySpan, lUnits,
pmEventGraph->Interval, pmEventGraph->USecPerPix);
}
/* Empty the draw area */
gdk_draw_rectangle(pmEventGraph->PixMap,
pmEventGraph->BackgroundGC,
TRUE,
0, 0,
pmEventGraph->HDrawSize,
pmEventGraph->VDrawSize);
#if 0
g_print("First Event Drawn : %f \n", EGIGetEventTimeInDouble(pFirstEvent));
g_print("Last Event Drawn : %f \n", EGIGetEventTimeInDouble(pLastEvent));
g_print("NFirst Event Drawn : %f \n", EGIGetEventTimeInDouble(pFirstEvent->Next));
g_print("PLast Event Drawn : %f \n", EGIGetEventTimeInDouble(pLastEvent->Prev));
g_print("Interval last/first : %f \n", EGIGetEventTimeInDouble(lLastEvent) - EGIGetEventTimeInDouble(lFirstEvent));
g_print("Interval pre-set : %f \n", pmEventGraph->Interval);
#endif
/* Draw the horizon */
if(pmEventGraph->ShowHorizon == TRUE)
EGIDrawHorizon(pmEventGraph);
/* Draw the viewable events */
EGIDrawEvents(pmEventGraph,
lDrawStart, lDrawEnd,
&lFirstEvent, &lLastEvent);
/* Draw the selection line */
EGIDrawSelectionLine(pmEventGraph);
}
/******************************************************************
* Function : EGIResetHAdjustment()
* Description :
* Parameters :
* Return values :
* History :
* Note :
******************************************************************/
void EGIResetHAdjustment(eventGraph* pmEGraph, gboolean pmKeepInRegion)
{
/* Are we somewhere else than in the begining */
if(pmEGraph->LastScrollVal != 0 && pmKeepInRegion)
/* Keep the scrollbar in the same region */
pmEGraph->LastScrollVal =
((gfloat) pmEGraph->HTrueSize) *
GTK_ADJUSTMENT(pmEGraph->HAdjustment)->value /
GTK_ADJUSTMENT(pmEGraph->HAdjustment)->upper;
#if 0
g_print("\nBefore \n");
g_print("Value : %f \n", GTK_ADJUSTMENT(pmEGraph->HAdjustment)->value);
g_print("Page size %f \n", GTK_ADJUSTMENT(pmEGraph->HAdjustment)->page_size);
g_print("Min Value %f \n", GTK_ADJUSTMENT(pmEGraph->HAdjustment)->lower);
g_print("Max Value %f \n", GTK_ADJUSTMENT(pmEGraph->HAdjustment)->upper);
#endif
/* Set scrollbar parameters */
GTK_ADJUSTMENT(pmEGraph->HAdjustment)->lower = 0;
GTK_ADJUSTMENT(pmEGraph->HAdjustment)->upper = (gfloat) pmEGraph->HTrueSize;
GTK_ADJUSTMENT(pmEGraph->HAdjustment)->value = pmEGraph->LastScrollVal;
GTK_ADJUSTMENT(pmEGraph->HAdjustment)->page_size = (gfloat) pmEGraph->HDrawSize;
GTK_ADJUSTMENT(pmEGraph->HAdjustment)->step_increment = 10;
GTK_ADJUSTMENT(pmEGraph->HAdjustment)->page_increment = (gfloat) pmEGraph->HDrawSize;
gtk_adjustment_changed(GTK_ADJUSTMENT(pmEGraph->HAdjustment));
/* Set drawable interval */
pmEGraph->Interval = (pmEGraph->Duration * (gdouble) pmEGraph->HDrawSize) / ((gdouble) pmEGraph->HTrueSize);
#if 0
g_print("After \n");
g_print("Value : %f \n", GTK_ADJUSTMENT(pmEGraph->HAdjustment)->value);
g_print("Page size %f \n", GTK_ADJUSTMENT(pmEGraph->HAdjustment)->page_size);
g_print("Min Value %f \n", GTK_ADJUSTMENT(pmEGraph->HAdjustment)->lower);
g_print("Max Value %f \n", GTK_ADJUSTMENT(pmEGraph->HAdjustment)->upper);
#endif
}
/**********************************************************************************/
/**************************** Signal handling functions ***************************/
/**********************************************************************************/
/******************************************************************
* Function : EGSHExposeEvent()
* Description :
* Parameters :
* Return values :
* History :
* Note :
******************************************************************/
void EGSHExposeEvent(GtkWidget* pmWidget, GdkEventExpose* pmEvent, eventGraph* pmEGraph)
{
gfloat lRStart; /* Start value of ruler */
gfloat lREnd; /* End value of ruler */
#if 0
g_print("Expose event \n");
#endif
/* Are we ready to expose something */
if((pmEGraph->System == NULL)
|| (pmEGraph->PixMap == NULL)
|| (pmEGraph->Init == FALSE))
return;
/* Draw the pixmap in the window */
gdk_draw_pixmap(pmEGraph->DrawArea->window,
pmEGraph->DrawArea->style->fg_gc[GTK_WIDGET_STATE(pmEGraph->DrawArea)],
pmEGraph->PixMap,
#if 0
pmEvent->area.x, pmEvent->area.y,
pmEvent->area.x, pmEvent->area.y,
pmEvent->area.width, pmEvent->area.height);
#else
0, 0,
0, 0,
pmEGraph->HDrawSize, pmEGraph->VDrawSize);
#endif
/* Set the ruler's values */
if(pmEGraph->DrawStartTime != 0)
{
/* Are we displaying in seconds */
if(pmEGraph->Interval >= 1000000)
{
lRStart = (gfloat) (pmEGraph->DrawStartTime / 1000000) / 1000;
lREnd = lRStart + (gfloat) (pmEGraph->Interval / 1000000) / 1000;
}
else /* Microseconds */
{
lRStart = (gfloat) fmod(pmEGraph->DrawStartTime, 1000000) / 1000;
lREnd = (gfloat) fmod(pmEGraph->DrawStartTime + pmEGraph->Interval, 1000000) / 1000;
}
if(lREnd < lRStart)
lREnd += 1000;
gtk_ruler_set_range(GTK_RULER(pmEGraph->HRuler), lRStart, lREnd, lRStart, lREnd);
}
/* Make sure that the scrolled process list is well drawn (if not done, list isn't properly sized !?!?) */
gtk_widget_queue_resize(pmEGraph->ScrolledList);
/* Stop the signal from propagating */
gtk_signal_emit_stop_by_name(GTK_OBJECT(pmWidget), "expose_event");
}
/******************************************************************
* Function : EGSHConfigureEvent()
* Description :
* Parameters :
* Return values :
* History :
* Note :
******************************************************************/
void EGSHConfigureEvent(GtkWidget* pmWidget, GdkEventExpose* pmEvent, eventGraph* pmEGraph)
{
guint lOldHDrawSize; /* Old horizontal draw size */
guint lOldVDrawSize; /* Old vertical draw size */
#if 0
g_print("Configure event \n");
#endif
/* Are we ready to expose something */
if((pmEGraph->System == NULL)
|| (pmEGraph->Init == FALSE))
return;
/* Remember old draw sizes */
lOldHDrawSize = pmEGraph->HDrawSize;
lOldVDrawSize = pmEGraph->VDrawSize;
/* Set new draw sizes */
pmEGraph->HDrawSize = (guint) GTK_WIDGET(pmEGraph->DrawArea)->allocation.width;
pmEGraph->VDrawSize = (guint) GTK_WIDGET(pmEGraph->DrawArea)->allocation.height;
/* Do we need more space than is available */
if(pmEGraph->VDrawSize < pmEGraph->VTrueSize)
pmEGraph->VDrawSize = pmEGraph->VTrueSize;
/* Does the horizontal drawing area have a significant size */
#if 0
if(pmEGraph->HDrawSize < 10)
return;
#endif
/* Have the draw sizes changed */
if((lOldHDrawSize == pmEGraph->HDrawSize)
&& (lOldVDrawSize == pmEGraph->VDrawSize))
{
/* Reset the HAdjustment */
EGIResetHAdjustment(pmEGraph, TRUE);
/* Get outta here */
return;
}
/* Was there a pixmap already */
if(pmEGraph->PixMap != NULL)
{
/* Free the already existing pixmap */
gdk_pixmap_unref(pmEGraph->PixMap);
pmEGraph->PixMap = NULL;
}
/* Create new pixmap where we can draw */
pmEGraph->PixMap = gdk_pixmap_new(pmEGraph->DrawArea->window,
pmEGraph->HDrawSize,
pmEGraph->VDrawSize,
-1);
/* Set draw area size (if this isn't done, scrolling down doesn't enable the user to see more of the graph) */
gtk_widget_set_usize(pmEGraph->DrawArea,
-1,
pmEGraph->VDrawSize);
/* Did we have cached icons? */
if(pmEGraph->KernelTimer.Pixmap != NULL)
{
/* Free the already existing icons */
gdk_pixmap_unref(pmEGraph->KernelTimer.Pixmap);
gdk_pixmap_unref(pmEGraph->SysCall.Pixmap);
gdk_pixmap_unref(pmEGraph->Trap.Pixmap);
gdk_pixmap_unref(pmEGraph->SchedChange.Pixmap);
gdk_pixmap_unref(pmEGraph->BottomHalf.Pixmap);
gdk_pixmap_unref(pmEGraph->IOStart.Pixmap);
gdk_pixmap_unref(pmEGraph->IOEnd.Pixmap);
gdk_pixmap_unref(pmEGraph->IRQ.Pixmap);
#if SUPP_RTAI
gdk_pixmap_unref(pmEGraph->RTAIMount.Pixmap);
gdk_pixmap_unref(pmEGraph->RTAIUmount.Pixmap);
gdk_pixmap_unref(pmEGraph->RTAIIrq.Pixmap);
gdk_pixmap_unref(pmEGraph->RTAITask.Pixmap);
gdk_pixmap_unref(pmEGraph->RTAITimer.Pixmap);
gdk_pixmap_unref(pmEGraph->RTAISem.Pixmap);
gdk_pixmap_unref(pmEGraph->RTAIMsg.Pixmap);
gdk_pixmap_unref(pmEGraph->RTAIRPC.Pixmap);
gdk_pixmap_unref(pmEGraph->RTAIMbx.Pixmap);
gdk_pixmap_unref(pmEGraph->RTAIFifo.Pixmap);
gdk_pixmap_unref(pmEGraph->RTAIShm.Pixmap);
gdk_pixmap_unref(pmEGraph->RTAIPosix.Pixmap);
gdk_pixmap_unref(pmEGraph->RTAILXRT.Pixmap);
gdk_pixmap_unref(pmEGraph->RTAILXRTI.Pixmap);
#endif /* SUPP_RTAI */
gdk_bitmap_unref(pmEGraph->KernelTimer.Mask);
gdk_bitmap_unref(pmEGraph->SysCall.Mask);
gdk_bitmap_unref(pmEGraph->Trap.Mask);
gdk_bitmap_unref(pmEGraph->SchedChange.Mask);
gdk_bitmap_unref(pmEGraph->BottomHalf.Mask);
gdk_bitmap_unref(pmEGraph->IOStart.Mask);
gdk_bitmap_unref(pmEGraph->IOEnd.Mask);
gdk_bitmap_unref(pmEGraph->IRQ.Mask);
#if SUPP_RTAI
gdk_bitmap_unref(pmEGraph->RTAIMount.Pixmap);
gdk_bitmap_unref(pmEGraph->RTAIUmount.Pixmap);
gdk_bitmap_unref(pmEGraph->RTAIIrq.Pixmap);
gdk_bitmap_unref(pmEGraph->RTAITask.Pixmap);
gdk_bitmap_unref(pmEGraph->RTAITimer.Pixmap);
gdk_bitmap_unref(pmEGraph->RTAISem.Pixmap);
gdk_bitmap_unref(pmEGraph->RTAIMsg.Pixmap);
gdk_bitmap_unref(pmEGraph->RTAIRPC.Pixmap);
gdk_bitmap_unref(pmEGraph->RTAIMbx.Pixmap);
gdk_bitmap_unref(pmEGraph->RTAIFifo.Pixmap);
gdk_bitmap_unref(pmEGraph->RTAIShm.Pixmap);
gdk_bitmap_unref(pmEGraph->RTAIPosix.Pixmap);
gdk_bitmap_unref(pmEGraph->RTAILXRT.Pixmap);
gdk_bitmap_unref(pmEGraph->RTAILXRTI.Pixmap);
#endif /* SUPP_RTAI */
pmEGraph->KernelTimer.Pixmap = NULL;
pmEGraph->SysCall.Pixmap = NULL;
pmEGraph->Trap.Pixmap = NULL;
pmEGraph->SchedChange.Pixmap = NULL;
pmEGraph->BottomHalf.Pixmap = NULL;
pmEGraph->IOStart.Pixmap = NULL;
pmEGraph->IOEnd.Pixmap = NULL;
pmEGraph->IRQ.Pixmap = NULL;
#if SUPP_RTAI
pmEGraph->RTAIMount.Pixmap = NULL;
pmEGraph->RTAIUmount.Pixmap = NULL;
pmEGraph->RTAIIrq.Pixmap = NULL;
pmEGraph->RTAITask.Pixmap = NULL;
pmEGraph->RTAITimer.Pixmap = NULL;
pmEGraph->RTAISem.Pixmap = NULL;
pmEGraph->RTAIMsg.Pixmap = NULL;
pmEGraph->RTAIRPC.Pixmap = NULL;
pmEGraph->RTAIMbx.Pixmap = NULL;
pmEGraph->RTAIFifo.Pixmap = NULL;
pmEGraph->RTAIShm.Pixmap = NULL;
pmEGraph->RTAIPosix.Pixmap = NULL;
pmEGraph->RTAILXRT.Pixmap = NULL;
pmEGraph->RTAILXRTI.Pixmap = NULL;
#endif
}
/* Create cached icons */
pmEGraph->KernelTimer.Pixmap = gdk_pixmap_create_from_xpm_d( pmEGraph->DrawArea->window,
&pmEGraph->KernelTimer.Mask,
NULL,
xpm_kernel_timer );
pmEGraph->SysCall.Pixmap = gdk_pixmap_create_from_xpm_d( pmEGraph->DrawArea->window,
&pmEGraph->SysCall.Mask,
NULL,
xpm_sys_call );
pmEGraph->Trap.Pixmap = gdk_pixmap_create_from_xpm_d( pmEGraph->DrawArea->window,
&pmEGraph->Trap.Mask,
NULL,
xpm_trap );
pmEGraph->SchedChange.Pixmap = gdk_pixmap_create_from_xpm_d( pmEGraph->DrawArea->window,
&pmEGraph->SchedChange.Mask,
NULL,
xpm_sched_change );
pmEGraph->BottomHalf.Pixmap = gdk_pixmap_create_from_xpm_d( pmEGraph->DrawArea->window,
&pmEGraph->BottomHalf.Mask,
NULL,
xpm_bottom_half );
pmEGraph->IOStart.Pixmap = gdk_pixmap_create_from_xpm_d( pmEGraph->DrawArea->window,
&pmEGraph->IOStart.Mask,
NULL,
xpm_io_start );
pmEGraph->IOEnd.Pixmap = gdk_pixmap_create_from_xpm_d( pmEGraph->DrawArea->window,
&pmEGraph->IOEnd.Mask,
NULL,
xpm_io_end );
pmEGraph->IRQ.Pixmap = gdk_pixmap_create_from_xpm_d( pmEGraph->DrawArea->window,
&pmEGraph->IRQ.Mask,
NULL,
xpm_irq );
#if SUPP_RTAI
pmEGraph->RTAIMount.Pixmap = gdk_pixmap_create_from_xpm_d( pmEGraph->DrawArea->window,
&pmEGraph->RTAIMount.Mask,
NULL,
xpm_RTAIMount );
pmEGraph->RTAIUmount.Pixmap = gdk_pixmap_create_from_xpm_d( pmEGraph->DrawArea->window,
&pmEGraph->RTAIUmount.Mask,
NULL,
xpm_RTAIUmount );
pmEGraph->RTAIIrq.Pixmap = gdk_pixmap_create_from_xpm_d( pmEGraph->DrawArea->window,
&pmEGraph->RTAIIrq.Mask,
NULL,
xpm_RTAIIrq );
pmEGraph->RTAITask.Pixmap = gdk_pixmap_create_from_xpm_d( pmEGraph->DrawArea->window,
&pmEGraph->RTAITask.Mask,
NULL,
xpm_RTAITask );
pmEGraph->RTAITimer.Pixmap = gdk_pixmap_create_from_xpm_d( pmEGraph->DrawArea->window,
&pmEGraph->RTAITimer.Mask,
NULL,
xpm_RTAITimer );
pmEGraph->RTAISem.Pixmap = gdk_pixmap_create_from_xpm_d( pmEGraph->DrawArea->window,
&pmEGraph->RTAISem.Mask,
NULL,
xpm_RTAISem );
pmEGraph->RTAIMsg.Pixmap = gdk_pixmap_create_from_xpm_d( pmEGraph->DrawArea->window,
&pmEGraph->RTAIMsg.Mask,
NULL,
xpm_RTAIMsg );
pmEGraph->RTAIRPC.Pixmap = gdk_pixmap_create_from_xpm_d( pmEGraph->DrawArea->window,
&pmEGraph->RTAIRPC.Mask,
NULL,
xpm_RTAIRPC );
pmEGraph->RTAIMbx.Pixmap = gdk_pixmap_create_from_xpm_d( pmEGraph->DrawArea->window,
&pmEGraph->RTAIMbx.Mask,
NULL,
xpm_RTAIMbx );
pmEGraph->RTAIFifo.Pixmap = gdk_pixmap_create_from_xpm_d( pmEGraph->DrawArea->window,
&pmEGraph->RTAIFifo.Mask,
NULL,
xpm_RTAIFifo );
pmEGraph->RTAIShm.Pixmap = gdk_pixmap_create_from_xpm_d( pmEGraph->DrawArea->window,
&pmEGraph->RTAIShm.Mask,
NULL,
xpm_RTAIShm );
pmEGraph->RTAIPosix.Pixmap = gdk_pixmap_create_from_xpm_d( pmEGraph->DrawArea->window,
&pmEGraph->RTAIPosix.Mask,
NULL,
xpm_RTAIPosix );
pmEGraph->RTAILXRT.Pixmap = gdk_pixmap_create_from_xpm_d( pmEGraph->DrawArea->window,
&pmEGraph->RTAILXRT.Mask,
NULL,
xpm_RTAILXRT );
pmEGraph->RTAILXRTI.Pixmap = gdk_pixmap_create_from_xpm_d( pmEGraph->DrawArea->window,
&pmEGraph->RTAILXRTI.Mask,
NULL,
xpm_RTAILXRTI );
#endif /* SUPP_RTAI */
/* Have the colors been allocated */
if(pmEGraph->ColorsAllocated == FALSE)
{
/* Create the Graphic Context for the Selected item */
/* Create default drawing contexts */
pmEGraph->BackgroundGC= EGICreateGC(pmEGraph->PixMap,
pmEGraph->BlackColor,
pmEGraph->BlackColor,
GDK_LINE_SOLID);
pmEGraph->HorizonGC = EGICreateGC(pmEGraph->PixMap,
pmEGraph->YellowColor,
pmEGraph->BlackColor,
GDK_LINE_SOLID);
pmEGraph->ProcessGC = EGICreateGC(pmEGraph->PixMap,
pmEGraph->GreenColor,
pmEGraph->BlackColor,
GDK_LINE_SOLID);
pmEGraph->Process0GC = EGICreateGC(pmEGraph->PixMap,
pmEGraph->RedColor,
pmEGraph->BlackColor,
GDK_LINE_SOLID);
pmEGraph->KernelGC = EGICreateGC(pmEGraph->PixMap,
pmEGraph->OrangeColor,
pmEGraph->BlackColor,
GDK_LINE_SOLID);
pmEGraph->TaskGC = EGICreateGC(pmEGraph->PixMap,
pmEGraph->RedColor,
pmEGraph->BlackColor,
GDK_LINE_SOLID);
pmEGraph->RTAIGC = EGICreateGC(pmEGraph->PixMap,
pmEGraph->RedColor,
pmEGraph->BlackColor,
GDK_LINE_SOLID);
pmEGraph->SysCallGC = EGICreateGC(pmEGraph->PixMap,
pmEGraph->BlueColor,
pmEGraph->BlackColor,
GDK_LINE_SOLID);
pmEGraph->TrapGC = EGICreateGC(pmEGraph->PixMap,
pmEGraph->GreyColor,
pmEGraph->BlackColor,
GDK_LINE_SOLID);
pmEGraph->InterruptGC = EGICreateGC(pmEGraph->PixMap,
pmEGraph->WhiteColor,
pmEGraph->BlackColor,
GDK_LINE_SOLID);
pmEGraph->TextGC = EGICreateGC(pmEGraph->PixMap,
pmEGraph->TurquoiseColor,
pmEGraph->BlackColor,
GDK_LINE_SOLID);
pmEGraph->SelectedGC = EGICreateGC(pmEGraph->PixMap,
pmEGraph->PurpleColor,
pmEGraph->BlackColor,
GDK_LINE_ON_OFF_DASH);
/* We're done allocating colors */
pmEGraph->ColorsAllocated = TRUE;
}
/* Reset HAdjustment settings */
EGIResetHAdjustment(pmEGraph, TRUE);
/* Draw the trace */
EGIDrawTrace(pmEGraph, TRUE);
/* Stop the signal from propagating */
gtk_signal_emit_stop_by_name(GTK_OBJECT(pmWidget), "configure_event");
}
/******************************************************************
* Function : EGSHHScrollChange()
* Description :
* Parameters :
* Return values :
* History :
* Note :
******************************************************************/
void EGSHHScrollChange(GtkAdjustment* pmAdjustment, gpointer pmData)
{
eventGraph* pEGraph; /* The event graph */
/* Get the event graph */
if((pEGraph = (eventGraph*) pmData) == NULL)
return;
/* Are we ready to expose something */
if((pEGraph->System == NULL)
|| (pEGraph->Init == FALSE))
return;
/* Redraw trace */
EGIDrawTrace(pEGraph, FALSE);
/* Draw the pixmap in the window */
gtk_widget_queue_draw(pEGraph->DrawArea);
/* Stop the signal from being propagated */
gtk_signal_emit_stop_by_name(GTK_OBJECT(pmAdjustment), "value-changed");
}
/******************************************************************
* Function : EGSHDeSelectListItem()
* Description :
* Parameters :
* Return values :
* History :
* Note :
* BUGFIX: removes the line on deselection. Order of signal
* handler installation is critical: the logic in here depends
* on a guarantee that it is only called by itself on a pure
* deselection, or AFTER the select of a new process. This
* prevents a superfluous redraw from this routine.
******************************************************************/
void EGSHDeSelectListItem(GtkWidget* pmListItem, gpointer pmData)
{
process* pSelProc; /* Selected process */
eventGraph* pEGraph; /* The event graph */
/* Get the event graph */
if((pEGraph = (eventGraph*) pmData) == NULL)
return;
/* Get the selected process */
pSelProc = (process *) gtk_object_get_data(GTK_OBJECT(pmListItem),
gProcessItemData);
/* Deselect event */
if(pSelProc == pEGraph->SelectedProc)
{
/* Ensure that no process is selected in this graph */
pEGraph->SelectedProc = NULL;
/* Redraw the trace */
EGIDrawTrace(pEGraph, TRUE);
/* Make sure that the changes are seen on the draw area */
gtk_widget_queue_resize(pEGraph->DrawArea);
}
}
/******************************************************************
* Function : EGSHSelectListItem()
* Description :
* Parameters :
* Return values :
* History :
* Note :
* ROC, Install this signal handler BEFORE deselection.
******************************************************************/
void EGSHSelectListItem(GtkWidget* pmListItem, gpointer pmData)
{
eventGraph* pEGraph; /* The event graph */
/* Get the event graph */
if((pEGraph = (eventGraph*) pmData) == NULL)
return;
/* Get the selected process */
pEGraph->SelectedProc = (process *) gtk_object_get_data(GTK_OBJECT(pmListItem),
gProcessItemData);
/* Redraw the event graph */
EGIDrawTrace(pEGraph, TRUE);
/* Make sure that the changes are seen on the draw area */
gtk_widget_queue_resize(pEGraph->DrawArea);
}
/**********************************************************************************/
/******************************* Windowing functions ******************************/
/**********************************************************************************/
/******************************************************************
* Function :
* EGForceTraceRedraw()
* Description :
* Forcefully redraw the trace in the trace window.
* Parameters :
* pmEGraph, The event graph who's redraw is to be forced.
* Return values :
* NONE
* History :
* Note :
* K.Y., 28/03/2001, Initial typing.
******************************************************************/
void EGForceTraceRedraw(eventGraph* pmEGraph)
{
EGIDrawTrace(pmEGraph, TRUE);
}
/******************************************************************
* Function :
* EGMouseOnIcon()
* Description :
* Tests for the presence of the mouse pointer within an eventgraph
* icon
* Parameters :
* x, y: Coordinates of the mouse pointer
* coords: eventInfo of the icon to test for
* Return values :
* TRUE if within coordinates, FALSE otherwise
* History :
* Note :
******************************************************************/
gboolean EGMouseOnIcon(gint x, gint y, eventInfo* coords)
{
return ((x >= coords->x && x <= (coords->x + EGRAPH_ICONS_WIDTH))
&&(y <= coords->y && y >= (coords->y - EGRAPH_ICONS_HEIGHT)));
}
/******************************************************************
* Function : EGZoomIn()
* Description :
* Parameters :
* Return values :
* History :
* Note :
******************************************************************/
void EGZoomIn(eventGraph* pmEGraph)
{
/* Change the number of micro-seconds per pixel */
pmEGraph->USecPerPix = pmEGraph->USecPerPix / EGRAPH_ZOOM_IN_FACTOR;
/* Is the new number of usec/pix too small */
if(pmEGraph->USecPerPix < EGRAPH_USEC_PER_PIX_MIN)
pmEGraph->USecPerPix = EGRAPH_USEC_PER_PIX_MIN;
/* Set the new true size */
pmEGraph->HTrueSize = (gulong) (pmEGraph->Duration / (gdouble) pmEGraph->USecPerPix);
/* Reset the horizontal scrollbar */
EGIResetHAdjustment(pmEGraph, TRUE);
/* Redraw the trace */
EGIDrawTrace(pmEGraph, TRUE);
/* Update the draw area per se */
gtk_widget_queue_resize(pmEGraph->DrawArea);
}
/******************************************************************
* Function : EGZoomOut()
* Description :
* Parameters :
* Return values :
* History :
* Note :
******************************************************************/
void EGZoomOut(eventGraph* pmEGraph)
{
/* Change the number of micro-seconds per pixel */
pmEGraph->USecPerPix = pmEGraph->USecPerPix * EGRAPH_ZOOM_OUT_FACTOR;
/* Is the new number of usec/pix too small */
if(pmEGraph->USecPerPix > EGRAPH_USEC_PER_PIX_MAX)
pmEGraph->USecPerPix = EGRAPH_USEC_PER_PIX_MAX;
/* Set the new true size */
pmEGraph->HTrueSize = (gulong) (pmEGraph->Duration / (gdouble) pmEGraph->USecPerPix);
/* Reset the horizontal scrollbar */
EGIResetHAdjustment(pmEGraph, TRUE);
/* Redraw the trace */
EGIDrawTrace(pmEGraph, TRUE);
/* Update the draw area per se */
gtk_widget_queue_resize(pmEGraph->DrawArea);
}
/******************************************************************
* Function : EGZoomTimeFrame()
* Description :
* Parameters :
* Return values :
* History :
* Note :
******************************************************************/
void EGZoomTimeFrame(eventGraph* pmEGraph, gdouble StartTime, gdouble EndTime)
{
gdouble Duration; /* The new value for the trace duration */
gdouble TempSwap; /* Temporary value to swap variables */
/* Restrict new times to allowed values */
if(StartTime > EndTime)
{
TempSwap = EndTime;
EndTime = StartTime;
StartTime = TempSwap;
}
if(StartTime < pmEGraph->StartTime || StartTime > pmEGraph->StartTime + pmEGraph->Duration)
StartTime = pmEGraph->StartTime;
if(EndTime < pmEGraph->StartTime || EndTime > pmEGraph->StartTime + pmEGraph->Duration)
EndTime = pmEGraph->StartTime + pmEGraph->Duration;
/* Calculate the newly desired duration */
Duration = EndTime - StartTime;
/* Change the number of micro-seconds per pixel */
pmEGraph->USecPerPix = Duration / GTK_WIDGET(pmEGraph->DrawArea)->allocation.width;
/* Is the new number of usec/pix too big */
if(pmEGraph->USecPerPix > EGRAPH_USEC_PER_PIX_MAX)
pmEGraph->USecPerPix = EGRAPH_USEC_PER_PIX_MAX;
/* Is the new number of usec/pix too small */
if(pmEGraph->USecPerPix < EGRAPH_USEC_PER_PIX_MIN)
pmEGraph->USecPerPix = EGRAPH_USEC_PER_PIX_MIN;
/* Set the new true size */
pmEGraph->HTrueSize = (gulong) (pmEGraph->Duration / (gdouble) pmEGraph->USecPerPix);
/* Set the new scroll value */
pmEGraph->LastScrollVal =
( ( (StartTime - pmEGraph->StartTime) / pmEGraph->Duration) * pmEGraph->HTrueSize);
/* Reset the horizontal scrollbar */
EGIResetHAdjustment(pmEGraph, FALSE);
/* Redraw the trace */
EGIDrawTrace(pmEGraph, TRUE);
/* Update the draw area per se */
gtk_widget_queue_resize(pmEGraph->DrawArea);
}
/******************************************************************
* Function : EGOneClickZoom()
* Description :
* A more directly useable zoom function using an existing routine
* driven by a single click on the event graph drawing area.
* I want a "click-persistent" zoom: the time point I click should
* be at the same relative pixel position in the new zoomed window.
* Parameters :
* pmEGraph, Event graph where zooming occurs.
* pmXPosition, The horizontal position where click occured.
* pmZoomIn, If "true" then zoom in otherwise zoom out.
* Return values :
* NONE
* History :
* ROC, Initial typing
* Note :
* Existing variables referenced:
*
* pEButton->x relative x coord of button press in pixels
* pEGraph->HDrawSize horizontal width of drawing area in pixels
* pEGraph->DrawStartTime current viewport left edge in useconds
* pEGraph->Interval current viewport width in useconds
* pEGraph->PixPerUSec always 0
* pEGraph->USecPerPix changes but of dubious use
******************************************************************/
void EGOneClickZoom(eventGraph* pmEGraph, gdouble pmXPosition, gboolean pmZoomIn)
{
gdouble lClickRelPos; /* Relative position of click position */
gdouble lNewStartTime; /* New start drawing time */
gdouble lNewTimeInterval; /* New time interval */
/* Compute relative position of click */
lClickRelPos = pmXPosition / (float)pmEGraph->HDrawSize;
/* PixPerUSec is always zero; USecPerPix gets fractional but I'm
not sure where to stop as zooming in too far has some weird artifacts.
I can't find a good time to stop zooming out but it doesn't seem to
hurt anything to do one or two extra clicks... ROC */
/* Are we zooming in */
if(pmZoomIn == TRUE)
{
/* Is the new interval too short */
if(pmEGraph->Interval < 10.0)
return; /* arbitrary */
/* Compute the new interval and start time */
lNewTimeInterval = pmEGraph->Interval / (float)EGRAPH_ZOOM_IN_FACTOR;
lNewStartTime = pmEGraph->DrawStartTime + lClickRelPos * lNewTimeInterval;
}
else
{
/* Is the new interval too long */
if(pmEGraph->Interval + 10.0 > pmEGraph->Duration)
return;
/* Compute the new interval and start time */
lNewTimeInterval = pmEGraph->Interval * (float)EGRAPH_ZOOM_OUT_FACTOR;
lNewStartTime = pmEGraph->DrawStartTime - lClickRelPos * pmEGraph->Interval;
}
/* Zoom to the new time frame the new */
EGZoomTimeFrame(pmEGraph, lNewStartTime, lNewStartTime + lNewTimeInterval);
}
/******************************************************************
* Function : EGScrollToEvent()
* Description :
* Parameters :
* Return values :
* History :
* Note :
******************************************************************/
void EGScrollToEvent(eventGraph* pmEGraph, event* pmEvent)
{
gfloat NewValue; /* The new value for the adjustment */
gdouble EventTime; /* The time of the event */
struct timeval lTime; /* Event time */
/* Is the Event graph passed valid? */
if(pmEGraph == NULL)
{
g_print("ScrollToEvent called without graph passed! \n");
exit(1);
}
/* Get event time */
DBEventTime(pmEGraph->EventDB, pmEvent, &lTime);
/* Get the time to scroll to */
EventTime = DBGetTimeInDouble(lTime);
/* Place the adjustment at the desired position */
NewValue = ( ( (EventTime - pmEGraph->StartTime) / pmEGraph->Duration) *
(GTK_ADJUSTMENT(pmEGraph->HAdjustment)->upper - GTK_ADJUSTMENT(pmEGraph->HAdjustment)->lower)
) + GTK_ADJUSTMENT(pmEGraph->HAdjustment)->lower
- (GTK_ADJUSTMENT(pmEGraph->HAdjustment)->page_size / 2);
/* Confine the adjustment to reasonable values */
if(NewValue < GTK_ADJUSTMENT(pmEGraph->HAdjustment)->lower)
NewValue = GTK_ADJUSTMENT(pmEGraph->HAdjustment)->lower;
if(NewValue > GTK_ADJUSTMENT(pmEGraph->HAdjustment)->upper)
NewValue = GTK_ADJUSTMENT(pmEGraph->HAdjustment)->upper;
/* Set the new adjustment */
gtk_adjustment_set_value(GTK_ADJUSTMENT(pmEGraph->HAdjustment), NewValue);
}
/******************************************************************
* Function : EGScrollLeft()
* Description :
* Parameters :
* Return values :
* History :
* Note :
******************************************************************/
void EGScrollLeft(eventGraph* pmEGraph)
{
gfloat lNewValue; /* The new value for the adjustment */
/* Set the new value to scroll left */
lNewValue = GTK_ADJUSTMENT(pmEGraph->HAdjustment)->value;
lNewValue -= GTK_ADJUSTMENT(pmEGraph->HAdjustment)->step_increment;
/* Confine the adjustment to reasonable values */
if(lNewValue < GTK_ADJUSTMENT(pmEGraph->HAdjustment)->lower)
lNewValue = GTK_ADJUSTMENT(pmEGraph->HAdjustment)->lower;
/* Update the adjustment's value */
gtk_adjustment_set_value(GTK_ADJUSTMENT(pmEGraph->HAdjustment), lNewValue);
}
/******************************************************************
* Function : EGScrollRight()
* Description :
* Parameters :
* Return values :
* History :
* Note :
******************************************************************/
void EGScrollRight(eventGraph* pmEGraph)
{
gfloat lNewValue; /* The new value for the adjustment */
gfloat lLimit; /* Adjustment limit */
/* Set the new value to scroll right */
lNewValue = GTK_ADJUSTMENT(pmEGraph->HAdjustment)->value;
lNewValue += GTK_ADJUSTMENT(pmEGraph->HAdjustment)->step_increment;
/* Set the limit */
lLimit = GTK_ADJUSTMENT(pmEGraph->HAdjustment)->upper
- GTK_ADJUSTMENT(pmEGraph->HAdjustment)->page_increment;
/* Confine the adjustment to reasonable values */
if(lNewValue > lLimit)
lNewValue = lLimit;
/* Update the adjustment's value */
gtk_adjustment_set_value(GTK_ADJUSTMENT(pmEGraph->HAdjustment), lNewValue);
}
/******************************************************************
* Function : EGScrollUp()
* Description :
* Parameters :
* Return values :
* History :
* Note :
******************************************************************/
void EGScrollUp(eventGraph* pmEGraph)
{
gfloat lNewValue; /* The new value for the adjustment */
GtkAdjustment* pAdjustment; /* The vertical adjustment of the scrolled list */
/* Get the vertical adjustment of the scrolled process list */
pAdjustment = gtk_scrolled_window_get_vadjustment(GTK_SCROLLED_WINDOW(pmEGraph->ScrolledList));
/* Set the new value to scroll up */
lNewValue = pAdjustment->value;
lNewValue -= pAdjustment->step_increment;
/* Confine the adjustment to reasonable values */
if(lNewValue < pAdjustment->lower)
lNewValue = pAdjustment->lower;
/* Update the adjustment's value */
gtk_adjustment_set_value(pAdjustment, lNewValue);
/* Make sure the list is drawn correctly */
gtk_widget_queue_resize(pmEGraph->ScrolledList);
}
/******************************************************************
* Function : EGScrollDown()
* Description :
* Parameters :
* Return values :
* History :
* Note :
******************************************************************/
void EGScrollDown(eventGraph* pmEGraph)
{
gfloat lCompareValue;
gfloat lNewValue; /* The new value for the adjustment */
GtkAdjustment* pAdjustment; /* The vertical adjustment of the scrolled list */
/* Get the vertical adjustment of the scrolled process list */
pAdjustment = gtk_scrolled_window_get_vadjustment(GTK_SCROLLED_WINDOW(pmEGraph->ScrolledList));
/* Set the new value to scroll down */
lNewValue = pAdjustment->value;
lNewValue += pAdjustment->step_increment;
/* Set the maximum value the new value should have */
lCompareValue = pAdjustment->upper - 2 * pAdjustment->page_increment;
#if 0 /* DEBUG */
g_print("Kernel height : %d \n", EGIFindKernelHeight(pmEGraph));
g_print("Adjustment upper : %d \n", (guint)(pAdjustment->upper));
g_print("Scrolled list height : %d \n", (guint) GTK_WIDGET(pmEGraph->ScrolledList)->allocation.height);
g_print("Page increment : %d \n", (guint)(pAdjustment->page_increment));
#endif
/* Confine the adjustment to reasonable values */
if(lNewValue > lCompareValue)
lNewValue = lCompareValue;
#if 0 /* DEBUG */
g_print("New Value : %d \n", (guint) lNewValue);
#endif
/* Update the adjustment's value */
gtk_adjustment_set_value(pAdjustment, lNewValue);
/* Make sure the list is drawn correctly */
gtk_widget_queue_resize(pmEGraph->ScrolledList);
}
/******************************************************************
* Function : EGPageUp()
* Description :
* Parameters :
* Return values :
* History :
* Note :
******************************************************************/
void EGPageUp(eventGraph* pmEGraph)
{
gfloat lNewValue; /* The new value for the adjustment */
/* Set the new value to scroll page up */
lNewValue = GTK_ADJUSTMENT(pmEGraph->HAdjustment)->value;
lNewValue -= GTK_ADJUSTMENT(pmEGraph->HAdjustment)->page_increment;
/* Confine the adjustment to reasonable values */
if(lNewValue < GTK_ADJUSTMENT(pmEGraph->HAdjustment)->lower)
lNewValue = GTK_ADJUSTMENT(pmEGraph->HAdjustment)->lower;
/* Update the adjustment's value */
gtk_adjustment_set_value(GTK_ADJUSTMENT(pmEGraph->HAdjustment), lNewValue);
}
/******************************************************************
* Function : EGPageDown()
* Description :
* Parameters :
* Return values :
* History :
* Note :
******************************************************************/
void EGPageDown(eventGraph* pmEGraph)
{
gfloat lNewValue; /* The new value for the adjustment */
gfloat lLimit; /* Adjustment limit */
/* Set the new value to scroll page down */
lNewValue = GTK_ADJUSTMENT(pmEGraph->HAdjustment)->value;
lNewValue += GTK_ADJUSTMENT(pmEGraph->HAdjustment)->page_increment;
/* Set the limit */
lLimit = GTK_ADJUSTMENT(pmEGraph->HAdjustment)->upper
- GTK_ADJUSTMENT(pmEGraph->HAdjustment)->page_increment;
/* Confine the adjustment to reasonable values */
if(lNewValue > lLimit)
lNewValue = lLimit;
/* Update the adjustment's value */
gtk_adjustment_set_value(GTK_ADJUSTMENT(pmEGraph->HAdjustment), lNewValue);
}
/******************************************************************
* Function : EGSetHorizonView()
* Description :
* Parameters :
* Return values :
* History :
* Note :
******************************************************************/
void EGSetHorizonView(eventGraph* pmEventGraph)
{
/* Is the button active or not (I know this sounds like silly code, but it's "safer" this way) */
if(pmEventGraph->ShowHorizon == FALSE)
pmEventGraph->ShowHorizon = FALSE;
else
pmEventGraph->ShowHorizon = TRUE;
/* Redraw the event graph */
EGIDrawTrace(pmEventGraph, TRUE);
/* Make sure that the changes are seen on the draw area */
gtk_widget_queue_resize(pmEventGraph->DrawArea);
}
/******************************************************************
* Function : EGConnectSignals()
* Description :
* Parameters :
* Return values :
* History :
* Note :
******************************************************************/
void EGConnectSignals(eventGraph* pmEventGraph)
{
/* Connect to the window events */
gtk_signal_connect(GTK_OBJECT(pmEventGraph->DrawArea),
"expose_event",
GTK_SIGNAL_FUNC(EGSHExposeEvent),
pmEventGraph);
gtk_signal_connect(GTK_OBJECT(pmEventGraph->DrawArea),
"configure_event",
GTK_SIGNAL_FUNC(EGSHConfigureEvent),
pmEventGraph);
/* Enable draw area to cause various events to take place */
gtk_widget_set_events(pmEventGraph->DrawArea, GDK_POINTER_MOTION_MASK /* motion_notify_event */
| GDK_BUTTON_PRESS_MASK); /* button-press-event */
/* Connect horizontal ruler */
gtk_signal_connect_object(GTK_OBJECT(pmEventGraph->DrawArea),
"motion_notify_event",
GTK_SIGNAL_FUNC(GTK_WIDGET_CLASS(GTK_OBJECT(pmEventGraph->HRuler)->klass)->motion_notify_event),
GTK_OBJECT(pmEventGraph->HRuler));
/* Connect to the horizontal adjustment */
gtk_signal_connect(GTK_OBJECT(pmEventGraph->HAdjustment),
"value-changed",
GTK_SIGNAL_FUNC(EGSHHScrollChange),
pmEventGraph);
}
/******************************************************************
* Function : EGShowEventGraph()
* Description :
* Parameters :
* Return values :
* History :
* Note :
******************************************************************/
void EGShowEventGraph(eventGraph* pmEventGraph)
{
/* Is there anything to be shown */
if(!pmEventGraph)
{
g_print("pmEventGraph is null in EGShowEventGraph! \n");
exit(1);
};
/* Show it all */
gtk_widget_show(pmEventGraph->HPanned);
gtk_widget_show(pmEventGraph->ProcVBox);
gtk_widget_show(pmEventGraph->DummyBox);
gtk_widget_show(pmEventGraph->DrawVBox);
gtk_widget_show(pmEventGraph->ScrolledList);
gtk_widget_show(pmEventGraph->List);
gtk_widget_show(pmEventGraph->HRuler);
gtk_widget_show(pmEventGraph->ScrolledDraw);
gtk_widget_show(pmEventGraph->DrawArea);
gtk_widget_show(pmEventGraph->HScrollBar);
}
/******************************************************************
* Function : EGCreateEventGraph()
* Description :
* Parameters :
* Return values :
* History :
* Note :
******************************************************************/
eventGraph* EGCreateEventGraph(gpointer pmMainWindow)
{
eventGraph* pEGraph; /* The event graph */
mainWindow* pMainWindow; /* Main window to which event graph belongs */
GtkRequisition lRequisition; /* Used to obtain widget sizes*/
/* Allocate space for new even graph */
pEGraph = (eventGraph*) g_malloc(sizeof(eventGraph));
/* Get main window */
pMainWindow = (mainWindow*) pmMainWindow;
/* Set state */
pEGraph->Init = FALSE;
pEGraph->ColorsAllocated = FALSE;
pEGraph->ShowHorizon = FALSE;
/* Set data */
pEGraph->EventDB = NULL;
pEGraph->System = NULL;
pEGraph->MainWindow = pmMainWindow;
pEGraph->EventIcons = NULL;
pEGraph->SelectedProc = NULL;
/* Initialize icon cache */
pEGraph->KernelTimer.Pixmap = NULL;
pEGraph->SysCall.Pixmap = NULL;
pEGraph->Trap.Pixmap = NULL;
pEGraph->SchedChange.Pixmap = NULL;
pEGraph->BottomHalf.Pixmap = NULL;
pEGraph->IOStart.Pixmap = NULL;
pEGraph->IOEnd.Pixmap = NULL;
pEGraph->IRQ.Pixmap = NULL;
#if SUPP_RTAI
pEGraph->RTAIMount.Pixmap = NULL;
pEGraph->RTAIUmount.Pixmap = NULL;
pEGraph->RTAIIrq.Pixmap = NULL;
pEGraph->RTAITask.Pixmap = NULL;
pEGraph->RTAITimer.Pixmap = NULL;
pEGraph->RTAISem.Pixmap = NULL;
pEGraph->RTAIMsg.Pixmap = NULL;
pEGraph->RTAIRPC.Pixmap = NULL;
pEGraph->RTAIMbx.Pixmap = NULL;
pEGraph->RTAIFifo.Pixmap = NULL;
pEGraph->RTAIShm.Pixmap = NULL;
pEGraph->RTAIPosix.Pixmap = NULL;
pEGraph->RTAILXRT.Pixmap = NULL;
pEGraph->RTAILXRTI.Pixmap = NULL;
#endif
/* Allocate main elements */
pEGraph->HPanned = gtk_hpaned_new();
gtk_box_pack_start(GTK_BOX(pMainWindow->GTHBox), pEGraph->HPanned, TRUE, TRUE, 0);
/* Create boxes and put them in hpanned */
pEGraph->ProcVBox = gtk_vbox_new(FALSE, 0);
pEGraph->DummyBox = gtk_vbox_new(FALSE, 0);
pEGraph->DrawVBox = gtk_vbox_new(FALSE, 0);
gtk_paned_add1(GTK_PANED(pEGraph->HPanned), pEGraph->ProcVBox);
gtk_paned_add2(GTK_PANED(pEGraph->HPanned), pEGraph->DrawVBox);
/* Create scrolled list and place it in the hpanned widget */
pEGraph->ScrolledList = gtk_scrolled_window_new(NULL, NULL);
pEGraph->List = gtk_list_new();
gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(pEGraph->ScrolledList),
GTK_POLICY_ALWAYS,
GTK_POLICY_ALWAYS);
gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(pEGraph->ScrolledList),
pEGraph->List);
gtk_widget_set_usize(GTK_WIDGET(pEGraph->ScrolledList), 150, -1);
/* Create horizontal ruler */
pEGraph->HRuler = gtk_hruler_new();
/* Set dummy box size */
gtk_widget_size_request(GTK_WIDGET(pEGraph->HRuler), &lRequisition);
gtk_widget_set_usize(GTK_WIDGET(pEGraph->DummyBox), 0, lRequisition.height);
/* gtk_box_set_spacing(GTK_BOX(pEGraph->ProcVBox), lRequisition.height);*/ /* This can work too */
/* Put scrolled list in VBox window */
gtk_box_pack_start(GTK_BOX(pEGraph->ProcVBox), pEGraph->DummyBox, FALSE, TRUE, 0);
gtk_box_pack_start(GTK_BOX(pEGraph->ProcVBox), pEGraph->ScrolledList, TRUE, TRUE, 0);
/* Create drawing area elements and place them in the hpanned widget */
pEGraph->DrawArea = gtk_drawing_area_new();
pEGraph->ScrolledDraw = gtk_scrolled_window_new
(NULL,
gtk_scrolled_window_get_vadjustment(GTK_SCROLLED_WINDOW(pEGraph->ScrolledList)));
gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(pEGraph->ScrolledDraw),
GTK_POLICY_NEVER,
GTK_POLICY_NEVER);
gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(pEGraph->ScrolledDraw),
pEGraph->DrawArea);
/* Create horizontal scrollbar */
pEGraph->HAdjustment = gtk_adjustment_new(0,0,0,0,0,0);
pEGraph->HScrollBar = gtk_hscrollbar_new(GTK_ADJUSTMENT(pEGraph->HAdjustment));
/* Put ruler and draw area in hbox */
gtk_box_pack_start(GTK_BOX(pEGraph->DrawVBox), pEGraph->HRuler, FALSE, TRUE, 0);
gtk_box_pack_start(GTK_BOX(pEGraph->DrawVBox), pEGraph->ScrolledDraw, TRUE, TRUE, 0);
gtk_box_pack_start(GTK_BOX(pEGraph->DrawVBox), pEGraph->HScrollBar, FALSE, TRUE, 0);
/* Set pixmap */
pEGraph->PixMap = NULL;
/* Create the colors */
pEGraph->RedColor = EGICreateColor(0xffff, 0, 0); /* (red, green, blue) */
pEGraph->GreenColor = EGICreateColor(0, 0xffff, 0);
pEGraph->BlueColor = EGICreateColor(0, 0, 0xffff);
pEGraph->GreyColor = EGICreateColor(0x8000, 0x8000, 0x8000);
pEGraph->GreenColor = EGICreateColor(0, 0xffff, 0);
pEGraph->BlackColor = EGICreateColor(0, 0, 0);
pEGraph->WhiteColor = EGICreateColor(0xffff, 0xffff, 0xffff);
pEGraph->OrangeColor = EGICreateColor(0xffff, 0x8000, 0);
pEGraph->YellowColor = EGICreateColor(0xffff, 0xffff, 0);
pEGraph->TurquoiseColor = EGICreateColor(0, 0xffff, 0xffff);
pEGraph->PurpleColor = EGICreateColor(0xffff, 0, 0xffff);
/* Load font to draw text */
pEGraph->TextFont = gdk_font_load("-*-courier-medium-r-*-*-12-*-*-*-m-*-*-*");
/* Initialize draw start time */
pEGraph->DrawStartTime = 0;
/* Return the new widget to the caller */
return pEGraph;
}
/******************************************************************
* Function : EGDisplayEventTrace()
* Description :
* Parameters :
* Return values :
* History :
* Note :
* ROC, ???: This generates superfluous draw(s) at startup
******************************************************************/
void EGDisplayEventTrace(eventGraph* pmEventGraph, systemInfo* pmSystem, db* pmEventDB)
{
/* Miscallaneous variables */
gint lNbProc; /* Number of processes in the system */
gint lNbTask; /* Number of RTAI tasks in system */
gchar lLabelString[270]; /* Label string */
/* Process variables */
process* pProc; /* Generic process pointer */
process* pProcFirst; /* First process in list */
#if SUPP_RTAI
/* RTAI tasks variables */
RTAItask* pTask; /* Generic RTAI task pointer */
RTAItask* pTaskFirst; /* First task in list */
#endif /* SUPP_RTAI */
/* Time and size variables */
struct timeval lTime; /* The duration of the trace */
/* Gtk widgets */
GtkWidget* pListItem; /* Item to add to list */
GtkRequisition lRequisition; /* Used to obtain widget sizes*/
/* Set data */
pmEventGraph->EventDB = pmEventDB;
pmEventGraph->System = pmSystem;
/* Can we draw anything */
if((ltt_test_bit(TRACE_SYSCALL_ENTRY, &(pmEventGraph->EventDB->EventMask))
&<t_test_bit(TRACE_SYSCALL_EXIT, &(pmEventGraph->EventDB->EventMask))
&<t_test_bit(TRACE_TRAP_ENTRY, &(pmEventGraph->EventDB->EventMask))
&<t_test_bit(TRACE_TRAP_EXIT, &(pmEventGraph->EventDB->EventMask))
&<t_test_bit(TRACE_IRQ_ENTRY, &(pmEventGraph->EventDB->EventMask))
&<t_test_bit(TRACE_IRQ_EXIT, &(pmEventGraph->EventDB->EventMask))
&<t_test_bit(TRACE_SCHEDCHANGE, &(pmEventGraph->EventDB->EventMask))
&<t_test_bit(TRACE_SYSCALL_ENTRY, &(pmEventGraph->EventDB->DetailsMask))
&<t_test_bit(TRACE_SYSCALL_EXIT, &(pmEventGraph->EventDB->DetailsMask))
&<t_test_bit(TRACE_TRAP_ENTRY, &(pmEventGraph->EventDB->DetailsMask))
&<t_test_bit(TRACE_TRAP_EXIT, &(pmEventGraph->EventDB->DetailsMask))
&<t_test_bit(TRACE_IRQ_ENTRY, &(pmEventGraph->EventDB->DetailsMask))
&<t_test_bit(TRACE_IRQ_EXIT, &(pmEventGraph->EventDB->DetailsMask))
&<t_test_bit(TRACE_SCHEDCHANGE, &(pmEventGraph->EventDB->DetailsMask))) != 1)
{
WDStatusBarDisplay(pmEventGraph->MainWindow,
"Insufficient trace information to draw graph");
return;
}
/* Is there any scheduling change at all in this trace? */
if(pmEventGraph->EventDB->SchedEventsExist == FALSE)
{
WDStatusBarDisplay(pmEventGraph->MainWindow,
"Need at least one scheduling change to draw graph");
return;
}
/* Do we have multiple CPUs */
if(pmEventGraph->EventDB->LogCPUID == TRUE)
WDStatusBarDisplay(pmEventGraph->MainWindow,
"Displaying only the information for CPU #0");
#if 0
g_print("Start Time : (%ld, %ld) \n", pmEventDB->StartTime.tv_sec, pmEventDB->StartTime.tv_usec);
g_print("First Event : (%ld, %ld) \n", pmEventDB->Events->Time.tv_sec, pmEventDB->Events->Time.tv_usec);
g_print("Total Nb Events : %d \n", pmEventDB->Nb);
#endif
/* Find trace start time */
pmEventGraph->StartTime = DBGetTimeInDouble(pmEventDB->DrawStartTime);
/* Find trace duration */
DBTimeSub(lTime, pmEventDB->EndTime, pmEventDB->DrawStartTime);
/* Find out the duration in microseconds */
pmEventGraph->Duration = DBGetTimeInDouble(lTime);
/* Initialize drawable time interval */
pmEventGraph->Interval = 0;
pmEventGraph->NbIntervalEvents = 0;
/* Add a bogus item in order to properly draw topmost item */
pListItem = gtk_list_item_new_with_label("");
gtk_container_add(GTK_CONTAINER(pmEventGraph->List), pListItem);
gtk_widget_show(pListItem);
gtk_signal_connect (GTK_OBJECT(pListItem),
"select",
GTK_SIGNAL_FUNC(EGSHSelectListItem),
pmEventGraph);
/* Display the processes in the process list */
lNbProc = 1;
lNbTask = 0;
pProcFirst = NULL;
for(pProc = pmSystem->Processes; pProc != NULL; pProc = pProc->Next)
{
/* Keep count on the number of processes */
lNbProc++;
/* Create list item */
if(pProc->Command != NULL)
sprintf(lLabelString, "%s (%d)", pProc->Command, pProc->PID);
else
{
/* Is this the 0 process */
if(pProc->PID == 0)
{
pProcFirst = pProc;
continue;
}
else
sprintf(lLabelString, "Unnamed child (%d)", pProc->PID);
}
pListItem = gtk_list_item_new_with_label(lLabelString);
/* Put pointer to process in label */
gtk_object_set_data(GTK_OBJECT(pListItem), gProcessItemData, pProc);
/* Attach Signal handlers */
gtk_signal_connect (GTK_OBJECT(pListItem),
"select",
GTK_SIGNAL_FUNC(EGSHSelectListItem),
pmEventGraph);
gtk_signal_connect (GTK_OBJECT(pListItem),
"deselect",
GTK_SIGNAL_FUNC(EGSHDeSelectListItem),
pmEventGraph);
/* Show the label */
gtk_widget_show(pListItem);
/* Append item into list */
gtk_container_add(GTK_CONTAINER(pmEventGraph->List), pListItem);
/* Set item position in list */
pProc->ListPos = gtk_list_child_position(GTK_LIST(pmEventGraph->List), pListItem);
}
/* Put first process */
if(pProcFirst != NULL)
{
/* Create new label */
sprintf(lLabelString, "Kernel (%d)", pProcFirst->PID);
pListItem = gtk_list_item_new_with_label(lLabelString);
gtk_signal_connect (GTK_OBJECT(pListItem),
"select",
GTK_SIGNAL_FUNC(EGSHSelectListItem),
pmEventGraph);
/* Put pointer to process in label */
gtk_object_set_data(GTK_OBJECT(pListItem), gProcessItemData, pProcFirst);
/* Show the label */
gtk_widget_show(pListItem);
/* Append item into list */
gtk_container_add(GTK_CONTAINER(pmEventGraph->List), pListItem);
/* Set item position in list */
pProcFirst->ListPos = gtk_list_child_position(GTK_LIST(pmEventGraph->List), pListItem);
}
#if SUPP_RTAI
/* Does this trace contain RTAI information */
if(pmEventDB->SystemType == TRACE_SYS_TYPE_RTAI_LINUX)
{
/* Display the tasks in the tasks list */
pTaskFirst = NULL;
for(pTask = RTAI_SYSTEM(pmSystem->SystemSpec)->Tasks;
pTask != NULL;
pTask = pTask->Next)
{
/* Keep count on the number of processes and RTAI tasks */
lNbProc++;
lNbTask++;
/* Create list item */
if(pTask->TID != 0)
sprintf(lLabelString, "RT: %d", pTask->TID);
else
{
pTaskFirst = pTask;
continue;
}
pListItem = gtk_list_item_new_with_label(lLabelString);
/* Put pointer to task in label */
gtk_object_set_data(GTK_OBJECT(pListItem), gProcessItemData, pTask);
/* Attach Signal handler */
gtk_signal_connect (GTK_OBJECT(pListItem),
"select",
GTK_SIGNAL_FUNC(EGSHSelectListItem),
pmEventGraph);
/* Show the label */
gtk_widget_show(pListItem);
/* Append item into list */
gtk_container_add(GTK_CONTAINER(pmEventGraph->List), pListItem);
/* Set item position in list */
pTask->ListPos = gtk_list_child_position(GTK_LIST(pmEventGraph->List), pListItem);
}
/* Put first task */
if(pTaskFirst != NULL)
{
/* Create new label */
sprintf(lLabelString, "RTAI");
pListItem = gtk_list_item_new_with_label(lLabelString);
gtk_signal_connect (GTK_OBJECT(pListItem),
"select",
GTK_SIGNAL_FUNC(EGSHSelectListItem),
pmEventGraph);
/* Put pointer to task in label */
gtk_object_set_data(GTK_OBJECT(pListItem), gProcessItemData, pTaskFirst);
/* Show the label */
gtk_widget_show(pListItem);
/* Append item into list */
gtk_container_add(GTK_CONTAINER(pmEventGraph->List), pListItem);
/* Set item position in list */
pTaskFirst->ListPos = gtk_list_child_position(GTK_LIST(pmEventGraph->List), pListItem);
}
}
#endif /* SUPP_RTAI */
/* Set number of processes and tasks */
pmEventGraph->NbProc = lNbProc;
pmEventGraph->NbTask = lNbTask;
/* Get the height of a label */
gtk_widget_size_request(GTK_WIDGET(pListItem), &lRequisition);
/* Set the label height */
pmEventGraph->LabelHeight = lRequisition.height;
/* Set the number of microseconds per pixel and pixels for start */
pmEventGraph->USecPerPix = EGRAPH_USEC_PER_PIX;
pmEventGraph->PixPerUSec = 0;
pmEventGraph->PixStart = EGRAPH_PIX_START;
/* Set size of image as if all events where displayed in the same pixmap */
if(pmEventGraph->USecPerPix > 0)
pmEventGraph->HTrueSize = ((gint) pmEventGraph->Duration) / pmEventGraph->USecPerPix;
else
pmEventGraph->HTrueSize = ((gint) pmEventGraph->Duration) * (gint) (1 / pmEventGraph->USecPerPix);
pmEventGraph->VTrueSize = pmEventGraph->LabelHeight * pmEventGraph->NbProc;
/* Initialize draw sizes */
pmEventGraph->HDrawSize = 0;
pmEventGraph->VDrawSize = 0;
/* Set start draw time and event */
memset(&(pmEventGraph->DrawStartEvent), 0 , sizeof(pmEventGraph->DrawStartEvent));
memset(&(pmEventGraph->DrawEndEvent), 0 , sizeof(pmEventGraph->DrawEndEvent));
pmEventGraph->DrawStartTime = pmEventGraph->StartTime;
/* Initialize scrollbar position */
pmEventGraph->LastScrollVal = 0;
/* We have finished initializing the graph */
pmEventGraph->Init = TRUE;
}
/******************************************************************
* Function : EGClearEventGraph()
* Description :
* Parameters :
* Return values :
* History :
* Note :
* ROC, THIS IS NOT CALLED DURING NORMAL STARTUP!!!!!
******************************************************************/
void EGClearEventGraph(eventGraph* pmEGraph)
{
/* Reset widget state */
pmEGraph->Init = FALSE;
pmEGraph->SelectedProc = NULL;
/* Reset data */
pmEGraph->EventDB = NULL;
pmEGraph->System = 0;
/* Reset the draw variables */
pmEGraph->NbProc = 0;
pmEGraph->LabelHeight = 0;
pmEGraph->PixStart = 0;
pmEGraph->PixPerUSec = 0;
pmEGraph->USecPerPix = 0;
pmEGraph->HTrueSize = 0;
pmEGraph->VTrueSize = 0;
pmEGraph->HDrawSize = 0;
pmEGraph->VDrawSize = 0;
pmEGraph->StartTime = 0;
pmEGraph->Duration = 0;
pmEGraph->Interval = 0;
/* Reset scroll information */
memset(&(pmEGraph->DrawStartEvent), 0 , sizeof(pmEGraph->DrawStartEvent));
memset(&(pmEGraph->DrawEndEvent), 0 , sizeof(pmEGraph->DrawEndEvent));
pmEGraph->DrawStartTime = 0;
pmEGraph->LastScrollVal = 0;
/* Empty event icon coordinates list */
if(pmEGraph->EventIcons)
{
/* Free all allocated coordinate items */
g_slist_foreach(pmEGraph->EventIcons, (GFunc) g_free, NULL);
/* Free the GList list items */
g_slist_free(pmEGraph->EventIcons);
/* Reset list pointer */
pmEGraph->EventIcons = NULL;
}
/* Remove the items in the process list */
gtk_list_clear_items(GTK_LIST(pmEGraph->List), 0, -1);
/* Reset the draw area size */
gtk_widget_set_usize(pmEGraph->DrawArea,
0,
0);
/* Reset the ruler */
gtk_ruler_set_range(GTK_RULER(pmEGraph->HRuler), 0, 0, 0, 0);
/* Reset the horizontal scrollbar */
GTK_ADJUSTMENT(pmEGraph->HAdjustment)->lower = 0;
GTK_ADJUSTMENT(pmEGraph->HAdjustment)->upper = 0;
GTK_ADJUSTMENT(pmEGraph->HAdjustment)->value = 0 ;
GTK_ADJUSTMENT(pmEGraph->HAdjustment)->page_size = 0;
GTK_ADJUSTMENT(pmEGraph->HAdjustment)->step_increment = 0;
GTK_ADJUSTMENT(pmEGraph->HAdjustment)->page_increment = 0;
gtk_adjustment_changed(GTK_ADJUSTMENT(pmEGraph->HAdjustment));
/* Make sure changes to the draw area are done */
/* IF THIS ISN'T DONE, THE DRAWING SOMEWHAT SOMETIMES DOESN'T GET ERASED ??? */
gtk_widget_hide(pmEGraph->ScrolledDraw);
gtk_widget_show(pmEGraph->ScrolledDraw);
}
/******************************************************************
* Function : EGDestroyEventGraph()
* Description :
* Parameters :
* Return values :
* History :
* Note :
******************************************************************/
void EGDestroyEventGraph(eventGraph** pmEGraph)
{
/* Has the graph already been freed? */
if(!pmEGraph) return;
if(!*pmEGraph) return;
/* Clear the event graph */
EGClearEventGraph(*pmEGraph);
/* Was there a pixmap already */
if((*pmEGraph)->PixMap != NULL)
{
/* Free the already existing pixmap */
gdk_pixmap_unref((*pmEGraph)->PixMap);
(*pmEGraph)->PixMap = NULL;
}
/* Did we have cached icons? */
if((*pmEGraph)->KernelTimer.Pixmap != NULL)
{
/* Free the already existing icons */
gdk_pixmap_unref((*pmEGraph)->KernelTimer.Pixmap);
gdk_pixmap_unref((*pmEGraph)->SysCall.Pixmap);
gdk_pixmap_unref((*pmEGraph)->Trap.Pixmap);
gdk_pixmap_unref((*pmEGraph)->SchedChange.Pixmap);
gdk_pixmap_unref((*pmEGraph)->BottomHalf.Pixmap);
gdk_pixmap_unref((*pmEGraph)->IOStart.Pixmap);
gdk_pixmap_unref((*pmEGraph)->IOEnd.Pixmap);
gdk_pixmap_unref((*pmEGraph)->IRQ.Pixmap);
gdk_bitmap_unref((*pmEGraph)->KernelTimer.Mask);
gdk_bitmap_unref((*pmEGraph)->SysCall.Mask);
gdk_bitmap_unref((*pmEGraph)->Trap.Mask);
gdk_bitmap_unref((*pmEGraph)->SchedChange.Mask);
gdk_bitmap_unref((*pmEGraph)->BottomHalf.Mask);
gdk_bitmap_unref((*pmEGraph)->IOStart.Mask);
gdk_bitmap_unref((*pmEGraph)->IOEnd.Mask);
gdk_bitmap_unref((*pmEGraph)->IRQ.Mask);
(*pmEGraph)->KernelTimer.Pixmap = NULL;
(*pmEGraph)->SysCall.Pixmap = NULL;
(*pmEGraph)->Trap.Pixmap = NULL;
(*pmEGraph)->SchedChange.Pixmap = NULL;
(*pmEGraph)->BottomHalf.Pixmap = NULL;
(*pmEGraph)->IOStart.Pixmap = NULL;
(*pmEGraph)->IOEnd.Pixmap = NULL;
(*pmEGraph)->IRQ.Pixmap = NULL;
}
/* Free allocated GDK structures */
/* Fonts */
gdk_font_unref((*pmEGraph)->TextFont);
/* Colors */
g_free((*pmEGraph)->RedColor);
g_free((*pmEGraph)->BlueColor);
g_free((*pmEGraph)->GreyColor);
g_free((*pmEGraph)->GreenColor);
g_free((*pmEGraph)->BlackColor);
g_free((*pmEGraph)->WhiteColor);
g_free((*pmEGraph)->OrangeColor);
g_free((*pmEGraph)->YellowColor);
g_free((*pmEGraph)->TurquoiseColor);
g_free((*pmEGraph)->PurpleColor);
/* The GCs, if any were allocated */
if((*pmEGraph)->ColorsAllocated == TRUE)
{
gdk_gc_destroy((*pmEGraph)->BackgroundGC);
gdk_gc_destroy((*pmEGraph)->HorizonGC);
gdk_gc_destroy((*pmEGraph)->ProcessGC);
gdk_gc_destroy((*pmEGraph)->Process0GC);
gdk_gc_destroy((*pmEGraph)->KernelGC);
gdk_gc_destroy((*pmEGraph)->SelectedGC);
gdk_gc_destroy((*pmEGraph)->SysCallGC);
gdk_gc_destroy((*pmEGraph)->TrapGC);
gdk_gc_destroy((*pmEGraph)->InterruptGC);
gdk_gc_destroy((*pmEGraph)->TextGC);
}
/* destroy the structure */
g_free(*pmEGraph);
/* reset the structure pointer */
*pmEGraph = NULL;
}
|