Skip to content

Commit a9eb683

Browse files
committed
Stuff lying about.
JSON cleanups, and clang-tidy improvements.
1 parent 24652fc commit a9eb683

28 files changed

Lines changed: 809 additions & 755 deletions

‎.gitignore‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,4 @@ ID
1313
.vscode
1414
build
1515
pi
16+
tidy

‎CMakeLists.txt‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ else()
6161
endif()
6262

6363
# Make sure to use the local libpstack headers rather than what's installed.
64-
include_directories("." ${LIBLZMA_INCLUDES} ${ZLIB_INCLUDES} ${PYTHON_INCLUDE_DIRS} )
64+
include_directories(${CMAKE_SOURCE_DIR} ${LIBLZMA_INCLUDES} ${ZLIB_INCLUDES} ${PYTHON_INCLUDE_DIRS} )
6565

6666
add_library(dwelf ${LIBTYPE} dump.cc dwarf.cc elf.cc reader.cc util.cc
6767
${inflatesrc} ${lzmasrc})
@@ -81,6 +81,7 @@ set (CLANG_TIDY "clang-tidy;-checks=*,-*readability-braces-around-statements,-cp
8181
set_target_properties(canal PROPERTIES CXX_CLANG_TIDY "${CLANG_TIDY}")
8282
set_target_properties(${PSTACK_BIN} PROPERTIES CXX_CLANG_TIDY "${CLANG_TIDY}")
8383
set_target_properties(dwelf PROPERTIES CXX_CLANG_TIDY "${CLANG_TIDY}")
84+
add_definitions("-DNDEBUG")
8485
set_target_properties(procman PROPERTIES CXX_CLANG_TIDY "${CLANG_TIDY}")
8586
endif()
8687

‎canal.cc‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,12 @@
66
#include <exception>
77
#include <algorithm>
88
#include <memory>
9-
#include <libpstack/proc.h>
10-
#include <libpstack/elf.h>
11-
#include <libpstack/dwarf.h>
129
#include <sys/types.h>
1310

11+
#include "libpstack/proc.h"
12+
#include "libpstack/elf.h"
13+
#include "libpstack/dwarf.h"
14+
1415
using namespace std;
1516

1617
static int

‎dead.cc‎

Lines changed: 9 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -123,8 +123,7 @@ CoreProcess::getRegs(lwpid_t pid, CoreRegisters *reg)
123123
#ifdef NT_PRSTATUS
124124
for (auto note : coreImage->notes) {
125125
if (note.name() == "CORE" && note.type() == NT_PRSTATUS) {
126-
prstatus_t prstatus;
127-
note.data()->readObj(0, &prstatus);
126+
const auto &prstatus = note.data()->readObj<prstatus_t>(0);
128127
if (prstatus.pr_pid == pid) {
129128
memcpy(reg, &prstatus.pr_reg, sizeof(*reg));
130129
return true;
@@ -136,13 +135,13 @@ CoreProcess::getRegs(lwpid_t pid, CoreRegisters *reg)
136135
}
137136

138137
void
139-
CoreProcess::resume(pid_t)
138+
CoreProcess::resume(pid_t /* unused */)
140139
{
141140
// can't resume post-mortem debugger.
142141
}
143142

144143
void
145-
CoreProcess::stop(lwpid_t)
144+
CoreProcess::stop(lwpid_t /* unused */)
146145
{
147146
// can't stop a dead process.
148147
}
@@ -157,25 +156,18 @@ CoreProcess::stopProcess()
157156
pid_t
158157
CoreProcess::getPID() const
159158
{
160-
for (auto note : coreImage->notes) {
161-
// Return the PID of the first task in the core.
162-
if (note.name() == "CORE" && note.type() == NT_PRSTATUS) {
163-
prstatus_t status;
164-
note.data()->readObj(0, &status);
165-
return status.pr_pid;
166-
}
167-
}
159+
// Return the PID of the first task in the core.
160+
for (auto note : coreImage->notes)
161+
if (note.name() == "CORE" && note.type() == NT_PRSTATUS)
162+
return note.data()->readObj<prstatus_t>(0).pr_pid;
168163
return -1;
169164
}
170165

171166
void
172167
CoreProcess::findLWPs()
173168
{
174169
for (auto note : coreImage->notes) {
175-
if (note.name() == "CORE" && note.type() == NT_PRSTATUS) {
176-
prstatus_t status;
177-
note.data()->readObj(0, &status);
178-
(void)lwps[status.pr_pid];
179-
}
170+
if (note.name() == "CORE" && note.type() == NT_PRSTATUS)
171+
(void)lwps[note.data()->readObj<prstatus_t>(0).pr_pid];
180172
}
181173
}

0 commit comments

Comments
 (0)