tesseract  4.0.0-1-g2a2b
globaloc.h File Reference
#include "host.h"

Go to the source code of this file.

Functions

void SavePixForCrash (int resolution, Pix *pix)
 
void signal_exit (int signal_code)
 
void err_exit ()
 
void set_global_loc_code (int loc_code)
 
void set_global_subloc_code (int loc_code)
 
void set_global_subsubloc_code (int loc_code)
 

Function Documentation

◆ err_exit()

void err_exit ( )

Definition at line 75 of file globaloc.cpp.

75  {
76  ASSERT_HOST("Fatal error encountered!" == nullptr);
77 }
#define ASSERT_HOST(x)
Definition: errcode.h:84

◆ SavePixForCrash()

void SavePixForCrash ( int  resolution,
Pix *  pix 
)

Definition at line 35 of file globaloc.cpp.

35  {
36 #ifdef __linux__
37 #ifndef ANDROID
38  int thread_id = syscall(SYS_gettid) % kMaxNumThreadPixes;
39 #else
40  int thread_id = gettid() % kMaxNumThreadPixes;
41 #endif
42  pixDestroy(&global_crash_pixes[thread_id]);
43  if (pix != nullptr) {
44  Pix* clone = pixClone(pix);
45  pixSetXRes(clone, resolution);
46  pixSetYRes(clone, resolution);
47  global_crash_pixes[thread_id] = clone;
48  }
49 #endif
50 }
const int kMaxNumThreadPixes
Definition: globaloc.cpp:31

◆ set_global_loc_code()

void set_global_loc_code ( int  loc_code)

Definition at line 80 of file globaloc.cpp.

80  {
81  // global_loc_code = loc_code;
82 }

◆ set_global_subloc_code()

void set_global_subloc_code ( int  loc_code)

Definition at line 85 of file globaloc.cpp.

85  {
86  // global_subloc_code = loc_code;
87 }

◆ set_global_subsubloc_code()

void set_global_subsubloc_code ( int  loc_code)

Definition at line 90 of file globaloc.cpp.

90  {
91  // global_subsubloc_code = loc_code;
92 }

◆ signal_exit()

void signal_exit ( int  signal_code)

Definition at line 53 of file globaloc.cpp.

53  {
54  tprintf("Received signal %d!\n", signal_code);
55 #ifdef __linux__
56 #ifndef ANDROID
57  int thread_id = syscall(SYS_gettid) % kMaxNumThreadPixes;
58 #else
59  int thread_id = gettid() % kMaxNumThreadPixes;
60 #endif
61  if (global_crash_pixes[thread_id] != nullptr) {
62  fprintf(stderr, "Crash caused by image with resolution %d\n",
63  pixGetYRes(global_crash_pixes[thread_id]));
64  fprintf(stderr, "<Cut here>\n");
65  pixWriteStreamPng(stderr, global_crash_pixes[thread_id], 0.0);
66  fprintf(stderr, "\n<End cut>\n");
67  }
68  // Raise an uncaught signal, so as to get a useful stack trace.
69  raise(SIGILL);
70 #else
71  abort();
72 #endif
73 }
const int kMaxNumThreadPixes
Definition: globaloc.cpp:31
DLLSYM void tprintf(const char *format,...)
Definition: tprintf.cpp:37