cmProcess.cxx 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743
  1. /* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
  2. file Copyright.txt or https://cmake.org/licensing for details. */
  3. #include "cmProcess.h"
  4. #include "cmCTest.h"
  5. #include "cmCTestRunTest.h"
  6. #include "cmCTestTestHandler.h"
  7. #include "cmsys/Process.h"
  8. #include <fcntl.h>
  9. #include <iostream>
  10. #include <signal.h>
  11. #include <string>
  12. #if defined(_WIN32)
  13. # include "cm_kwiml.h"
  14. #else
  15. # include <unistd.h>
  16. #endif
  17. #include <utility>
  18. #define CM_PROCESS_BUF_SIZE 65536
  19. #if defined(_WIN32) && !defined(__CYGWIN__)
  20. # include <io.h>
  21. static int cmProcessGetPipes(int* fds)
  22. {
  23. SECURITY_ATTRIBUTES attr;
  24. HANDLE readh, writeh;
  25. attr.nLength = sizeof(attr);
  26. attr.lpSecurityDescriptor = nullptr;
  27. attr.bInheritHandle = FALSE;
  28. if (!CreatePipe(&readh, &writeh, &attr, 0))
  29. return uv_translate_sys_error(GetLastError());
  30. fds[0] = _open_osfhandle((intptr_t)readh, 0);
  31. fds[1] = _open_osfhandle((intptr_t)writeh, 0);
  32. if (fds[0] == -1 || fds[1] == -1) {
  33. CloseHandle(readh);
  34. CloseHandle(writeh);
  35. return uv_translate_sys_error(GetLastError());
  36. }
  37. return 0;
  38. }
  39. #else
  40. # include <errno.h>
  41. static int cmProcessGetPipes(int* fds)
  42. {
  43. if (pipe(fds) == -1) {
  44. return uv_translate_sys_error(errno);
  45. }
  46. if (fcntl(fds[0], F_SETFD, FD_CLOEXEC) == -1 ||
  47. fcntl(fds[1], F_SETFD, FD_CLOEXEC) == -1) {
  48. close(fds[0]);
  49. close(fds[1]);
  50. return uv_translate_sys_error(errno);
  51. }
  52. return 0;
  53. }
  54. #endif
  55. cmProcess::cmProcess(cmCTestRunTest& runner)
  56. : Runner(runner)
  57. , Conv(cmProcessOutput::UTF8, CM_PROCESS_BUF_SIZE)
  58. {
  59. this->Timeout = cmDuration::zero();
  60. this->TotalTime = cmDuration::zero();
  61. this->ExitValue = 0;
  62. this->Id = 0;
  63. this->StartTime = std::chrono::steady_clock::time_point();
  64. }
  65. cmProcess::~cmProcess() = default;
  66. void cmProcess::SetCommand(std::string const& command)
  67. {
  68. this->Command = command;
  69. }
  70. void cmProcess::SetCommandArguments(std::vector<std::string> const& args)
  71. {
  72. this->Arguments = args;
  73. }
  74. void cmProcess::SetWorkingDirectory(std::string const& dir)
  75. {
  76. this->WorkingDirectory = dir;
  77. }
  78. bool cmProcess::StartProcess(uv_loop_t& loop, std::vector<size_t>* affinity)
  79. {
  80. this->ProcessState = cmProcess::State::Error;
  81. if (this->Command.empty()) {
  82. return false;
  83. }
  84. this->StartTime = std::chrono::steady_clock::now();
  85. this->ProcessArgs.clear();
  86. // put the command as arg0
  87. this->ProcessArgs.push_back(this->Command.c_str());
  88. // now put the command arguments in
  89. for (std::string const& arg : this->Arguments) {
  90. this->ProcessArgs.push_back(arg.c_str());
  91. }
  92. this->ProcessArgs.push_back(nullptr); // null terminate the list
  93. cm::uv_timer_ptr timer;
  94. int status = timer.init(loop, this);
  95. if (status != 0) {
  96. cmCTestLog(this->Runner.GetCTest(), ERROR_MESSAGE,
  97. "Error initializing timer: " << uv_strerror(status)
  98. << std::endl);
  99. return false;
  100. }
  101. cm::uv_pipe_ptr pipe_writer;
  102. cm::uv_pipe_ptr pipe_reader;
  103. pipe_writer.init(loop, 0);
  104. pipe_reader.init(loop, 0, this);
  105. int fds[2] = { -1, -1 };
  106. status = cmProcessGetPipes(fds);
  107. if (status != 0) {
  108. cmCTestLog(this->Runner.GetCTest(), ERROR_MESSAGE,
  109. "Error initializing pipe: " << uv_strerror(status)
  110. << std::endl);
  111. return false;
  112. }
  113. uv_pipe_open(pipe_reader, fds[0]);
  114. uv_pipe_open(pipe_writer, fds[1]);
  115. uv_stdio_container_t stdio[3];
  116. stdio[0].flags = UV_INHERIT_FD;
  117. stdio[0].data.fd = 0;
  118. stdio[1].flags = UV_INHERIT_STREAM;
  119. stdio[1].data.stream = pipe_writer;
  120. stdio[2] = stdio[1];
  121. uv_process_options_t options = uv_process_options_t();
  122. options.file = this->Command.data();
  123. options.args = const_cast<char**>(this->ProcessArgs.data());
  124. options.stdio_count = 3; // in, out and err
  125. options.exit_cb = &cmProcess::OnExitCB;
  126. options.stdio = stdio;
  127. #if !defined(CMAKE_USE_SYSTEM_LIBUV)
  128. std::vector<char> cpumask;
  129. if (affinity && !affinity->empty()) {
  130. cpumask.resize(static_cast<size_t>(uv_cpumask_size()), 0);
  131. for (auto p : *affinity) {
  132. cpumask[p] = 1;
  133. }
  134. options.cpumask = cpumask.data();
  135. options.cpumask_size = cpumask.size();
  136. } else {
  137. options.cpumask = nullptr;
  138. options.cpumask_size = 0;
  139. }
  140. #else
  141. static_cast<void>(affinity);
  142. #endif
  143. status =
  144. uv_read_start(pipe_reader, &cmProcess::OnAllocateCB, &cmProcess::OnReadCB);
  145. if (status != 0) {
  146. cmCTestLog(this->Runner.GetCTest(), ERROR_MESSAGE,
  147. "Error starting read events: " << uv_strerror(status)
  148. << std::endl);
  149. return false;
  150. }
  151. status = this->Process.spawn(loop, options, this);
  152. if (status != 0) {
  153. cmCTestLog(this->Runner.GetCTest(), ERROR_MESSAGE,
  154. "Process not started\n " << this->Command << "\n["
  155. << uv_strerror(status) << "]\n");
  156. return false;
  157. }
  158. this->PipeReader = std::move(pipe_reader);
  159. this->Timer = std::move(timer);
  160. this->StartTimer();
  161. this->ProcessState = cmProcess::State::Executing;
  162. return true;
  163. }
  164. void cmProcess::StartTimer()
  165. {
  166. auto properties = this->Runner.GetTestProperties();
  167. auto msec =
  168. std::chrono::duration_cast<std::chrono::milliseconds>(this->Timeout);
  169. if (msec != std::chrono::milliseconds(0) || !properties->ExplicitTimeout) {
  170. this->Timer.start(&cmProcess::OnTimeoutCB,
  171. static_cast<uint64_t>(msec.count()), 0);
  172. }
  173. }
  174. bool cmProcess::Buffer::GetLine(std::string& line)
  175. {
  176. // Scan for the next newline.
  177. for (size_type sz = this->size(); this->Last != sz; ++this->Last) {
  178. if ((*this)[this->Last] == '\n' || (*this)[this->Last] == '\0') {
  179. // Extract the range first..last as a line.
  180. const char* text = this->data() + this->First;
  181. size_type length = this->Last - this->First;
  182. while (length && text[length - 1] == '\r') {
  183. length--;
  184. }
  185. line.assign(text, length);
  186. // Start a new range for the next line.
  187. ++this->Last;
  188. this->First = Last;
  189. // Return the line extracted.
  190. return true;
  191. }
  192. }
  193. // Available data have been exhausted without a newline.
  194. if (this->First != 0) {
  195. // Move the partial line to the beginning of the buffer.
  196. this->erase(this->begin(), this->begin() + this->First);
  197. this->First = 0;
  198. this->Last = this->size();
  199. }
  200. return false;
  201. }
  202. bool cmProcess::Buffer::GetLast(std::string& line)
  203. {
  204. // Return the partial last line, if any.
  205. if (!this->empty()) {
  206. line.assign(this->data(), this->size());
  207. this->First = this->Last = 0;
  208. this->clear();
  209. return true;
  210. }
  211. return false;
  212. }
  213. void cmProcess::OnReadCB(uv_stream_t* stream, ssize_t nread,
  214. const uv_buf_t* buf)
  215. {
  216. auto self = static_cast<cmProcess*>(stream->data);
  217. self->OnRead(nread, buf);
  218. }
  219. void cmProcess::OnRead(ssize_t nread, const uv_buf_t* buf)
  220. {
  221. std::string line;
  222. if (nread > 0) {
  223. std::string strdata;
  224. this->Conv.DecodeText(buf->base, static_cast<size_t>(nread), strdata);
  225. this->Output.insert(this->Output.end(), strdata.begin(), strdata.end());
  226. while (this->Output.GetLine(line)) {
  227. this->Runner.CheckOutput(line);
  228. line.clear();
  229. }
  230. return;
  231. }
  232. if (nread == 0) {
  233. return;
  234. }
  235. // The process will provide no more data.
  236. if (nread != UV_EOF) {
  237. auto error = static_cast<int>(nread);
  238. cmCTestLog(this->Runner.GetCTest(), ERROR_MESSAGE,
  239. "Error reading stream: " << uv_strerror(error) << std::endl);
  240. }
  241. // Look for partial last lines.
  242. if (this->Output.GetLast(line)) {
  243. this->Runner.CheckOutput(line);
  244. }
  245. this->ReadHandleClosed = true;
  246. this->PipeReader.reset();
  247. if (this->ProcessHandleClosed) {
  248. uv_timer_stop(this->Timer);
  249. this->Runner.FinalizeTest();
  250. }
  251. }
  252. void cmProcess::OnAllocateCB(uv_handle_t* handle, size_t suggested_size,
  253. uv_buf_t* buf)
  254. {
  255. auto self = static_cast<cmProcess*>(handle->data);
  256. self->OnAllocate(suggested_size, buf);
  257. }
  258. void cmProcess::OnAllocate(size_t /*suggested_size*/, uv_buf_t* buf)
  259. {
  260. if (this->Buf.size() != CM_PROCESS_BUF_SIZE) {
  261. this->Buf.resize(CM_PROCESS_BUF_SIZE);
  262. }
  263. *buf =
  264. uv_buf_init(this->Buf.data(), static_cast<unsigned int>(this->Buf.size()));
  265. }
  266. void cmProcess::OnTimeoutCB(uv_timer_t* timer)
  267. {
  268. auto self = static_cast<cmProcess*>(timer->data);
  269. self->OnTimeout();
  270. }
  271. void cmProcess::OnTimeout()
  272. {
  273. if (this->ProcessState != cmProcess::State::Executing) {
  274. return;
  275. }
  276. this->ProcessState = cmProcess::State::Expired;
  277. bool const was_still_reading = !this->ReadHandleClosed;
  278. if (!this->ReadHandleClosed) {
  279. this->ReadHandleClosed = true;
  280. this->PipeReader.reset();
  281. }
  282. if (!this->ProcessHandleClosed) {
  283. // Kill the child and let our on-exit handler finish the test.
  284. cmsysProcess_KillPID(static_cast<unsigned long>(this->Process->pid));
  285. } else if (was_still_reading) {
  286. // Our on-exit handler already ran but did not finish the test
  287. // because we were still reading output. We've just dropped
  288. // our read handler, so we need to finish the test now.
  289. this->Runner.FinalizeTest();
  290. }
  291. }
  292. void cmProcess::OnExitCB(uv_process_t* process, int64_t exit_status,
  293. int term_signal)
  294. {
  295. auto self = static_cast<cmProcess*>(process->data);
  296. self->OnExit(exit_status, term_signal);
  297. }
  298. void cmProcess::OnExit(int64_t exit_status, int term_signal)
  299. {
  300. if (this->ProcessState != cmProcess::State::Expired) {
  301. if (
  302. #if defined(_WIN32)
  303. ((DWORD)exit_status & 0xF0000000) == 0xC0000000
  304. #else
  305. term_signal != 0
  306. #endif
  307. ) {
  308. this->ProcessState = cmProcess::State::Exception;
  309. } else {
  310. this->ProcessState = cmProcess::State::Exited;
  311. }
  312. }
  313. // Record exit information.
  314. this->ExitValue = exit_status;
  315. this->Signal = term_signal;
  316. this->TotalTime = std::chrono::steady_clock::now() - this->StartTime;
  317. // Because of a processor clock scew the runtime may become slightly
  318. // negative. If someone changed the system clock while the process was
  319. // running this may be even more. Make sure not to report a negative
  320. // duration here.
  321. if (this->TotalTime <= cmDuration::zero()) {
  322. this->TotalTime = cmDuration::zero();
  323. }
  324. this->ProcessHandleClosed = true;
  325. if (this->ReadHandleClosed) {
  326. uv_timer_stop(this->Timer);
  327. this->Runner.FinalizeTest();
  328. }
  329. }
  330. cmProcess::State cmProcess::GetProcessStatus()
  331. {
  332. return this->ProcessState;
  333. }
  334. void cmProcess::ChangeTimeout(cmDuration t)
  335. {
  336. this->Timeout = t;
  337. this->StartTimer();
  338. }
  339. void cmProcess::ResetStartTime()
  340. {
  341. this->StartTime = std::chrono::steady_clock::now();
  342. }
  343. cmProcess::Exception cmProcess::GetExitException()
  344. {
  345. auto exception = Exception::None;
  346. #if defined(_WIN32) && !defined(__CYGWIN__)
  347. auto exit_code = (DWORD)this->ExitValue;
  348. if ((exit_code & 0xF0000000) != 0xC0000000) {
  349. return exception;
  350. }
  351. if (exit_code) {
  352. switch (exit_code) {
  353. case STATUS_DATATYPE_MISALIGNMENT:
  354. case STATUS_ACCESS_VIOLATION:
  355. case STATUS_IN_PAGE_ERROR:
  356. case STATUS_INVALID_HANDLE:
  357. case STATUS_NONCONTINUABLE_EXCEPTION:
  358. case STATUS_INVALID_DISPOSITION:
  359. case STATUS_ARRAY_BOUNDS_EXCEEDED:
  360. case STATUS_STACK_OVERFLOW:
  361. exception = Exception::Fault;
  362. break;
  363. case STATUS_FLOAT_DENORMAL_OPERAND:
  364. case STATUS_FLOAT_DIVIDE_BY_ZERO:
  365. case STATUS_FLOAT_INEXACT_RESULT:
  366. case STATUS_FLOAT_INVALID_OPERATION:
  367. case STATUS_FLOAT_OVERFLOW:
  368. case STATUS_FLOAT_STACK_CHECK:
  369. case STATUS_FLOAT_UNDERFLOW:
  370. # ifdef STATUS_FLOAT_MULTIPLE_FAULTS
  371. case STATUS_FLOAT_MULTIPLE_FAULTS:
  372. # endif
  373. # ifdef STATUS_FLOAT_MULTIPLE_TRAPS
  374. case STATUS_FLOAT_MULTIPLE_TRAPS:
  375. # endif
  376. case STATUS_INTEGER_DIVIDE_BY_ZERO:
  377. case STATUS_INTEGER_OVERFLOW:
  378. exception = Exception::Numerical;
  379. break;
  380. case STATUS_CONTROL_C_EXIT:
  381. exception = Exception::Interrupt;
  382. break;
  383. case STATUS_ILLEGAL_INSTRUCTION:
  384. case STATUS_PRIVILEGED_INSTRUCTION:
  385. exception = Exception::Illegal;
  386. break;
  387. default:
  388. exception = Exception::Other;
  389. }
  390. }
  391. #else
  392. if (this->Signal) {
  393. switch (this->Signal) {
  394. case SIGSEGV:
  395. exception = Exception::Fault;
  396. break;
  397. case SIGFPE:
  398. exception = Exception::Numerical;
  399. break;
  400. case SIGINT:
  401. exception = Exception::Interrupt;
  402. break;
  403. case SIGILL:
  404. exception = Exception::Illegal;
  405. break;
  406. default:
  407. exception = Exception::Other;
  408. }
  409. }
  410. #endif
  411. return exception;
  412. }
  413. std::string cmProcess::GetExitExceptionString()
  414. {
  415. std::string exception_str;
  416. #if defined(_WIN32)
  417. switch (this->ExitValue) {
  418. case STATUS_CONTROL_C_EXIT:
  419. exception_str = "User interrupt";
  420. break;
  421. case STATUS_FLOAT_DENORMAL_OPERAND:
  422. exception_str = "Floating-point exception (denormal operand)";
  423. break;
  424. case STATUS_FLOAT_DIVIDE_BY_ZERO:
  425. exception_str = "Divide-by-zero";
  426. break;
  427. case STATUS_FLOAT_INEXACT_RESULT:
  428. exception_str = "Floating-point exception (inexact result)";
  429. break;
  430. case STATUS_FLOAT_INVALID_OPERATION:
  431. exception_str = "Invalid floating-point operation";
  432. break;
  433. case STATUS_FLOAT_OVERFLOW:
  434. exception_str = "Floating-point overflow";
  435. break;
  436. case STATUS_FLOAT_STACK_CHECK:
  437. exception_str = "Floating-point stack check failed";
  438. break;
  439. case STATUS_FLOAT_UNDERFLOW:
  440. exception_str = "Floating-point underflow";
  441. break;
  442. # ifdef STATUS_FLOAT_MULTIPLE_FAULTS
  443. case STATUS_FLOAT_MULTIPLE_FAULTS:
  444. exception_str = "Floating-point exception (multiple faults)";
  445. break;
  446. # endif
  447. # ifdef STATUS_FLOAT_MULTIPLE_TRAPS
  448. case STATUS_FLOAT_MULTIPLE_TRAPS:
  449. exception_str = "Floating-point exception (multiple traps)";
  450. break;
  451. # endif
  452. case STATUS_INTEGER_DIVIDE_BY_ZERO:
  453. exception_str = "Integer divide-by-zero";
  454. break;
  455. case STATUS_INTEGER_OVERFLOW:
  456. exception_str = "Integer overflow";
  457. break;
  458. case STATUS_DATATYPE_MISALIGNMENT:
  459. exception_str = "Datatype misalignment";
  460. break;
  461. case STATUS_ACCESS_VIOLATION:
  462. exception_str = "Access violation";
  463. break;
  464. case STATUS_IN_PAGE_ERROR:
  465. exception_str = "In-page error";
  466. break;
  467. case STATUS_INVALID_HANDLE:
  468. exception_str = "Invalid handle";
  469. break;
  470. case STATUS_NONCONTINUABLE_EXCEPTION:
  471. exception_str = "Noncontinuable exception";
  472. break;
  473. case STATUS_INVALID_DISPOSITION:
  474. exception_str = "Invalid disposition";
  475. break;
  476. case STATUS_ARRAY_BOUNDS_EXCEEDED:
  477. exception_str = "Array bounds exceeded";
  478. break;
  479. case STATUS_STACK_OVERFLOW:
  480. exception_str = "Stack overflow";
  481. break;
  482. case STATUS_ILLEGAL_INSTRUCTION:
  483. exception_str = "Illegal instruction";
  484. break;
  485. case STATUS_PRIVILEGED_INSTRUCTION:
  486. exception_str = "Privileged instruction";
  487. break;
  488. case STATUS_NO_MEMORY:
  489. default:
  490. char buf[1024];
  491. const char* fmt = "Exit code 0x%" KWIML_INT_PRIx64 "\n";
  492. _snprintf(buf, 1024, fmt, this->ExitValue);
  493. exception_str.assign(buf);
  494. }
  495. #else
  496. switch (this->Signal) {
  497. # ifdef SIGSEGV
  498. case SIGSEGV:
  499. exception_str = "Segmentation fault";
  500. break;
  501. # endif
  502. # ifdef SIGBUS
  503. # if !defined(SIGSEGV) || SIGBUS != SIGSEGV
  504. case SIGBUS:
  505. exception_str = "Bus error";
  506. break;
  507. # endif
  508. # endif
  509. # ifdef SIGFPE
  510. case SIGFPE:
  511. exception_str = "Floating-point exception";
  512. break;
  513. # endif
  514. # ifdef SIGILL
  515. case SIGILL:
  516. exception_str = "Illegal instruction";
  517. break;
  518. # endif
  519. # ifdef SIGINT
  520. case SIGINT:
  521. exception_str = "User interrupt";
  522. break;
  523. # endif
  524. # ifdef SIGABRT
  525. case SIGABRT:
  526. exception_str = "Child aborted";
  527. break;
  528. # endif
  529. # ifdef SIGKILL
  530. case SIGKILL:
  531. exception_str = "Child killed";
  532. break;
  533. # endif
  534. # ifdef SIGTERM
  535. case SIGTERM:
  536. exception_str = "Child terminated";
  537. break;
  538. # endif
  539. # ifdef SIGHUP
  540. case SIGHUP:
  541. exception_str = "SIGHUP";
  542. break;
  543. # endif
  544. # ifdef SIGQUIT
  545. case SIGQUIT:
  546. exception_str = "SIGQUIT";
  547. break;
  548. # endif
  549. # ifdef SIGTRAP
  550. case SIGTRAP:
  551. exception_str = "SIGTRAP";
  552. break;
  553. # endif
  554. # ifdef SIGIOT
  555. # if !defined(SIGABRT) || SIGIOT != SIGABRT
  556. case SIGIOT:
  557. exception_str = "SIGIOT";
  558. break;
  559. # endif
  560. # endif
  561. # ifdef SIGUSR1
  562. case SIGUSR1:
  563. exception_str = "SIGUSR1";
  564. break;
  565. # endif
  566. # ifdef SIGUSR2
  567. case SIGUSR2:
  568. exception_str = "SIGUSR2";
  569. break;
  570. # endif
  571. # ifdef SIGPIPE
  572. case SIGPIPE:
  573. exception_str = "SIGPIPE";
  574. break;
  575. # endif
  576. # ifdef SIGALRM
  577. case SIGALRM:
  578. exception_str = "SIGALRM";
  579. break;
  580. # endif
  581. # ifdef SIGSTKFLT
  582. case SIGSTKFLT:
  583. exception_str = "SIGSTKFLT";
  584. break;
  585. # endif
  586. # ifdef SIGCHLD
  587. case SIGCHLD:
  588. exception_str = "SIGCHLD";
  589. break;
  590. # elif defined(SIGCLD)
  591. case SIGCLD:
  592. exception_str = "SIGCLD";
  593. break;
  594. # endif
  595. # ifdef SIGCONT
  596. case SIGCONT:
  597. exception_str = "SIGCONT";
  598. break;
  599. # endif
  600. # ifdef SIGSTOP
  601. case SIGSTOP:
  602. exception_str = "SIGSTOP";
  603. break;
  604. # endif
  605. # ifdef SIGTSTP
  606. case SIGTSTP:
  607. exception_str = "SIGTSTP";
  608. break;
  609. # endif
  610. # ifdef SIGTTIN
  611. case SIGTTIN:
  612. exception_str = "SIGTTIN";
  613. break;
  614. # endif
  615. # ifdef SIGTTOU
  616. case SIGTTOU:
  617. exception_str = "SIGTTOU";
  618. break;
  619. # endif
  620. # ifdef SIGURG
  621. case SIGURG:
  622. exception_str = "SIGURG";
  623. break;
  624. # endif
  625. # ifdef SIGXCPU
  626. case SIGXCPU:
  627. exception_str = "SIGXCPU";
  628. break;
  629. # endif
  630. # ifdef SIGXFSZ
  631. case SIGXFSZ:
  632. exception_str = "SIGXFSZ";
  633. break;
  634. # endif
  635. # ifdef SIGVTALRM
  636. case SIGVTALRM:
  637. exception_str = "SIGVTALRM";
  638. break;
  639. # endif
  640. # ifdef SIGPROF
  641. case SIGPROF:
  642. exception_str = "SIGPROF";
  643. break;
  644. # endif
  645. # ifdef SIGWINCH
  646. case SIGWINCH:
  647. exception_str = "SIGWINCH";
  648. break;
  649. # endif
  650. # ifdef SIGPOLL
  651. case SIGPOLL:
  652. exception_str = "SIGPOLL";
  653. break;
  654. # endif
  655. # ifdef SIGIO
  656. # if !defined(SIGPOLL) || SIGIO != SIGPOLL
  657. case SIGIO:
  658. exception_str = "SIGIO";
  659. break;
  660. # endif
  661. # endif
  662. # ifdef SIGPWR
  663. case SIGPWR:
  664. exception_str = "SIGPWR";
  665. break;
  666. # endif
  667. # ifdef SIGSYS
  668. case SIGSYS:
  669. exception_str = "SIGSYS";
  670. break;
  671. # endif
  672. # ifdef SIGUNUSED
  673. # if !defined(SIGSYS) || SIGUNUSED != SIGSYS
  674. case SIGUNUSED:
  675. exception_str = "SIGUNUSED";
  676. break;
  677. # endif
  678. # endif
  679. default:
  680. exception_str = "Signal ";
  681. exception_str += std::to_string(this->Signal);
  682. }
  683. #endif
  684. return exception_str;
  685. }