fix: guard PIObject dump diagnostics by PIP_INTROSPECTION and drop PIP_FORCE_NO_PIINTROSPECTION

- invert friend block in piobject.h (friends needed when introspection
  is enabled) and remove dead friend PIObjectManager
- guard PIObject::dump()/dumpApplication()/dumpApplicationToFile()
  declarations and definitions by PIP_INTROSPECTION
  (dumpApplicationToFile additionally requires PIP_HAS_FILESYSTEM)
- guard dumpApplicationToFile() call in __sighandler__ by
  PIP_INTROSPECTION && PIP_HAS_FILESYSTEM
- replace '#if defined(PIP_INTROSPECTION) && !defined(PIP_FORCE_NO_PIINTROSPECTION)'
  with plain '#ifdef PIP_INTROSPECTION' everywhere, remove PIP_FORCE_NO_PIINTROSPECTION
- fix broken PIINTROSPECTION_CONTAINER_ALLOC(T, (as - ...)) in
  pideque.h/pivector.h ('as' no longer exists, use new_rsize)
This commit is contained in:
2026-08-22 13:44:58 +03:00
parent 75cfdd2e4c
commit 858d205fd3
16 changed files with 38 additions and 29 deletions
+3 -3
View File
@@ -1272,7 +1272,7 @@ public:
template<typename T1 = T, typename std::enable_if<std::is_trivially_copyable<T1>::value, int>::type = 0>
inline PIDeque<T> & _resizeRaw(size_t new_size) {
#if defined(PIP_INTROSPECTION) && !defined(PIP_FORCE_NO_PIINTROSPECTION)
#ifdef PIP_INTROSPECTION
if (new_size > pid_size) {
PIINTROSPECTION_CONTAINER_USED(T, (new_size - pid_size));
}
@@ -2678,7 +2678,7 @@ private:
pid_size = new_size;
const size_t new_rsize = _PIContainerConstants<T>::calcNewSize(pid_rsize, pid_start + new_size);
if (new_rsize != pid_rsize) {
PIINTROSPECTION_CONTAINER_ALLOC(T, (as - pid_rsize))
PIINTROSPECTION_CONTAINER_ALLOC(T, (new_rsize - pid_rsize))
T * new_data = reinterpret_cast<T *>(realloc(reinterpret_cast<void *>(pid_data), new_rsize * sizeof(T)));
#ifndef NDEBUG
if (!new_data) {
@@ -2697,7 +2697,7 @@ private:
if (new_rsize > pid_rsize) {
T * tmp_data = reinterpret_cast<T *>(malloc(new_rsize * sizeof(T)));
const size_t new_start = pid_start + new_rsize - pid_rsize;
PIINTROSPECTION_CONTAINER_ALLOC(T, (as - pid_rsize))
PIINTROSPECTION_CONTAINER_ALLOC(T, (new_rsize - pid_rsize))
if (pid_rsize > 0 && pid_data) {
memcpy(reinterpret_cast<void *>(tmp_data + new_start),
reinterpret_cast<const void *>(pid_data + pid_start),
+2 -2
View File
@@ -1274,7 +1274,7 @@ public:
template<typename T1 = T, typename std::enable_if<std::is_trivially_copyable<T1>::value, int>::type = 0>
inline PIVector<T> & _resizeRaw(size_t new_size) {
#if defined(PIP_INTROSPECTION) && !defined(PIP_FORCE_NO_PIINTROSPECTION)
#ifdef PIP_INTROSPECTION
if (new_size > piv_size) {
PIINTROSPECTION_CONTAINER_USED(T, (new_size - piv_size));
}
@@ -2575,7 +2575,7 @@ private:
piv_size = new_size;
const size_t new_rsize = _PIContainerConstants<T>::calcNewSize(piv_rsize, new_size);
if (new_rsize == piv_rsize) return;
PIINTROSPECTION_CONTAINER_ALLOC(T, (as - piv_rsize))
PIINTROSPECTION_CONTAINER_ALLOC(T, (new_rsize - piv_rsize))
T * new_data = reinterpret_cast<T *>(realloc(reinterpret_cast<void *>(piv_data), new_rsize * sizeof(T)));
#ifndef NDEBUG
if (!new_data) {
+5 -3
View File
@@ -84,9 +84,11 @@ PRIVATE_DEFINITION_END(PIInit)
void __sighandler__(PISignals::Signal s) {
// piCout << Hex << int(s);
if (s == PISignals::StopTTYInput || s == PISignals::StopTTYOutput) piMSleep(10);
# if defined(PIP_INTROSPECTION) && defined(PIP_HAS_FILESYSTEM)
if (s == PISignals::UserDefined1)
dumpApplicationToFile(PIDir::home().path() + PIDir::separator + PIStringAscii("_PIP_DUMP_") +
PIString::fromNumber(PIProcess::currentPID()));
# endif
}
@@ -181,9 +183,9 @@ PIInit::PIInit() {
// piCout << __sysoemname__;
# else // PIP_ICU
# ifdef WINDOWS
__syslocname__ = (char *)CP_ACP;
__sysoemname__ = (char *)CP_OEMCP;
__utf8name__ = (char *)CP_UTF8;
__syslocname__ = (char *)CP_ACP;
__sysoemname__ = (char *)CP_OEMCP;
__utf8name__ = (char *)CP_UTF8;
# endif
# endif // PIP_ICU
# ifdef MAC_OS
+6 -2
View File
@@ -681,6 +681,7 @@ bool PIObject::isPIObject(const PIObject * o) {
}
#ifdef PIP_INTROSPECTION
void PIObject::dump(const PIString & line_prefix) const {
// printf("dump %s \"%s\"\n", className(), name().data());
PICout(PICoutManipulators::AddNewLine) << line_prefix << "class " << className() << " (" << (const void *)this << ", \"" << name()
@@ -731,9 +732,10 @@ void PIObject::dump(const PIString & line_prefix) const {
PICout(PICoutManipulators::AddNewLine) << line_prefix << " }";
PICout(PICoutManipulators::AddNewLine) << line_prefix << "}";
}
#endif // PIP_INTROSPECTION
#ifdef PIP_HAS_THREADS
#ifdef PIP_INTROSPECTION
void dumpApplication(bool with_objects) {
PIMutexLocker _ml(PIObject::mutexObjects());
// printf("dump application ...\n");
@@ -763,6 +765,7 @@ void dumpApplication(bool with_objects) {
}
# if defined(PIP_HAS_FILESYSTEM)
bool dumpApplicationToFile(const PIString & path, bool with_objects) {
PIFile f(path + "_tmp");
f.setName("_S.DumpFile");
@@ -779,7 +782,8 @@ bool dumpApplicationToFile(const PIString & path, bool with_objects) {
PIFile::rename(path + "_tmp", path);
return true;
}
#endif
# endif // PIP_HAS_FILESYSTEM
#endif // PIP_INTROSPECTION
void PIObject::__MetaData::addScope(const char * s, uint shash) {
+7 -4
View File
@@ -54,8 +54,7 @@
//! требует явного опустошения очереди через \a callQueuedEvents() или
//! \a maybeCallQueuedEvents().
class PIP_EXPORT PIObject {
#ifndef PIP_INTROSPECTION
friend class PIObjectManager;
#ifdef PIP_INTROSPECTION
friend PIP_EXPORT void dumpApplication(bool);
friend class PIIntrospection;
#endif
@@ -376,9 +375,11 @@ public:
return executeQueued(o, performer, method, PIVector<PIVariantSimple>() << v0 << v1 << v2 << v3);
}
#ifdef PIP_INTROSPECTION
//! \~english Dumps object diagnostics to the project output stream.
//! \~russian Выводит диагностическую информацию об объекте в проектный поток вывода.
void dump(const PIString & line_prefix = PIString()) const;
#endif // PIP_INTROSPECTION
//! \~english Returns the registered inheritance scope of this object, including its own class.
@@ -838,16 +839,18 @@ private:
bool thread_safe_ = false, proc_event_queue = false;
};
#ifdef PIP_HAS_THREADS
#ifdef PIP_INTROSPECTION
//! \~english Dumps application-level %PIObject diagnostics.
//! \~russian Выводит диагностическую информацию уровня приложения для %PIObject.
PIP_EXPORT void dumpApplication(bool with_objects = true);
# if defined(PIP_HAS_FILESYSTEM)
//! \~english Dumps application-level %PIObject diagnostics to file "path".
//! \~russian Выводит диагностическую информацию уровня приложения для %PIObject в файл "path".
PIP_EXPORT bool dumpApplicationToFile(const PIString & path, bool with_objects = true);
# endif // PIP_HAS_FILESYSTEM
#endif
#endif // PIP_INTROSPECTION
#endif // PIOBJECT_H
@@ -82,7 +82,7 @@ class PIIntrospectionServer;
#else
#if defined(PIP_INTROSPECTION) && !defined(PIP_FORCE_NO_PIINTROSPECTION)
#ifdef PIP_INTROSPECTION
# define __PIINTROSPECTION_SINGLETON_H__(T) static PIIntrospection##T##Interface * instance();
# define __PIINTROSPECTION_SINGLETON_CPP__(T) \
@@ -27,7 +27,7 @@ PIIntrospectionContainersType::~PIIntrospectionContainersType() {
}
#if defined(PIP_INTROSPECTION) && !defined(PIP_FORCE_NO_PIINTROSPECTION)
#ifdef PIP_INTROSPECTION
# include "piintrospection_containers_p.h"
@@ -61,7 +61,7 @@ struct PIP_EXPORT PIIntrospectionContainersType {
bool has_demangled = false;
};
#if defined(PIP_INTROSPECTION) && !defined(PIP_FORCE_NO_PIINTROSPECTION)
#ifdef PIP_INTROSPECTION
# include "piintrospection_base.h"
@@ -17,7 +17,7 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#if defined(PIP_INTROSPECTION) && !defined(PIP_FORCE_NO_PIINTROSPECTION)
#ifdef PIP_INTROSPECTION
# include "piintrospection_server.h"
@@ -43,7 +43,7 @@
#else
# if defined(PIP_INTROSPECTION) && !defined(PIP_FORCE_NO_PIINTROSPECTION)
# ifdef PIP_INTROSPECTION
# include "pipeer.h"
@@ -19,7 +19,7 @@
#include "piintrospection_server_p.h"
#if defined(PIP_INTROSPECTION) && !defined(PIP_FORCE_NO_PIINTROSPECTION)
#ifdef PIP_INTROSPECTION
# include "pichunkstream.h"
# include "piinit.h"
@@ -173,4 +173,4 @@ void PIIntrospection::unpackObjects(PIByteArray & ba, PIVector<PIIntrospection::
ba >> objects;
}
#endif // #if defined(PIP_INTROSPECTION) && !defined(PIP_FORCE_NO_PIINTROSPECTION)
#endif // PIP_INTROSPECTION
@@ -27,7 +27,7 @@
#include "piintrospection_threads_p.h"
#include "pisystemmonitor.h"
#if defined(PIP_INTROSPECTION) && !defined(PIP_FORCE_NO_PIINTROSPECTION)
#ifdef PIP_INTROSPECTION
class PIP_EXPORT PIIntrospection {
public:
@@ -169,5 +169,5 @@ BINARY_STREAM_READ(PIIntrospection::ObjectInfo) {
return s;
}
#endif // #if defined(PIP_INTROSPECTION) && !defined(PIP_FORCE_NO_PIINTROSPECTION)
#endif // PIP_INTROSPECTION
#endif // PIINTROSPECTION_SERVER_P_H
@@ -17,7 +17,7 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#if defined(PIP_INTROSPECTION) && !defined(PIP_FORCE_NO_PIINTROSPECTION)
#ifdef PIP_INTROSPECTION
# include "piintrospection_threads.h"
@@ -25,7 +25,7 @@
#ifndef PIINTROSPECTION_THREADS_H
#define PIINTROSPECTION_THREADS_H
#if defined(PIP_INTROSPECTION) && !defined(PIP_FORCE_NO_PIINTROSPECTION)
#ifdef PIP_INTROSPECTION
# include "piintrospection_base.h"
@@ -19,7 +19,7 @@
#include "piintrospection_threads_p.h"
#if defined(PIP_INTROSPECTION) && !defined(PIP_FORCE_NO_PIINTROSPECTION)
#ifdef PIP_INTROSPECTION
PIIntrospectionThreads::ThreadInfo::ThreadInfo() {
id = delay = 0;
@@ -80,4 +80,4 @@ void PIIntrospectionThreads::threadRunDone(PIThread * t, ullong us) {
ti.run_us = (ti.run_us * 0.8) + (us * 0.2); /// WARNING
}
#endif // #if defined(PIP_INTROSPECTION) && !defined(PIP_FORCE_NO_PIINTROSPECTION)
#endif // PIP_INTROSPECTION
@@ -22,7 +22,7 @@
#include "pibase.h"
#if defined(PIP_INTROSPECTION) && !defined(PIP_FORCE_NO_PIINTROSPECTION)
#ifdef PIP_INTROSPECTION
#include "pimap.h"
#include "pithread.h"
@@ -72,5 +72,5 @@ BINARY_STREAM_READ(PIIntrospectionThreads::ThreadInfo) {
return s;
}
#endif // #if defined(PIP_INTROSPECTION) && !defined(PIP_FORCE_NO_PIINTROSPECTION)
#endif // PIP_INTROSPECTION
#endif // PIINTROSPECTION_THREADS_P_H