├── .gitignore ├── Cargo.toml ├── LICENSE ├── README.md ├── examples └── dump.rs ├── src ├── event_reader.rs ├── header.rs ├── info_reader.rs ├── lib.rs └── tools.rs └── tests ├── dump.stdout ├── dump_test.rs └── perf.data /.gitignore: -------------------------------------------------------------------------------- 1 | target 2 | Cargo.lock 3 | -------------------------------------------------------------------------------- /Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "linux-perf-file-reader" 3 | version = "0.2.0" 4 | authors = ["Mikhail Modin "] 5 | description = "Library for parse perf.data file from Linux perf tool" 6 | homepage = "https://github.com/mikhail-m1/linux-perf-file-reader" 7 | repository = "https://github.com/mikhail-m1/linux-perf-file-reader" 8 | readme = "README.md" 9 | license = "GPL-3.0" 10 | edition = "2018" 11 | 12 | [dependencies] 13 | bitflags = "1.2" 14 | error-chain = "0.12.2" 15 | serde = "1.0" 16 | serde_derive = "1.0" 17 | log = "0.4" 18 | 19 | [dev-dependencies] 20 | env_logger ="0.7" 21 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU General Public License is a free, copyleft license for 11 | software and other kinds of works. 12 | 13 | The licenses for most software and other practical works are designed 14 | to take away your freedom to share and change the works. By contrast, 15 | the GNU General Public License is intended to guarantee your freedom to 16 | share and change all versions of a program--to make sure it remains free 17 | software for all its users. We, the Free Software Foundation, use the 18 | GNU General Public License for most of our software; it applies also to 19 | any other work released this way by its authors. You can apply it to 20 | your programs, too. 21 | 22 | When we speak of free software, we are referring to freedom, not 23 | price. Our General Public Licenses are designed to make sure that you 24 | have the freedom to distribute copies of free software (and charge for 25 | them if you wish), that you receive source code or can get it if you 26 | want it, that you can change the software or use pieces of it in new 27 | free programs, and that you know you can do these things. 28 | 29 | To protect your rights, we need to prevent others from denying you 30 | these rights or asking you to surrender the rights. Therefore, you have 31 | certain responsibilities if you distribute copies of the software, or if 32 | you modify it: responsibilities to respect the freedom of others. 33 | 34 | For example, if you distribute copies of such a program, whether 35 | gratis or for a fee, you must pass on to the recipients the same 36 | freedoms that you received. You must make sure that they, too, receive 37 | or can get the source code. And you must show them these terms so they 38 | know their rights. 39 | 40 | Developers that use the GNU GPL protect your rights with two steps: 41 | (1) assert copyright on the software, and (2) offer you this License 42 | giving you legal permission to copy, distribute and/or modify it. 43 | 44 | For the developers' and authors' protection, the GPL clearly explains 45 | that there is no warranty for this free software. For both users' and 46 | authors' sake, the GPL requires that modified versions be marked as 47 | changed, so that their problems will not be attributed erroneously to 48 | authors of previous versions. 49 | 50 | Some devices are designed to deny users access to install or run 51 | modified versions of the software inside them, although the manufacturer 52 | can do so. This is fundamentally incompatible with the aim of 53 | protecting users' freedom to change the software. The systematic 54 | pattern of such abuse occurs in the area of products for individuals to 55 | use, which is precisely where it is most unacceptable. Therefore, we 56 | have designed this version of the GPL to prohibit the practice for those 57 | products. If such problems arise substantially in other domains, we 58 | stand ready to extend this provision to those domains in future versions 59 | of the GPL, as needed to protect the freedom of users. 60 | 61 | Finally, every program is threatened constantly by software patents. 62 | States should not allow patents to restrict development and use of 63 | software on general-purpose computers, but in those that do, we wish to 64 | avoid the special danger that patents applied to a free program could 65 | make it effectively proprietary. To prevent this, the GPL assures that 66 | patents cannot be used to render the program non-free. 67 | 68 | The precise terms and conditions for copying, distribution and 69 | modification follow. 70 | 71 | TERMS AND CONDITIONS 72 | 73 | 0. Definitions. 74 | 75 | "This License" refers to version 3 of the GNU General Public License. 76 | 77 | "Copyright" also means copyright-like laws that apply to other kinds of 78 | works, such as semiconductor masks. 79 | 80 | "The Program" refers to any copyrightable work licensed under this 81 | License. Each licensee is addressed as "you". "Licensees" and 82 | "recipients" may be individuals or organizations. 83 | 84 | To "modify" a work means to copy from or adapt all or part of the work 85 | in a fashion requiring copyright permission, other than the making of an 86 | exact copy. The resulting work is called a "modified version" of the 87 | earlier work or a work "based on" the earlier work. 88 | 89 | A "covered work" means either the unmodified Program or a work based 90 | on the Program. 91 | 92 | To "propagate" a work means to do anything with it that, without 93 | permission, would make you directly or secondarily liable for 94 | infringement under applicable copyright law, except executing it on a 95 | computer or modifying a private copy. Propagation includes copying, 96 | distribution (with or without modification), making available to the 97 | public, and in some countries other activities as well. 98 | 99 | To "convey" a work means any kind of propagation that enables other 100 | parties to make or receive copies. Mere interaction with a user through 101 | a computer network, with no transfer of a copy, is not conveying. 102 | 103 | An interactive user interface displays "Appropriate Legal Notices" 104 | to the extent that it includes a convenient and prominently visible 105 | feature that (1) displays an appropriate copyright notice, and (2) 106 | tells the user that there is no warranty for the work (except to the 107 | extent that warranties are provided), that licensees may convey the 108 | work under this License, and how to view a copy of this License. If 109 | the interface presents a list of user commands or options, such as a 110 | menu, a prominent item in the list meets this criterion. 111 | 112 | 1. Source Code. 113 | 114 | The "source code" for a work means the preferred form of the work 115 | for making modifications to it. "Object code" means any non-source 116 | form of a work. 117 | 118 | A "Standard Interface" means an interface that either is an official 119 | standard defined by a recognized standards body, or, in the case of 120 | interfaces specified for a particular programming language, one that 121 | is widely used among developers working in that language. 122 | 123 | The "System Libraries" of an executable work include anything, other 124 | than the work as a whole, that (a) is included in the normal form of 125 | packaging a Major Component, but which is not part of that Major 126 | Component, and (b) serves only to enable use of the work with that 127 | Major Component, or to implement a Standard Interface for which an 128 | implementation is available to the public in source code form. A 129 | "Major Component", in this context, means a major essential component 130 | (kernel, window system, and so on) of the specific operating system 131 | (if any) on which the executable work runs, or a compiler used to 132 | produce the work, or an object code interpreter used to run it. 133 | 134 | The "Corresponding Source" for a work in object code form means all 135 | the source code needed to generate, install, and (for an executable 136 | work) run the object code and to modify the work, including scripts to 137 | control those activities. However, it does not include the work's 138 | System Libraries, or general-purpose tools or generally available free 139 | programs which are used unmodified in performing those activities but 140 | which are not part of the work. For example, Corresponding Source 141 | includes interface definition files associated with source files for 142 | the work, and the source code for shared libraries and dynamically 143 | linked subprograms that the work is specifically designed to require, 144 | such as by intimate data communication or control flow between those 145 | subprograms and other parts of the work. 146 | 147 | The Corresponding Source need not include anything that users 148 | can regenerate automatically from other parts of the Corresponding 149 | Source. 150 | 151 | The Corresponding Source for a work in source code form is that 152 | same work. 153 | 154 | 2. Basic Permissions. 155 | 156 | All rights granted under this License are granted for the term of 157 | copyright on the Program, and are irrevocable provided the stated 158 | conditions are met. This License explicitly affirms your unlimited 159 | permission to run the unmodified Program. The output from running a 160 | covered work is covered by this License only if the output, given its 161 | content, constitutes a covered work. This License acknowledges your 162 | rights of fair use or other equivalent, as provided by copyright law. 163 | 164 | You may make, run and propagate covered works that you do not 165 | convey, without conditions so long as your license otherwise remains 166 | in force. You may convey covered works to others for the sole purpose 167 | of having them make modifications exclusively for you, or provide you 168 | with facilities for running those works, provided that you comply with 169 | the terms of this License in conveying all material for which you do 170 | not control copyright. Those thus making or running the covered works 171 | for you must do so exclusively on your behalf, under your direction 172 | and control, on terms that prohibit them from making any copies of 173 | your copyrighted material outside their relationship with you. 174 | 175 | Conveying under any other circumstances is permitted solely under 176 | the conditions stated below. Sublicensing is not allowed; section 10 177 | makes it unnecessary. 178 | 179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 180 | 181 | No covered work shall be deemed part of an effective technological 182 | measure under any applicable law fulfilling obligations under article 183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 184 | similar laws prohibiting or restricting circumvention of such 185 | measures. 186 | 187 | When you convey a covered work, you waive any legal power to forbid 188 | circumvention of technological measures to the extent such circumvention 189 | is effected by exercising rights under this License with respect to 190 | the covered work, and you disclaim any intention to limit operation or 191 | modification of the work as a means of enforcing, against the work's 192 | users, your or third parties' legal rights to forbid circumvention of 193 | technological measures. 194 | 195 | 4. Conveying Verbatim Copies. 196 | 197 | You may convey verbatim copies of the Program's source code as you 198 | receive it, in any medium, provided that you conspicuously and 199 | appropriately publish on each copy an appropriate copyright notice; 200 | keep intact all notices stating that this License and any 201 | non-permissive terms added in accord with section 7 apply to the code; 202 | keep intact all notices of the absence of any warranty; and give all 203 | recipients a copy of this License along with the Program. 204 | 205 | You may charge any price or no price for each copy that you convey, 206 | and you may offer support or warranty protection for a fee. 207 | 208 | 5. Conveying Modified Source Versions. 209 | 210 | You may convey a work based on the Program, or the modifications to 211 | produce it from the Program, in the form of source code under the 212 | terms of section 4, provided that you also meet all of these conditions: 213 | 214 | a) The work must carry prominent notices stating that you modified 215 | it, and giving a relevant date. 216 | 217 | b) The work must carry prominent notices stating that it is 218 | released under this License and any conditions added under section 219 | 7. This requirement modifies the requirement in section 4 to 220 | "keep intact all notices". 221 | 222 | c) You must license the entire work, as a whole, under this 223 | License to anyone who comes into possession of a copy. This 224 | License will therefore apply, along with any applicable section 7 225 | additional terms, to the whole of the work, and all its parts, 226 | regardless of how they are packaged. This License gives no 227 | permission to license the work in any other way, but it does not 228 | invalidate such permission if you have separately received it. 229 | 230 | d) If the work has interactive user interfaces, each must display 231 | Appropriate Legal Notices; however, if the Program has interactive 232 | interfaces that do not display Appropriate Legal Notices, your 233 | work need not make them do so. 234 | 235 | A compilation of a covered work with other separate and independent 236 | works, which are not by their nature extensions of the covered work, 237 | and which are not combined with it such as to form a larger program, 238 | in or on a volume of a storage or distribution medium, is called an 239 | "aggregate" if the compilation and its resulting copyright are not 240 | used to limit the access or legal rights of the compilation's users 241 | beyond what the individual works permit. Inclusion of a covered work 242 | in an aggregate does not cause this License to apply to the other 243 | parts of the aggregate. 244 | 245 | 6. Conveying Non-Source Forms. 246 | 247 | You may convey a covered work in object code form under the terms 248 | of sections 4 and 5, provided that you also convey the 249 | machine-readable Corresponding Source under the terms of this License, 250 | in one of these ways: 251 | 252 | a) Convey the object code in, or embodied in, a physical product 253 | (including a physical distribution medium), accompanied by the 254 | Corresponding Source fixed on a durable physical medium 255 | customarily used for software interchange. 256 | 257 | b) Convey the object code in, or embodied in, a physical product 258 | (including a physical distribution medium), accompanied by a 259 | written offer, valid for at least three years and valid for as 260 | long as you offer spare parts or customer support for that product 261 | model, to give anyone who possesses the object code either (1) a 262 | copy of the Corresponding Source for all the software in the 263 | product that is covered by this License, on a durable physical 264 | medium customarily used for software interchange, for a price no 265 | more than your reasonable cost of physically performing this 266 | conveying of source, or (2) access to copy the 267 | Corresponding Source from a network server at no charge. 268 | 269 | c) Convey individual copies of the object code with a copy of the 270 | written offer to provide the Corresponding Source. This 271 | alternative is allowed only occasionally and noncommercially, and 272 | only if you received the object code with such an offer, in accord 273 | with subsection 6b. 274 | 275 | d) Convey the object code by offering access from a designated 276 | place (gratis or for a charge), and offer equivalent access to the 277 | Corresponding Source in the same way through the same place at no 278 | further charge. You need not require recipients to copy the 279 | Corresponding Source along with the object code. If the place to 280 | copy the object code is a network server, the Corresponding Source 281 | may be on a different server (operated by you or a third party) 282 | that supports equivalent copying facilities, provided you maintain 283 | clear directions next to the object code saying where to find the 284 | Corresponding Source. Regardless of what server hosts the 285 | Corresponding Source, you remain obligated to ensure that it is 286 | available for as long as needed to satisfy these requirements. 287 | 288 | e) Convey the object code using peer-to-peer transmission, provided 289 | you inform other peers where the object code and Corresponding 290 | Source of the work are being offered to the general public at no 291 | charge under subsection 6d. 292 | 293 | A separable portion of the object code, whose source code is excluded 294 | from the Corresponding Source as a System Library, need not be 295 | included in conveying the object code work. 296 | 297 | A "User Product" is either (1) a "consumer product", which means any 298 | tangible personal property which is normally used for personal, family, 299 | or household purposes, or (2) anything designed or sold for incorporation 300 | into a dwelling. In determining whether a product is a consumer product, 301 | doubtful cases shall be resolved in favor of coverage. For a particular 302 | product received by a particular user, "normally used" refers to a 303 | typical or common use of that class of product, regardless of the status 304 | of the particular user or of the way in which the particular user 305 | actually uses, or expects or is expected to use, the product. A product 306 | is a consumer product regardless of whether the product has substantial 307 | commercial, industrial or non-consumer uses, unless such uses represent 308 | the only significant mode of use of the product. 309 | 310 | "Installation Information" for a User Product means any methods, 311 | procedures, authorization keys, or other information required to install 312 | and execute modified versions of a covered work in that User Product from 313 | a modified version of its Corresponding Source. The information must 314 | suffice to ensure that the continued functioning of the modified object 315 | code is in no case prevented or interfered with solely because 316 | modification has been made. 317 | 318 | If you convey an object code work under this section in, or with, or 319 | specifically for use in, a User Product, and the conveying occurs as 320 | part of a transaction in which the right of possession and use of the 321 | User Product is transferred to the recipient in perpetuity or for a 322 | fixed term (regardless of how the transaction is characterized), the 323 | Corresponding Source conveyed under this section must be accompanied 324 | by the Installation Information. But this requirement does not apply 325 | if neither you nor any third party retains the ability to install 326 | modified object code on the User Product (for example, the work has 327 | been installed in ROM). 328 | 329 | The requirement to provide Installation Information does not include a 330 | requirement to continue to provide support service, warranty, or updates 331 | for a work that has been modified or installed by the recipient, or for 332 | the User Product in which it has been modified or installed. Access to a 333 | network may be denied when the modification itself materially and 334 | adversely affects the operation of the network or violates the rules and 335 | protocols for communication across the network. 336 | 337 | Corresponding Source conveyed, and Installation Information provided, 338 | in accord with this section must be in a format that is publicly 339 | documented (and with an implementation available to the public in 340 | source code form), and must require no special password or key for 341 | unpacking, reading or copying. 342 | 343 | 7. Additional Terms. 344 | 345 | "Additional permissions" are terms that supplement the terms of this 346 | License by making exceptions from one or more of its conditions. 347 | Additional permissions that are applicable to the entire Program shall 348 | be treated as though they were included in this License, to the extent 349 | that they are valid under applicable law. If additional permissions 350 | apply only to part of the Program, that part may be used separately 351 | under those permissions, but the entire Program remains governed by 352 | this License without regard to the additional permissions. 353 | 354 | When you convey a copy of a covered work, you may at your option 355 | remove any additional permissions from that copy, or from any part of 356 | it. (Additional permissions may be written to require their own 357 | removal in certain cases when you modify the work.) You may place 358 | additional permissions on material, added by you to a covered work, 359 | for which you have or can give appropriate copyright permission. 360 | 361 | Notwithstanding any other provision of this License, for material you 362 | add to a covered work, you may (if authorized by the copyright holders of 363 | that material) supplement the terms of this License with terms: 364 | 365 | a) Disclaiming warranty or limiting liability differently from the 366 | terms of sections 15 and 16 of this License; or 367 | 368 | b) Requiring preservation of specified reasonable legal notices or 369 | author attributions in that material or in the Appropriate Legal 370 | Notices displayed by works containing it; or 371 | 372 | c) Prohibiting misrepresentation of the origin of that material, or 373 | requiring that modified versions of such material be marked in 374 | reasonable ways as different from the original version; or 375 | 376 | d) Limiting the use for publicity purposes of names of licensors or 377 | authors of the material; or 378 | 379 | e) Declining to grant rights under trademark law for use of some 380 | trade names, trademarks, or service marks; or 381 | 382 | f) Requiring indemnification of licensors and authors of that 383 | material by anyone who conveys the material (or modified versions of 384 | it) with contractual assumptions of liability to the recipient, for 385 | any liability that these contractual assumptions directly impose on 386 | those licensors and authors. 387 | 388 | All other non-permissive additional terms are considered "further 389 | restrictions" within the meaning of section 10. If the Program as you 390 | received it, or any part of it, contains a notice stating that it is 391 | governed by this License along with a term that is a further 392 | restriction, you may remove that term. If a license document contains 393 | a further restriction but permits relicensing or conveying under this 394 | License, you may add to a covered work material governed by the terms 395 | of that license document, provided that the further restriction does 396 | not survive such relicensing or conveying. 397 | 398 | If you add terms to a covered work in accord with this section, you 399 | must place, in the relevant source files, a statement of the 400 | additional terms that apply to those files, or a notice indicating 401 | where to find the applicable terms. 402 | 403 | Additional terms, permissive or non-permissive, may be stated in the 404 | form of a separately written license, or stated as exceptions; 405 | the above requirements apply either way. 406 | 407 | 8. Termination. 408 | 409 | You may not propagate or modify a covered work except as expressly 410 | provided under this License. Any attempt otherwise to propagate or 411 | modify it is void, and will automatically terminate your rights under 412 | this License (including any patent licenses granted under the third 413 | paragraph of section 11). 414 | 415 | However, if you cease all violation of this License, then your 416 | license from a particular copyright holder is reinstated (a) 417 | provisionally, unless and until the copyright holder explicitly and 418 | finally terminates your license, and (b) permanently, if the copyright 419 | holder fails to notify you of the violation by some reasonable means 420 | prior to 60 days after the cessation. 421 | 422 | Moreover, your license from a particular copyright holder is 423 | reinstated permanently if the copyright holder notifies you of the 424 | violation by some reasonable means, this is the first time you have 425 | received notice of violation of this License (for any work) from that 426 | copyright holder, and you cure the violation prior to 30 days after 427 | your receipt of the notice. 428 | 429 | Termination of your rights under this section does not terminate the 430 | licenses of parties who have received copies or rights from you under 431 | this License. If your rights have been terminated and not permanently 432 | reinstated, you do not qualify to receive new licenses for the same 433 | material under section 10. 434 | 435 | 9. Acceptance Not Required for Having Copies. 436 | 437 | You are not required to accept this License in order to receive or 438 | run a copy of the Program. Ancillary propagation of a covered work 439 | occurring solely as a consequence of using peer-to-peer transmission 440 | to receive a copy likewise does not require acceptance. However, 441 | nothing other than this License grants you permission to propagate or 442 | modify any covered work. These actions infringe copyright if you do 443 | not accept this License. Therefore, by modifying or propagating a 444 | covered work, you indicate your acceptance of this License to do so. 445 | 446 | 10. Automatic Licensing of Downstream Recipients. 447 | 448 | Each time you convey a covered work, the recipient automatically 449 | receives a license from the original licensors, to run, modify and 450 | propagate that work, subject to this License. You are not responsible 451 | for enforcing compliance by third parties with this License. 452 | 453 | An "entity transaction" is a transaction transferring control of an 454 | organization, or substantially all assets of one, or subdividing an 455 | organization, or merging organizations. If propagation of a covered 456 | work results from an entity transaction, each party to that 457 | transaction who receives a copy of the work also receives whatever 458 | licenses to the work the party's predecessor in interest had or could 459 | give under the previous paragraph, plus a right to possession of the 460 | Corresponding Source of the work from the predecessor in interest, if 461 | the predecessor has it or can get it with reasonable efforts. 462 | 463 | You may not impose any further restrictions on the exercise of the 464 | rights granted or affirmed under this License. For example, you may 465 | not impose a license fee, royalty, or other charge for exercise of 466 | rights granted under this License, and you may not initiate litigation 467 | (including a cross-claim or counterclaim in a lawsuit) alleging that 468 | any patent claim is infringed by making, using, selling, offering for 469 | sale, or importing the Program or any portion of it. 470 | 471 | 11. Patents. 472 | 473 | A "contributor" is a copyright holder who authorizes use under this 474 | License of the Program or a work on which the Program is based. The 475 | work thus licensed is called the contributor's "contributor version". 476 | 477 | A contributor's "essential patent claims" are all patent claims 478 | owned or controlled by the contributor, whether already acquired or 479 | hereafter acquired, that would be infringed by some manner, permitted 480 | by this License, of making, using, or selling its contributor version, 481 | but do not include claims that would be infringed only as a 482 | consequence of further modification of the contributor version. For 483 | purposes of this definition, "control" includes the right to grant 484 | patent sublicenses in a manner consistent with the requirements of 485 | this License. 486 | 487 | Each contributor grants you a non-exclusive, worldwide, royalty-free 488 | patent license under the contributor's essential patent claims, to 489 | make, use, sell, offer for sale, import and otherwise run, modify and 490 | propagate the contents of its contributor version. 491 | 492 | In the following three paragraphs, a "patent license" is any express 493 | agreement or commitment, however denominated, not to enforce a patent 494 | (such as an express permission to practice a patent or covenant not to 495 | sue for patent infringement). To "grant" such a patent license to a 496 | party means to make such an agreement or commitment not to enforce a 497 | patent against the party. 498 | 499 | If you convey a covered work, knowingly relying on a patent license, 500 | and the Corresponding Source of the work is not available for anyone 501 | to copy, free of charge and under the terms of this License, through a 502 | publicly available network server or other readily accessible means, 503 | then you must either (1) cause the Corresponding Source to be so 504 | available, or (2) arrange to deprive yourself of the benefit of the 505 | patent license for this particular work, or (3) arrange, in a manner 506 | consistent with the requirements of this License, to extend the patent 507 | license to downstream recipients. "Knowingly relying" means you have 508 | actual knowledge that, but for the patent license, your conveying the 509 | covered work in a country, or your recipient's use of the covered work 510 | in a country, would infringe one or more identifiable patents in that 511 | country that you have reason to believe are valid. 512 | 513 | If, pursuant to or in connection with a single transaction or 514 | arrangement, you convey, or propagate by procuring conveyance of, a 515 | covered work, and grant a patent license to some of the parties 516 | receiving the covered work authorizing them to use, propagate, modify 517 | or convey a specific copy of the covered work, then the patent license 518 | you grant is automatically extended to all recipients of the covered 519 | work and works based on it. 520 | 521 | A patent license is "discriminatory" if it does not include within 522 | the scope of its coverage, prohibits the exercise of, or is 523 | conditioned on the non-exercise of one or more of the rights that are 524 | specifically granted under this License. You may not convey a covered 525 | work if you are a party to an arrangement with a third party that is 526 | in the business of distributing software, under which you make payment 527 | to the third party based on the extent of your activity of conveying 528 | the work, and under which the third party grants, to any of the 529 | parties who would receive the covered work from you, a discriminatory 530 | patent license (a) in connection with copies of the covered work 531 | conveyed by you (or copies made from those copies), or (b) primarily 532 | for and in connection with specific products or compilations that 533 | contain the covered work, unless you entered into that arrangement, 534 | or that patent license was granted, prior to 28 March 2007. 535 | 536 | Nothing in this License shall be construed as excluding or limiting 537 | any implied license or other defenses to infringement that may 538 | otherwise be available to you under applicable patent law. 539 | 540 | 12. No Surrender of Others' Freedom. 541 | 542 | If conditions are imposed on you (whether by court order, agreement or 543 | otherwise) that contradict the conditions of this License, they do not 544 | excuse you from the conditions of this License. If you cannot convey a 545 | covered work so as to satisfy simultaneously your obligations under this 546 | License and any other pertinent obligations, then as a consequence you may 547 | not convey it at all. For example, if you agree to terms that obligate you 548 | to collect a royalty for further conveying from those to whom you convey 549 | the Program, the only way you could satisfy both those terms and this 550 | License would be to refrain entirely from conveying the Program. 551 | 552 | 13. Use with the GNU Affero General Public License. 553 | 554 | Notwithstanding any other provision of this License, you have 555 | permission to link or combine any covered work with a work licensed 556 | under version 3 of the GNU Affero General Public License into a single 557 | combined work, and to convey the resulting work. The terms of this 558 | License will continue to apply to the part which is the covered work, 559 | but the special requirements of the GNU Affero General Public License, 560 | section 13, concerning interaction through a network will apply to the 561 | combination as such. 562 | 563 | 14. Revised Versions of this License. 564 | 565 | The Free Software Foundation may publish revised and/or new versions of 566 | the GNU General Public License from time to time. Such new versions will 567 | be similar in spirit to the present version, but may differ in detail to 568 | address new problems or concerns. 569 | 570 | Each version is given a distinguishing version number. If the 571 | Program specifies that a certain numbered version of the GNU General 572 | Public License "or any later version" applies to it, you have the 573 | option of following the terms and conditions either of that numbered 574 | version or of any later version published by the Free Software 575 | Foundation. If the Program does not specify a version number of the 576 | GNU General Public License, you may choose any version ever published 577 | by the Free Software Foundation. 578 | 579 | If the Program specifies that a proxy can decide which future 580 | versions of the GNU General Public License can be used, that proxy's 581 | public statement of acceptance of a version permanently authorizes you 582 | to choose that version for the Program. 583 | 584 | Later license versions may give you additional or different 585 | permissions. However, no additional obligations are imposed on any 586 | author or copyright holder as a result of your choosing to follow a 587 | later version. 588 | 589 | 15. Disclaimer of Warranty. 590 | 591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 599 | 600 | 16. Limitation of Liability. 601 | 602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 610 | SUCH DAMAGES. 611 | 612 | 17. Interpretation of Sections 15 and 16. 613 | 614 | If the disclaimer of warranty and limitation of liability provided 615 | above cannot be given local legal effect according to their terms, 616 | reviewing courts shall apply local law that most closely approximates 617 | an absolute waiver of all civil liability in connection with the 618 | Program, unless a warranty or assumption of liability accompanies a 619 | copy of the Program in return for a fee. 620 | 621 | END OF TERMS AND CONDITIONS 622 | 623 | How to Apply These Terms to Your New Programs 624 | 625 | If you develop a new program, and you want it to be of the greatest 626 | possible use to the public, the best way to achieve this is to make it 627 | free software which everyone can redistribute and change under these terms. 628 | 629 | To do so, attach the following notices to the program. It is safest 630 | to attach them to the start of each source file to most effectively 631 | state the exclusion of warranty; and each file should have at least 632 | the "copyright" line and a pointer to where the full notice is found. 633 | 634 | {one line to give the program's name and a brief idea of what it does.} 635 | Copyright (C) {year} {name of author} 636 | 637 | This program is free software: you can redistribute it and/or modify 638 | it under the terms of the GNU General Public License as published by 639 | the Free Software Foundation, either version 3 of the License, or 640 | (at your option) any later version. 641 | 642 | This program is distributed in the hope that it will be useful, 643 | but WITHOUT ANY WARRANTY; without even the implied warranty of 644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 645 | GNU General Public License for more details. 646 | 647 | You should have received a copy of the GNU General Public License 648 | along with this program. If not, see . 649 | 650 | Also add information on how to contact you by electronic and paper mail. 651 | 652 | If the program does terminal interaction, make it output a short 653 | notice like this when it starts in an interactive mode: 654 | 655 | {project} Copyright (C) {year} {fullname} 656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 657 | This is free software, and you are welcome to redistribute it 658 | under certain conditions; type `show c' for details. 659 | 660 | The hypothetical commands `show w' and `show c' should show the appropriate 661 | parts of the General Public License. Of course, your program's commands 662 | might be different; for a GUI interface, you would use an "about box". 663 | 664 | You should also get your employer (if you work as a programmer) or school, 665 | if any, to sign a "copyright disclaimer" for the program, if necessary. 666 | For more information on this, and how to apply and follow the GNU GPL, see 667 | . 668 | 669 | The GNU General Public License does not permit incorporating your program 670 | into proprietary programs. If your program is a subroutine library, you 671 | may consider it more useful to permit linking proprietary applications with 672 | the library. If this is what you want to do, use the GNU Lesser General 673 | Public License instead of this License. But first, please read 674 | . 675 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Rust library for parsing Linux perf tool output (perf.data) 2 | Currently just support of main events are implemented. It was part of other project which hasn't been finished. If you are interested in this library let me know. 3 | 4 | Documentation: https://docs.rs/linux-perf-file-reader/latest/linux_perf_file_reader/ 5 | 6 | Dump of a perf.data from `sleep`: https://github.com/mikhail-m1/linux-perf-file-reader/blob/master/tests/dump.stdout 7 | 8 | ## To Do 9 | * Support more events. 10 | * Check performance on big files. 11 | 12 | ## Contribution 13 | Any feedback is wellcome. 14 | -------------------------------------------------------------------------------- /examples/dump.rs: -------------------------------------------------------------------------------- 1 | #[macro_use] 2 | extern crate log; 3 | extern crate env_logger; 4 | extern crate linux_perf_file_reader; 5 | #[allow(unused_imports)] 6 | 7 | macro_rules! print_if_some_child { 8 | ($format: expr, $parent: expr, $($field: tt),*) => { 9 | $(if $parent.$field.is_some() { 10 | print!($format, stringify!($field), $parent.$field.as_ref().unwrap()); 11 | })* 12 | }; 13 | } 14 | 15 | macro_rules! print_if_some { 16 | ($format: expr, $($field: tt),*) => { 17 | $(if $field.is_some() { 18 | print!($format, stringify!($field), $field.as_ref().unwrap()); 19 | })* 20 | }; 21 | } 22 | 23 | fn main() { 24 | env_logger::init(); 25 | use linux_perf_file_reader::Event; 26 | let args: Vec = std::env::args().collect(); 27 | match linux_perf_file_reader::read_perf_file( 28 | args.get(1) 29 | .expect("use with perf.data file in command line"), 30 | ) { 31 | Err(e) => { 32 | error!("Error: {}", e); 33 | for e in e.iter().skip(1) { 34 | error!("caused by: {}", e); 35 | } 36 | std::process::exit(-1); 37 | } 38 | Ok(ref perf) => { 39 | println!("Info:"); 40 | print_if_some_child!( 41 | " {}: {}\n", 42 | perf.info, 43 | hostname, 44 | os_release, 45 | tools_version, 46 | arch, 47 | cpu_description, 48 | cpu_id, 49 | total_memory 50 | ); 51 | print_if_some_child!( 52 | " {}: {:?}\n", 53 | perf.info, 54 | command_line, 55 | cpu_topology, 56 | cpu_count 57 | ); 58 | if let Some(ref event_description) = perf.info.event_descriptions { 59 | for d in event_description { 60 | println!(" event_attribute {}{:?}: {:?}", d.name, d.ids, d.attributes); 61 | } 62 | } 63 | println!("\nAttrs:"); 64 | for attr in perf.event_attributes.iter() { 65 | println!(" {:?}", attr); 66 | } 67 | 68 | println!("\nEvents:"); 69 | for event in perf.events.iter() { 70 | match event { 71 | &Event::MMap { 72 | pid, 73 | tid, 74 | addr, 75 | len, 76 | pgoff, 77 | ref filename, 78 | ref sample_id, 79 | } => { 80 | println!( 81 | " Mmap: pid: {}, tid: {}, addr: {:x}, len: {}, pgoff: {:x} - {}", 82 | pid, tid, addr, len, pgoff, filename 83 | ); 84 | print_sample_id(sample_id); 85 | } 86 | &Event::MMap2 { 87 | pid, 88 | tid, 89 | addr, 90 | len, 91 | pgoff, 92 | maj, 93 | min, 94 | ino, 95 | ino_generation, 96 | prot, 97 | flags, 98 | ref filename, 99 | ref sample_id, 100 | } => { 101 | println!( 102 | " Mmap2: pid: {}, tid: {}, addr: {:x}, len: {}, pgoff: {:x} - {}", 103 | pid, tid, addr, len, pgoff, filename 104 | ); 105 | println!( 106 | " dev: {}:{} inode: {}, inode generation: {}, prot: {}, flags: {}", 107 | maj, min, ino, ino_generation, prot, flags 108 | ); 109 | print_sample_id(sample_id); 110 | } 111 | &Event::Exit { 112 | pid, 113 | ppid, 114 | tid, 115 | ptid, 116 | time, 117 | ref sample_id, 118 | } => { 119 | println!( 120 | " Exit: pid: {}, ppid: {}, tid:{}, ptid: {}, time: {}", 121 | pid, ppid, tid, ptid, time 122 | ); 123 | print_sample_id(sample_id); 124 | } 125 | &Event::Comm { 126 | pid, 127 | tid, 128 | ref comm, 129 | ref sample_id, 130 | } => { 131 | println!(" Comm: pid: {}, tid:{}, comm: {}", pid, tid, comm); 132 | print_sample_id(sample_id); 133 | } 134 | &Event::Sample { 135 | identifier, 136 | ip, 137 | pid, 138 | tid, 139 | time, 140 | addr, 141 | id, 142 | stream_id, 143 | cpu, 144 | res, 145 | period, 146 | ref call_chain, 147 | } => { 148 | print!(" Sample:"); 149 | print_if_some!(" {}: {:x}", ip, addr); 150 | print_if_some!( 151 | " {}: {}", pid, tid, time, id, identifier, stream_id, cpu, res, period 152 | ); 153 | println!(""); 154 | if !call_chain.is_empty() { 155 | println!(" call chain: "); 156 | for addr in call_chain.iter() { 157 | println!(" {:x}", addr); 158 | } 159 | } 160 | } 161 | &Event::FinishedRound => {} 162 | &Event::Unsupported => {} 163 | } 164 | } 165 | } 166 | } 167 | } 168 | 169 | fn print_sample_id(sample_id: &linux_perf_file_reader::SampleId) { 170 | print!(" Sample:"); 171 | print_if_some_child!(" {}: {}", sample_id, pid, tid, time, id, stream_id, cpu, res, identifier); 172 | println!(""); 173 | } 174 | -------------------------------------------------------------------------------- /src/event_reader.rs: -------------------------------------------------------------------------------- 1 | use crate::tools::{collect_n, read_raw, read_string}; 2 | use crate::*; 3 | use std::collections::HashMap; 4 | use std::io::{Read, Seek}; 5 | 6 | #[repr(u32)] 7 | #[derive(Debug)] 8 | #[allow(dead_code)] 9 | enum RecordType { 10 | MMap = 1, 11 | Lost = 2, 12 | Comm = 3, 13 | Exit = 4, 14 | Fork = 7, 15 | Read = 8, 16 | Sample = 9, 17 | MMap2 = 10, 18 | Aux = 11, 19 | ItraceStart = 12, 20 | LostSamples = 13, 21 | Switch = 14, 22 | SwitchCpuWide = 15, 23 | Attr = 64, 24 | EventType = 65, /* depreceated */ 25 | TracingData = 66, 26 | BuildId = 67, 27 | FinishedRound = 68, 28 | IdIndex = 69, 29 | AuxTraceInfo = 70, 30 | AuxTrace = 71, 31 | AuxTraceError = 72, 32 | } 33 | 34 | #[repr(C)] 35 | #[derive(Debug)] 36 | struct EventHeader { 37 | record_type: RecordType, 38 | misc: u16, 39 | size: u16, 40 | } 41 | 42 | #[repr(C)] 43 | #[derive(Debug)] 44 | struct MMapPart { 45 | pid: u32, 46 | tid: u32, 47 | addr: u64, 48 | len: u64, 49 | pgoff: u64, 50 | } 51 | 52 | #[repr(C)] 53 | #[derive(Debug)] 54 | struct MMap2Part { 55 | pid: u32, 56 | tid: u32, 57 | addr: u64, 58 | len: u64, 59 | pgoff: u64, 60 | maj: u32, 61 | min: u32, 62 | ino: u64, 63 | ino_generation: u64, 64 | prot: u32, 65 | flags: u32, 66 | } 67 | 68 | #[repr(C)] 69 | #[derive(Debug)] 70 | struct ExitPart { 71 | pid: u32, 72 | ppid: u32, 73 | tid: u32, 74 | ptid: u32, 75 | time: u64, 76 | } 77 | 78 | #[repr(C)] 79 | #[derive(Debug)] 80 | struct CommPart { 81 | pid: u32, 82 | tid: u32, 83 | } 84 | 85 | macro_rules! bool_to_option { 86 | ($v: expr, $c: expr) => { 87 | if $v { 88 | Some($c) 89 | } else { 90 | None 91 | } 92 | }; 93 | } 94 | 95 | struct SampleReader { 96 | id_to_sample_format: HashMap, 97 | sample_id_format: SampleFormat, 98 | sample_id_size: usize, 99 | } 100 | 101 | impl SampleReader { 102 | fn new(event_desciptions: &[EventDescription]) -> Result { 103 | if event_desciptions.len() == 0 { 104 | Err(ErrorKind::NoEventInInfoSection.into()) 105 | } else if event_desciptions.len() > 1 106 | && !event_desciptions.iter().all(|d| { 107 | d.attributes 108 | .sample_format 109 | .contains(SampleFormat::IDENTIFIER) 110 | }) 111 | && !event_desciptions.iter().all(|d| { 112 | d.attributes.sample_format == event_desciptions[0].attributes.sample_format 113 | }) 114 | { 115 | Err(ErrorKind::NoIndentifierInEventInInfoAttributes.into()) 116 | } else { 117 | let first = event_desciptions[0].attributes.sample_format; 118 | let map = event_desciptions 119 | .iter() 120 | .flat_map(|d| { 121 | d.ids 122 | .iter() 123 | .map(move |id| (*id, d.attributes.sample_format)) 124 | }) 125 | .collect(); 126 | Ok(SampleReader { 127 | id_to_sample_format: map, 128 | sample_id_format: first, 129 | sample_id_size: Self::sample_id_size(&first), 130 | }) 131 | } 132 | } 133 | 134 | fn sample_id_size(s: &SampleFormat) -> usize { 135 | let mut size = 0; 136 | if s.contains(SampleFormat::TID) { 137 | size += 8; 138 | } 139 | if s.contains(SampleFormat::TIME) { 140 | size += 8; 141 | } 142 | if s.contains(SampleFormat::ID) { 143 | size += 8; 144 | } 145 | if s.contains(SampleFormat::STREAM_ID) { 146 | size += 8; 147 | } 148 | if s.contains(SampleFormat::CPU) { 149 | size += 8; 150 | } 151 | if s.contains(SampleFormat::IDENTIFIER) { 152 | size += 8; 153 | } 154 | size 155 | } 156 | 157 | fn read_sample_id(&self, file: &mut impl Read) -> io::Result { 158 | let s = self.sample_id_format; 159 | let pid = bool_to_option!(s.contains(SampleFormat::TID), read_raw(file)?); 160 | let tid = bool_to_option!(s.contains(SampleFormat::TID), read_raw(file)?); 161 | let time = bool_to_option!(s.contains(SampleFormat::TIME), read_raw(file)?); 162 | let id = bool_to_option!(s.contains(SampleFormat::ID), read_raw(file)?); 163 | let stream_id = bool_to_option!(s.contains(SampleFormat::STREAM_ID), read_raw(file)?); 164 | let cpu = bool_to_option!(s.contains(SampleFormat::CPU), read_raw(file)?); 165 | let res = bool_to_option!(s.contains(SampleFormat::CPU), read_raw(file)?); 166 | let identifier = bool_to_option!(s.contains(SampleFormat::IDENTIFIER), read_raw(file)?); 167 | Ok(SampleId { 168 | pid, 169 | tid, 170 | time, 171 | id, 172 | stream_id, 173 | cpu, 174 | res, 175 | identifier, 176 | }) 177 | } 178 | 179 | fn read_sample(&self, file: &mut impl Read) -> io::Result { 180 | let mut s = self.sample_id_format; 181 | let identifier = bool_to_option!(s.contains(SampleFormat::IDENTIFIER), read_raw(file)?); 182 | if let Some(id) = identifier.as_ref() { 183 | if let Some(actual_format) = self.id_to_sample_format.get(id) { 184 | s = *actual_format; 185 | } 186 | } 187 | let ip = bool_to_option!(s.contains(SampleFormat::IP), read_raw(file)?); 188 | let pid = bool_to_option!(s.contains(SampleFormat::TID), read_raw(file)?); 189 | let tid = bool_to_option!(s.contains(SampleFormat::TID), read_raw(file)?); 190 | let time = bool_to_option!(s.contains(SampleFormat::TIME), read_raw(file)?); 191 | let addr = bool_to_option!(s.contains(SampleFormat::ADDR), read_raw(file)?); 192 | let id = bool_to_option!(s.contains(SampleFormat::ID), read_raw(file)?); 193 | let stream_id = bool_to_option!(s.contains(SampleFormat::STREAM_ID), read_raw(file)?); 194 | let cpu = bool_to_option!(s.contains(SampleFormat::CPU), read_raw(file)?); 195 | let res = bool_to_option!(s.contains(SampleFormat::CPU), read_raw(file)?); 196 | let period = bool_to_option!(s.contains(SampleFormat::PERIOD), read_raw(file)?); 197 | let call_chain: Vec = if !s.contains(SampleFormat::CALLCHAIN) { 198 | vec![] 199 | } else { 200 | collect_n( 201 | { 202 | let x: u64 = read_raw(file)?; 203 | x 204 | } as usize, 205 | || read_raw(file), 206 | )? 207 | }; 208 | use Event::Sample; 209 | Ok(Sample { 210 | identifier, 211 | ip, 212 | pid, 213 | tid, 214 | time, 215 | addr, 216 | id, 217 | stream_id, 218 | cpu, 219 | res, 220 | period, 221 | call_chain, 222 | }) 223 | } 224 | } 225 | 226 | pub fn read_events( 227 | file: &mut File, 228 | header: &PerfHeader, 229 | event_desciptions: &[EventDescription], 230 | ) -> Result<(Vec, u64, u64)> { 231 | let sample_reader = SampleReader::new(event_desciptions)?; 232 | 233 | let mut events = Vec::new(); 234 | let mut position = file.seek(io::SeekFrom::Start(header.data.offset))?; 235 | let mut size = 0; 236 | let mut start = std::u64::MAX; 237 | let mut end = 0; 238 | debug!("read events"); 239 | while size < header.data.size { 240 | let event_header: EventHeader = read_raw(file)?; 241 | debug!("{:x} {:?}", position, event_header); 242 | 243 | match event_header.record_type { 244 | RecordType::MMap => { 245 | let part: MMapPart = read_raw(file)?; 246 | let filename = read_string( 247 | file, 248 | event_header.size as usize 249 | - mem::size_of::() 250 | - mem::size_of::() 251 | - sample_reader.sample_id_size, 252 | )?; 253 | let s = sample_reader.read_sample_id(file)?; 254 | events.push(Event::MMap { 255 | pid: part.pid, 256 | tid: part.tid, 257 | addr: part.addr, 258 | pgoff: part.pgoff, 259 | len: part.len, 260 | filename: filename, 261 | sample_id: s, 262 | }); 263 | } 264 | RecordType::Sample => { 265 | let sample = sample_reader.read_sample(file)?; 266 | if let Event::Sample { 267 | time: Some(time), .. 268 | } = sample 269 | { 270 | start = std::cmp::min(start, time); 271 | end = std::cmp::max(end, time); 272 | } 273 | events.push(sample); 274 | } 275 | RecordType::MMap2 => { 276 | let part: MMap2Part = read_raw(file)?; 277 | let filename = read_string( 278 | file, 279 | event_header.size as usize 280 | - mem::size_of::() 281 | - mem::size_of::() 282 | - sample_reader.sample_id_size, 283 | )?; 284 | let s = sample_reader.read_sample_id(file)?; 285 | events.push(Event::MMap2 { 286 | pid: part.pid, 287 | tid: part.tid, 288 | addr: part.addr, 289 | pgoff: part.pgoff, 290 | len: part.len, 291 | maj: part.maj, 292 | min: part.min, 293 | ino: part.ino, 294 | ino_generation: part.ino_generation, 295 | prot: part.prot, 296 | flags: part.flags, 297 | filename: filename, 298 | sample_id: s, 299 | }); 300 | } 301 | RecordType::Exit => { 302 | let part: ExitPart = read_raw(file)?; 303 | let s = sample_reader.read_sample_id(file)?; 304 | events.push(Event::Exit { 305 | pid: part.pid, 306 | ppid: part.ppid, 307 | tid: part.tid, 308 | ptid: part.ptid, 309 | time: part.time, 310 | sample_id: s, 311 | }); 312 | start = std::cmp::min(start, part.time); 313 | end = std::cmp::max(end, part.time); 314 | } 315 | RecordType::Comm => { 316 | let part: CommPart = read_raw(file)?; 317 | let comm = read_string( 318 | file, 319 | event_header.size as usize 320 | - mem::size_of::() 321 | - mem::size_of::() 322 | - sample_reader.sample_id_size, 323 | )?; 324 | let s = sample_reader.read_sample_id(file)?; 325 | events.push(Event::Comm { 326 | pid: part.pid, 327 | tid: part.tid, 328 | comm: comm, 329 | sample_id: s, 330 | }); 331 | } 332 | RecordType::FinishedRound => events.push(Event::FinishedRound), 333 | _ => events.push(Event::Unsupported), 334 | } 335 | size += event_header.size as u64; 336 | position = file.seek(io::SeekFrom::Start(header.data.offset + size))?; 337 | } 338 | Ok((events, start, end)) 339 | } 340 | -------------------------------------------------------------------------------- /src/header.rs: -------------------------------------------------------------------------------- 1 | bitflags! { 2 | pub struct HeaderFlags: u64 { 3 | const TRACING_DATA = 1 << 1; 4 | const BUILD_ID = 1 << 2; 5 | const HOSTNAME = 1 << 3; 6 | const OSRELEASE = 1 << 4; 7 | const VERSION = 1 << 5; 8 | const ARCH = 1 << 6; 9 | const NRCPUS = 1 << 7; 10 | const CPUDESC = 1 << 8; 11 | const CPUID = 1 << 9; 12 | const TOTAL_MEM = 1 << 10; 13 | const CMDLINE = 1 << 11; 14 | const EVENT_DESC = 1 << 12; 15 | const CPU_TOPOLOGY = 1 << 13; 16 | const NUMA_TOPOLOGY = 1 << 14; 17 | const BRANCH_STACK = 1 << 15; 18 | const PMU_MAPPINGS = 1 << 16; 19 | const GROUP_DESC = 1 << 17; 20 | const AUXTRACE = 1 << 18; 21 | const STAT = 1 << 19; 22 | const CACHE = 1 << 20; 23 | } 24 | } 25 | 26 | pub const PERF_FILE_SIGNATURE: u64 = 0x32454c4946524550; 27 | 28 | #[repr(C)] 29 | #[derive(Debug)] 30 | pub struct PerfHeader { 31 | pub magic: u64, /* PERFILE2 */ 32 | pub size: u64, /* size of the header */ 33 | pub attr_size: u64, /* size of an attribute in attrs */ 34 | pub attrs: PerfFileSection, 35 | pub data: PerfFileSection, 36 | pub header_types: PerfFileSection, 37 | pub flags: HeaderFlags, 38 | pub flags1: [u64; 3], 39 | } 40 | 41 | #[repr(C)] 42 | #[derive(Debug)] 43 | pub struct PerfFileSection { 44 | pub offset: u64, /* offset from start of file */ 45 | pub size: u64, /* size of the section */ 46 | } 47 | -------------------------------------------------------------------------------- /src/info_reader.rs: -------------------------------------------------------------------------------- 1 | use crate::*; 2 | use header::*; 3 | use tools::{collect_n, read_raw, read_string}; 4 | 5 | pub fn read_info(file: &mut File, header: &PerfHeader) -> io::Result { 6 | let mut reader = HeaderInfoReader::new(file, header)?; 7 | 8 | reader.skip(HeaderFlags::TRACING_DATA); 9 | reader.skip(HeaderFlags::BUILD_ID); 10 | let hostname = reader.get_string(HeaderFlags::HOSTNAME)?; 11 | let os_release = reader.get_string(HeaderFlags::OSRELEASE)?; 12 | let tools_version = reader.get_string(HeaderFlags::VERSION)?; 13 | let arch = reader.get_string(HeaderFlags::ARCH)?; 14 | let cpu_count = reader.get::(HeaderFlags::NRCPUS)?; 15 | let cpu_description = reader.get_string(HeaderFlags::CPUDESC)?; 16 | let cpu_id = reader.get_string(HeaderFlags::CPUID)?; 17 | let total_memory = reader.get::(HeaderFlags::TOTAL_MEM)?; 18 | let command_line = reader.get_string_array(HeaderFlags::CMDLINE)?; 19 | let event_descriptions = reader.get_event_description()?; 20 | let cpu_topology = reader.get_string_array(HeaderFlags::CPU_TOPOLOGY)?; 21 | reader.skip(HeaderFlags::NUMA_TOPOLOGY); 22 | reader.skip(HeaderFlags::BRANCH_STACK); 23 | reader.skip(HeaderFlags::PMU_MAPPINGS); 24 | reader.skip(HeaderFlags::GROUP_DESC); 25 | reader.skip(HeaderFlags::AUXTRACE); 26 | reader.skip(HeaderFlags::STAT); 27 | reader.skip(HeaderFlags::CACHE); 28 | if reader.has_more() { 29 | warn!("Unknown flags in header"); 30 | } 31 | 32 | Ok(Info { 33 | hostname, 34 | os_release, 35 | tools_version, 36 | cpu_count, 37 | event_descriptions, 38 | arch, 39 | cpu_id, 40 | cpu_description, 41 | total_memory, 42 | command_line, 43 | cpu_topology, 44 | }) 45 | } 46 | 47 | struct HeaderInfoReader<'a> { 48 | file: &'a mut File, 49 | sections: Vec, 50 | current: usize, 51 | flags: HeaderFlags, 52 | } 53 | 54 | fn bits_count(mut v: u64) -> u8 { 55 | let mut c = 0; 56 | while v != 0 { 57 | v &= v - 1; 58 | c += 1; 59 | } 60 | c 61 | } 62 | 63 | impl<'a> HeaderInfoReader<'a> { 64 | fn new(file: &'a mut File, header: &PerfHeader) -> io::Result { 65 | file.seek(io::SeekFrom::Start(header.data.offset + header.data.size))?; 66 | let sections: Vec = 67 | collect_n(bits_count(header.flags.bits()) as usize, || read_raw(file))?; 68 | debug!( 69 | "flags: {:x}, have {} info records, start at 0x{:x}", 70 | header.flags.bits(), 71 | sections.len(), 72 | header.data.offset + header.data.size 73 | ); 74 | Ok(HeaderInfoReader { 75 | file: file, 76 | sections: sections, 77 | current: 0, 78 | flags: header.flags, 79 | }) 80 | } 81 | 82 | fn seek(&mut self, flag: HeaderFlags) -> io::Result<()> { 83 | let section = &self.sections[self.current]; 84 | debug!( 85 | "Read section {} {:?}, size {}", 86 | self.current, flag, section.size 87 | ); 88 | self.file.seek(io::SeekFrom::Start(section.offset))?; 89 | self.current += 1; 90 | Ok(()) 91 | } 92 | 93 | fn get_string(&mut self, flag: HeaderFlags) -> io::Result> { 94 | if self.flags.contains(flag) && self.sections.len() > self.current { 95 | self.seek(flag)?; 96 | let size: u32 = read_raw(self.file)?; 97 | Ok(Some(read_string(self.file, size as usize)?)) 98 | } else { 99 | Ok(None) 100 | } 101 | } 102 | 103 | fn get_string_array(&mut self, flag: HeaderFlags) -> io::Result>> { 104 | if self.flags.contains(flag) && self.sections.len() > self.current { 105 | self.seek(flag)?; 106 | let count: u32 = read_raw(self.file)?; 107 | Ok(Some(collect_n(count as usize, || { 108 | let size: u32 = read_raw(self.file)?; 109 | read_string(self.file, size as usize) 110 | })?)) 111 | } else { 112 | Ok(None) 113 | } 114 | } 115 | 116 | fn get_event_description(&mut self) -> io::Result>> { 117 | if self.flags.contains(HeaderFlags::EVENT_DESC) && self.sections.len() > self.current { 118 | self.seek(HeaderFlags::EVENT_DESC)?; 119 | let count: u32 = read_raw(self.file)?; 120 | let size: u32 = read_raw(self.file)?; 121 | debug!(" EVENT_DESC: count {}, size {}", count, size); 122 | let all_attributes = collect_n(count as usize, || { 123 | let attributes: EventAttributes = read_raw(self.file)?; 124 | self.file.seek(io::SeekFrom::Current( 125 | size as i64 - mem::size_of::() as i64, 126 | ))?; 127 | let id_count: u32 = read_raw(self.file)?; 128 | let name_size: u32 = read_raw(self.file)?; 129 | let name = read_string(self.file, name_size as usize)?; 130 | let ids: io::Result> = 131 | collect_n(id_count as usize, || read_raw(self.file)?); 132 | ids.map(|ids| EventDescription { 133 | attributes, 134 | name, 135 | ids, 136 | }) 137 | })?; 138 | Ok(Some(all_attributes)) 139 | } else { 140 | Ok(None) 141 | } 142 | } 143 | 144 | fn get(&mut self, flag: HeaderFlags) -> io::Result> { 145 | if self.flags.contains(flag) && self.sections.len() > self.current { 146 | self.seek(flag)?; 147 | let v: T = read_raw(self.file)?; 148 | Ok(Some(v)) 149 | } else { 150 | Ok(None) 151 | } 152 | } 153 | 154 | fn skip(&mut self, flag: HeaderFlags) { 155 | if self.flags.contains(flag) && self.sections.len() > self.current { 156 | debug!( 157 | "Skip section {} {:?} size {}", 158 | self.current, flag, self.sections[self.current].size 159 | ); 160 | self.current += 1; 161 | } 162 | } 163 | 164 | fn has_more(&self) -> bool { 165 | self.sections.len() > self.current 166 | } 167 | } 168 | -------------------------------------------------------------------------------- /src/lib.rs: -------------------------------------------------------------------------------- 1 | #![recursion_limit = "1024"] 2 | #[macro_use] 3 | extern crate error_chain; 4 | #[macro_use] 5 | extern crate log; 6 | #[macro_use] 7 | extern crate bitflags; 8 | #[macro_use] 9 | extern crate serde_derive; 10 | extern crate serde; 11 | 12 | use std::fs::File; 13 | use std::io::Seek; 14 | use std::{io, mem}; 15 | 16 | mod event_reader; 17 | mod header; 18 | mod info_reader; 19 | use header::*; 20 | mod tools; 21 | use tools::read_raw; 22 | 23 | mod errors { 24 | error_chain! { 25 | foreign_links { 26 | IOError(::std::io::Error); 27 | } 28 | 29 | errors { 30 | InvalidSinature { 31 | description("invalid perf file signature") 32 | } 33 | NoEventInInfoSection { 34 | description("cannot read dump without event info") 35 | } 36 | NoIndentifierInEventInInfoAttributes { 37 | description("cannot read dump without IDENTIFIER flag and different sample format") 38 | } 39 | } 40 | } 41 | } 42 | 43 | use errors::*; 44 | 45 | pub use errors::Error; 46 | pub use errors::ErrorKind; 47 | 48 | #[repr(u32)] 49 | #[derive(Debug)] 50 | pub enum PerfType { 51 | Hardware = 0, 52 | Software = 1, 53 | Tracepoint = 2, 54 | HwCache = 3, 55 | Raw = 4, 56 | Breakpoint = 5, 57 | } 58 | 59 | #[repr(u64)] 60 | #[derive(Debug)] 61 | pub enum HwId { 62 | CpuCycles = 0, 63 | Instructions = 1, 64 | CacheReferences = 2, 65 | CacheMisses = 3, 66 | BranchInstructions = 4, 67 | BranchMisses = 5, 68 | BusCycles = 6, 69 | StalledCyclesFrontend = 7, 70 | StalledCyclesBackend = 8, 71 | RefCpuCycles = 9, 72 | } 73 | 74 | bitflags! { 75 | pub struct AttrFlags: u64 { 76 | const DISABLED = 1; /* off by default */ 77 | const INHERIT = 1 << 1; /* children inherit it */ 78 | const PINNED = 1 << 2; /* must always be on PMU */ 79 | const EXLUSIVE = 1 << 3; /* only group on PMU */ 80 | const EXCLUDE_USER = 1 << 4; /* don't count user */ 81 | const EXCLUDE_KERNEL = 1 << 5; /* ditto kernel */ 82 | const EXCLUDE_HV = 1 << 6; /* ditto hypervisor */ 83 | const EXCLUDE_IDLE = 1 << 7; /* don't count when idle */ 84 | const MMAP = 1 << 8; /* include mmap data */ 85 | const COMM = 1 << 9; /* include comm data */ 86 | const FREQ = 1 << 10; /* use freq, not period */ 87 | const INHERIT_STAT = 1 << 11; /* per task counts */ 88 | const ENABLE_ON_EXEC = 1 << 12; /* next exec enables */ 89 | const TASK = 1 << 13; /* trace fork/exit */ 90 | const WATERMARK = 1 << 14; /* wakeup_watermark */ 91 | /* 92 | * precise_ip: 93 | * 94 | * 0 - SAMPLE_IP can have arbitrary skid 95 | * 1 - SAMPLE_IP must have constant skid 96 | * 2 - SAMPLE_IP requested to have 0 skid 97 | * 3 - SAMPLE_IP must have 0 skid 98 | */ 99 | const PRECISE_IP1 = 1 << 15; 100 | const PRECISE_IP2 = 1 << 16; 101 | const MMAP_DATA = 1 << 17; /* non-exec mmap data */ 102 | const SAMPLE_ID_ALL = 1 << 18; /* sample_type all events */ 103 | const EXCLUDE_HOST = 1 << 19; /* don't count in host */ 104 | const EXCLUDE_GUEST = 1 << 20; /* don't count in guest */ 105 | const EXCLUDE_CALLCHAIN_KERNEL = 1 << 21; /* exclude kernel callchains */ 106 | const EXCLUDE_CALLCHAIN_USER = 1 << 22; /* exclude user callchains */ 107 | const MMAP2 = 1 << 23; /* include mmap with inode data */ 108 | const COMM_EXEC = 1 << 24; /* flag comm events that are due to an exec */ 109 | const USE_CLOCKID = 1 << 25; /* use @clockid for time fields */ 110 | const CONTEXT_SWITCH = 1 << 26; /* context switch data */ 111 | const WRITE_BACKWARD = 1 << 27; /* Write ring buffer from end to beginning */ 112 | } 113 | } 114 | 115 | bitflags! { 116 | pub struct SampleFormat: u64 { 117 | const IP = 1 << 0; 118 | const TID = 1 << 1; 119 | const TIME = 1 << 2; 120 | const ADDR = 1 << 3; 121 | const READ = 1 << 4; 122 | const CALLCHAIN = 1 << 5; 123 | const ID = 1 << 6; 124 | const CPU = 1 << 7; 125 | const PERIOD = 1 << 8; 126 | const STREAM_ID = 1 << 9; 127 | const RAW = 1 << 10; 128 | const BRANCH_STACK = 1 << 11; 129 | const REGS_USER = 1 << 12; 130 | const STACK_USER = 1 << 13; 131 | const WEIGHT = 1 << 14; 132 | const DATA_SRC = 1 << 15; 133 | const IDENTIFIER = 1 << 16; 134 | const TRANSACTION = 1 << 17; 135 | const REGS_INTR = 1 << 18; 136 | } 137 | } 138 | 139 | bitflags! { 140 | pub struct ReadFormat: u64 { 141 | const TOTAL_TIME_ENABLED = 1 << 0; 142 | const TOTAL_TIME_RUNNING = 1 << 1; 143 | const ID = 1 << 2; 144 | const GROUP = 1 << 3; 145 | } 146 | } 147 | 148 | #[repr(C)] 149 | #[derive(Debug)] 150 | pub struct EventAttributes { 151 | pub perf_type: PerfType, 152 | pub size: u32, 153 | pub config: u64, //TODO: HwId for type hardware, 154 | pub sample_period_or_freq: u64, 155 | pub sample_format: SampleFormat, 156 | pub read_format: ReadFormat, 157 | pub flags: AttrFlags, 158 | pub wakeup_events_or_watermakr: u32, /* wakeup every n events or bytes before wakeup */ 159 | pub bp_type: u32, 160 | pub bp_addr_or_config1: u32, 161 | pub bp_len_or_config2: u64, 162 | pub branch_sample_type: u64, // enum perf_branch_sample_type 163 | pub sample_regs_user: u64, // Defines set of user regs to dump on samples See asm/perf_regs.h. 164 | pub sample_stack_user: u32, // Defines size of the user stack to dump on samples. 165 | pub clockid: i32, 166 | /* 167 | * Defines set of regs to dump for each sample 168 | * state captured on: 169 | * - precise = 0: PMU interrupt 170 | * - precise > 0: sampled instruction 171 | */ 172 | pub sample_regs_intr: u64, 173 | pub aux_watermark: u32, //Wakeup watermark for AUX area 174 | pub sample_max_stack: u16, 175 | pub reserved_2: u16, 176 | } 177 | 178 | #[derive(Debug)] 179 | pub struct Perf { 180 | pub info: Info, 181 | pub event_attributes: Vec, 182 | pub events: Vec, 183 | pub start: u64, 184 | pub end: u64, 185 | } 186 | 187 | #[derive(Debug, Serialize)] 188 | pub struct Info { 189 | pub hostname: Option, 190 | pub os_release: Option, 191 | pub tools_version: Option, 192 | pub arch: Option, 193 | pub cpu_count: Option, 194 | pub cpu_description: Option, 195 | pub cpu_id: Option, 196 | pub total_memory: Option, 197 | pub command_line: Option>, 198 | pub cpu_topology: Option>, 199 | pub event_descriptions: Option>, 200 | // TODO add others 201 | } 202 | 203 | #[repr(C)] 204 | #[derive(Debug, Serialize)] 205 | pub struct CpuCount { 206 | pub online: u32, 207 | pub available: u32, 208 | } 209 | 210 | #[derive(Debug, Serialize)] 211 | pub struct EventDescription { 212 | #[serde(skip_serializing)] 213 | pub attributes: EventAttributes, 214 | pub name: String, 215 | pub ids: Vec, 216 | } 217 | 218 | #[derive(Debug)] 219 | pub enum Event { 220 | MMap { 221 | pid: u32, 222 | tid: u32, 223 | addr: u64, 224 | len: u64, 225 | pgoff: u64, 226 | filename: String, 227 | sample_id: SampleId, 228 | }, 229 | MMap2 { 230 | pid: u32, 231 | tid: u32, 232 | addr: u64, 233 | len: u64, 234 | pgoff: u64, 235 | maj: u32, 236 | min: u32, 237 | ino: u64, 238 | ino_generation: u64, 239 | prot: u32, 240 | flags: u32, 241 | filename: String, 242 | sample_id: SampleId, 243 | }, 244 | Sample { 245 | identifier: Option, 246 | ip: Option, 247 | pid: Option, 248 | tid: Option, 249 | time: Option, 250 | addr: Option, 251 | id: Option, 252 | stream_id: Option, 253 | cpu: Option, 254 | res: Option, 255 | period: Option, 256 | //TODO read_format 257 | call_chain: Vec, // TODO add others 258 | }, 259 | Exit { 260 | pid: u32, 261 | ppid: u32, 262 | tid: u32, 263 | ptid: u32, 264 | time: u64, 265 | sample_id: SampleId, 266 | }, 267 | Comm { 268 | pid: u32, 269 | tid: u32, 270 | comm: String, 271 | sample_id: SampleId, 272 | }, 273 | FinishedRound, 274 | Unsupported, 275 | } 276 | 277 | #[repr(C)] 278 | #[derive(Debug)] 279 | pub struct SampleId { 280 | pub pid: Option, 281 | pub tid: Option, 282 | pub time: Option, 283 | pub id: Option, 284 | pub stream_id: Option, 285 | pub cpu: Option, 286 | pub res: Option, 287 | pub identifier: Option, 288 | } 289 | 290 | pub fn is_perf_file>(path: &P) -> Result { 291 | let metadata = std::fs::metadata(path)?; 292 | if metadata.len() < mem::size_of::() as u64 { 293 | return Ok(false); 294 | } 295 | let mut file = File::open(&path)?; 296 | let header: PerfHeader = read_raw(&mut file)?; 297 | Ok(header.magic == PERF_FILE_SIGNATURE) 298 | } 299 | 300 | pub fn read_perf_file_info>(path: &P) -> Result { 301 | let mut file = File::open(path)?; 302 | let header: PerfHeader = read_raw(&mut file)?; 303 | if header.magic != PERF_FILE_SIGNATURE { 304 | return Err(ErrorKind::InvalidSinature.into()); 305 | } 306 | Ok(info_reader::read_info(&mut file, &header)?) 307 | } 308 | 309 | pub fn read_perf_file>(path: &P) -> Result { 310 | let mut file = File::open(path)?; 311 | debug!("read header"); 312 | let header: PerfHeader = read_raw(&mut file)?; 313 | if header.magic != PERF_FILE_SIGNATURE { 314 | return Err(ErrorKind::InvalidSinature.into()); 315 | } 316 | debug!("header: {:?}\nread info", header); 317 | let info = info_reader::read_info(&mut file, &header)?; 318 | 319 | debug!("read attr"); 320 | let event_attributes = (0..(header.attrs.size / header.attr_size)) 321 | .map(|i| { 322 | file.seek(io::SeekFrom::Start( 323 | header.attrs.offset + i * header.attr_size, 324 | ))?; 325 | Ok(read_raw(&mut file)?) 326 | }) 327 | .collect::>>()?; 328 | 329 | if info.event_descriptions.is_none() { 330 | Err(ErrorKind::NoEventInInfoSection.into()) 331 | } else { 332 | let (events, start, end) = event_reader::read_events( 333 | &mut file, 334 | &header, 335 | &info.event_descriptions.as_ref().unwrap(), 336 | )?; 337 | Ok(Perf { 338 | info, 339 | event_attributes, 340 | events, 341 | start, 342 | end, 343 | }) 344 | } 345 | } 346 | -------------------------------------------------------------------------------- /src/tools.rs: -------------------------------------------------------------------------------- 1 | use std::io::Read; 2 | use std::{io, mem, result, slice}; 3 | 4 | pub fn read_raw(file: &mut impl Read) -> io::Result { 5 | let size = mem::size_of::(); 6 | unsafe { 7 | let mut t = mem::MaybeUninit::::uninit(); 8 | let slice = slice::from_raw_parts_mut(mem::transmute(&mut t), size); 9 | file.read_exact(slice)?; 10 | Ok(t.assume_init()) 11 | } 12 | } 13 | 14 | pub fn read_string(file: &mut impl Read, size: usize) -> io::Result { 15 | let mut buff = vec![0u8; size]; 16 | file.read_exact(&mut buff)?; 17 | let end = buff.iter().position(|x| *x == 0).unwrap_or(buff.len()); 18 | let s = String::from_utf8_lossy(&buff[0..end]).to_string(); 19 | //debug!("read str max size:{}, result: {}, `{}`", size, s.len(), s); 20 | Ok(s) 21 | } 22 | 23 | pub fn collect_n(count: usize, mut function: F) -> result::Result, E> 24 | where 25 | F: FnMut() -> result::Result, 26 | { 27 | let mut v = Vec::with_capacity(count); 28 | for _ in 0..count { 29 | v.push(function()?); 30 | } 31 | Ok(v) 32 | } 33 | -------------------------------------------------------------------------------- /tests/dump.stdout: -------------------------------------------------------------------------------- 1 | Info: 2 | hostname: zenux 3 | os_release: 4.8.0-30-generic 4 | tools_version: 4.8.6 5 | arch: x86_64 6 | cpu_description: Intel(R) Core(TM) i7-5500U CPU @ 2.40GHz 7 | total_memory: 8075544 8 | command_line: ["/usr/lib/linux-hwe-edge-tools-4.8.0-30/perf", "record", "sleep", "1"] 9 | cpu_topology: ["0-3"] 10 | cpu_count: CpuCount { online: 4, available: 4 } 11 | event_attribute cycles:ppp[]: EventAttributes { perf_type: Hardware, size: 112, config: 0, sample_period_or_freq: 4000, sample_format: IP | TID | TIME | PERIOD, read_format: (empty), flags: DISABLED | INHERIT | MMAP | COMM | FREQ | ENABLE_ON_EXEC | TASK | PRECISE_IP1 | PRECISE_IP2 | SAMPLE_ID_ALL | EXCLUDE_GUEST | MMAP2 | COMM_EXEC, wakeup_events_or_watermakr: 0, bp_type: 0, bp_addr_or_config1: 0, bp_len_or_config2: 0, branch_sample_type: 0, sample_regs_user: 0, sample_stack_user: 0, clockid: 0, sample_regs_intr: 0, aux_watermark: 0, sample_max_stack: 0, reserved_2: 0 } 12 | 13 | Attrs: 14 | EventAttributes { perf_type: Hardware, size: 112, config: 0, sample_period_or_freq: 4000, sample_format: IP | TID | TIME | PERIOD, read_format: (empty), flags: DISABLED | INHERIT | MMAP | COMM | FREQ | ENABLE_ON_EXEC | TASK | PRECISE_IP1 | PRECISE_IP2 | SAMPLE_ID_ALL | EXCLUDE_GUEST | MMAP2 | COMM_EXEC, wakeup_events_or_watermakr: 0, bp_type: 0, bp_addr_or_config1: 0, bp_len_or_config2: 0, branch_sample_type: 0, sample_regs_user: 0, sample_stack_user: 0, clockid: 0, sample_regs_intr: 0, aux_watermark: 0, sample_max_stack: 0, reserved_2: 0 } 15 | 16 | Events: 17 | Mmap: pid: 4294967295, tid: 0, addr: ffffffffa1e00000, len: 509419520, pgoff: ffffffffa1e00000 - [kernel.kallsyms]_text 18 | Sample: pid: 0 tid: 0 time: 0 19 | Mmap: pid: 4294967295, tid: 0, addr: ffffffffc03d2000, len: 49152, pgoff: 0 - /lib/modules/4.8.0-30-generic/kernel/drivers/net/fjes/fjes.ko 20 | Sample: pid: 0 tid: 0 time: 0 21 | Mmap: pid: 4294967295, tid: 0, addr: ffffffffc03de000, len: 49152, pgoff: 0 - /lib/modules/4.8.0-30-generic/kernel/drivers/mmc/host/sdhci.ko 22 | Sample: pid: 0 tid: 0 time: 0 23 | Mmap: pid: 4294967295, tid: 0, addr: ffffffffc03ea000, len: 20480, pgoff: 0 - /lib/modules/4.8.0-30-generic/kernel/drivers/thermal/intel_soc_dts_iosf.ko 24 | Sample: pid: 0 tid: 0 time: 0 25 | Mmap: pid: 4294967295, tid: 0, addr: ffffffffc03ef000, len: 45056, pgoff: 0 - /lib/modules/4.8.0-30-generic/kernel/drivers/acpi/video.ko 26 | Sample: pid: 0 tid: 0 time: 0 27 | Mmap: pid: 4294967295, tid: 0, addr: ffffffffc03fa000, len: 20480, pgoff: 0 - /lib/modules/4.8.0-30-generic/kernel/drivers/thermal/int340x_thermal/int340x_thermal_zone.ko 28 | Sample: pid: 0 tid: 0 time: 0 29 | Mmap: pid: 4294967295, tid: 0, addr: ffffffffc03ff000, len: 36864, pgoff: 0 - /lib/modules/4.8.0-30-generic/kernel/drivers/mmc/host/sdhci-acpi.ko 30 | Sample: pid: 0 tid: 0 time: 0 31 | Mmap: pid: 4294967295, tid: 0, addr: ffffffffc0408000, len: 36864, pgoff: 0 - /lib/modules/4.8.0-30-generic/kernel/drivers/platform/x86/wmi.ko 32 | Sample: pid: 0 tid: 0 time: 0 33 | Mmap: pid: 4294967295, tid: 0, addr: ffffffffc0411000, len: 36864, pgoff: 0 - /lib/modules/4.8.0-30-generic/kernel/drivers/ata/libahci.ko 34 | Sample: pid: 0 tid: 0 time: 0 35 | Mmap: pid: 4294967295, tid: 0, addr: ffffffffc041a000, len: 20480, pgoff: 0 - /lib/modules/4.8.0-30-generic/kernel/drivers/thermal/int340x_thermal/processor_thermal_device.ko 36 | Sample: pid: 0 tid: 0 time: 0 37 | Mmap: pid: 4294967295, tid: 0, addr: ffffffffc041f000, len: 372736, pgoff: 0 - /lib/modules/4.8.0-30-generic/kernel/drivers/gpu/drm/drm.ko 38 | Sample: pid: 0 tid: 0 time: 0 39 | Mmap: pid: 4294967295, tid: 0, addr: ffffffffc047a000, len: 45056, pgoff: 0 - /lib/modules/4.8.0-30-generic/kernel/fs/autofs4/autofs4.ko 40 | Sample: pid: 0 tid: 0 time: 0 41 | Mmap: pid: 4294967295, tid: 0, addr: ffffffffc0485000, len: 69632, pgoff: 0 - /lib/modules/4.8.0-30-generic/kernel/drivers/parport/parport.ko 42 | Sample: pid: 0 tid: 0 time: 0 43 | Mmap: pid: 4294967295, tid: 0, addr: ffffffffc0496000, len: 20480, pgoff: 0 - /lib/modules/4.8.0-30-generic/kernel/sound/soundcore.ko 44 | Sample: pid: 0 tid: 0 time: 0 45 | Mmap: pid: 4294967295, tid: 0, addr: ffffffffc049b000, len: 40960, pgoff: 0 - /lib/modules/4.8.0-30-generic/kernel/drivers/ata/ahci.ko 46 | Sample: pid: 0 tid: 0 time: 0 47 | Mmap: pid: 4294967295, tid: 0, addr: ffffffffc04a5000, len: 28672, pgoff: 0 - /lib/modules/4.8.0-30-generic/kernel/drivers/char/lp.ko 48 | Sample: pid: 0 tid: 0 time: 0 49 | Mmap: pid: 4294967295, tid: 0, addr: ffffffffc04ac000, len: 28672, pgoff: 0 - /lib/modules/4.8.0-30-generic/kernel/drivers/video/fbdev/core/fb_sys_fops.ko 50 | Sample: pid: 0 tid: 0 time: 0 51 | Mmap: pid: 4294967295, tid: 0, addr: ffffffffc04b3000, len: 139264, pgoff: 0 - /lib/modules/4.8.0-30-generic/kernel/drivers/input/mouse/psmouse.ko 52 | Sample: pid: 0 tid: 0 time: 0 53 | Mmap: pid: 4294967295, tid: 0, addr: ffffffffc04d5000, len: 20480, pgoff: 0 - /lib/modules/4.8.0-30-generic/kernel/drivers/video/fbdev/core/sysimgblt.ko 54 | Sample: pid: 0 tid: 0 time: 0 55 | Mmap: pid: 4294967295, tid: 0, addr: ffffffffc04da000, len: 24576, pgoff: 0 - /lib/modules/4.8.0-30-generic/kernel/drivers/char/ppdev.ko 56 | Sample: pid: 0 tid: 0 time: 0 57 | Mmap: pid: 4294967295, tid: 0, addr: ffffffffc04e0000, len: 28672, pgoff: 0 - /lib/modules/4.8.0-30-generic/kernel/sound/core/seq/snd-seq-midi-event.ko 58 | Sample: pid: 0 tid: 0 time: 0 59 | Mmap: pid: 4294967295, tid: 0, addr: ffffffffc04e7000, len: 28672, pgoff: 0 - /lib/modules/4.8.0-30-generic/kernel/drivers/video/fbdev/core/sysfillrect.ko 60 | Sample: pid: 0 tid: 0 time: 0 61 | Mmap: pid: 4294967295, tid: 0, addr: ffffffffc04ee000, len: 28672, pgoff: 0 - /lib/modules/4.8.0-30-generic/kernel/drivers/video/fbdev/core/syscopyarea.ko 62 | Sample: pid: 0 tid: 0 time: 0 63 | Mmap: pid: 4294967295, tid: 0, addr: ffffffffc04f5000, len: 20480, pgoff: 0 - /lib/modules/4.8.0-30-generic/kernel/drivers/i2c/algos/i2c-algo-bit.ko 64 | Sample: pid: 0 tid: 0 time: 0 65 | Mmap: pid: 4294967295, tid: 0, addr: ffffffffc04fa000, len: 36864, pgoff: 0 - /lib/modules/4.8.0-30-generic/kernel/drivers/parport/parport_pc.ko 66 | Sample: pid: 0 tid: 0 time: 0 67 | Mmap: pid: 4294967295, tid: 0, addr: ffffffffc0503000, len: 36864, pgoff: 0 - /lib/modules/4.8.0-30-generic/kernel/drivers/macintosh/mac_hid.ko 68 | Sample: pid: 0 tid: 0 time: 0 69 | Mmap: pid: 4294967295, tid: 0, addr: ffffffffc050c000, len: 40960, pgoff: 0 - /lib/modules/4.8.0-30-generic/kernel/drivers/pci/hotplug/shpchp.ko 70 | Sample: pid: 0 tid: 0 time: 0 71 | Mmap: pid: 4294967295, tid: 0, addr: ffffffffc0516000, len: 20480, pgoff: 0 - /lib/modules/4.8.0-30-generic/kernel/drivers/thermal/int340x_thermal/int3402_thermal.ko 72 | Sample: pid: 0 tid: 0 time: 0 73 | Mmap: pid: 4294967295, tid: 0, addr: ffffffffc051b000, len: 28672, pgoff: 0 - /lib/modules/4.8.0-30-generic/kernel/sound/core/snd-hwdep.ko 74 | Sample: pid: 0 tid: 0 time: 0 75 | Mmap: pid: 4294967295, tid: 0, addr: ffffffffc0522000, len: 172032, pgoff: 0 - /lib/modules/4.8.0-30-generic/kernel/drivers/gpu/drm/drm_kms_helper.ko 76 | Sample: pid: 0 tid: 0 time: 0 77 | Mmap: pid: 4294967295, tid: 0, addr: ffffffffc054c000, len: 20480, pgoff: 0 - /lib/modules/4.8.0-30-generic/kernel/drivers/thermal/int340x_thermal/int3406_thermal.ko 78 | Sample: pid: 0 tid: 0 time: 0 79 | Mmap: pid: 4294967295, tid: 0, addr: ffffffffc0551000, len: 20480, pgoff: 0 - /lib/modules/4.8.0-30-generic/kernel/drivers/i2c/busses/i2c-designware-platform.ko 80 | Sample: pid: 0 tid: 0 time: 0 81 | Mmap: pid: 4294967295, tid: 0, addr: ffffffffc0556000, len: 32768, pgoff: 0 - /lib/modules/4.8.0-30-generic/kernel/drivers/acpi/acpi_pad.ko 82 | Sample: pid: 0 tid: 0 time: 0 83 | Mmap: pid: 4294967295, tid: 0, addr: ffffffffc055e000, len: 1318912, pgoff: 0 - /lib/modules/4.8.0-30-generic/kernel/drivers/gpu/drm/i915/i915.ko 84 | Sample: pid: 0 tid: 0 time: 0 85 | Mmap: pid: 4294967295, tid: 0, addr: ffffffffc06a0000, len: 106496, pgoff: 0 - /lib/modules/4.8.0-30-generic/kernel/drivers/misc/mei/mei.ko 86 | Sample: pid: 0 tid: 0 time: 0 87 | Mmap: pid: 4294967295, tid: 0, addr: ffffffffc06ba000, len: 61440, pgoff: 0 - /lib/modules/4.8.0-30-generic/kernel/drivers/misc/mei/mei-me.ko 88 | Sample: pid: 0 tid: 0 time: 0 89 | Mmap: pid: 4294967295, tid: 0, addr: ffffffffc06c9000, len: 69632, pgoff: 0 - /lib/modules/4.8.0-30-generic/kernel/drivers/iio/industrialio.ko 90 | Sample: pid: 0 tid: 0 time: 0 91 | Mmap: pid: 4294967295, tid: 0, addr: ffffffffc06da000, len: 36864, pgoff: 0 - /lib/modules/4.8.0-30-generic/kernel/sound/core/snd-rawmidi.ko 92 | Sample: pid: 0 tid: 0 time: 0 93 | Mmap: pid: 4294967295, tid: 0, addr: ffffffffc06e3000, len: 20480, pgoff: 0 - /lib/modules/4.8.0-30-generic/kernel/drivers/thermal/int340x_thermal/acpi_thermal_rel.ko 94 | Sample: pid: 0 tid: 0 time: 0 95 | Mmap: pid: 4294967295, tid: 0, addr: ffffffffc06e8000, len: 20480, pgoff: 0 - /lib/modules/4.8.0-30-generic/kernel/drivers/iio/buffer/kfifo_buf.ko 96 | Sample: pid: 0 tid: 0 time: 0 97 | Mmap: pid: 4294967295, tid: 0, addr: ffffffffc06ed000, len: 20480, pgoff: 0 - /lib/modules/4.8.0-30-generic/kernel/drivers/platform/x86/asus-wireless.ko 98 | Sample: pid: 0 tid: 0 time: 0 99 | Mmap: pid: 4294967295, tid: 0, addr: ffffffffc06f2000, len: 20480, pgoff: 0 - /lib/modules/4.8.0-30-generic/kernel/drivers/iio/light/acpi-als.ko 100 | Sample: pid: 0 tid: 0 time: 0 101 | Mmap: pid: 4294967295, tid: 0, addr: ffffffffc06f7000, len: 32768, pgoff: 0 - /lib/modules/4.8.0-30-generic/kernel/drivers/thermal/int340x_thermal/int3400_thermal.ko 102 | Sample: pid: 0 tid: 0 time: 0 103 | Mmap: pid: 4294967295, tid: 0, addr: ffffffffc06ff000, len: 90112, pgoff: 0 - /lib/modules/4.8.0-30-generic/kernel/sound/core/snd.ko 104 | Sample: pid: 0 tid: 0 time: 0 105 | Mmap: pid: 4294967295, tid: 0, addr: ffffffffc0715000, len: 20480, pgoff: 0 - /lib/modules/4.8.0-30-generic/kernel/drivers/input/serio/serio_raw.ko 106 | Sample: pid: 0 tid: 0 time: 0 107 | Mmap: pid: 4294967295, tid: 0, addr: ffffffffc071a000, len: 20480, pgoff: 0 - /lib/modules/4.8.0-30-generic/kernel/sound/core/seq/snd-seq-midi.ko 108 | Sample: pid: 0 tid: 0 time: 0 109 | Mmap: pid: 4294967295, tid: 0, addr: ffffffffc071f000, len: 40960, pgoff: 0 - /lib/modules/4.8.0-30-generic/kernel/drivers/i2c/busses/i2c-designware-core.ko 110 | Sample: pid: 0 tid: 0 time: 0 111 | Mmap: pid: 4294967295, tid: 0, addr: ffffffffc0729000, len: 45056, pgoff: 0 - /lib/modules/4.8.0-30-generic/kernel/drivers/spi/spi-pxa2xx-platform.ko 112 | Sample: pid: 0 tid: 0 time: 0 113 | Mmap: pid: 4294967295, tid: 0, addr: ffffffffc0734000, len: 36864, pgoff: 0 - /lib/modules/4.8.0-30-generic/kernel/drivers/tty/serial/8250/8250_dw.ko 114 | Sample: pid: 0 tid: 0 time: 0 115 | Mmap: pid: 4294967295, tid: 0, addr: ffffffffc073d000, len: 40960, pgoff: 0 - /lib/modules/4.8.0-30-generic/kernel/sound/core/snd-timer.ko 116 | Sample: pid: 0 tid: 0 time: 0 117 | Mmap: pid: 4294967295, tid: 0, addr: ffffffffc0747000, len: 28672, pgoff: 0 - /lib/modules/4.8.0-30-generic/kernel/sound/soc/intel/common/snd-soc-sst-match.ko 118 | Sample: pid: 0 tid: 0 time: 0 119 | Mmap: pid: 4294967295, tid: 0, addr: ffffffffc074e000, len: 32768, pgoff: 0 - /lib/modules/4.8.0-30-generic/kernel/sound/soc/intel/common/snd-soc-sst-acpi.ko 120 | Sample: pid: 0 tid: 0 time: 0 121 | Mmap: pid: 4294967295, tid: 0, addr: ffffffffc0756000, len: 40960, pgoff: 0 - /lib/modules/4.8.0-30-generic/kernel/drivers/dma/dw/dw_dmac_core.ko 122 | Sample: pid: 0 tid: 0 time: 0 123 | Mmap: pid: 4294967295, tid: 0, addr: ffffffffc0760000, len: 20480, pgoff: 0 - /lib/modules/4.8.0-30-generic/kernel/sound/core/seq/snd-seq-device.ko 124 | Sample: pid: 0 tid: 0 time: 0 125 | Mmap: pid: 4294967295, tid: 0, addr: ffffffffc0765000, len: 20480, pgoff: 0 - /lib/modules/4.8.0-30-generic/kernel/arch/x86/events/intel/intel-rapl-perf.ko 126 | Sample: pid: 0 tid: 0 time: 0 127 | Mmap: pid: 4294967295, tid: 0, addr: ffffffffc076a000, len: 32768, pgoff: 0 - /lib/modules/4.8.0-30-generic/kernel/drivers/hwmon/coretemp.ko 128 | Sample: pid: 0 tid: 0 time: 0 129 | Mmap: pid: 4294967295, tid: 0, addr: ffffffffc0772000, len: 20480, pgoff: 0 - /lib/modules/4.8.0-30-generic/kernel/drivers/dma/dw/dw_dmac.ko 130 | Sample: pid: 0 tid: 0 time: 0 131 | Mmap: pid: 4294967295, tid: 0, addr: ffffffffc0777000, len: 73728, pgoff: 0 - /lib/modules/4.8.0-30-generic/kernel/sound/core/seq/snd-seq.ko 132 | Sample: pid: 0 tid: 0 time: 0 133 | Mmap: pid: 4294967295, tid: 0, addr: ffffffffc0789000, len: 114688, pgoff: 0 - /lib/modules/4.8.0-30-generic/kernel/sound/core/snd-pcm.ko 134 | Sample: pid: 0 tid: 0 time: 0 135 | Mmap: pid: 4294967295, tid: 0, addr: ffffffffc07a5000, len: 49152, pgoff: 0 - /lib/modules/4.8.0-30-generic/kernel/sound/pci/hda/snd-hda-intel.ko 136 | Sample: pid: 0 tid: 0 time: 0 137 | Mmap: pid: 4294967295, tid: 0, addr: ffffffffc07b1000, len: 90112, pgoff: 0 - /lib/modules/4.8.0-30-generic/kernel/sound/hda/snd-hda-core.ko 138 | Sample: pid: 0 tid: 0 time: 0 139 | Mmap: pid: 4294967295, tid: 0, addr: ffffffffc07c7000, len: 28672, pgoff: 0 - /lib/modules/4.8.0-30-generic/kernel/drivers/input/input-leds.ko 140 | Sample: pid: 0 tid: 0 time: 0 141 | Mmap: pid: 4294967295, tid: 0, addr: ffffffffc07ce000, len: 28672, pgoff: 0 - /lib/modules/4.8.0-30-generic/kernel/sound/pci/hda/snd-hda-codec-conexant.ko 142 | Sample: pid: 0 tid: 0 time: 0 143 | Mmap: pid: 4294967295, tid: 0, addr: ffffffffc07d5000, len: 40960, pgoff: 0 - /lib/modules/4.8.0-30-generic/kernel/drivers/input/joydev.ko 144 | Sample: pid: 0 tid: 0 time: 0 145 | Mmap: pid: 4294967295, tid: 0, addr: ffffffffc07df000, len: 36864, pgoff: 0 - /lib/modules/4.8.0-30-generic/kernel/drivers/mfd/lpc_ich.ko 146 | Sample: pid: 0 tid: 0 time: 0 147 | Mmap: pid: 4294967295, tid: 0, addr: ffffffffc07e8000, len: 139264, pgoff: 0 - /lib/modules/4.8.0-30-generic/kernel/sound/pci/hda/snd-hda-codec.ko 148 | Sample: pid: 0 tid: 0 time: 0 149 | Mmap: pid: 4294967295, tid: 0, addr: ffffffffc080a000, len: 20480, pgoff: 0 - /lib/modules/4.8.0-30-generic/kernel/arch/x86/events/intel/intel-cstate.ko 150 | Sample: pid: 0 tid: 0 time: 0 151 | Mmap: pid: 4294967295, tid: 0, addr: ffffffffc080f000, len: 20480, pgoff: 0 - /lib/modules/4.8.0-30-generic/kernel/arch/x86/crypto/glue_helper.ko 152 | Sample: pid: 0 tid: 0 time: 0 153 | Mmap: pid: 4294967295, tid: 0, addr: ffffffffc0814000, len: 20480, pgoff: 0 - /lib/modules/4.8.0-30-generic/kernel/crypto/arc4.ko 154 | Sample: pid: 0 tid: 0 time: 0 155 | Mmap: pid: 4294967295, tid: 0, addr: ffffffffc0819000, len: 28672, pgoff: 0 - /lib/modules/4.8.0-30-generic/kernel/crypto/cryptd.ko 156 | Sample: pid: 0 tid: 0 time: 0 157 | Mmap: pid: 4294967295, tid: 0, addr: ffffffffc0820000, len: 20480, pgoff: 0 - /lib/modules/4.8.0-30-generic/kernel/drivers/thermal/intel_pch_thermal.ko 158 | Sample: pid: 0 tid: 0 time: 0 159 | Mmap: pid: 4294967295, tid: 0, addr: ffffffffc0825000, len: 77824, pgoff: 0 - /lib/modules/4.8.0-30-generic/kernel/sound/pci/hda/snd-hda-codec-generic.ko 160 | Sample: pid: 0 tid: 0 time: 0 161 | Mmap: pid: 4294967295, tid: 0, addr: ffffffffc0838000, len: 53248, pgoff: 0 - /lib/modules/4.8.0-30-generic/kernel/sound/pci/hda/snd-hda-codec-hdmi.ko 162 | Sample: pid: 0 tid: 0 time: 0 163 | Mmap: pid: 4294967295, tid: 0, addr: ffffffffc0845000, len: 585728, pgoff: 0 - /lib/modules/4.8.0-30-generic/kernel/net/wireless/cfg80211.ko 164 | Sample: pid: 0 tid: 0 time: 0 165 | Mmap: pid: 4294967295, tid: 0, addr: ffffffffc08d4000, len: 20480, pgoff: 0 - /lib/modules/4.8.0-30-generic/kernel/drivers/input/sparse-keymap.ko 166 | Sample: pid: 0 tid: 0 time: 0 167 | Mmap: pid: 4294967295, tid: 0, addr: ffffffffc08d9000, len: 20480, pgoff: 0 - /lib/modules/4.8.0-30-generic/kernel/crypto/ablk_helper.ko 168 | Sample: pid: 0 tid: 0 time: 0 169 | Mmap: pid: 4294967295, tid: 0, addr: ffffffffc08de000, len: 20480, pgoff: 0 - /lib/modules/4.8.0-30-generic/kernel/arch/x86/crypto/ghash-clmulni-intel.ko 170 | Sample: pid: 0 tid: 0 time: 0 171 | Mmap: pid: 4294967295, tid: 0, addr: ffffffffc08e3000, len: 20480, pgoff: 0 - /lib/modules/4.8.0-30-generic/kernel/crypto/lrw.ko 172 | Sample: pid: 0 tid: 0 time: 0 173 | Mmap: pid: 4294967295, tid: 0, addr: ffffffffc08e8000, len: 24576, pgoff: 0 - /lib/modules/4.8.0-30-generic/kernel/arch/x86/crypto/aes-x86_64.ko 174 | Sample: pid: 0 tid: 0 time: 0 175 | Mmap: pid: 4294967295, tid: 0, addr: ffffffffc08ee000, len: 20480, pgoff: 0 - /lib/modules/4.8.0-30-generic/kernel/virt/lib/irqbypass.ko 176 | Sample: pid: 0 tid: 0 time: 0 177 | Mmap: pid: 4294967295, tid: 0, addr: ffffffffc08f3000, len: 40960, pgoff: 0 - /lib/modules/4.8.0-30-generic/kernel/drivers/platform/x86/asus-wmi.ko 178 | Sample: pid: 0 tid: 0 time: 0 179 | Mmap: pid: 4294967295, tid: 0, addr: ffffffffc08fd000, len: 253952, pgoff: 0 - /lib/modules/4.8.0-30-generic/kernel/arch/x86/crypto/crc32-pclmul.ko 180 | Sample: pid: 0 tid: 0 time: 0 181 | Mmap: pid: 4294967295, tid: 0, addr: ffffffffc093b000, len: 172032, pgoff: 0 - /lib/modules/4.8.0-30-generic/kernel/arch/x86/crypto/aesni-intel.ko 182 | Sample: pid: 0 tid: 0 time: 0 183 | Mmap: pid: 4294967295, tid: 0, addr: ffffffffc0965000, len: 765952, pgoff: 0 - /lib/modules/4.8.0-30-generic/kernel/net/mac80211/mac80211.ko 184 | Sample: pid: 0 tid: 0 time: 0 185 | Mmap: pid: 4294967295, tid: 0, addr: ffffffffc0a20000, len: 20480, pgoff: 0 - /lib/modules/4.8.0-30-generic/kernel/drivers/thermal/x86_pkg_temp_thermal.ko 186 | Sample: pid: 0 tid: 0 time: 0 187 | Mmap: pid: 4294967295, tid: 0, addr: ffffffffc0a25000, len: 20480, pgoff: 0 - /lib/modules/4.8.0-30-generic/kernel/fs/nls/nls_iso8859-1.ko 188 | Sample: pid: 0 tid: 0 time: 0 189 | Mmap: pid: 4294967295, tid: 0, addr: ffffffffc0a2a000, len: 24576, pgoff: 0 - /lib/modules/4.8.0-30-generic/kernel/drivers/powercap/intel_rapl.ko 190 | Sample: pid: 0 tid: 0 time: 0 191 | Mmap: pid: 4294967295, tid: 0, addr: ffffffffc0a30000, len: 28672, pgoff: 0 - /lib/modules/4.8.0-30-generic/kernel/drivers/platform/x86/asus-nb-wmi.ko 192 | Sample: pid: 0 tid: 0 time: 0 193 | Mmap: pid: 4294967295, tid: 0, addr: ffffffffc0a37000, len: 45056, pgoff: 0 - /lib/modules/4.8.0-30-generic/kernel/drivers/media/media.ko 194 | Sample: pid: 0 tid: 0 time: 0 195 | Mmap: pid: 4294967295, tid: 0, addr: ffffffffc0a42000, len: 24576, pgoff: 0 - /lib/modules/4.8.0-30-generic/kernel/drivers/media/v4l2-core/videobuf2-memops.ko 196 | Sample: pid: 0 tid: 0 time: 0 197 | Mmap: pid: 4294967295, tid: 0, addr: ffffffffc0a48000, len: 28672, pgoff: 0 - /lib/modules/4.8.0-30-generic/kernel/drivers/bluetooth/btintel.ko 198 | Sample: pid: 0 tid: 0 time: 0 199 | Mmap: pid: 4294967295, tid: 0, addr: ffffffffc0a4f000, len: 20480, pgoff: 0 - /lib/modules/4.8.0-30-generic/kernel/arch/x86/crypto/crct10dif-pclmul.ko 200 | Sample: pid: 0 tid: 0 time: 0 201 | Mmap: pid: 4294967295, tid: 0, addr: ffffffffc0a54000, len: 20480, pgoff: 0 - /lib/modules/4.8.0-30-generic/kernel/drivers/bluetooth/btbcm.ko 202 | Sample: pid: 0 tid: 0 time: 0 203 | Mmap: pid: 4294967295, tid: 0, addr: ffffffffc0a59000, len: 20480, pgoff: 0 - /lib/modules/4.8.0-30-generic/kernel/drivers/bluetooth/btrtl.ko 204 | Sample: pid: 0 tid: 0 time: 0 205 | Mmap: pid: 4294967295, tid: 0, addr: ffffffffc0a5e000, len: 364544, pgoff: 0 - /lib/modules/4.8.0-30-generic/kernel/drivers/net/wireless/intel/iwlwifi/iwlwifi.ko 206 | Sample: pid: 0 tid: 0 time: 0 207 | Mmap: pid: 4294967295, tid: 0, addr: ffffffffc0ab7000, len: 20480, pgoff: 0 - /lib/modules/4.8.0-30-generic/kernel/drivers/media/v4l2-core/videobuf2-vmalloc.ko 208 | Sample: pid: 0 tid: 0 time: 0 209 | Mmap: pid: 4294967295, tid: 0, addr: ffffffffc0abc000, len: 49152, pgoff: 0 - /lib/modules/4.8.0-30-generic/kernel/drivers/bluetooth/btusb.ko 210 | Sample: pid: 0 tid: 0 time: 0 211 | Mmap: pid: 4294967295, tid: 0, addr: ffffffffc0ac8000, len: 602112, pgoff: 0 - /lib/modules/4.8.0-30-generic/kernel/arch/x86/kvm/kvm.ko 212 | Sample: pid: 0 tid: 0 time: 0 213 | Mmap: pid: 4294967295, tid: 0, addr: ffffffffc0b5b000, len: 565248, pgoff: 0 - /lib/modules/4.8.0-30-generic/kernel/net/bluetooth/bluetooth.ko 214 | Sample: pid: 0 tid: 0 time: 0 215 | Mmap: pid: 4294967295, tid: 0, addr: ffffffffc0be5000, len: 28672, pgoff: 0 - /lib/modules/4.8.0-30-generic/kernel/drivers/media/v4l2-core/videobuf2-v4l2.ko 216 | Sample: pid: 0 tid: 0 time: 0 217 | Mmap: pid: 4294967295, tid: 0, addr: ffffffffc0bec000, len: 94208, pgoff: 0 - /lib/modules/4.8.0-30-generic/kernel/drivers/media/usb/uvc/uvcvideo.ko 218 | Sample: pid: 0 tid: 0 time: 0 219 | Mmap: pid: 4294967295, tid: 0, addr: ffffffffc0c03000, len: 24576, pgoff: 0 - /lib/modules/4.8.0-30-generic/kernel/net/bluetooth/bnep/bnep.ko 220 | Sample: pid: 0 tid: 0 time: 0 221 | Mmap: pid: 4294967295, tid: 0, addr: ffffffffc0c09000, len: 184320, pgoff: 0 - /lib/modules/4.8.0-30-generic/kernel/drivers/media/v4l2-core/videodev.ko 222 | Sample: pid: 0 tid: 0 time: 0 223 | Mmap: pid: 4294967295, tid: 0, addr: ffffffffc0c36000, len: 20480, pgoff: 0 - /lib/modules/4.8.0-30-generic/kernel/arch/x86/kernel/msr.ko 224 | Sample: pid: 0 tid: 0 time: 0 225 | Mmap: pid: 4294967295, tid: 0, addr: ffffffffc0c3b000, len: 20480, pgoff: 0 - /lib/modules/4.8.0-30-generic/kernel/drivers/char/nvram.ko 226 | Sample: pid: 0 tid: 0 time: 0 227 | Mmap: pid: 4294967295, tid: 0, addr: ffffffffc0c40000, len: 24576, pgoff: 0 - /lib/modules/4.8.0-30-generic/kernel/crypto/ccm.ko 228 | Sample: pid: 0 tid: 0 time: 0 229 | Mmap: pid: 4294967295, tid: 0, addr: ffffffffc0c46000, len: 45056, pgoff: 0 - /lib/modules/4.8.0-30-generic/kernel/drivers/media/v4l2-core/videobuf2-core.ko 230 | Sample: pid: 0 tid: 0 time: 0 231 | Mmap: pid: 4294967295, tid: 0, addr: ffffffffc0c51000, len: 81920, pgoff: 0 - /lib/modules/4.8.0-30-generic/kernel/net/bluetooth/rfcomm/rfcomm.ko 232 | Sample: pid: 0 tid: 0 time: 0 233 | Mmap: pid: 4294967295, tid: 0, addr: ffffffffc0c65000, len: 20480, pgoff: 0 - /lib/modules/4.8.0-30-generic/kernel/crypto/cmac.ko 234 | Sample: pid: 0 tid: 0 time: 0 235 | Mmap: pid: 4294967295, tid: 0, addr: ffffffffc0c6a000, len: 118784, pgoff: 0 - /lib/modules/4.8.0-30-generic/kernel/drivers/usb/storage/usb-storage.ko 236 | Sample: pid: 0 tid: 0 time: 0 237 | Mmap: pid: 4294967295, tid: 0, addr: ffffffffc0c87000, len: 28672, pgoff: 0 - /lib/modules/4.8.0-30-generic/kernel/drivers/usb/storage/uas.ko 238 | Sample: pid: 0 tid: 0 time: 0 239 | Mmap: pid: 4294967295, tid: 0, addr: ffffffffc0c8e000, len: 1089536, pgoff: 0 - /lib/modules/4.8.0-30-generic/kernel/drivers/net/wireless/intel/iwlwifi/mvm/iwlmvm.ko 240 | Sample: pid: 0 tid: 0 time: 0 241 | Mmap: pid: 4294967295, tid: 0, addr: ffffffffc0d98000, len: 1059487743, pgoff: 0 - /lib/modules/4.8.0-30-generic/kernel/arch/x86/kvm/kvm-intel.ko 242 | Sample: pid: 0 tid: 0 time: 0 243 | Comm: pid: 19321, tid:19321, comm: perf 244 | Sample: pid: 0 tid: 0 time: 0 245 | Sample: ip: ffffffffa1f8784c pid: 19321 tid: 19321 time: 28243780506164 period: 1 246 | Sample: ip: ffffffffa1e0d664 pid: 19321 tid: 19321 time: 28243780509236 period: 1 247 | Sample: ip: ffffffffa1e36f43 pid: 19321 tid: 19321 time: 28243780510762 period: 10 248 | Sample: ip: ffffffffa1e36f43 pid: 19321 tid: 19321 time: 28243780512222 period: 208 249 | Sample: ip: ffffffffa1e37039 pid: 19321 tid: 19321 time: 28243780513711 period: 4641 250 | Comm: pid: 19321, tid:19321, comm: sleep 251 | Sample: pid: 19321 tid: 19321 time: 28243780514767 252 | Sample: ip: ffffffffa203a817 pid: 19321 tid: 19321 time: 28243780516105 period: 101267 253 | Mmap2: pid: 19321, tid: 19321, addr: 400000, len: 28672, pgoff: 0 - /bin/sleep 254 | dev: 8:5 inode: 12058743, inode generation: 3518563414, prot: 5, flags: 6146 255 | Sample: pid: 19321 tid: 19321 time: 28243780524408 256 | Mmap2: pid: 19321, tid: 19321, addr: 7f5e50d32000, len: 2260992, pgoff: 0 - /lib/x86_64-linux-gnu/ld-2.23.so 257 | dev: 8:5 inode: 5117017, inode generation: 3481120611, prot: 5, flags: 6146 258 | Sample: pid: 19321 tid: 19321 time: 28243780532305 259 | Mmap2: pid: 19321, tid: 19321, addr: 7ffe6ff5f000, len: 8192, pgoff: 0 - [vdso] 260 | dev: 0:0 inode: 0, inode generation: 0, prot: 0, flags: 0 261 | Sample: pid: 19321 tid: 19321 time: 28243780543252 262 | Sample: ip: ffffffffa222c6c0 pid: 19321 tid: 19321 time: 28243780552396 period: 1413261 263 | Mmap2: pid: 19321, tid: 19321, addr: 7f5e50969000, len: 3969024, pgoff: 0 - /lib/x86_64-linux-gnu/libc-2.23.so 264 | dev: 8:5 inode: 5118780, inode generation: 3481120622, prot: 5, flags: 4098 265 | Sample: pid: 19321 tid: 19321 time: 28243780607396 266 | Exit: pid: 19321, ppid: 19321, tid:19321, ptid: 19321, time: 28244781002998 267 | Sample: pid: 19321 tid: 19321 time: 28244781002721 268 | -------------------------------------------------------------------------------- /tests/dump_test.rs: -------------------------------------------------------------------------------- 1 | use std::io::Read; 2 | 3 | #[test] 4 | fn test_chdir() { 5 | let output = std::process::Command::new("target/debug/examples/dump") 6 | .arg("tests/perf.data") 7 | .output() 8 | .expect("failed to run dump example"); 9 | 10 | let mut expected = Vec::new(); 11 | 12 | std::fs::File::open("tests/dump.stdout").expect("cannot open dump.stdout") 13 | .read_to_end(&mut expected).expect("cannot read dump.stdout"); 14 | 15 | assert_eq!(expected, output.stdout); 16 | } 17 | -------------------------------------------------------------------------------- /tests/perf.data: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mikhail-m1/linux-perf-file-reader/64ba7c12a02ec0d71e3529e88ea4e89bf52280e4/tests/perf.data --------------------------------------------------------------------------------