summaryrefslogtreecommitdiff
path: root/tools/perf/python/export-to-postgresql.py
AgeCommit message (Collapse)Author
9 daysperf python: Avoid shadowing exception name in PostgreSQL exporterLeo Yan
During the perf build, pylint reports: ************* Module export-to-postgresql python/export-to-postgresql.py:319:8: W0621: Redefining name 'e' from outer scope (line 100) (redefined-outer-name) Rename 'e' to 'db_error' to clear the warning. Fixes: b1f968c9656a8a87 ("perf python: Port export-to-postgresql to perf module") Reviewed-by: Ian Rogers <irogers@google.com> Assisted-by: Codex:gpt-6 Signed-off-by: Leo Yan <leo.yan@arm.com> Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
13 daysperf python: Port export-to-postgresql to perf moduleIan Rogers
Port export-to-postgresql.py to a standalone script in tools/perf/python/ using the perf module and libpq via ctypes. Improvements compared to the legacy script: - Remove the dependency on PySide/QtSql for database creation and DDL execution by driving libpq directly via ctypes (PQconnectdb, PQexec, PQputCopyData, PQputCopyEnd) and streaming binary PostgreSQL COPY files in PostgresExporter, enabling export on headless servers without Qt installed. - Harden database connection and SQL identifier handling by rejecting URI ('://') and connection-parameter ('=') injection strings in setup_db() and connect(), escaping single quotes and backslashes in connection strings, and quoting SQL identifiers (quote_ident). - Support Intel PT and instruction trace export via perf.session(itrace=...) and perf.call_return callbacks, reconstructing relational call_paths and calls tables (including id=0 placeholder rows and callfk/returnfk foreign keys) and unpacking synthesized PT payloads (ptwrite, cbr, mwait, pwre, exstop, pwrx). - Use a dedicated context_switch ID counter so context-switch exports do not advance sample database IDs out of sync with call_return references. Update Documentation/db-export.txt and add a shell test (test_export_to_postgresql_python.sh) to verify the standalone exporter. Assisted-by: Antigravity:gemini-3.1-pro Signed-off-by: Ian Rogers <irogers@google.com> Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>