diff --git a/LICENSE b/LICENSE index ee5839968a2bf86c93283efc09d40fd050b7cfa2..9e32cdef1625daed25cf365c865f01050877cff3 100644 --- a/LICENSE +++ b/LICENSE @@ -1,127 +1,127 @@ - 木兰宽松许可证, 第2版 - - 木兰宽松许可证, 第2版 - 2020年1月 http://license.coscl.org.cn/MulanPSL2 - - - 您对“软件”的复制、使用、修改及分发受木兰宽松许可证,第2版(“本许可证”)的如下条款的约束: - - 0. 定义 - - “软件”是指由“贡献”构成的许可在“本许可证”下的程序和相关文档的集合。 - - “贡献”是指由任一“贡献者”许可在“本许可证”下的受版权法保护的作品。 - - “贡献者”是指将受版权法保护的作品许可在“本许可证”下的自然人或“法人实体”。 - - “法人实体”是指提交贡献的机构及其“关联实体”。 - - “关联实体”是指,对“本许可证”下的行为方而言,控制、受控制或与其共同受控制的机构,此处的控制是指有受控方或共同受控方至少50%直接或间接的投票权、资金或其他有价证券。 - - 1. 授予版权许可 - - 每个“贡献者”根据“本许可证”授予您永久性的、全球性的、免费的、非独占的、不可撤销的版权许可,您可以复制、使用、修改、分发其“贡献”,不论修改与否。 - - 2. 授予专利许可 - - 每个“贡献者”根据“本许可证”授予您永久性的、全球性的、免费的、非独占的、不可撤销的(根据本条规定撤销除外)专利许可,供您制造、委托制造、使用、许诺销售、销售、进口其“贡献”或以其他方式转移其“贡献”。前述专利许可仅限于“贡献者”现在或将来拥有或控制的其“贡献”本身或其“贡献”与许可“贡献”时的“软件”结合而将必然会侵犯的专利权利要求,不包括对“贡献”的修改或包含“贡献”的其他结合。如果您或您的“关联实体”直接或间接地,就“软件”或其中的“贡献”对任何人发起专利侵权诉讼(包括反诉或交叉诉讼)或其他专利维权行动,指控其侵犯专利权,则“本许可证”授予您对“软件”的专利许可自您提起诉讼或发起维权行动之日终止。 - - 3. 无商标许可 - - “本许可证”不提供对“贡献者”的商品名称、商标、服务标志或产品名称的商标许可,但您为满足第4条规定的声明义务而必须使用除外。 - - 4. 分发限制 - - 您可以在任何媒介中将“软件”以源程序形式或可执行形式重新分发,不论修改与否,但您必须向接收者提供“本许可证”的副本,并保留“软件”中的版权、商标、专利及免责声明。 - - 5. 免责声明与责任限制 - - “软件”及其中的“贡献”在提供时不带任何明示或默示的担保。在任何情况下,“贡献者”或版权所有者不对任何人因使用“软件”或其中的“贡献”而引发的任何直接或间接损失承担责任,不论因何种原因导致或者基于何种法律理论,即使其曾被建议有此种损失的可能性。 - - 6. 语言 - “本许可证”以中英文双语表述,中英文版本具有同等法律效力。如果中英文版本存在任何冲突不一致,以中文版为准。 - - 条款结束 - - 如何将木兰宽松许可证,第2版,应用到您的软件 - - 如果您希望将木兰宽松许可证,第2版,应用到您的新软件,为了方便接收者查阅,建议您完成如下三步: - - 1, 请您补充如下声明中的空白,包括软件名、软件的首次发表年份以及您作为版权人的名字; - - 2, 请您在软件包的一级目录下创建以“LICENSE”为名的文件,将整个许可证文本放入该文件中; - - 3, 请将如下声明文本放入每个源文件的头部注释中。 - - Copyright (c) [Year] [name of copyright holder] - [Software Name] is licensed under Mulan PSL v2. - You can use this software according to the terms and conditions of the Mulan PSL v2. - You may obtain a copy of Mulan PSL v2 at: - http://license.coscl.org.cn/MulanPSL2 - THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. - See the Mulan PSL v2 for more details. - - - Mulan Permissive Software License,Version 2 - - Mulan Permissive Software License,Version 2 (Mulan PSL v2) - January 2020 http://license.coscl.org.cn/MulanPSL2 - - Your reproduction, use, modification and distribution of the Software shall be subject to Mulan PSL v2 (this License) with the following terms and conditions: - - 0. Definition - - Software means the program and related documents which are licensed under this License and comprise all Contribution(s). - - Contribution means the copyrightable work licensed by a particular Contributor under this License. - - Contributor means the Individual or Legal Entity who licenses its copyrightable work under this License. - - Legal Entity means the entity making a Contribution and all its Affiliates. - - Affiliates means entities that control, are controlled by, or are under common control with the acting entity under this License, ‘control’ means direct or indirect ownership of at least fifty percent (50%) of the voting power, capital or other securities of controlled or commonly controlled entity. - - 1. Grant of Copyright License - - Subject to the terms and conditions of this License, each Contributor hereby grants to you a perpetual, worldwide, royalty-free, non-exclusive, irrevocable copyright license to reproduce, use, modify, or distribute its Contribution, with modification or not. - - 2. Grant of Patent License - - Subject to the terms and conditions of this License, each Contributor hereby grants to you a perpetual, worldwide, royalty-free, non-exclusive, irrevocable (except for revocation under this Section) patent license to make, have made, use, offer for sale, sell, import or otherwise transfer its Contribution, where such patent license is only limited to the patent claims owned or controlled by such Contributor now or in future which will be necessarily infringed by its Contribution alone, or by combination of the Contribution with the Software to which the Contribution was contributed. The patent license shall not apply to any modification of the Contribution, and any other combination which includes the Contribution. If you or your Affiliates directly or indirectly institute patent litigation (including a cross claim or counterclaim in a litigation) or other patent enforcement activities against any individual or entity by alleging that the Software or any Contribution in it infringes patents, then any patent license granted to you under this License for the Software shall terminate as of the date such litigation or activity is filed or taken. - - 3. No Trademark License - - No trademark license is granted to use the trade names, trademarks, service marks, or product names of Contributor, except as required to fulfill notice requirements in Section 4. - - 4. Distribution Restriction - - You may distribute the Software in any medium with or without modification, whether in source or executable forms, provided that you provide recipients with a copy of this License and retain copyright, patent, trademark and disclaimer statements in the Software. - - 5. Disclaimer of Warranty and Limitation of Liability - - THE SOFTWARE AND CONTRIBUTION IN IT ARE PROVIDED WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED. IN NO EVENT SHALL ANY CONTRIBUTOR OR COPYRIGHT HOLDER BE LIABLE TO YOU FOR ANY DAMAGES, INCLUDING, BUT NOT LIMITED TO ANY DIRECT, OR INDIRECT, SPECIAL OR CONSEQUENTIAL DAMAGES ARISING FROM YOUR USE OR INABILITY TO USE THE SOFTWARE OR THE CONTRIBUTION IN IT, NO MATTER HOW IT’S CAUSED OR BASED ON WHICH LEGAL THEORY, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. - - 6. Language - - THIS LICENSE IS WRITTEN IN BOTH CHINESE AND ENGLISH, AND THE CHINESE VERSION AND ENGLISH VERSION SHALL HAVE THE SAME LEGAL EFFECT. IN THE CASE OF DIVERGENCE BETWEEN THE CHINESE AND ENGLISH VERSIONS, THE CHINESE VERSION SHALL PREVAIL. - - END OF THE TERMS AND CONDITIONS - - How to Apply the Mulan Permissive Software License,Version 2 (Mulan PSL v2) to Your Software - - To apply the Mulan PSL v2 to your work, for easy identification by recipients, you are suggested to complete following three steps: - - i Fill in the blanks in following statement, including insert your software name, the year of the first publication of your software, and your name identified as the copyright owner; - - ii Create a file named “LICENSE” which contains the whole context of this License in the first directory of your software package; - - iii Attach the statement to the appropriate annotated syntax at the beginning of each source file. - - - Copyright (c) [Year] [name of copyright holder] - [Software Name] is licensed under Mulan PSL v2. - You can use this software according to the terms and conditions of the Mulan PSL v2. - You may obtain a copy of Mulan PSL v2 at: - http://license.coscl.org.cn/MulanPSL2 - THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. - See the Mulan PSL v2 for more details. + 木兰宽松许可证, 第2版 + + 木兰宽松许可证, 第2版 + 2020年1月 http://license.coscl.org.cn/MulanPSL2 + + + 您对“软件”的复制、使用、修改及分发受木兰宽松许可证,第2版(“本许可证”)的如下条款的约束: + + 0. 定义 + + “软件”是指由“贡献”构成的许可在“本许可证”下的程序和相关文档的集合。 + + “贡献”是指由任一“贡献者”许可在“本许可证”下的受版权法保护的作品。 + + “贡献者”是指将受版权法保护的作品许可在“本许可证”下的自然人或“法人实体”。 + + “法人实体”是指提交贡献的机构及其“关联实体”。 + + “关联实体”是指,对“本许可证”下的行为方而言,控制、受控制或与其共同受控制的机构,此处的控制是指有受控方或共同受控方至少50%直接或间接的投票权、资金或其他有价证券。 + + 1. 授予版权许可 + + 每个“贡献者”根据“本许可证”授予您永久性的、全球性的、免费的、非独占的、不可撤销的版权许可,您可以复制、使用、修改、分发其“贡献”,不论修改与否。 + + 2. 授予专利许可 + + 每个“贡献者”根据“本许可证”授予您永久性的、全球性的、免费的、非独占的、不可撤销的(根据本条规定撤销除外)专利许可,供您制造、委托制造、使用、许诺销售、销售、进口其“贡献”或以其他方式转移其“贡献”。前述专利许可仅限于“贡献者”现在或将来拥有或控制的其“贡献”本身或其“贡献”与许可“贡献”时的“软件”结合而将必然会侵犯的专利权利要求,不包括对“贡献”的修改或包含“贡献”的其他结合。如果您或您的“关联实体”直接或间接地,就“软件”或其中的“贡献”对任何人发起专利侵权诉讼(包括反诉或交叉诉讼)或其他专利维权行动,指控其侵犯专利权,则“本许可证”授予您对“软件”的专利许可自您提起诉讼或发起维权行动之日终止。 + + 3. 无商标许可 + + “本许可证”不提供对“贡献者”的商品名称、商标、服务标志或产品名称的商标许可,但您为满足第4条规定的声明义务而必须使用除外。 + + 4. 分发限制 + + 您可以在任何媒介中将“软件”以源程序形式或可执行形式重新分发,不论修改与否,但您必须向接收者提供“本许可证”的副本,并保留“软件”中的版权、商标、专利及免责声明。 + + 5. 免责声明与责任限制 + + “软件”及其中的“贡献”在提供时不带任何明示或默示的担保。在任何情况下,“贡献者”或版权所有者不对任何人因使用“软件”或其中的“贡献”而引发的任何直接或间接损失承担责任,不论因何种原因导致或者基于何种法律理论,即使其曾被建议有此种损失的可能性。 + + 6. 语言 + “本许可证”以中英文双语表述,中英文版本具有同等法律效力。如果中英文版本存在任何冲突不一致,以中文版为准。 + + 条款结束 + + 如何将木兰宽松许可证,第2版,应用到您的软件 + + 如果您希望将木兰宽松许可证,第2版,应用到您的新软件,为了方便接收者查阅,建议您完成如下三步: + + 1, 请您补充如下声明中的空白,包括软件名、软件的首次发表年份以及您作为版权人的名字; + + 2, 请您在软件包的一级目录下创建以“LICENSE”为名的文件,将整个许可证文本放入该文件中; + + 3, 请将如下声明文本放入每个源文件的头部注释中。 + + Copyright (c) [Year] [name of copyright holder] + [Software Name] is licensed under Mulan PSL v2. + You can use this software according to the terms and conditions of the Mulan PSL v2. + You may obtain a copy of Mulan PSL v2 at: + http://license.coscl.org.cn/MulanPSL2 + THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. + See the Mulan PSL v2 for more details. + + + Mulan Permissive Software License,Version 2 + + Mulan Permissive Software License,Version 2 (Mulan PSL v2) + January 2020 http://license.coscl.org.cn/MulanPSL2 + + Your reproduction, use, modification and distribution of the Software shall be subject to Mulan PSL v2 (this License) with the following terms and conditions: + + 0. Definition + + Software means the program and related documents which are licensed under this License and comprise all Contribution(s). + + Contribution means the copyrightable work licensed by a particular Contributor under this License. + + Contributor means the Individual or Legal Entity who licenses its copyrightable work under this License. + + Legal Entity means the entity making a Contribution and all its Affiliates. + + Affiliates means entities that control, are controlled by, or are under common control with the acting entity under this License, ‘control’ means direct or indirect ownership of at least fifty percent (50%) of the voting power, capital or other securities of controlled or commonly controlled entity. + + 1. Grant of Copyright License + + Subject to the terms and conditions of this License, each Contributor hereby grants to you a perpetual, worldwide, royalty-free, non-exclusive, irrevocable copyright license to reproduce, use, modify, or distribute its Contribution, with modification or not. + + 2. Grant of Patent License + + Subject to the terms and conditions of this License, each Contributor hereby grants to you a perpetual, worldwide, royalty-free, non-exclusive, irrevocable (except for revocation under this Section) patent license to make, have made, use, offer for sale, sell, import or otherwise transfer its Contribution, where such patent license is only limited to the patent claims owned or controlled by such Contributor now or in future which will be necessarily infringed by its Contribution alone, or by combination of the Contribution with the Software to which the Contribution was contributed. The patent license shall not apply to any modification of the Contribution, and any other combination which includes the Contribution. If you or your Affiliates directly or indirectly institute patent litigation (including a cross claim or counterclaim in a litigation) or other patent enforcement activities against any individual or entity by alleging that the Software or any Contribution in it infringes patents, then any patent license granted to you under this License for the Software shall terminate as of the date such litigation or activity is filed or taken. + + 3. No Trademark License + + No trademark license is granted to use the trade names, trademarks, service marks, or product names of Contributor, except as required to fulfill notice requirements in Section 4. + + 4. Distribution Restriction + + You may distribute the Software in any medium with or without modification, whether in source or executable forms, provided that you provide recipients with a copy of this License and retain copyright, patent, trademark and disclaimer statements in the Software. + + 5. Disclaimer of Warranty and Limitation of Liability + + THE SOFTWARE AND CONTRIBUTION IN IT ARE PROVIDED WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED. IN NO EVENT SHALL ANY CONTRIBUTOR OR COPYRIGHT HOLDER BE LIABLE TO YOU FOR ANY DAMAGES, INCLUDING, BUT NOT LIMITED TO ANY DIRECT, OR INDIRECT, SPECIAL OR CONSEQUENTIAL DAMAGES ARISING FROM YOUR USE OR INABILITY TO USE THE SOFTWARE OR THE CONTRIBUTION IN IT, NO MATTER HOW IT’S CAUSED OR BASED ON WHICH LEGAL THEORY, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. + + 6. Language + + THIS LICENSE IS WRITTEN IN BOTH CHINESE AND ENGLISH, AND THE CHINESE VERSION AND ENGLISH VERSION SHALL HAVE THE SAME LEGAL EFFECT. IN THE CASE OF DIVERGENCE BETWEEN THE CHINESE AND ENGLISH VERSIONS, THE CHINESE VERSION SHALL PREVAIL. + + END OF THE TERMS AND CONDITIONS + + How to Apply the Mulan Permissive Software License,Version 2 (Mulan PSL v2) to Your Software + + To apply the Mulan PSL v2 to your work, for easy identification by recipients, you are suggested to complete following three steps: + + i Fill in the blanks in following statement, including insert your software name, the year of the first publication of your software, and your name identified as the copyright owner; + + ii Create a file named “LICENSE” which contains the whole context of this License in the first directory of your software package; + + iii Attach the statement to the appropriate annotated syntax at the beginning of each source file. + + + Copyright (c) [Year] [name of copyright holder] + [Software Name] is licensed under Mulan PSL v2. + You can use this software according to the terms and conditions of the Mulan PSL v2. + You may obtain a copy of Mulan PSL v2 at: + http://license.coscl.org.cn/MulanPSL2 + THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. + See the Mulan PSL v2 for more details. diff --git a/python/modules/_libkperf/Config.py b/python/modules/_libkperf/Config.py index 1f718d4352276fa5f7d7894bb72cd105fdf6b620..aef5f1920bafd329be96b973e853a30f09db0ea0 100644 --- a/python/modules/_libkperf/Config.py +++ b/python/modules/_libkperf/Config.py @@ -38,7 +38,7 @@ def libkperf_path() -> str: sym_so = ctypes.CDLL(libsym_path(), mode=ctypes.RTLD_GLOBAL) -kperf_so = ctypes.CDLL(libkperf_path()) +kperf_so = ctypes.CDLL(libkperf_path(), mode=ctypes.RTLD_GLOBAL) __all__ = [ diff --git a/python/modules/_libkperf/Perror.py b/python/modules/_libkperf/Perror.py index 028d4ffd0ef36e8f62b7f198ddea387249c8c920..042aa2cd6f738af60f53a6406fc057653059ddd0 100644 --- a/python/modules/_libkperf/Perror.py +++ b/python/modules/_libkperf/Perror.py @@ -18,20 +18,52 @@ from .Config import UTF_8, kperf_so def Perrorno() -> int: + """ + int Perrorno(); + """ c_Perrorno = kperf_so.Perrorno c_Perrorno.argtypes = [] c_Perrorno.restype = ctypes.c_int + return c_Perrorno() def Perror() -> str: + """ + const char* Perror(); + """ c_Perror = kperf_so.Perror c_Perror.argtypes = [] c_Perror.restype = ctypes.c_char_p + return c_Perror().decode(UTF_8) +def GetWarn() -> int: + """ + int GetWarn(); + """ + c_GetWarn = kperf_so.GetWarn + c_GetWarn.argtypes = [] + c_GetWarn.restype = ctypes.c_int + + return c_GetWarn() + + +def GetWarnMsg() -> str: + """ + const char* GetWarnMsg(); + """ + c_GetWarnMsg = kperf_so.GetWarnMsg + c_GetWarnMsg.argtypes = [] + c_GetWarnMsg.restype = ctypes.c_char_p + + return c_GetWarnMsg().decode(UTF_8) + + __all__ = [ 'Perrorno', 'Perror', + 'GetWarn', + 'GetWarnMsg', ] diff --git a/python/modules/_libkperf/Pmu.py b/python/modules/_libkperf/Pmu.py index e9f4cf4a9b88c54af8e21ab649b06593e2ec544c..1055547e1c84edc287775e70a7682cc04bb53548 100644 --- a/python/modules/_libkperf/Pmu.py +++ b/python/modules/_libkperf/Pmu.py @@ -28,22 +28,48 @@ class SampleRateUnion(ctypes.Union): class CtypesPmuAttr(ctypes.Structure): + """ + struct PmuAttr { + char** evtList; // event list + unsigned numEvt; // length of event list + int* pidList; // pid list + unsigned numPid; // length of pid list + int* cpuList; // cpu id list + unsigned numCpu; // length of cpu id list + + union { + unsigned period; // sample period + unsigned freq; // sample frequency + }; + unsigned useFreq : 1; + unsigned excludeUser : 1; // don't count user + unsigned excludeKernel : 1; // don't count kernel + enum SymbolMode symbolMode; // refer to comments of SymbolMode + unsigned callStack : 1; // collect complete call stack + // SPE related fields. + enum SpeFilter dataFilter; // spe data filter + enum SpeEventFilter evFilter; // spe event filter + unsigned long minLatency; // collect only samples with latency or higher + }; + """ - _fields_ = [('evtList', ctypes.POINTER(ctypes.c_char_p)), - ('numEvt', ctypes.c_uint), - ('pidList', ctypes.POINTER(ctypes.c_int)), - ('numPid', ctypes.c_uint), - ('cpuList', ctypes.POINTER(ctypes.c_int)), - ('numCpu', ctypes.c_uint), - ('sampleRate', SampleRateUnion), - ('useFreq', ctypes.c_bool), - ('excludeUser', ctypes.c_bool), - ('excludeKernel', ctypes.c_bool), - ('symbolMode', ctypes.c_uint), - ('callStack', ctypes.c_bool), - ('dataFilter', ctypes.c_uint64), # The enumeration for dataFilter will use 64 bits - ('evFilter', ctypes.c_uint), - ('minLatency', ctypes.c_ulong)] + _fields_ = [ + ('evtList', ctypes.POINTER(ctypes.c_char_p)), + ('numEvt', ctypes.c_uint), + ('pidList', ctypes.POINTER(ctypes.c_int)), + ('numPid', ctypes.c_uint), + ('cpuList', ctypes.POINTER(ctypes.c_int)), + ('numCpu', ctypes.c_uint), + ('sampleRate', SampleRateUnion), + ('useFreq', ctypes.c_bool), + ('excludeUser', ctypes.c_bool), + ('excludeKernel', ctypes.c_bool), + ('symbolMode', ctypes.c_uint), + ('callStack', ctypes.c_bool), + ('dataFilter', ctypes.c_uint64), # The enumeration for dataFilter will use 64 bits + ('evFilter', ctypes.c_uint), + ('minLatency', ctypes.c_ulong) + ] def __init__(self, evtList: List[str] = None, @@ -164,10 +190,10 @@ class PmuAttr: return [self.c_pmu_attr.pidList[i] for i in range(self.numPid)] @pidList.setter - def pidList(self, pidList: List[str]) -> None: + def pidList(self, pidList: List[int]) -> None: if pidList: numPid = len(pidList) - self.c_pmu_attr.pidList = (ctypes.c_char_p * numPid)(*[pid.encode(UTF_8) for pid in pidList]) + self.c_pmu_attr.pidList = (ctypes.c_int * numPid)(*[pid for pid in pidList]) self.c_pmu_attr.numPid = ctypes.c_uint(numPid) else: self.c_pmu_attr.pidList = None @@ -182,10 +208,10 @@ class PmuAttr: return [self.c_pmu_attr.cpuList[i] for i in range(self.numCpu)] @cpuList.setter - def cpuList(self, cpuList: List[str]) -> None: + def cpuList(self, cpuList: List[int]) -> None: if cpuList: numCpu = len(cpuList) - self.c_pmu_attr.cpuList = (ctypes.c_char_p * numCpu)(*[cpu.encode(UTF_8) for cpu in cpuList]) + self.c_pmu_attr.cpuList = (ctypes.c_int * numCpu)(*[cpu for cpu in cpuList]) self.c_pmu_attr.numCpu = ctypes.c_uint(numCpu) else: self.c_pmu_attr.cpuList = None @@ -281,6 +307,13 @@ class PmuAttr: class CtypesCpuTopology(ctypes.Structure): + """ + struct CpuTopology { + int coreId; + int numaId; + int socketId; + }; + """ _fields_ = [ ('coreId', ctypes.c_int), @@ -350,6 +383,13 @@ class CpuTopology: class CtypesPmuDataExt(ctypes.Structure): + """ + struct PmuDataExt { + unsigned long pa; // physical address + unsigned long va; // virtual address + unsigned long event; // event id + }; + """ _fields_ = [ ('pa', ctypes.c_ulong), @@ -417,6 +457,22 @@ class PmuDataExt: class CtypesPmuData(ctypes.Structure): + """ + struct PmuData { + struct Stack* stack; // call stack + const char *evt; // event name + int64_t ts; // time stamp + pid_t pid; // process id + int tid; // thread id + unsigned cpu; // cpu id + struct CpuTopology *cpuTopo; // cpu topology + const char *comm; // process command + uint64_t period; // number of Samples + uint64_t count; // event count. Only available for Counting. + struct PmuDataExt *ext; // extension. Only available for Spe. + }; + """ + _fields_ = [ ('stack', ctypes.POINTER(CtypesStack)), ('evt', ctypes.c_char_p), @@ -616,6 +672,9 @@ class PmuData: def PmuOpen(collectType: int, pmuAttr: PmuAttr) -> int: + """ + int PmuOpen(enum PmuTaskType collectType, struct PmuAttr *attr); + """ c_PmuOpen = kperf_so.PmuOpen c_PmuOpen.argtypes = [ctypes.c_int, ctypes.POINTER(CtypesPmuAttr)] c_PmuOpen.restype = ctypes.c_int @@ -626,6 +685,9 @@ def PmuOpen(collectType: int, pmuAttr: PmuAttr) -> int: def PmuEventListFree() -> None: + """ + int PmuOpen(enum PmuTaskType collectType, struct PmuAttr *attr); + """ c_PmuEventListFree = kperf_so.PmuEventListFree c_PmuEventListFree.argtypes = [] c_PmuEventListFree.restype = None @@ -634,6 +696,9 @@ def PmuEventListFree() -> None: def PmuEventList(eventType: int) -> Iterator[str]: + """ + const char** PmuEventList(enum PmuEventType eventType, unsigned *numEvt); + """ c_PmuEventList = kperf_so.PmuEventList c_PmuEventList.argtypes = [ctypes.c_int] c_PmuEventList.restype = ctypes.POINTER(ctypes.c_char_p) @@ -646,6 +711,9 @@ def PmuEventList(eventType: int) -> Iterator[str]: def PmuEnable(pd: int) -> int: + """ + int PmuEnable(int pd); + """ c_PmuEnable = kperf_so.PmuEnable c_PmuEnable.argtypes = [ctypes.c_int] c_PmuEnable.restype = ctypes.c_int @@ -656,6 +724,9 @@ def PmuEnable(pd: int) -> int: def PmuDisable(pd: int) -> int: + """ + int PmuDisable(int pd); + """ c_PmuDisable = kperf_so.PmuDisable c_PmuDisable.argtypes = [ctypes.c_int] c_PmuDisable.restype = ctypes.c_int @@ -666,6 +737,9 @@ def PmuDisable(pd: int) -> int: def PmuCollect(pd: int, milliseconds: int, interval: int) -> int: + """ + int PmuCollect(int pd, int milliseconds, unsigned interval); + """ c_PmuCollect = kperf_so.PmuCollect c_PmuCollect.argtypes = [ctypes.c_int, ctypes.c_int, ctypes.c_uint] c_PmuCollect.restype = ctypes.c_int @@ -678,6 +752,9 @@ def PmuCollect(pd: int, milliseconds: int, interval: int) -> int: def PmuStop(pd: int) -> None: + """ + void PmuStop(int pd); + """ c_PmuStop = kperf_so.PmuStop c_PmuStop.argtypes = [ctypes.c_int] c_PmuStop.restype = None @@ -688,6 +765,9 @@ def PmuStop(pd: int) -> None: def PmuDataFree(pmuData: ctypes.POINTER(CtypesPmuData)) -> None: + """ + void PmuDataFree(struct PmuData* pmuData); + """ c_PmuDataFree = kperf_so.PmuDataFree c_PmuDataFree.argtypes = [ctypes.POINTER(CtypesPmuData)] c_PmuDataFree.restype = None @@ -695,6 +775,9 @@ def PmuDataFree(pmuData: ctypes.POINTER(CtypesPmuData)) -> None: def PmuRead(pd: int) -> PmuData: + """ + int PmuRead(int pd, struct PmuData** pmuData); + """ c_PmuRead = kperf_so.PmuRead c_PmuRead.argtypes = [ctypes.c_int, ctypes.POINTER(ctypes.POINTER(CtypesPmuData))] c_PmuRead.restype = ctypes.c_int @@ -707,6 +790,9 @@ def PmuRead(pd: int) -> PmuData: def PmuAppendData(fromData: ctypes.POINTER(CtypesPmuData), toData: ctypes.POINTER(ctypes.POINTER(CtypesPmuData))) -> int: + """ + int PmuAppendData(struct PmuData *fromData, struct PmuData **toData); + """ c_PmuAppendData = kperf_so.PmuAppendData c_PmuAppendData.argtypes = [ctypes.POINTER(CtypesPmuData), ctypes.POINTER(ctypes.POINTER(CtypesPmuData))] c_PmuAppendData.restype = ctypes.c_int @@ -715,6 +801,9 @@ def PmuAppendData(fromData: ctypes.POINTER(CtypesPmuData), toData: ctypes.POINTE def PmuClose(pd: int) -> None: + """ + void PmuClose(int pd); + """ c_PmuClose = kperf_so.PmuClose c_PmuClose.argtypes = [ctypes.c_int] c_PmuClose.restype = None @@ -724,10 +813,27 @@ def PmuClose(pd: int) -> None: c_PmuClose(c_pd) +def PmuDumpData(pmuData: PmuData, filepath: str, dumpDwf: int) -> None: + """ + int PmuDumpData(struct PmuData *pmuData, unsigned len, char *filepath, int dumpDwf); + """ + c_PmuDumpData = kperf_so.PmuDumpData + c_PmuDumpData.argtypes = [ctypes.POINTER(CtypesPmuData), ctypes.c_uint, ctypes.c_char_p, ctypes] + c_PmuDumpData.restype = ctypes.c_int + + c_len = ctypes.c_uint(pmuData.len) + c_filepath = ctypes.c_char_p(filepath.encode(UTF_8)) + c_dumpDwf = ctypes.c_int(dumpDwf) + + c_PmuDumpData(pmuData.pointer, c_len, c_filepath, c_dumpDwf) + + __all__ = [ + 'CtypesPmuAttr', 'PmuAttr', 'CpuTopology', 'PmuDataExt', + 'CtypesPmuData', 'ImplPmuData', 'PmuData', 'PmuOpen', @@ -737,4 +843,5 @@ __all__ = [ 'PmuStop', 'PmuRead', 'PmuClose', + 'PmuDumpData', ] diff --git a/python/modules/_libkperf/Symbol.py b/python/modules/_libkperf/Symbol.py index 00cbb040ae02d6326765b21caf48b4dcc20ccddd..6db0f2c50ccb2f5d8d61eb9c153e314fcf8f081f 100644 --- a/python/modules/_libkperf/Symbol.py +++ b/python/modules/_libkperf/Symbol.py @@ -18,6 +18,19 @@ from .Config import UTF_8, sym_so class CtypesSymbol(ctypes.Structure): + """ + struct Symbol { + unsigned long addr; // address (dynamic allocated) of this symbol + char* module; // binary name of which the symbol belongs to + char* symbolName; // name of the symbol + char* fileName; // corresponding file of current symbol + unsigned int lineNum; // line number of a symbol in the file + unsigned long offset; + unsigned long codeMapEndAddr; // function end address + unsigned long codeMapAddr; // real srcAddr of Asm Code or + __u64 count; + }; + """ _fields_ = [ ('addr', ctypes.c_ulong), @@ -166,6 +179,14 @@ class Symbol: class CtypesStack(ctypes.Structure): + """ + struct Stack { + struct Symbol* symbol; // symbol info for current stack + struct Stack* next; // points to next position in stack + struct Stack* prev; // points to previous position in stack + __u64 count; + } __attribute__((aligned(64))); + """ _fields_ = [ ('symbol', ctypes.POINTER(CtypesSymbol)), @@ -253,6 +274,14 @@ class Stack: class CtypesAsmCode(ctypes.Structure): + """ + struct AsmCode { + unsigned long addr; // address of asm file + char* code; // code of asm + char* fileName; // this source file name of this asm code + unsigned int lineNum; // the real line of this addr + }; + """ _fields_ = [ ('addr', ctypes.c_ulong), @@ -333,7 +362,255 @@ class AsmCode: return asm_code +class CtypesStackAsm(ctypes.Structure): + """ + struct StackAsm { + char* funcName; // function name of void + unsigned long funcStartAddr; // start address of function + unsigned long functFileOffset; // offset of function in this file + struct StackAsm* next; // points to next position in stack + struct AsmCode* asmCode; // asm code + }; + """ + + _fields_ = [ + ('fileName', ctypes.c_char_p), + ('funcStartAddr', ctypes.c_ulong), + ('functFileOffset', ctypes.c_ulong), + ('next', ctypes.POINTER('CtypesStackAsm')), + ('asmCode', ctypes.POINTER(CtypesAsmCode)), + ] + + def __init__(self, + fileName: str = '', + funcStartAddr: int = 0, + functFileOffset: int = 0, + next: 'CtypesStackAsm' = None, + asmCode: CtypesAsmCode = None, + *args: Any, **kw: Any) -> None: + super().__init__(*args, **kw) + self.fileName = ctypes.c_char_p(fileName.encode(UTF_8)) + self.funcStartAddr = ctypes.c_ulong(funcStartAddr) + self.functFileOffset = ctypes.c_ulong(functFileOffset) + self.next = next + self.asmCode = asmCode + + +class StackAsm: + + __slots__ = ['__c_stack_asm'] + + def __init__(self, + fileName: str = '', + funcStartAddr: int = 0, + functFileOffset: int = 0, + next: 'StackAsm' = None, + asmCode: AsmCode = None) -> None: + self.__c_stack_asm = CtypesStackAsm( + fileName=fileName, + funcStartAddr=funcStartAddr, + functFileOffset=functFileOffset, + next=next.c_stack_asm if next else None, + asmCode=asmCode.c_asm_code if asmCode else None, + ) + + @property + def c_stack_asm(self) -> CtypesStackAsm: + return self.__c_stack_asm + + @property + def fileName(self) -> str: + return self.c_stack_asm.fileName.decode(UTF_8) + + @fileName.setter + def fileName(self, fileName: str) -> None: + self.c_stack_asm.fileName = ctypes.c_char_p(fileName.encode(UTF_8)) + + @property + def funcStartAddr(self) -> int: + return self.c_stack_asm.funcStartAddr + + @funcStartAddr.setter + def funcStartAddr(self, funcStartAddr: int) -> None: + self.c_stack_asm.funcStartAddr = ctypes.c_ulong(funcStartAddr) + + @property + def functFileOffset(self) -> int: + return self.c_stack_asm.functFileOffset + + @functFileOffset.setter + def functFileOffset(self, functFileOffset: int) -> None: + self.c_stack_asm.functFileOffset = ctypes.c_ulong(functFileOffset) + + @property + def next(self) -> 'StackAsm': + return self.from_c_stack_asm(self.c_stack_asm.next.contents) if self.c_stack_asm.next else None + + @next.setter + def next(self, next: 'StackAsm') -> None: + self.c_stack_asm.next = next.c_stack_asm if next else None + + @property + def asmCode(self) -> AsmCode: + return AsmCode.from_c_asm_code(self.c_stack_asm.asmCode.contents) if self.c_stack_asm.asmCode else None + + @asmCode.setter + def asmCode(self, asmCode: AsmCode) -> None: + self.c_stack_asm.asmCode = asmCode.c_asm_code if asmCode else None + + @classmethod + def from_c_stack_asm(cls, c_stack_asm: CtypesStackAsm) -> 'StackAsm': + stack_asm = cls() + stack_asm.__c_stack_asm = c_stack_asm + return stack_asm + + +class CtypesProcTopology(ctypes.Structure): + """ + struct ProcTopology { + int pid; + int tid; + int ppid; + int numChild; + int* childPid; + char* comm; + char* exe; + bool kernel; + }; + """ + + _fields_ = [ + ('pid', ctypes.c_int), + ('tid', ctypes.c_int), + ('ppid', ctypes.c_int), + ('numChild', ctypes.c_int), + ('childPid', ctypes.POINTER(ctypes.c_int)), + ('comm', ctypes.c_char_p), + ('exe', ctypes.c_char_p), + ('kernel', ctypes.c_bool), + ] + + def __init__(self, + pid: int = 0, + tid: int = 0, + ppid: int = 0, + childPid: List[int] = None, + comm: str = '', + exe: str = '', + kernel: bool = False, + *args: Any, **kw: Any) -> None: + super().__init__(*args, **kw) + self.pid = ctypes.c_int(pid) + self.tid = ctypes.c_int(tid) + self.ppid = ctypes.c_int(ppid) + if childPid: + numChildPid = len(childPid) + self.childPid = (ctypes.c_int * numChildPid)(*childPid) + self.numChild = ctypes.c_int(numChildPid) + else: + self.childPid = None + self.numChild = ctypes.c_int(0) + self.comm = ctypes.c_char_p(comm.encode(UTF_8)) + self.exe = ctypes.c_char_p(exe.encode(UTF_8)) + self.kernel = ctypes.c_bool(kernel) + + +class ProcTopology: + + __slots__ = ['__c_proc_topology'] + + def __init__(self, + pid: int = 0, + tid: int = 0, + ppid: int = 0, + childPid: List[int] = None, + comm: str = '', + exe: str = '', + kernel: bool = False) -> None: + self.__c_proc_topology = CtypesProcTopology( + pid = pid, + tid=tid, + ppid=ppid, + childPid=childPid, + comm=comm, + exe=exe, + kernel=kernel + ) + + @property + def c_proc_topology(self) -> CtypesProcTopology: + return self.__c_proc_topology + + @property + def pid(self) -> int: + return self.c_proc_topology.pid + + @pid.setter + def pid(self, pid: int) -> None: + self.c_proc_topology.pid = ctypes.c_int(pid) + + @property + def tid(self) -> int: + return self.c_proc_topology.tid + + @tid.setter + def tid(self, tid: int) -> None: + self.c_proc_topology.tid = ctypes.c_int(tid) + + + @property + def ppid(self) -> int: + return self.c_proc_topology.ppid + + @ppid.setter + def ppid(self, ppid: int) -> None: + self.c_proc_topology.ppid = ctypes.c_int(ppid) + + @property + def numChild(self) -> int: + return self.c_proc_topology.numChild + + @property + def childPid(self) -> List[int]: + return [self.c_proc_topology.childPid[i] for i in range(self.numChild)] + + @childPid.setter + def childPid(self, childPid: List[int]) -> None: + if childPid: + numChildPid = len(childPid) + self.c_proc_topology.childPid = (ctypes.c_int * numChildPid)(*childPid) + self.c_proc_topology.numChild = ctypes.c_int(numChildPid) + else: + self.c_proc_topology.childPid = None + self.c_proc_topology.numChild = ctypes.c_int(0) + + @property + def comm(self) -> str: + return self.c_proc_topology.comm.decode(UTF_8) + + @comm.setter + def comm(self, comm: str) -> None: + self.c_proc_topology.comm = ctypes.c_char_p(comm.encode(UTF_8)) + + @property + def exe(self) -> str: + return self.c_proc_topology.exe.decode(UTF_8) + + @exe.setter + def exe(self, exe: str) -> None: + self.c_proc_topology.exe = ctypes.c_char_p(exe.encode(UTF_8)) + + @classmethod + def from_c_proc_topology(cls, c_proc_topology: CtypesProcTopology) -> 'ProcTopology': + proc_topology = cls() + proc_topology.__c_proc_topology = c_proc_topology + return proc_topology + + def SymResolverRecordKernel() -> None: + """ + int SymResolverRecordKernel(); + """ c_SymResolverRecordKernel = sym_so.SymResolverRecordKernel c_SymResolverRecordKernel.argtypes = [] c_SymResolverRecordKernel.restype = ctypes.c_int @@ -342,6 +619,9 @@ def SymResolverRecordKernel() -> None: def SymResolverRecordModule(pid: int) -> None: + """ + int SymResolverRecordModule(int pid); + """ c_SymResolverRecordModule = sym_so.SymResolverRecordModule c_SymResolverRecordModule.argtypes = [ctypes.c_int] c_SymResolverRecordModule.restype = ctypes.c_int @@ -352,6 +632,9 @@ def SymResolverRecordModule(pid: int) -> None: def SymResolverRecordModuleNoDwarf(pid: int) -> None: + """ + int SymResolverRecordModuleNoDwarf(int pid); + """ c_SymResolverRecordModuleNoDwarf = sym_so.SymResolverRecordModuleNoDwarf c_SymResolverRecordModuleNoDwarf.argtypes = [ctypes.c_int] c_SymResolverRecordModuleNoDwarf.restype = ctypes.c_int @@ -362,6 +645,9 @@ def SymResolverRecordModuleNoDwarf(pid: int) -> None: def StackToHash(pid: int, stackList: List[int]) -> Iterator[Stack]: + """ + struct Stack* StackToHash(int pid, unsigned long* stack, int nr); + """ c_StackToHash = sym_so.StackToHash c_StackToHash.argtypes = [ctypes.c_int, ctypes.POINTER(ctypes.c_ulong), ctypes.c_int] c_StackToHash.restype = ctypes.POINTER(CtypesStack) @@ -379,6 +665,9 @@ def StackToHash(pid: int, stackList: List[int]) -> Iterator[Stack]: def SymResolverMapAddr(pid: int, addr: int) -> Symbol: + """ + struct Symbol* SymResolverMapAddr(int pid, unsigned long addr); + """ c_SymResolverMapAddr = sym_so.SymResolverMapAddr c_SymResolverMapAddr.argtypes = [ctypes.c_int, ctypes.c_ulong] c_SymResolverMapAddr.restype = ctypes.POINTER(CtypesSymbol) @@ -392,6 +681,9 @@ def SymResolverMapAddr(pid: int, addr: int) -> Symbol: def FreeModuleData(pid: int) -> None: + """ + void FreeModuleData(int pid); + """ c_FreeModuleData = sym_so.FreeModuleData c_FreeModuleData.argtypes = [ctypes.c_int] c_FreeModuleData.restype = None @@ -402,6 +694,9 @@ def FreeModuleData(pid: int) -> None: def SymResolverDestroy() -> None: + """ + void SymResolverDestroy(); + """ c_SymResolverDestroy = sym_so.SymResolverDestroy c_SymResolverDestroy.argtypes = [] c_SymResolverDestroy.restype = None @@ -414,6 +709,12 @@ __all__ = [ 'Symbol', 'CtypesStack', 'Stack', + 'CtypesAsmCode', + 'AsmCode', + 'CtypesStackAsm', + 'StackAsm', + 'CtypesProcTopology', + 'ProcTopology', 'SymResolverRecordKernel', 'SymResolverRecordModule', 'SymResolverRecordModuleNoDwarf', diff --git a/python/modules/kperf/perror.py b/python/modules/kperf/perror.py index df59178afbadd1a79b2c1f0f8bab4cf1d8dece4d..fbb701704a69e90329be30b193f5fc99d372937a 100644 --- a/python/modules/kperf/perror.py +++ b/python/modules/kperf/perror.py @@ -15,15 +15,104 @@ Description: kperf perror module import _libkperf +class Error: + # default code + SUCCESS = 0 + COMMON_ERR_NOMEM = 1 # not enough memory + + # libsym 100-1000 + LIBSYM_ERR_BASE = 100 + LIBSYM_ERR_KALLSYMS_INVALID = LIBSYM_ERR_BASE + LIBSYM_ERR_DWARF_FORMAT_FAILED = 101 + LIBSYM_ERR_ELFIN_FOMAT_FAILED = 102 + LIBSYM_ERR_OPEN_FILE_FAILED = 103 + LIBSYM_ERR_NOT_FIND_PID = 104 + LIBSYM_ERR_MAP_ADDR_MODULE_FAILED = 105 + LIBSYM_ERR_MAP_KERNAL_ADDR_FAILED = 106 + LIBSYM_ERR_PARAM_PID_INVALID = 107 + LIBSYM_ERR_STRCPY_OPERATE_FAILED = 108 + LIBSYM_ERR_SNPRINF_OPERATE_FAILED = 109 + LIBSYM_ERR_MAP_CODE_KERNEL_NOT_SUPPORT = 110 + LIBSYM_ERR_MAP_CODE_FIND_ELF_FAILED = 111 + LIBSYM_ERR_CMD_OPERATE_FAILED = 112 + LIBSYM_ERR_FILE_NOT_RGE = 113 + LIBSYM_ERR_START_SMALLER_END = 114 + LIBSYM_ERR_STOUL_OPERATE_FAILED = 115 + LIBSYM_ERR_FILE_INVALID = 116 + # libperf = 1000-3000 + LIBPERF_ERR_NO_AVAIL_PD = 1000 + LIBPERF_ERR_CHIP_TYPE_INVALID = 1001 + LIBPERF_ERR_FAIL_LISTEN_PROC = 1002 + LIBPERF_ERR_INVALID_CPULIST = 1003 + LIBPERF_ERR_INVALID_PIDLIST = 1004 + LIBPERF_ERR_INVALID_EVTLIST = 1005 + LIBPERF_ERR_INVALID_PD = 1006 + LIBPERF_ERR_INVALID_EVENT = 1007 + LIBPERF_ERR_SPE_UNAVAIL = 1008 + LIBPERF_ERR_FAIL_GET_CPU = 1009 + LIBPERF_ERR_FAIL_GET_PROC = 1010 + LIBPERF_ERR_NO_PERMISSION = 1011 + LIBPERF_ERR_DEVICE_BUSY = 1012 + LIBPERF_ERR_DEVICE_INVAL = 1013 + LIBPERF_ERR_FAIL_MMAP = 1014 + LIBPERF_ERR_FAIL_RESOLVE_MODULE = 1015 + LIBPERF_ERR_KERNEL_NOT_SUPPORT = 1016 + LIBPERF_ERR_INVALID_METRIC_TYPE = 1017 + LIBPERF_ERR_INVALID_PID = 1018 + LIBPERF_ERR_INVALID_TASK_TYPE = 1019 + LIBPERF_ERR_INVALID_TIME = 1020 + LIBPERF_ERR_NO_PROC = 1021 + LIBPERF_ERR_TOO_MANY_FD = 1022 + LIBPERF_ERR_RAISE_FD = 1023 + LIBPERF_ERR_INVALID_PMU_DATA = 1024 + LIBPERF_ERR_FAILED_PMU_ENABLE = 1025 + LIBPERF_ERR_FAILED_PMU_DISABLE = 1026 + LIBPERF_ERR_FAILED_PMU_RESET = 1027 + LIBPERF_ERR_NOT_OPENED = 1028 + LIBPERF_ERR_QUERY_EVENT_TYPE_INVALID = 1029 + LIBPERF_ERR_QUERY_EVENT_LIST_FAILED = 1030 + LIBPERF_ERR_PATH_INACCESSIBLE = 1031 + LIBPERF_ERR_INVALID_SAMPLE_RATE = 1032 + + UNKNOWN_ERROR = 9999 + + # warnning code + LIBPERF_WARN_CTXID_LOST = 1000 + LIBPERF_WARN_FAIL_GET_PROC = 1001 + + def errorno() -> int: + """ + Obtaining error codes + """ return _libkperf.Perrorno() def error()-> str: + """ + Obtaining Error Information + """ return _libkperf.Perror() +def get_warn() -> int: + """ + Get warning codes + """ + return _libkperf.GetWarn() + + +def get_warn_msg()-> str: + """ + Get warning message + """ + return _libkperf.GetWarnMsg() + + __all__ = [ + 'Error', 'errorno', 'error', + 'get_warn', + 'get_warn_msg' ] diff --git a/python/modules/kperf/pmu.py b/python/modules/kperf/pmu.py index ebb911dd780a730b84c7b2bf0705210b1ea64a9e..5c89d8f4f269af16e6c591c28a8ab222840e32a4 100644 --- a/python/modules/kperf/pmu.py +++ b/python/modules/kperf/pmu.py @@ -150,6 +150,21 @@ def close(pd: int) -> None: return _libkperf.PmuClose(pd) +def dump(pmuData: PmuData, filepath: str, dump_dwf: int) -> None: + """ + /** + Dump pmu data to a specific file. + If file exists, then data will be appended to file. + If file does not exist, then file will be created. + Dump format: comm pid tid cpu period evt count addr symbolName offset module fileName lineNum + :param pmuData: data list. + :param filepath: path of the output file. + :param dump_dwf: if 0, source file and line number of symbols will not be dumped, otherwise, they will be dumped to file. + :return: None + """ + return _libkperf.PmuDumpData(pmuData, filepath, dump_dwf) + + __all__ = [ 'PmuTaskType', 'PmuEventType', @@ -168,4 +183,5 @@ __all__ = [ 'read', 'stop', 'close', + 'dump', ] diff --git a/python/modules/ksym/symbol.py b/python/modules/ksym/symbol.py index 2e4e6f0202cdc55ceb8af9c0aef4d29985f4e113..df3ea9c8bdadc26600aa0c99b271b1c2643b2621 100644 --- a/python/modules/ksym/symbol.py +++ b/python/modules/ksym/symbol.py @@ -69,14 +69,23 @@ def record_module(pid: int, dwarf: bool = True) -> None: def get_stack(pid: int, stacks: List[int]) -> Iterator[Stack]: + """ + Convert a callstack to a unsigned long long hashid + """ return _libkperf.StackToHash(pid, stacks) def get_symbol(pid: int, addr: int) -> Symbol: + """ + Map a specific address to a symbol + """ return _libkperf.SymResolverMapAddr(pid, addr) def free_module(pid: int) -> None: + """ + free pid module data + """ _libkperf.FreeModuleData(pid)