Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
KDE:Unstable:Frameworks
kcrash
_service:obs_scm:kcrash-VERSIONgit.20240519T101...
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File _service:obs_scm:kcrash-VERSIONgit.20240519T101152~2f9f41e.obscpio of Package kcrash
07070100000000000081A40000000000000000000000016649D068000000AE000000000000000000000000000000000000004100000000kcrash-VERSIONgit.20240519T101152~2f9f41e/.git-blame-ignore-revs# SPDX-License-Identifier: CC0-1.0 # SPDX-FileCopyrightText: none # clang-format 03b8fd740f9c9c7b6d0ff7a31c127e7ea2ff0cf7 # astyle 0003b51ada4f5abeab0e51fad80dc09ab254abb2 07070100000001000081A40000000000000000000000016649D06800000131000000000000000000000000000000000000003500000000kcrash-VERSIONgit.20240519T101152~2f9f41e/.gitignore# Ignore the following files *~ *.[oa] *.diff *.kate-swp *.kdev4 .kdev_include_paths *.kdevelop.pcs *.moc *.moc.cpp *.orig *.user .*.swp .swp.* Doxyfile Makefile avail random_seed /build*/ CMakeLists.txt.user* *.unc-backup* .cmake/ /.clang-format /compile_commands.json .clangd .idea /cmake-build* .cache 07070100000002000081A40000000000000000000000016649D06800000109000000000000000000000000000000000000003900000000kcrash-VERSIONgit.20240519T101152~2f9f41e/.gitlab-ci.yml# SPDX-FileCopyrightText: 2020 Volker Krause <vkrause@kde.org> # SPDX-License-Identifier: CC0-1.0 include: - project: sysadmin/ci-utilities file: - /gitlab-templates/linux.yml - /gitlab-templates/freebsd.yml - /gitlab-templates/windows.yml 07070100000003000081A40000000000000000000000016649D068000000E8000000000000000000000000000000000000003600000000kcrash-VERSIONgit.20240519T101152~2f9f41e/.kde-ci.ymlDependencies: - 'on': ['@all'] 'require': 'frameworks/extra-cmake-modules': '@same' 'frameworks/kcoreaddons' : '@same' Options: test-before-installing: True require-passing-tests-on: [ 'Linux', 'FreeBSD', 'Windows' ] 07070100000004000081A40000000000000000000000016649D06800000ED1000000000000000000000000000000000000003900000000kcrash-VERSIONgit.20240519T101152~2f9f41e/CMakeLists.txtcmake_minimum_required(VERSION 3.16) set(KF_VERSION "5.117.0") # handled by release scripts set(KF_DEP_VERSION "5.116.0") # handled by release scripts project(KCrash VERSION ${KF_VERSION}) include(FeatureSummary) find_package(ECM 5.116.0 NO_MODULE) set_package_properties(ECM PROPERTIES TYPE REQUIRED DESCRIPTION "Extra CMake Modules." URL "https://commits.kde.org/extra-cmake-modules") feature_summary(WHAT REQUIRED_PACKAGES_NOT_FOUND FATAL_ON_MISSING_REQUIRED_PACKAGES) set(CMAKE_MODULE_PATH ${ECM_MODULE_PATH}) include(KDEInstallDirs) include(KDEFrameworkCompilerSettings NO_POLICY_SCOPE) include(KDECMakeSettings) include(KDEGitCommitHooks) include(ECMDeprecationSettings) set(REQUIRED_QT_VERSION 5.15.2) find_package(Qt${QT_MAJOR_VERSION} ${REQUIRED_QT_VERSION} CONFIG REQUIRED Core Gui) if (UNIX AND NOT APPLE AND NOT ANDROID) option(WITH_X11 "Build with X11 integration" ON) else() set(WITH_X11 OFF) endif() if (WITH_X11) find_package(X11 REQUIRED) if (QT_MAJOR_VERSION STREQUAL "5") find_package(Qt5 ${REQUIRED_QT_VERSION} CONFIG REQUIRED X11Extras) endif() set(HAVE_X11 TRUE) endif() find_package(Qt${QT_MAJOR_VERSION}Test ${REQUIRED_QT_VERSION} CONFIG REQUIRED) include(GenerateExportHeader) include(ECMSetupVersion) include(ECMGenerateHeaders) include(ECMAddQch) include(ECMQtDeclareLoggingCategory) option(BUILD_QCH "Build API documentation in QCH format (for e.g. Qt Assistant, Qt Creator & KDevelop)" OFF) add_feature_info(QCH ${BUILD_QCH} "API documentation in QCH format (for e.g. Qt Assistant, Qt Creator & KDevelop)") ecm_setup_version(PROJECT VARIABLE_PREFIX KCrash VERSION_HEADER "${CMAKE_CURRENT_BINARY_DIR}/src/kcrash_version.h" PACKAGE_VERSION_FILE "${CMAKE_CURRENT_BINARY_DIR}/KF5CrashConfigVersion.cmake" SOVERSION 5) find_package(KF5CoreAddons ${KF_DEP_VERSION} REQUIRED) set(KCRASH_CORE_PATTERN_RAISE_DEFAULT ON) option(KCRASH_CORE_PATTERN_RAISE "Enables raising signals to kernel core patterns (iff the pattern is a process). You may wish to not install drkonqi if this can cause a UI conflict." ${KCRASH_CORE_PATTERN_RAISE_DEFAULT}) add_feature_info("Core Pattern Raising" KCRASH_CORE_PATTERN_RAISE "Raising signals to kernel core patterns (iff the pattern is a process). You may wish to not install drkonqi if this can cause a UI conflict.") ecm_set_disabled_deprecation_versions( QT 5.15.2 KF 5.95.0 ) add_subdirectory(src) if (BUILD_TESTING) add_subdirectory(autotests) endif() # create a Config.cmake and a ConfigVersion.cmake file and install them set(CMAKECONFIG_INSTALL_DIR "${KDE_INSTALL_CMAKEPACKAGEDIR}/KF5Crash") if (BUILD_QCH) ecm_install_qch_export( TARGETS KF5Crash_QCH FILE KF5CrashQchTargets.cmake DESTINATION "${CMAKECONFIG_INSTALL_DIR}" COMPONENT Devel ) set(PACKAGE_INCLUDE_QCHTARGETS "include(\"\${CMAKE_CURRENT_LIST_DIR}/KF5CrashQchTargets.cmake\")") endif() include(CMakePackageConfigHelpers) configure_package_config_file( "${CMAKE_CURRENT_SOURCE_DIR}/KF5CrashConfig.cmake.in" "${CMAKE_CURRENT_BINARY_DIR}/KF5CrashConfig.cmake" INSTALL_DESTINATION ${CMAKECONFIG_INSTALL_DIR} ) install(FILES "${CMAKE_CURRENT_BINARY_DIR}/KF5CrashConfig.cmake" "${CMAKE_CURRENT_BINARY_DIR}/KF5CrashConfigVersion.cmake" DESTINATION "${CMAKECONFIG_INSTALL_DIR}" COMPONENT Devel ) install(EXPORT KF5CrashTargets DESTINATION "${CMAKECONFIG_INSTALL_DIR}" FILE KF5CrashTargets.cmake NAMESPACE KF5:: ) install(FILES ${CMAKE_CURRENT_BINARY_DIR}/src/kcrash_version.h DESTINATION ${KDE_INSTALL_INCLUDEDIR_KF}/KCrash COMPONENT Devel ) feature_summary(WHAT ALL FATAL_ON_MISSING_REQUIRED_PACKAGES) kde_configure_git_pre_commit_hook(CHECKS CLANG_FORMAT) 07070100000005000081A40000000000000000000000016649D06800000242000000000000000000000000000000000000004200000000kcrash-VERSIONgit.20240519T101152~2f9f41e/KF5CrashConfig.cmake.in@PACKAGE_INIT@ # Any changes in this file will be overwritten by CMake. include(CMakeFindDependencyMacro) find_dependency(Qt@QT_MAJOR_VERSION@Core @REQUIRED_QT_VERSION@) if (NOT @BUILD_SHARED_LIBS@) find_dependency(Qt@QT_MAJOR_VERSION@Gui @REQUIRED_QT_VERSION@) find_dependency(KF5CoreAddons REQUIRED) if (@WITH_X11@) if (TARGET Qt5::Core) find_dependency(Qt5X11Extras REQUIRED) endif() find_dependency(X11 REQUIRED) endif() endif() include("${CMAKE_CURRENT_LIST_DIR}/KF5CrashTargets.cmake") @PACKAGE_INCLUDE_QCHTARGETS@ 07070100000006000041ED0000000000000000000000026649D06800000000000000000000000000000000000000000000003300000000kcrash-VERSIONgit.20240519T101152~2f9f41e/LICENSES07070100000007000081A40000000000000000000000016649D06800001B88000000000000000000000000000000000000003F00000000kcrash-VERSIONgit.20240519T101152~2f9f41e/LICENSES/CC0-1.0.txtCreative Commons Legal Code CC0 1.0 Universal CREATIVE COMMONS CORPORATION IS NOT A LAW FIRM AND DOES NOT PROVIDE LEGAL SERVICES. DISTRIBUTION OF THIS DOCUMENT DOES NOT CREATE AN ATTORNEY-CLIENT RELATIONSHIP. CREATIVE COMMONS PROVIDES THIS INFORMATION ON AN "AS-IS" BASIS. CREATIVE COMMONS MAKES NO WARRANTIES REGARDING THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS PROVIDED HEREUNDER, AND DISCLAIMS LIABILITY FOR DAMAGES RESULTING FROM THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS PROVIDED HEREUNDER. Statement of Purpose The laws of most jurisdictions throughout the world automatically confer exclusive Copyright and Related Rights (defined below) upon the creator and subsequent owner(s) (each and all, an "owner") of an original work of authorship and/or a database (each, a "Work"). Certain owners wish to permanently relinquish those rights to a Work for the purpose of contributing to a commons of creative, cultural and scientific works ("Commons") that the public can reliably and without fear of later claims of infringement build upon, modify, incorporate in other works, reuse and redistribute as freely as possible in any form whatsoever and for any purposes, including without limitation commercial purposes. These owners may contribute to the Commons to promote the ideal of a free culture and the further production of creative, cultural and scientific works, or to gain reputation or greater distribution for their Work in part through the use and efforts of others. For these and/or other purposes and motivations, and without any expectation of additional consideration or compensation, the person associating CC0 with a Work (the "Affirmer"), to the extent that he or she is an owner of Copyright and Related Rights in the Work, voluntarily elects to apply CC0 to the Work and publicly distribute the Work under its terms, with knowledge of his or her Copyright and Related Rights in the Work and the meaning and intended legal effect of CC0 on those rights. 1. Copyright and Related Rights. A Work made available under CC0 may be protected by copyright and related or neighboring rights ("Copyright and Related Rights"). Copyright and Related Rights include, but are not limited to, the following: i. the right to reproduce, adapt, distribute, perform, display, communicate, and translate a Work; ii. moral rights retained by the original author(s) and/or performer(s); iii. publicity and privacy rights pertaining to a person's image or likeness depicted in a Work; iv. rights protecting against unfair competition in regards to a Work, subject to the limitations in paragraph 4(a), below; v. rights protecting the extraction, dissemination, use and reuse of data in a Work; vi. database rights (such as those arising under Directive 96/9/EC of the European Parliament and of the Council of 11 March 1996 on the legal protection of databases, and under any national implementation thereof, including any amended or successor version of such directive); and vii. other similar, equivalent or corresponding rights throughout the world based on applicable law or treaty, and any national implementations thereof. 2. Waiver. To the greatest extent permitted by, but not in contravention of, applicable law, Affirmer hereby overtly, fully, permanently, irrevocably and unconditionally waives, abandons, and surrenders all of Affirmer's Copyright and Related Rights and associated claims and causes of action, whether now known or unknown (including existing as well as future claims and causes of action), in the Work (i) in all territories worldwide, (ii) for the maximum duration provided by applicable law or treaty (including future time extensions), (iii) in any current or future medium and for any number of copies, and (iv) for any purpose whatsoever, including without limitation commercial, advertising or promotional purposes (the "Waiver"). Affirmer makes the Waiver for the benefit of each member of the public at large and to the detriment of Affirmer's heirs and successors, fully intending that such Waiver shall not be subject to revocation, rescission, cancellation, termination, or any other legal or equitable action to disrupt the quiet enjoyment of the Work by the public as contemplated by Affirmer's express Statement of Purpose. 3. Public License Fallback. Should any part of the Waiver for any reason be judged legally invalid or ineffective under applicable law, then the Waiver shall be preserved to the maximum extent permitted taking into account Affirmer's express Statement of Purpose. In addition, to the extent the Waiver is so judged Affirmer hereby grants to each affected person a royalty-free, non transferable, non sublicensable, non exclusive, irrevocable and unconditional license to exercise Affirmer's Copyright and Related Rights in the Work (i) in all territories worldwide, (ii) for the maximum duration provided by applicable law or treaty (including future time extensions), (iii) in any current or future medium and for any number of copies, and (iv) for any purpose whatsoever, including without limitation commercial, advertising or promotional purposes (the "License"). The License shall be deemed effective as of the date CC0 was applied by Affirmer to the Work. Should any part of the License for any reason be judged legally invalid or ineffective under applicable law, such partial invalidity or ineffectiveness shall not invalidate the remainder of the License, and in such case Affirmer hereby affirms that he or she will not (i) exercise any of his or her remaining Copyright and Related Rights in the Work or (ii) assert any associated claims and causes of action with respect to the Work, in either case contrary to Affirmer's express Statement of Purpose. 4. Limitations and Disclaimers. a. No trademark or patent rights held by Affirmer are waived, abandoned, surrendered, licensed or otherwise affected by this document. b. Affirmer offers the Work as-is and makes no representations or warranties of any kind concerning the Work, express, implied, statutory or otherwise, including without limitation warranties of title, merchantability, fitness for a particular purpose, non infringement, or the absence of latent or other defects, accuracy, or the present or absence of errors, whether or not discoverable, all to the greatest extent permissible under applicable law. c. Affirmer disclaims responsibility for clearing rights of other persons that may apply to the Work or any use thereof, including without limitation any person's Copyright and Related Rights in the Work. Further, Affirmer disclaims responsibility for obtaining any necessary consents, permissions or other rights required for any use of the Work. d. Affirmer understands and acknowledges that Creative Commons is not a party to this document and has no duty or obligation with respect to this CC0 or use of the Work. 07070100000008000081A40000000000000000000000016649D068000060C6000000000000000000000000000000000000004900000000kcrash-VERSIONgit.20240519T101152~2f9f41e/LICENSES/LGPL-2.0-or-later.txtGNU LIBRARY GENERAL PUBLIC LICENSE Version 2, June 1991 Copyright (C) 1991 Free Software Foundation, Inc. 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. [This is the first released version of the library GPL. It is numbered 2 because it goes with version 2 of the ordinary GPL.] Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public Licenses are intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This license, the Library General Public License, applies to some specially designated Free Software Foundation software, and to any other libraries whose authors decide to use it. You can use it for your libraries, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the library, or if you modify it. For example, if you distribute copies of the library, whether gratis or for a fee, you must give the recipients all the rights that we gave you. You must make sure that they, too, receive or can get the source code. If you link a program with the library, you must provide complete object files to the recipients so that they can relink them with the library, after making changes to the library and recompiling it. And you must show them these terms so they know their rights. Our method of protecting your rights has two steps: (1) copyright the library, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the library. Also, for each distributor's protection, we want to make certain that everyone understands that there is no warranty for this free library. If the library is modified by someone else and passed on, we want its recipients to know that what they have is not the original version, so that any problems introduced by others will not reflect on the original authors' reputations. Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that companies distributing free software will individually obtain patent licenses, thus in effect transforming the program into proprietary software. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all. Most GNU software, including some libraries, is covered by the ordinary GNU General Public License, which was designed for utility programs. This license, the GNU Library General Public License, applies to certain designated libraries. This license is quite different from the ordinary one; be sure to read it in full, and don't assume that anything in it is the same as in the ordinary license. The reason we have a separate public license for some libraries is that they blur the distinction we usually make between modifying or adding to a program and simply using it. Linking a program with a library, without changing the library, is in some sense simply using the library, and is analogous to running a utility program or application program. However, in a textual and legal sense, the linked executable is a combined work, a derivative of the original library, and the ordinary General Public License treats it as such. Because of this blurred distinction, using the ordinary General Public License for libraries did not effectively promote software sharing, because most developers did not use the libraries. We concluded that weaker conditions might promote sharing better. However, unrestricted linking of non-free programs would deprive the users of those programs of all benefit from the free status of the libraries themselves. This Library General Public License is intended to permit developers of non-free programs to use free libraries, while preserving your freedom as a user of such programs to change the free libraries that are incorporated in them. (We have not seen how to achieve this as regards changes in header files, but we have achieved it as regards changes in the actual functions of the Library.) The hope is that this will lead to faster development of free libraries. The precise terms and conditions for copying, distribution and modification follow. Pay close attention to the difference between a "work based on the library" and a "work that uses the library". The former contains code derived from the library, while the latter only works together with the library. Note that it is possible for a library to be covered by the ordinary General Public License rather than by this special one. TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License Agreement applies to any software library which contains a notice placed by the copyright holder or other authorized party saying it may be distributed under the terms of this Library General Public License (also called "this License"). Each licensee is addressed as "you". A "library" means a collection of software functions and/or data prepared so as to be conveniently linked with application programs (which use some of those functions and data) to form executables. The "Library", below, refers to any such software library or work which has been distributed under these terms. A "work based on the Library" means either the Library or any derivative work under copyright law: that is to say, a work containing the Library or a portion of it, either verbatim or with modifications and/or translated straightforwardly into another language. (Hereinafter, translation is included without limitation in the term "modification".) "Source code" for a work means the preferred form of the work for making modifications to it. For a library, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the library. Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running a program using the Library is not restricted, and output from such a program is covered only if its contents constitute a work based on the Library (independent of the use of the Library in a tool for writing it). Whether that is true depends on what the Library does and what the program that uses the Library does. 1. You may copy and distribute verbatim copies of the Library's complete source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and distribute a copy of this License along with the Library. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Library or any portion of it, thus forming a work based on the Library, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a) The modified work must itself be a software library. b) You must cause the files modified to carry prominent notices stating that you changed the files and the date of any change. c) You must cause the whole of the work to be licensed at no charge to all third parties under the terms of this License. d) If a facility in the modified Library refers to a function or a table of data to be supplied by an application program that uses the facility, other than as an argument passed when the facility is invoked, then you must make a good faith effort to ensure that, in the event an application does not supply such function or table, the facility still operates, and performs whatever part of its purpose remains meaningful. (For example, a function in a library to compute square roots has a purpose that is entirely well-defined independent of the application. Therefore, Subsection 2d requires that any application-supplied function or table used by this function must be optional: if the application does not supply it, the square root function must still compute square roots.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Library, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Library, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Library. In addition, mere aggregation of another work not based on the Library with the Library (or with a work based on the Library) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may opt to apply the terms of the ordinary GNU General Public License instead of this License to a given copy of the Library. To do this, you must alter all the notices that refer to this License, so that they refer to the ordinary GNU General Public License, version 2, instead of to this License. (If a newer version than version 2 of the ordinary GNU General Public License has appeared, then you can specify that version instead if you wish.) Do not make any other change in these notices. Once this change is made in a given copy, it is irreversible for that copy, so the ordinary GNU General Public License applies to all subsequent copies and derivative works made from that copy. This option is useful when you wish to copy part of the code of the Library into a program that is not a library. 4. You may copy and distribute the Library (or a portion or derivative of it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange. If distribution of object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place satisfies the requirement to distribute the source code, even though third parties are not compelled to copy the source along with the object code. 5. A program that contains no derivative of any portion of the Library, but is designed to work with the Library by being compiled or linked with it, is called a "work that uses the Library". Such a work, in isolation, is not a derivative work of the Library, and therefore falls outside the scope of this License. However, linking a "work that uses the Library" with the Library creates an executable that is a derivative of the Library (because it contains portions of the Library), rather than a "work that uses the library". The executable is therefore covered by this License. Section 6 states terms for distribution of such executables. When a "work that uses the Library" uses material from a header file that is part of the Library, the object code for the work may be a derivative work of the Library even though the source code is not. Whether this is true is especially significant if the work can be linked without the Library, or if the work is itself a library. The threshold for this to be true is not precisely defined by law. If such an object file uses only numerical parameters, data structure layouts and accessors, and small macros and small inline functions (ten lines or less in length), then the use of the object file is unrestricted, regardless of whether it is legally a derivative work. (Executables containing this object code plus portions of the Library will still fall under Section 6.) Otherwise, if the work is a derivative of the Library, you may distribute the object code for the work under the terms of Section 6. Any executables containing that work also fall under Section 6, whether or not they are linked directly with the Library itself. 6. As an exception to the Sections above, you may also compile or link a "work that uses the Library" with the Library to produce a work containing portions of the Library, and distribute that work under terms of your choice, provided that the terms permit modification of the work for the customer's own use and reverse engineering for debugging such modifications. You must give prominent notice with each copy of the work that the Library is used in it and that the Library and its use are covered by this License. You must supply a copy of this License. If the work during execution displays copyright notices, you must include the copyright notice for the Library among them, as well as a reference directing the user to the copy of this License. Also, you must do one of these things: a) Accompany the work with the complete corresponding machine-readable source code for the Library including whatever changes were used in the work (which must be distributed under Sections 1 and 2 above); and, if the work is an executable linked with the Library, with the complete machine-readable "work that uses the Library", as object code and/or source code, so that the user can modify the Library and then relink to produce a modified executable containing the modified Library. (It is understood that the user who changes the contents of definitions files in the Library will not necessarily be able to recompile the application to use the modified definitions.) b) Accompany the work with a written offer, valid for at least three years, to give the same user the materials specified in Subsection 6a, above, for a charge no more than the cost of performing this distribution. c) If distribution of the work is made by offering access to copy from a designated place, offer equivalent access to copy the above specified materials from the same place. d) Verify that the user has already received a copy of these materials or that you have already sent this user a copy. For an executable, the required form of the "work that uses the Library" must include any data and utility programs needed for reproducing the executable from it. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. It may happen that this requirement contradicts the license restrictions of other proprietary libraries that do not normally accompany the operating system. Such a contradiction means you cannot use both them and the Library together in an executable that you distribute. 7. You may place library facilities that are a work based on the Library side-by-side in a single library together with other library facilities not covered by this License, and distribute such a combined library, provided that the separate distribution of the work based on the Library and of the other library facilities is otherwise permitted, and provided that you do these two things: a) Accompany the combined library with a copy of the same work based on the Library, uncombined with any other library facilities. This must be distributed under the terms of the Sections above. b) Give prominent notice with the combined library of the fact that part of it is a work based on the Library, and explaining where to find the accompanying uncombined form of the same work. 8. You may not copy, modify, sublicense, link with, or distribute the Library except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense, link with, or distribute the Library is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 9. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Library or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Library (or any work based on the Library), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Library or works based on it. 10. Each time you redistribute the Library (or any work based on the Library), the recipient automatically receives a license from the original licensor to copy, distribute, link with or modify the Library subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License. 11. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Library at all. For example, if a patent license would not permit royalty-free redistribution of the Library by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Library. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply, and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 12. If the distribution and/or use of the Library is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Library under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 13. The Free Software Foundation may publish revised and/or new versions of the Library General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Library specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Library does not specify a license version number, you may choose any version ever published by the Free Software Foundation. 14. If you wish to incorporate parts of the Library into other free programs whose distribution conditions are incompatible with these, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Libraries If you develop a new library, and you want it to be of the greatest possible use to the public, we recommend making it free software that everyone can redistribute and change. You can do so by permitting redistribution under these terms (or, alternatively, under the terms of the ordinary General Public License). To apply these terms, attach the following notices to the library. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. one line to give the library's name and an idea of what it does. Copyright (C) year name of author This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. Also add information on how to contact you by electronic and paper mail. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the library, if necessary. Here is a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the library `Frob' (a library for tweaking knobs) written by James Random Hacker. signature of Ty Coon, 1 April 1990 Ty Coon, President of Vice That's all there is to it! 07070100000009000081A40000000000000000000000016649D06800000091000000000000000000000000000000000000003400000000kcrash-VERSIONgit.20240519T101152~2f9f41e/README.md# KCrash Graceful handling of application crashes ## Introduction KCrash provides support for intercepting and handling application crashes. 0707010000000A000041ED0000000000000000000000036649D06800000000000000000000000000000000000000000000003400000000kcrash-VERSIONgit.20240519T101152~2f9f41e/autotests0707010000000B000081A40000000000000000000000016649D06800000541000000000000000000000000000000000000004300000000kcrash-VERSIONgit.20240519T101152~2f9f41e/autotests/CMakeLists.txtremove_definitions(-DQT_NO_CAST_FROM_ASCII) include(ECMAddTests) find_package(Qt${QT_MAJOR_VERSION}Widgets ${REQUIRED_QT_VERSION} CONFIG QUIET) if(NOT TARGET Qt${QT_MAJOR_VERSION}::Test) message(STATUS "Qt${QT_MAJOR_VERSION}Test not found, autotests will not be built.") return() endif() if(NOT Qt${QT_MAJOR_VERSION}Widgets_FOUND) message(STATUS "Qt${QT_MAJOR_VERSION}Widgets not found, autotests will not be built.") return() endif() # Include src so we have access to config-kcrash.h include_directories(${CMAKE_CURRENT_BINARY_DIR}/../src) # crash_tester enter an infinite loop on Windows (one step from a fork bomb) # and holds up the CI system infinitely. Disable it in absence of a fix. if(NOT WIN32) ecm_add_tests( kcrashtest.cpp LINK_LIBRARIES Qt${QT_MAJOR_VERSION}::Core Qt${QT_MAJOR_VERSION}::Test ) add_executable(test_crasher test_crasher.cpp) target_link_libraries(test_crasher Qt${QT_MAJOR_VERSION}::Widgets KF5::Crash) ecm_mark_as_test(test_crasher) ecm_mark_nongui_executable(test_crasher) add_dependencies(kcrashtest test_crasher) endif() ecm_add_tests( coreconfigtest.cpp LINK_LIBRARIES Qt${QT_MAJOR_VERSION}::Core Qt${QT_MAJOR_VERSION}::Test ) ecm_add_tests( metadatatest.cpp LINK_LIBRARIES Qt${QT_MAJOR_VERSION}::Core Qt${QT_MAJOR_VERSION}::Test ) 0707010000000C000041ED0000000000000000000000026649D06800000000000000000000000000000000000000000000004200000000kcrash-VERSIONgit.20240519T101152~2f9f41e/autotests/core_patterns0707010000000D000081A40000000000000000000000016649D06800000039000000000000000000000000000000000000004700000000kcrash-VERSIONgit.20240519T101152~2f9f41e/autotests/core_patterns/exec|/lib/systemd/systemd-coredump %P %u %g %s %t 1213213 %e 0707010000000E000081A40000000000000000000000016649D0680000002C000000000000000000000000000000000000004E00000000kcrash-VERSIONgit.20240519T101152~2f9f41e/autotests/core_patterns/exec-apport|/usr/share/apport/apport %p %s %c %d %P %E 0707010000000F000081A40000000000000000000000016649D0680000003E000000000000000000000000000000000000005600000000kcrash-VERSIONgit.20240519T101152~2f9f41e/autotests/core_patterns/exec-apport.licenseSPDX-License-Identifier: CC0-1.0 SPDX-FileCopyrightText: none 07070100000010000081A40000000000000000000000016649D0680000003E000000000000000000000000000000000000004F00000000kcrash-VERSIONgit.20240519T101152~2f9f41e/autotests/core_patterns/exec.licenseSPDX-License-Identifier: CC0-1.0 SPDX-FileCopyrightText: none 07070100000011000081A40000000000000000000000016649D0680000001C000000000000000000000000000000000000004A00000000kcrash-VERSIONgit.20240519T101152~2f9f41e/autotests/core_patterns/no-exec/tmp/cores/core.%e.%p.%h.%t 07070100000012000081A40000000000000000000000016649D0680000003E000000000000000000000000000000000000005200000000kcrash-VERSIONgit.20240519T101152~2f9f41e/autotests/core_patterns/no-exec.licenseSPDX-License-Identifier: CC0-1.0 SPDX-FileCopyrightText: none 07070100000013000081A40000000000000000000000016649D068000004C9000000000000000000000000000000000000004700000000kcrash-VERSIONgit.20240519T101152~2f9f41e/autotests/coreconfigtest.cpp/* SPDX-FileCopyrightText: 2016-2021 Harald Sitter <sitter@kde.org> SPDX-License-Identifier: LGPL-2.0-or-later */ #include <QTest> #include "../src/coreconfig.cpp" class CoreConfigTest : public QObject { Q_OBJECT private Q_SLOTS: void initTestCase() { } void testExec() { KCrash::CoreConfig c(QFINDTESTDATA("core_patterns/exec")); #if KCRASH_CORE_PATTERN_RAISE QCOMPARE(c.isProcess(), true); QCOMPARE(c.isCoredumpd(), true); #else QCOMPARE(c.isProcess(), false); QCOMPARE(c.isCoredumpd(), false); #endif } void testExecNot() { #if !KCRASH_CORE_PATTERN_RAISE QSKIP("Not useful when opting out of re-raising.") #endif KCrash::CoreConfig c(QFINDTESTDATA("core_patterns/exec-apport")); QCOMPARE(c.isProcess(), true); QCOMPARE(c.isCoredumpd(), false); } void testNoFile() { KCrash::CoreConfig c(QStringLiteral("/meow/kitteh/meow")); QCOMPARE(c.isProcess(), false); } void testNoExec() { KCrash::CoreConfig c(QFINDTESTDATA("core_patterns/no-exec")); QCOMPARE(c.isProcess(), false); } }; QTEST_MAIN(CoreConfigTest) #include "coreconfigtest.moc" 07070100000014000081A40000000000000000000000016649D06800000996000000000000000000000000000000000000004300000000kcrash-VERSIONgit.20240519T101152~2f9f41e/autotests/kcrashtest.cpp/* This file is part of the KDE libraries SPDX-FileCopyrightText: 2013 David Faure <faure@kde.org> SPDX-License-Identifier: LGPL-2.0-or-later */ #include <QDebug> #include <QFile> #include <QProcess> #include <QTest> class KCrashTest : public QObject { Q_OBJECT private Q_SLOTS: void initTestCase() { // Don't bring up drkonqi qputenv("KDE_DEBUG", "1"); // change to the bin dir QDir::setCurrent(QCoreApplication::applicationDirPath()); } void testAutoRestart(); void testAutoRestartDirectly(); void testEmergencySave(); }; static const char s_logFileName[] = "kcrashtest_log"; static QByteArray readLogFile() { QFile logFile(QFile::encodeName(s_logFileName)); if (!logFile.open(QIODevice::ReadOnly)) { return QByteArray(); } return logFile.readAll(); } static void startCrasher(const QByteArray &flag, const QByteArray &expectedOutput) { QFile::remove(QFile::encodeName(s_logFileName)); QProcess proc; QString processName; #ifdef Q_OS_WIN QVERIFY(QFile::exists("./test_crasher.exe")); processName = "test_crasher.exe"; #else QVERIFY(QFile::exists("./test_crasher")); processName = QStringLiteral("./test_crasher"); #endif // qDebug() << proc.args(); QProcessEnvironment env = QProcessEnvironment::systemEnvironment(); env.insert(QStringLiteral("ASAN_OPTIONS"), QStringLiteral("handle_segv=0,poison_heap=0")); // Disable ASAN proc.setProcessEnvironment(env); proc.setProcessChannelMode(QProcess::ForwardedChannels); proc.start(processName, QStringList() << flag); bool ok = proc.waitForFinished(); QVERIFY(ok); QByteArray logData; for (int i = 0; i < 50; ++i) { logData = readLogFile(); if (logData == expectedOutput) { return; } QTest::qSleep(100); } qDebug() << proc.readAllStandardError(); QCOMPARE(QString(logData), QString(expectedOutput)); } void KCrashTest::testAutoRestart() // use kdeinit if possible, otherwise directly (ex: on CI) { startCrasher("AR", "starting AR\nautorestarted AR\n"); } void KCrashTest::testAutoRestartDirectly() // test directly (so a developer can test the CI case) { startCrasher("ARD", "starting ARD\nautorestarted ARD\n"); } void KCrashTest::testEmergencySave() { startCrasher("ES", "starting ES\nsaveFunction called\n"); } QTEST_MAIN(KCrashTest) #include "kcrashtest.moc" 07070100000015000081A40000000000000000000000016649D068000006CB000000000000000000000000000000000000004500000000kcrash-VERSIONgit.20240519T101152~2f9f41e/autotests/metadatatest.cpp/* SPDX-License-Identifier: LGPL-2.0-or-later SPDX-FileCopyrightText: 2021 Harald Sitter <sitter@kde.org> */ #include <QTest> #include "../src/metadata.cpp" using namespace KCrash; class MetadataTest : public QObject { Q_OBJECT private Q_SLOTS: void testEverything() { QTemporaryDir tmpDir; QVERIFY(tmpDir.isValid()); const QString iniFile = QStringLiteral("%1/foo.ini").arg(tmpDir.path()); Metadata data("BEFEHL"); #ifdef Q_OS_LINUX MetadataINIWriter iniWriter(iniFile.toLocal8Bit()); data.setAdditionalWriter(&iniWriter); #endif data.add("--ABC", "FOO"); data.addBool("--Meow"); data.close(); const int argc = data.argc; QCOMPARE(argc, 4); QCOMPARE(data.argv.at(0), QStringLiteral("BEFEHL")); // make sure we do stringy comparison QCOMPARE(data.argv.at(1), QStringLiteral("--ABC")); QCOMPARE(data.argv.at(2), QStringLiteral("FOO")); QCOMPARE(data.argv.at(3), QStringLiteral("--Meow")); QCOMPARE(data.argv.at(4), nullptr); // list should be null terminated #ifdef Q_OS_LINUX QFile::exists(iniFile); QFile ini(iniFile); QVERIFY(ini.open(QFile::ReadOnly)); QCOMPARE(ini.readLine(), "[KCrash]\n"); QCOMPARE(ini.readLine(), "ABC=FOO\n"); QCOMPARE(ini.readLine(), "Meow=true\n"); QVERIFY(ini.atEnd()); // nothing after final newline #endif } void testNoFile() { // Doesn't explode without writer Metadata data("BEFEHL"); data.add("--ABC", "FOO"); data.close(); const int argc = data.argc; QCOMPARE(argc, 3); } }; QTEST_MAIN(MetadataTest) #include "metadatatest.moc" 07070100000016000081A40000000000000000000000016649D06800000699000000000000000000000000000000000000004500000000kcrash-VERSIONgit.20240519T101152~2f9f41e/autotests/test_crasher.cpp/* This file is part of the KDE libraries SPDX-FileCopyrightText: 2013 David Faure <faure@kde.org> SPDX-License-Identifier: LGPL-2.0-or-later */ #include <QApplication> #include <QDebug> #include <QFile> #include <kcrash.h> #ifdef Q_OS_UNIX #include <cerrno> #include <sys/resource.h> // setrlimit #endif QFile output; void saveFunction(int) { output.write("saveFunction called\n"); output.flush(); } int main(int argc, char **argv) { QApplication app(argc, argv); const QStringList args = app.arguments(); QByteArray flag = args.count() > 1 ? args.at(1).toLatin1() : QByteArray(); if (flag == "AR") { // auto restart KCrash::setFlags(KCrash::AutoRestart); } else if (flag == "ARD") { // auto restart, always directly KCrash::setFlags(KCrash::AutoRestart | KCrash::AlwaysDirectly); } else if (flag == "ES") { // emergency save KCrash::setEmergencySaveFunction(saveFunction); } #ifdef Q_OS_UNIX // No core file struct rlimit rlp; rlp.rlim_cur = 0; rlp.rlim_max = 0; if (setrlimit(RLIMIT_CORE, &rlp) != 0) { qDebug() << strerror(errno); } #endif output.setFileName(QStringLiteral("kcrashtest_log")); if (!output.open(QIODevice::WriteOnly | QIODevice::Append)) { return 1; } if (qEnvironmentVariableIsEmpty("KCRASH_AUTO_RESTARTED")) { output.write("starting "); output.write(flag); output.write("\n"); output.flush(); // CRASH! delete (char *)0xdead; } else { output.write("autorestarted "); output.write(flag); output.write("\n"); output.close(); } return 0; } 07070100000017000081A40000000000000000000000016649D0680000017F000000000000000000000000000000000000003800000000kcrash-VERSIONgit.20240519T101152~2f9f41e/metainfo.yamlmaintainer: dfaure description: Support for application crash analysis and bug report from apps tier: 2 type: integration platforms: - name: Linux - name: FreeBSD - name: macOS - name: Windows portingAid: false deprecated: false release: true libraries: - qmake: KCrash cmake: "KF5::Crash" cmakename: KF5Crash public_lib: true group: Frameworks subgroup: Tier 2 07070100000018000041ED0000000000000000000000026649D06800000000000000000000000000000000000000000000002E00000000kcrash-VERSIONgit.20240519T101152~2f9f41e/src07070100000019000081A40000000000000000000000016649D06800000C1F000000000000000000000000000000000000003D00000000kcrash-VERSIONgit.20240519T101152~2f9f41e/src/CMakeLists.txtadd_library(KF5Crash) add_library(KF5::Crash ALIAS KF5Crash) target_sources(KF5Crash PRIVATE coreconfig.cpp coreconfig_p.h kcrash.cpp kcrash.h metadata.cpp metadata_p.h ) configure_file( ${CMAKE_CURRENT_SOURCE_DIR}/config-kcrash.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config-kcrash.h ) ecm_qt_export_logging_category( IDENTIFIER LOG_KCRASH CATEGORY_NAME kf.crash OLD_CATEGORY_NAMES org.kde.kcrash DESCRIPTION "KCrash" EXPORT KCRASH ) generate_export_header(KF5Crash BASE_NAME KCrash) target_include_directories(KF5Crash INTERFACE "$<INSTALL_INTERFACE:${KDE_INSTALL_INCLUDEDIR_KF}/KCrash>") target_link_libraries(KF5Crash PUBLIC Qt${QT_MAJOR_VERSION}::Core) target_link_libraries(KF5Crash PRIVATE Qt${QT_MAJOR_VERSION}::Gui KF5::CoreAddons) # FIXME: It is needed to work around undefined reference error on FreeBSD # caused by --no-undefined because the `environ' variable does not exist # in libc.so.7 -- it is in crt1.o, and so not available to shared # libraries. We just drop the normal no-undefined flag for library building # here, on the assumption that Linux CI will catch any *actual* undefineds. if (CMAKE_SYSTEM_NAME MATCHES "FreeBSD") string(REPLACE "-Wl,--no-undefined" "" CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS}") endif () if(WITH_X11) if (QT_MAJOR_VERSION STREQUAL "5") target_link_libraries(KF5Crash PRIVATE Qt5::X11Extras) endif() target_link_libraries(KF5Crash PRIVATE X11::X11) endif() set_target_properties(KF5Crash PROPERTIES VERSION ${KCrash_VERSION} SOVERSION ${KCrash_SOVERSION} EXPORT_NAME Crash ) ecm_generate_headers(KCrash_HEADERS HEADER_NAMES KCrash REQUIRED_HEADERS KCrash_HEADERS ) install(TARGETS KF5Crash EXPORT KF5CrashTargets ${KF_INSTALL_TARGETS_DEFAULT_ARGS}) install(FILES ${CMAKE_CURRENT_BINARY_DIR}/kcrash_export.h ${KCrash_HEADERS} DESTINATION ${KDE_INSTALL_INCLUDEDIR_KF}/KCrash COMPONENT Devel ) ecm_qt_install_logging_categories( EXPORT KCRASH FILE kcrash.categories DESTINATION ${KDE_INSTALL_LOGGINGCATEGORIESDIR} ) if(BUILD_QCH) ecm_add_qch( KF5Crash_QCH NAME KCrash BASE_NAME KF5Crash VERSION ${KF_VERSION} ORG_DOMAIN org.kde SOURCES # using only public headers, to cover only public API ${KCrash_HEADERS} MD_MAINPAGE "${CMAKE_SOURCE_DIR}/README.md" LINK_QCHS Qt5Core_QCH INCLUDE_DIRS ${CMAKE_CURRENT_BINARY_DIR} BLANK_MACROS KCRASH_EXPORT KCRASH_DEPRECATED KCRASH_DEPRECATED_EXPORT TAGFILE_INSTALL_DESTINATION ${KDE_INSTALL_QTQCHDIR} QCH_INSTALL_DESTINATION ${KDE_INSTALL_QTQCHDIR} COMPONENT Devel ) endif() include(ECMGeneratePriFile) ecm_generate_pri_file(BASE_NAME KCrash LIB_NAME KF5Crash DEPS "core" FILENAME_VAR PRI_FILENAME INCLUDE_INSTALL_DIR ${KDE_INSTALL_INCLUDEDIR_KF}/KCrash) install(FILES ${PRI_FILENAME} DESTINATION ${ECM_MKSPECS_INSTALL_DIR}) 0707010000001A000081A40000000000000000000000016649D068000000A7000000000000000000000000000000000000004400000000kcrash-VERSIONgit.20240519T101152~2f9f41e/src/config-kcrash.h.cmake#cmakedefine01 HAVE_X11 #cmakedefine01 KCRASH_CORE_PATTERN_RAISE #define kde_socklen_t socklen_t #define KDE_INSTALL_FULL_LIBEXECDIR "${KDE_INSTALL_FULL_LIBEXECDIR}" 0707010000001B000081A40000000000000000000000016649D06800000361000000000000000000000000000000000000003D00000000kcrash-VERSIONgit.20240519T101152~2f9f41e/src/coreconfig.cpp/* SPDX-FileCopyrightText: 2016-2021 Harald Sitter <sitter@kde.org> SPDX-License-Identifier: LGPL-2.0-or-later */ #include "coreconfig_p.h" #include <QFile> #include <config-kcrash.h> namespace KCrash { CoreConfig::CoreConfig(const QString &path) { #if !KCRASH_CORE_PATTERN_RAISE return; // Leave everything false unless enabled. #endif QFile file(path); if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) { return; } char first = 0; if (!file.getChar(&first)) { return; } m_supported = true; m_process = first == '|'; if (file.readLine().contains(QByteArrayLiteral("systemd-coredump"))) { m_coredumpd = true; } } bool CoreConfig::isProcess() const { return m_supported && m_process; } bool CoreConfig::isCoredumpd() const { return m_coredumpd; } } // namespace KCrash 0707010000001C000081A40000000000000000000000016649D06800000292000000000000000000000000000000000000003D00000000kcrash-VERSIONgit.20240519T101152~2f9f41e/src/coreconfig_p.h/* SPDX-FileCopyrightText: 2016-2021 Harald Sitter <sitter@kde.org> SPDX-License-Identifier: LGPL-2.0-or-later */ #ifndef KCRASH_CORECONFIG_H #define KCRASH_CORECONFIG_H #include <QString> namespace KCrash { class CoreConfig { public: CoreConfig(const QString &path = QStringLiteral("/proc/sys/kernel/core_pattern")); bool isProcess() const; // should this need expansion please refactor to enum. could also store cmdline and compare in kcrash.cpp bool isCoredumpd() const; private: bool m_supported = false; bool m_process = false; bool m_coredumpd = false; }; } // namespace KCrash #endif // KCRASH_CORECONFIG_H 0707010000001D000081A40000000000000000000000016649D06800007607000000000000000000000000000000000000003900000000kcrash-VERSIONgit.20240519T101152~2f9f41e/src/kcrash.cpp/* This file is part of the KDE Libraries SPDX-FileCopyrightText: 2000 Timo Hummel <timo.hummel@sap.com> SPDX-FileCopyrightText: 2000 Tom Braun <braunt@fh-konstanz.de> SPDX-FileCopyrightText: 2010 George Kiagiadakis <kiagiadakis.george@gmail.com> SPDX-FileCopyrightText: 2009 KDE e.V. <kde-ev-board@kde.org> SPDX-FileCopyrightText: 2021 Harald Sitter <sitter@kde.org> SPDX-FileContributor: 2009 Adriaan de Groot <groot@kde.org> SPDX-License-Identifier: LGPL-2.0-or-later */ #include "kcrash.h" #include <config-kcrash.h> #include <signal.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <qplatformdefs.h> #ifndef Q_OS_WIN #include <cerrno> #include <sys/resource.h> #include <sys/un.h> #else #include <qt_windows.h> #endif #ifdef Q_OS_LINUX #include <sys/poll.h> #include <sys/prctl.h> #endif #include <KAboutData> #include <algorithm> #include <array> #include <memory> #include <QDebug> #include <QDir> #include <QFile> #include <QGuiApplication> #include <QLibraryInfo> #include <QStandardPaths> #include <QThread> #include <QLoggingCategory> Q_DECLARE_LOGGING_CATEGORY(LOG_KCRASH) // logging category for this framework, default: log stuff >= info Q_LOGGING_CATEGORY(LOG_KCRASH, "kf.crash", QtInfoMsg) #if HAVE_X11 #include <X11/Xlib.h> #if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) #include <QX11Info> #endif #endif #include "coreconfig_p.h" #include "metadata_p.h" // Copy from klauncher_cmds typedef struct { long cmd; long arg_length; } kcrash_launcher_header; #define LAUNCHER_OK 4 #define LAUNCHER_EXEC_NEW 12 namespace KCrash { KCRASH_EXPORT bool loadedByKdeinit = false; void setApplicationFilePath(const QString &filePath); // Create socket path to transfer ptrace scope and open connection } #ifdef Q_OS_LINUX static QByteArray s_socketpath; #endif struct Args { ~Args() { clear(); } void clear() { if (!argc) { return; } for (int i = 0; i < argc; ++i) { delete[] argv[i]; } delete[] argv; argv = nullptr; argc = 0; } void resize(int size) { clear(); argc = size; argv = new char *[argc + 1]; for (int i = 0; i < argc + 1; ++i) { argv[i] = nullptr; } } explicit operator bool() const { return argc > 0; } int argc = 0; // null-terminated array of null-terminated strings char **argv = nullptr; }; static KCrash::HandlerType s_emergencySaveFunction = nullptr; static KCrash::HandlerType s_crashHandler = nullptr; static std::unique_ptr<char[]> s_appFilePath; // this is the actual QCoreApplication::applicationFilePath static std::unique_ptr<char[]> s_appName; // the binary name (may be altered by the application) static std::unique_ptr<char[]> s_appPath; // the binary dir path (may be altered by the application) static Args s_autoRestartCommandLine; static std::unique_ptr<char[]> s_drkonqiPath; static KCrash::CrashFlags s_flags = KCrash::CrashFlags(); static int s_launchDrKonqi = -1; // -1=initial value 0=disabled 1=enabled static int s_originalSignal = -1; static QByteArray s_metadataPath; static std::unique_ptr<char[]> s_kcrashErrorMessage; Q_GLOBAL_STATIC(KCrash::CoreConfig, s_coreConfig) static void kcrashInitialize() { // Static because in some cases this is called multiple times // but if an application had any of the bad cases we always want // to skip the check static bool doAutoInitKCrash = true; if (!doAutoInitKCrash) { return; } QCoreApplication *app = QCoreApplication::instance(); if (!app) { doAutoInitKCrash = false; return; } if (!QCoreApplication::startingUp()) { // If the app has already started, this means we're not being run as part of // qt_call_pre_routines, which most probably means that we're being run as part // of KCrash being loaded as part of some plugin of the app, so don't // do any magic doAutoInitKCrash = false; return; } if (!QCoreApplication::eventDispatcher()) { // We are called with event dispatcher being null when KCrash is being loaded // through plasma-integration instead of being linked to the app (i.e. QtCreator vs Okular) // For apps that don't link directly to KCrash do not do the magic doAutoInitKCrash = false; return; } KCrash::initialize(); } Q_COREAPP_STARTUP_FUNCTION(kcrashInitialize) static QStringList libexecPaths() { // Static since we only need to evaluate once. static QStringList list = QFile::decodeName(qgetenv("LIBEXEC_PATH")).split(QLatin1Char(':'), Qt::SkipEmptyParts) // env var is used first + QStringList{ QCoreApplication::applicationDirPath(), // then look where our application binary is located QLibraryInfo::location(QLibraryInfo::LibraryExecutablesPath), // look where libexec path is (can be set in qt.conf) QFile::decodeName(KDE_INSTALL_FULL_LIBEXECDIR) // look at our installation location }; return list; } namespace KCrash { void setApplicationFilePath(const QString &filePath); void startProcess(int argc, const char *argv[], bool waitAndExit); #if defined(Q_OS_WIN) LONG WINAPI win32UnhandledExceptionFilter(_EXCEPTION_POINTERS *exceptionInfo); #endif } static bool shouldWriteMetadataToDisk() { #ifdef Q_OS_LINUX // NB: The daemon being currently running must not be a condition here. If something crashes during logout // the daemon may already be gone but we'll still want to deal with the crash on next login! // Similar reasoning applies to not checking the presence of the launcher socket. const bool drkonqiCoredumpHelper = !QStandardPaths::findExecutable(QStringLiteral("drkonqi-coredump-processor"), libexecPaths()).isEmpty(); return s_coreConfig()->isCoredumpd() && drkonqiCoredumpHelper && !qEnvironmentVariableIsSet("KCRASH_NO_METADATA"); #else return false; #endif } void KCrash::initialize() { if (s_launchDrKonqi == 0) { // disabled by the program itself return; } const QStringList args = QCoreApplication::arguments(); if (!qEnvironmentVariableIsSet("KDE_DEBUG") // && !qEnvironmentVariableIsSet("KCRASH_AUTO_RESTARTED") // && !qEnvironmentVariableIntValue("RUNNING_UNDER_RR") // && qEnvironmentVariableIntValue("KCRASH_DUMP_ONLY") == 0) { // enable drkonqi KCrash::setDrKonqiEnabled(true); } else { // This loads qtlogging.ini very early which prevents unittests from doing QStandardPaths::setTestModeEnabled(true) in initTestCase() // qCDebug(LOG_KCRASH) << "KCrash disabled through environment."; } if (QCoreApplication::instance()) { const QString path = QCoreApplication::applicationFilePath(); s_appFilePath.reset(qstrdup(qPrintable(path))); // This intentionally cannot be changed by the application! KCrash::setApplicationFilePath(path); } else { qWarning() << "This process needs a QCoreApplication instance in order to use KCrash"; } #ifdef Q_OS_LINUX // Create socket path to transfer ptrace scope and open connection s_socketpath = QFile::encodeName(QStringLiteral("%1/kcrash_%2").arg(QStandardPaths::writableLocation(QStandardPaths::RuntimeLocation)).arg(getpid())); #endif if (shouldWriteMetadataToDisk()) { // We do not actively clean up metadata via KCrash but some other service. This potentially means we litter // a lot -> put the metadata in a subdir. const QString metadataDir = QStandardPaths::writableLocation(QStandardPaths::GenericCacheLocation) + QStringLiteral("/kcrash-metadata"); if (QDir().mkpath(metadataDir)) { s_metadataPath = QFile::encodeName(metadataDir + QStringLiteral("/%1.ini").arg(QCoreApplication::applicationPid())); } if (!s_crashHandler) { // Always enable the default handler. We cannot create the metadata ahead of time since we do not know // when the application metadata is "complete". // TODO: kf6 maybe change the way init works and have the users run it when their done with kaboutdata etc.? // the problem with delayed writing is that our crash handler (or any crash handler really) introduces a delay // in dumping and this in turn increases the risk of another stepping into a puddle (SEGV only runs on the // faulting thread; all other threads continue running!). therefore it'd be greatly preferred if we // were able to write the metadata during initial app setup instead of when a crash occurs setCrashHandler(defaultCrashHandler); } } // empty s_metadataPath disables writing s_coreConfig(); // Initialize. } void KCrash::setEmergencySaveFunction(HandlerType saveFunction) { s_emergencySaveFunction = saveFunction; /* * We need at least the default crash handler for * emergencySaveFunction to be called */ if (s_emergencySaveFunction && !s_crashHandler) { setCrashHandler(defaultCrashHandler); } } KCrash::HandlerType KCrash::emergencySaveFunction() { return s_emergencySaveFunction; } // Set the default crash handler in 10 seconds // This is used after an autorestart, the second instance of the application // is started with KCRASH_AUTO_RESTARTED=1, and we // set the defaultCrashHandler (to handle autorestart) after 10s. // The delay is to see if we stay up for more than 10s time, to avoid infinite // respawning if the app crashes on startup. class KCrashDelaySetHandler : public QObject { public: KCrashDelaySetHandler() { startTimer(10000); // 10 s } protected: void timerEvent(QTimerEvent *event) override { if (!s_crashHandler) { // not set meanwhile KCrash::setCrashHandler(KCrash::defaultCrashHandler); } killTimer(event->timerId()); this->deleteLater(); } }; void KCrash::setFlags(KCrash::CrashFlags flags) { s_flags = flags; if (s_flags & AutoRestart) { // We need at least the default crash handler for autorestart to work. if (!s_crashHandler) { if (qEnvironmentVariableIsSet("KCRASH_AUTO_RESTARTED")) { new KCrashDelaySetHandler; } else { setCrashHandler(defaultCrashHandler); } } } } void KCrash::setApplicationFilePath(const QString &filePath) { const int pos = filePath.lastIndexOf(QLatin1Char('/')); const QString appName = filePath.mid(pos + 1); const QString appPath = filePath.left(pos); // could be empty, in theory s_appName.reset(qstrdup(QFile::encodeName(appName).constData())); s_appPath.reset(qstrdup(QFile::encodeName(appPath).constData())); // Prepare the auto-restart command QStringList args = QCoreApplication::arguments(); if (args.isEmpty()) { // edge case: tst_QX11Info::startupId does QApplication app(argc, nullptr)... args.append(filePath); } else { args[0] = filePath; // replace argv[0] with full path above } s_autoRestartCommandLine.resize(args.count()); for (int i = 0; i < args.count(); ++i) { s_autoRestartCommandLine.argv[i] = qstrdup(QFile::encodeName(args.at(i)).constData()); } } void KCrash::setDrKonqiEnabled(bool enabled) { const int launchDrKonqi = enabled ? 1 : 0; if (s_launchDrKonqi == launchDrKonqi) { return; } s_launchDrKonqi = launchDrKonqi; if (s_launchDrKonqi && !s_drkonqiPath) { #ifdef Q_OS_WINDOWS static const QString drkonqi = QStringLiteral("drkonqi.exe"); #else static const QString drkonqi = QStringLiteral("drkonqi"); #endif const QString exec = QStandardPaths::findExecutable(drkonqi, libexecPaths()); if (exec.isEmpty()) { qCDebug(LOG_KCRASH) << "Could not find drkonqi in search paths:" << libexecPaths(); s_launchDrKonqi = 0; } else { s_drkonqiPath.reset(qstrdup(qPrintable(exec))); } } // we need at least the default crash handler to launch drkonqi if (s_launchDrKonqi && !s_crashHandler) { setCrashHandler(defaultCrashHandler); } } bool KCrash::isDrKonqiEnabled() { return s_launchDrKonqi == 1; } void KCrash::setCrashHandler(HandlerType handler) { #if defined(Q_OS_WIN) static LPTOP_LEVEL_EXCEPTION_FILTER s_previousExceptionFilter = NULL; if (handler && !s_previousExceptionFilter) { s_previousExceptionFilter = SetUnhandledExceptionFilter(KCrash::win32UnhandledExceptionFilter); } else if (!handler && s_previousExceptionFilter) { SetUnhandledExceptionFilter(s_previousExceptionFilter); s_previousExceptionFilter = NULL; } #else if (!handler) { handler = SIG_DFL; } sigset_t mask; sigemptyset(&mask); #ifdef SIGSEGV signal(SIGSEGV, handler); sigaddset(&mask, SIGSEGV); #endif #ifdef SIGBUS signal(SIGBUS, handler); sigaddset(&mask, SIGBUS); #endif #ifdef SIGFPE signal(SIGFPE, handler); sigaddset(&mask, SIGFPE); #endif #ifdef SIGILL signal(SIGILL, handler); sigaddset(&mask, SIGILL); #endif #ifdef SIGABRT signal(SIGABRT, handler); sigaddset(&mask, SIGABRT); #endif sigprocmask(SIG_UNBLOCK, &mask, nullptr); #endif s_crashHandler = handler; } KCrash::HandlerType KCrash::crashHandler() { return s_crashHandler; } #if !defined(Q_OS_WIN) && !defined(Q_OS_OSX) static void closeAllFDs() { // Close all remaining file descriptors except for stdin/stdout/stderr struct rlimit rlp = {}; getrlimit(RLIMIT_NOFILE, &rlp); for (rlim_t i = 3; i < rlp.rlim_cur; i++) { close(i); } } #endif void crashOnSigTerm(int sig) { Q_UNUSED(sig) raise(s_originalSignal); } void KCrash::defaultCrashHandler(int sig) { // WABA: Do NOT use qDebug() in this function because it is much too risky! // Handle possible recursions static int crashRecursionCounter = 0; crashRecursionCounter++; // Nothing before this, please ! s_originalSignal = sig; #if !defined(Q_OS_WIN) signal(SIGALRM, SIG_DFL); alarm(3); // Kill me... (in case we deadlock in malloc) #endif if (crashRecursionCounter < 2) { if (s_emergencySaveFunction) { s_emergencySaveFunction(sig); } if ((s_flags & AutoRestart) && s_autoRestartCommandLine) { QThread::sleep(1); startProcess(s_autoRestartCommandLine.argc, const_cast<const char **>(s_autoRestartCommandLine.argv), false); } crashRecursionCounter++; } if (crashRecursionCounter < 3) { // If someone is telling me to stop while I'm already crashing, then I should resume crashing signal(SIGTERM, &crashOnSigTerm); // NB: all metadata writing ought to happen before closing FDs to reduce synchronization problems with dbus. // WARNING: do not forget to increase Metadata::argv's size when adding more potential arguments! Metadata data(s_drkonqiPath.get()); #ifdef Q_OS_LINUX // The ini is required to be scoped here, as opposed to the conditional scope, so its lifetime is the same as // the regular data instance! MetadataINIWriter ini(s_metadataPath); if (ini.isWritable()) { // Add the canonical exe path so the coredump daemon has more data points to map metadata to journald entry. ini.add("--exe", s_appFilePath.get(), MetadataWriter::BoolValue::No); data.setAdditionalWriter(&ini); } #endif const QByteArray platformName = QGuiApplication::platformName().toUtf8(); if (!platformName.isEmpty()) { data.add("--platform", platformName.constData()); } #if HAVE_X11 if (platformName == QByteArrayLiteral("xcb")) { // start up on the correct display char *display = nullptr; #if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) if (QX11Info::display()) { display = XDisplayString(QX11Info::display()); #else if (auto disp = qGuiApp->nativeInterface<QNativeInterface::QX11Application>()->display()) { display = XDisplayString(disp); #endif } else { display = getenv("DISPLAY"); } data.add("--display", display); } #endif data.add("--appname", s_appName ? s_appName.get() : "<unknown>"); if (loadedByKdeinit) { data.addBool("--kdeinit"); } // only add apppath if it's not NULL if (s_appPath && s_appPath[0]) { data.add("--apppath", s_appPath.get()); } // signal number -- will never be NULL char sigtxt[10]; sprintf(sigtxt, "%d", sig); data.add("--signal", sigtxt); char pidtxt[20]; sprintf(pidtxt, "%lld", QCoreApplication::applicationPid()); data.add("--pid", pidtxt); const KAboutData *about = KAboutData::applicationDataPointer(); if (about) { if (about->internalVersion()) { data.add("--appversion", about->internalVersion()); } if (about->internalProgramName()) { data.add("--programname", about->internalProgramName()); } if (about->internalBugAddress()) { data.add("--bugaddress", about->internalBugAddress()); } if (about->internalProductName()) { data.add("--productname", about->internalProductName()); } } if (s_flags & SaferDialog) { data.addBool("--safer"); } if ((s_flags & AutoRestart) && s_autoRestartCommandLine) { data.addBool("--restarted"); } #if defined(Q_OS_WIN) char threadId[8] = {0}; sprintf(threadId, "%d", GetCurrentThreadId()); data.add("--thread", threadId); #endif data.close(); const int argc = data.argc; const char **argv = data.argv.data(); #ifndef NDEBUG fprintf(stderr, "KCrash: crashing... crashRecursionCounter = %d\n", crashRecursionCounter); fprintf(stderr, "KCrash: Application Name = %s path = %s pid = %lld\n", s_appName ? s_appName.get() : "<unknown>", s_appPath ? s_appPath.get() : "<unknown>", QCoreApplication::applicationPid()); fprintf(stderr, "KCrash: Arguments: "); for (int i = 0; i < s_autoRestartCommandLine.argc; ++i) { fprintf(stderr, "%s ", s_autoRestartCommandLine.argv[i]); } fprintf(stderr, "\n"); #else fprintf(stderr, "KCrash: Application '%s' crashing...\n", s_appName ? s_appName.get() : "<unknown>"); #endif #if !defined(Q_OS_WIN) && !defined(Q_OS_OSX) if (!(s_flags & KeepFDs)) { // This tries to prevent problems where applications fail to release resources that drkonqi might need. // Specifically this was introduced to ensure that an application that had grabbed the X11 cursor would // forcefully have it removed upon crash to ensure it is ungrabbed by the time drkonqi makes an appearance. // This is also the point in time when, for example, dbus services are lost. Closing the socket indicates // to dbus-daemon that the process has disappeared and it will forcefully reclaim the registered service names. // // Once we close our socket we lose potential dbus names and if we were running as a systemd service anchored to a name, // the daemon may decide to jump at us with a TERM signal. We'll want to have finished the metadata by now and // be near our tracing/raise(). closeAllFDs(); } #if HAVE_X11 #if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) else if (QX11Info::display()) { close(ConnectionNumber(QX11Info::display())); } #else else if (auto display = qGuiApp->nativeInterface<QNativeInterface::QX11Application>()->display()) { close(ConnectionNumber(display)); } #endif #endif #endif if (s_launchDrKonqi != 1) { setCrashHandler(nullptr); #if !defined(Q_OS_WIN) raise(sig); // dump core, or whatever is the default action for this signal. #endif return; } startProcess(argc, argv, true); } if (crashRecursionCounter < 4) { fprintf(stderr, "Unable to start Dr. Konqi\n"); } if (s_coreConfig->isProcess()) { fprintf(stderr, "Re-raising signal for core dump handling.\n"); KCrash::setCrashHandler(nullptr); raise(sig); // not getting here } _exit(255); } #if defined(Q_OS_WIN) void KCrash::startProcess(int argc, const char *argv[], bool waitAndExit) { QString cmdLine; for (int i = 0; i < argc; ++i) { cmdLine.append(QLatin1Char('\"')); cmdLine.append(QFile::decodeName(argv[i])); cmdLine.append(QStringLiteral("\" ")); } PROCESS_INFORMATION procInfo; STARTUPINFOW startupInfo = {sizeof(STARTUPINFO), 0, 0, 0, (ulong)CW_USEDEFAULT, (ulong)CW_USEDEFAULT, (ulong)CW_USEDEFAULT, (ulong)CW_USEDEFAULT, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; bool success = CreateProcess(0, (wchar_t *)cmdLine.utf16(), NULL, NULL, false, CREATE_UNICODE_ENVIRONMENT, NULL, NULL, &startupInfo, &procInfo); if (success && waitAndExit) { // wait for child to exit WaitForSingleObject(procInfo.hProcess, INFINITE); _exit(253); } } // glue function for calling the unix signal handler from the windows unhandled exception filter LONG WINAPI KCrash::win32UnhandledExceptionFilter(_EXCEPTION_POINTERS *exceptionInfo) { // kdbgwin needs the context inside exceptionInfo because if getting the context after the // exception happened, it will walk down the stack and will stop at KiUserEventDispatch in // ntdll.dll, which is supposed to dispatch the exception from kernel mode back to user mode // so... let's create some shared memory HANDLE hMapFile = NULL; hMapFile = CreateFileMapping(INVALID_HANDLE_VALUE, NULL, PAGE_READWRITE, 0, sizeof(CONTEXT), TEXT("Local\\KCrashShared")); LPCTSTR pBuf = NULL; pBuf = (LPCTSTR)MapViewOfFile(hMapFile, FILE_MAP_ALL_ACCESS, 0, 0, sizeof(CONTEXT)); CopyMemory((PVOID)pBuf, exceptionInfo->ContextRecord, sizeof(CONTEXT)); if (s_crashHandler) { s_crashHandler(exceptionInfo->ExceptionRecord->ExceptionCode); } CloseHandle(hMapFile); return EXCEPTION_EXECUTE_HANDLER; // allow windows to do the default action (terminate) } #else static pid_t startDirectly(const char *argv[]); #ifdef Q_OS_LINUX static int write_socket(int sock, char *buffer, int len); static int read_socket(int sock, char *buffer, int len); static int openDrKonqiSocket(const QByteArray &socketpath); static int pollDrKonqiSocket(pid_t pid, int sockfd); #endif void KCrash::startProcess(int argc, const char *argv[], bool waitAndExit) { Q_UNUSED(argc); fprintf(stderr, "KCrash: Attempting to start %s\n", argv[0]); pid_t pid = startDirectly(argv); if (pid > 0 && waitAndExit) { // Seems we made it.... alarm(0); // Stop the pending alarm that was set at the top of the defaultCrashHandler bool running = true; // Wait forever until the started process exits. This code path is executed // when launching drkonqi. Note that DrKonqi will SIGSTOP this process in the meantime // and only send SIGCONT when it is about to attach a debugger. #ifdef Q_OS_LINUX // Declare the process that will be debugging the crashed KDE app (#245529). // For now that will be DrKonqi, which may ask to transfer the ptrace scope to // a debugger it is not an ancestor of (because it was started via kdeinit or // KProcess::startDetached()) using a socket. #ifndef PR_SET_PTRACER #define PR_SET_PTRACER 0x59616d61 #endif prctl(PR_SET_PTRACER, pid, 0, 0, 0); int sockfd = openDrKonqiSocket(s_socketpath); if (sockfd >= 0) { // Wait while DrKonqi is running and the socket connection exists // If the process was started directly, use waitpid(), as it's a child... while ((running = waitpid(pid, nullptr, WNOHANG) != pid) && pollDrKonqiSocket(pid, sockfd) >= 0) { } close(sockfd); unlink(s_socketpath.constData()); } #endif if (running) { // If the process was started directly, use waitpid(), as it's a child... while (waitpid(pid, nullptr, 0) != pid) { } } if (!s_coreConfig->isProcess()) { // Only exit if we don't forward to core dumps _exit(253); } } } extern "C" char **environ; static pid_t startDirectly(const char *argv[]) { char **environ_end; for (environ_end = environ; *environ_end; ++environ_end) { } std::array<const char *, 1024> environ_data; // hope it's big enough if ((unsigned)(environ_end - environ) + 2 >= environ_data.size()) { fprintf(stderr, "environ_data in KCrash not big enough!\n"); return 0; } auto end = std::copy_if(environ, environ_end, environ_data.begin(), [](const char *s) { static const char envvar[] = "KCRASH_AUTO_RESTARTED="; return strncmp(envvar, s, sizeof(envvar) - 1) != 0; }); *end++ = "KCRASH_AUTO_RESTARTED=1"; *end++ = nullptr; pid_t pid = fork(); switch (pid) { case -1: fprintf(stderr, "KCrash failed to fork(), errno = %d\n", errno); return 0; case 0: setgroups(0, nullptr); // Remove any extraneous groups if (setgid(getgid()) < 0 || setuid(getuid()) < 0) { _exit(253); // This cannot happen. Theoretically. } #ifndef Q_OS_OSX closeAllFDs(); // We are in the child now. Close FDs unconditionally. #endif execve(argv[0], const_cast<char **>(argv), const_cast<char **>(environ_data.data())); fprintf(stderr, "KCrash failed to exec(), errno = %d\n", errno); _exit(253); default: return pid; } } #ifdef Q_OS_LINUX /* * Write 'len' bytes from 'buffer' into 'sock'. * returns 0 on success, -1 on failure. */ static int write_socket(int sock, char *buffer, int len) { ssize_t result; int bytes_left = len; while (bytes_left > 0) { result = write(sock, buffer, bytes_left); if (result > 0) { buffer += result; bytes_left -= result; } else if (result == 0) { return -1; } else if ((result == -1) && (errno != EINTR) && (errno != EAGAIN)) { return -1; } } return 0; } /* * Read 'len' bytes from 'sock' into 'buffer'. * returns 0 on success, -1 on failure. */ static int read_socket(int sock, char *buffer, int len) { ssize_t result; int bytes_left = len; while (bytes_left > 0) { result = read(sock, buffer, bytes_left); if (result > 0) { buffer += result; bytes_left -= result; } else if (result == 0) { return -1; } else if ((result == -1) && (errno != EINTR) && (errno != EAGAIN)) { return -1; } } return 0; } static int openDrKonqiSocket(const QByteArray &socketpath) { int sockfd = socket(PF_UNIX, SOCK_STREAM, 0); if (sockfd < 0) { perror("Warning: socket() for communication with DrKonqi failed"); return -1; } struct sockaddr_un drkonqi_server; drkonqi_server.sun_family = AF_UNIX; if (socketpath.size() >= static_cast<int>(sizeof(drkonqi_server.sun_path))) { fprintf(stderr, "Warning: socket path is too long\n"); close(sockfd); return -1; } strcpy(drkonqi_server.sun_path, socketpath.constData()); unlink(drkonqi_server.sun_path); // remove potential stale socket if (bind(sockfd, (struct sockaddr *)&drkonqi_server, sizeof(drkonqi_server)) < 0) { perror("Warning: bind() for communication with DrKonqi failed"); close(sockfd); unlink(drkonqi_server.sun_path); return -1; } listen(sockfd, 1); return sockfd; } static int pollDrKonqiSocket(pid_t pid, int sockfd) { struct pollfd fd; fd.fd = sockfd; fd.events = POLLIN; int r; do { r = poll(&fd, 1, 1000); // wait for 1 second for a request by DrKonqi } while (r == -1 && errno == EINTR); // only continue if POLLIN event returned if (r == 0) { // timeout return 0; } else if (r == -1 || !(fd.revents & POLLIN)) { // some error return -1; } static struct sockaddr_un drkonqi_client; static socklen_t cllength = sizeof(drkonqi_client); int clsockfd; do { clsockfd = accept(sockfd, (struct sockaddr *)&drkonqi_client, &cllength); } while (clsockfd == -1 && errno == EINTR); if (clsockfd < 0) { return -1; } // check whether the message is coming from DrKonqi static struct ucred ucred; static socklen_t credlen = sizeof(struct ucred); if (getsockopt(clsockfd, SOL_SOCKET, SO_PEERCRED, &ucred, &credlen) < 0) { return -1; } if (ucred.pid != pid) { fprintf(stderr, "Warning: peer pid does not match DrKonqi pid\n"); return -1; } // read PID to change ptrace scope static const int msize = 21; // most digits in a 64bit int (+sign +'\0') char msg[msize]; if (read_socket(clsockfd, msg, msize) == 0) { int dpid = atoi(msg); prctl(PR_SET_PTRACER, dpid, 0, 0, 0); // confirm change to DrKonqi if (write_socket(clsockfd, msg, msize) == 0) { fprintf(stderr, "KCrash: ptrace access transferred to %s\n", msg); } } close(clsockfd); return 1; } #endif #endif // Q_OS_UNIX void KCrash::setErrorMessage(const QString &message) { s_kcrashErrorMessage.reset(qstrdup(message.toUtf8().constData())); } 0707010000001E000081A40000000000000000000000016649D06800001504000000000000000000000000000000000000003700000000kcrash-VERSIONgit.20240519T101152~2f9f41e/src/kcrash.h/* This file is part of the KDE Libraries SPDX-FileCopyrightText: 2000 Timo Hummel <timo.hummel@sap.com> SPDX-FileCopyrightText: 2000 Tom Braun <braunt@fh-konstanz.de> SPDX-License-Identifier: LGPL-2.0-or-later */ #ifndef KCRASH_H #define KCRASH_H #include <kcrash_export.h> #include <qglobal.h> class QString; /** * This namespace contains functions to handle crashes. * It allows you to set a crash handler function that will be called * when your application crashes and also provides a default crash * handler that implements the following functionality: * @li Launches the KDE crash display application (DrKonqi) to let * the user report the bug and/or debug it. * @li Calls an emergency save function that you can set with * setEmergencySaveFunction() to attempt to save the application's data. * @li Autorestarts your application. * * @note All the above features are optional and you need to enable them * explicitly. By default, the defaultCrashHandler() will not do anything. * However, if you are using KApplication, it will by default enable launching * DrKonqi on crashes, unless the --nocrashhandler argument was passed on * the command line or the environment variable KDE_DEBUG is set to any value. */ namespace KCrash { /** * Initialize KCrash. * * This does nothing if $KDE_DEBUG is set. * * Call this in your main() to ensure that the crash handler is always launched. * @since 5.15 */ KCRASH_EXPORT void initialize(); /** * The default crash handler. * Do not call this function directly. Instead, use * setCrashHandler() to set it as your application's crash handler. * @param signal the signal number * @note If you implement your own crash handler, you will have to * call this function from your implementation if you want to use the * features of this namespace. */ KCRASH_EXPORT void defaultCrashHandler(int signal); /** * Typedef for a pointer to a crash handler function. * The function's argument is the number of the signal. */ typedef void (*HandlerType)(int); /** * Install a function to be called when a crash occurs. * A crash occurs when one of the following signals is * caught: SIGSEGV, SIGBUS, SIGFPE, SIGILL, SIGABRT. * @param handler this can be one of: * @li null, in which case signal catching is disabled * (by setting the signal handler for the crash signals to SIG_DFL) * @li a user defined function in the form: * static (if in a class) void myCrashHandler(int); * @li if handler is omitted, the default crash handler is installed * @note If you use setDrKonqiEnabled(true), setEmergencySaveFunction(myfunc) * or setFlags(AutoRestart), you do not need to call this function * explicitly. The default crash handler is automatically installed by * those functions if needed. However, if you set a custom crash handler, * those functions will not change it. */ KCRASH_EXPORT void setCrashHandler(HandlerType handler = defaultCrashHandler); /** * Returns the installed crash handler. * @return the crash handler */ KCRASH_EXPORT HandlerType crashHandler(); /** * Installs a function which should try to save the application's data. * @note It is the crash handler's responsibility to call this function. * Therefore, if no crash handler is set, the default crash handler * is installed to ensure the save function will be called. * @param saveFunction the handler to install */ KCRASH_EXPORT void setEmergencySaveFunction(HandlerType saveFunction = nullptr); /** * Returns the currently set emergency save function. * @return the emergency save function */ KCRASH_EXPORT HandlerType emergencySaveFunction(); /** * Options to determine how the default crash handler should behave. * @see CrashFlags */ enum CrashFlag { KeepFDs = 1, ///< don't close all file descriptors immediately SaferDialog = 2, ///< start DrKonqi without arbitrary disk access AlwaysDirectly = 4, ///< never try to to start DrKonqi via kdeinit. Use fork() and exec() instead. @deprecated This is now the default, and does not need to be set. AutoRestart = 8, ///< autorestart this application. Only sensible for KUniqueApplications. @since 4.1. }; /** * Stores a combination of #CrashFlag values. */ Q_DECLARE_FLAGS(CrashFlags, CrashFlag) Q_DECLARE_OPERATORS_FOR_FLAGS(CrashFlags) /** * Set options to determine how the default crash handler should behave. * @param flags ORed together CrashFlags */ KCRASH_EXPORT void setFlags(KCrash::CrashFlags flags); /** * Enables or disables launching DrKonqi from the crash handler. * By default, launching DrKonqi is enabled when QCoreApplication is created. * To disable it: * @code void disableDrKonqi() { KCrash::setDrKonqiEnabled(false); } Q_CONSTRUCTOR_FUNCTION(disableDrKonqi) * \endcode * @note It is the crash handler's responsibility to launch DrKonqi. * Therefore, if no crash handler is set, this method also installs * the default crash handler to ensure that DrKonqi will be launched. * @since 4.5 */ KCRASH_EXPORT void setDrKonqiEnabled(bool enabled); /** * Returns true if DrKonqi is set to be launched from the crash handler or false otherwise. * @since 4.5 */ KCRASH_EXPORT bool isDrKonqiEnabled(); /** * Allows providing information to be included in the bug report. * * @since 5.69 */ KCRASH_EXPORT void setErrorMessage(const QString &message); } #endif 0707010000001F000081A40000000000000000000000016649D06800000DEE000000000000000000000000000000000000003B00000000kcrash-VERSIONgit.20240519T101152~2f9f41e/src/metadata.cpp/* SPDX-License-Identifier: LGPL-2.0-or-later SPDX-FileCopyrightText: 2021 Harald Sitter <sitter@kde.org> */ #include "metadata_p.h" #include <QByteArray> #include <cerrno> #ifdef Q_OS_LINUX #include <cstring> #include <fcntl.h> #include <sys/stat.h> #include <sys/types.h> #include <unistd.h> #endif namespace KCrash { #ifdef Q_OS_LINUX MetadataINIWriter::MetadataINIWriter(const QByteArray &path) : MetadataWriter() { if (path.isEmpty()) { return; } fd = ::open(path.constData(), O_WRONLY | O_CREAT | O_NONBLOCK | O_TRUNC | O_CLOEXEC, S_IRUSR | S_IWUSR); if (fd == -1) { fprintf(stderr, "Failed to open metadata file: %s\n", strerror(errno)); } else if (fd >= 0) { writable = true; const char *header = "[KCrash]\n"; write(fd, header, strlen(header)); } else { fprintf(stderr, "MetadataINIWriter: Unexpected fd %d\n", fd); Q_UNREACHABLE(); } } void MetadataINIWriter::close() { if (fd >= 0 && ::close(fd) == -1) { fprintf(stderr, "Failed to close metadata file: %s\n", strerror(errno)); } writable = false; } void MetadataINIWriter::add(const char *key, const char *value, BoolValue boolValue) { Q_ASSERT(key); Q_ASSERT(value); Q_ASSERT(key[0] == '-' && key[1] == '-'); // well-formed '--' prefix. This is important. MetadataWriter presume this Q_UNUSED(boolValue); // value is a bool string but we don't care, we always write the value anyway if (fd < 0) { return; } const int ret = snprintf(iniLine.data(), iniLine.max_size(), "%s=%s\n", key + 2 /** skip the leading -- */, value); if (ret < 0) { fprintf(stderr, "Failed to generate metadata line for '%s', '%s'\n", key, value); return; } // Cannot be negative anymore. const std::make_unsigned<decltype(ret)>::type lineLength = ret; fprintf(stderr, "%d -- %s", lineLength, iniLine.data()); Q_ASSERT(lineLength <= iniLine.max_size()); // is not truncated41 write(fd, iniLine.data(), lineLength); } bool MetadataINIWriter::isWritable() const { return writable; } #endif Metadata::Metadata(const char *cmd) { // NB: cmd may be null! Just because we create metadata doesn't mean we'll execute drkonqi (we may only need the // backing writers) Q_ASSERT(argc == 0); argv.at(argc++) = cmd; } void Metadata::setAdditionalWriter(MetadataWriter *writer) { // Once set the writer oughtn't be reset as we have no use case for this and should we get one in the future // it'll need at least review of the existing code to handle writer switching correctly. Q_ASSERT(m_writer == nullptr); Q_ASSERT(writer != nullptr); m_writer = writer; } void Metadata::add(const char *key, const char *value) { add(key, value, BoolValue::No); } void Metadata::addBool(const char *key) { add(key, "true", BoolValue::Yes); } void Metadata::close() { // NULL terminated list argv.at(argc) = nullptr; if (m_writer) { m_writer->close(); } } void Metadata::add(const char *key, const char *value, BoolValue boolValue) { Q_ASSERT(key); Q_ASSERT(value); Q_ASSERT(key[0] == '-' && key[1] == '-'); // well-formed '--' prefix. This is important. MetadataWriter presume this Q_ASSERT(argc < argv.max_size()); // argv has a static max size. guard against exhaustion argv.at(argc++) = key; if (!boolValue) { argv.at(argc++) = value; } if (m_writer) { m_writer->add(key, value, boolValue); } } } // namespace KCrash 07070100000020000081A40000000000000000000000016649D0680000096B000000000000000000000000000000000000003B00000000kcrash-VERSIONgit.20240519T101152~2f9f41e/src/metadata_p.h/* SPDX-License-Identifier: LGPL-2.0-or-later SPDX-FileCopyrightText: 2021 Harald Sitter <sitter@kde.org> */ #ifndef KCRASH_METADATA_H #define KCRASH_METADATA_H #include <QtGlobal> #include <array> class QByteArray; namespace KCrash { // A metadata writer interface. class MetadataWriter { public: enum BoolValue { No = false, Yes = true }; virtual void add(const char *key, const char *value, BoolValue boolValue) = 0; virtual void close() = 0; protected: MetadataWriter() = default; virtual ~MetadataWriter() = default; private: Q_DISABLE_COPY_MOVE(MetadataWriter) }; #ifdef Q_OS_LINUX // This writes the metadata file. Only really useful on Linux for now as this needs // cleanup by a helper daemon later. Also, this is only ever useful when coredump is in use. class MetadataINIWriter : public MetadataWriter { public: explicit MetadataINIWriter(const QByteArray &path); ~MetadataINIWriter() override = default; void add(const char *key, const char *value, BoolValue boolValue) override; void close() override; // open or not, all functions are generally save to call without checking this [[nodiscard]] bool isWritable() const; private: bool writable = false; int fd = -1; std::array<char, 1024> iniLine{}; // arbitrary max size Q_DISABLE_COPY_MOVE(MetadataINIWriter) }; #endif // Compile the crash metadata. These are the primary ARGV metadata, but additional // metadata writers may be added behind it to (e.g.) write the data to a file as well. // man 7 signal-safety class Metadata : public MetadataWriter { public: explicit Metadata(const char *cmd); ~Metadata() override = default; // Add an additional writer that should receive write calls as well. Do not call this after having called add. void setAdditionalWriter(MetadataWriter *writer); void add(const char *key, const char *value); void addBool(const char *key); // Also closes the backing writer. void close() override; std::array<const char *, 31> argv{}; std::size_t argc = 0; private: void add(const char *key, const char *value, BoolValue boolValue) override; // Obviously if we should ever need more writers, refactor to std::initializer_list or something similar. MetadataWriter *m_writer = nullptr; Q_DISABLE_COPY_MOVE(Metadata) }; } // namespace KCrash #endif // KCRASH_METADATA_H 07070100000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000B00000000TRAILER!!!193 blocks
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor