Skip to content

Commit ec84a76

Browse files
committed
[feat] google breakpad && vs code debug setting
1 parent 7c4f4ad commit ec84a76

File tree

10 files changed

+96
-19
lines changed

10 files changed

+96
-19
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,3 +47,4 @@ build/computervision.dir
4747
build/computervision.sln
4848
build/computervision.vcxproj
4949
build/computervision.vcxproj.filters
50+
dump_file/log/*

.vscode/c_cpp_properties.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
"${workspaceFolder}/include/component",
2626
"D:\\thirdpartyforwindows\\opencv\\build\\include",
2727
"D:\\thirdpartyforwindows\\Boost\\boost_1_66_0\\include",
28-
"${workspaceFolder}/include/component"
28+
"D:\\thirdpartyforwindows\\breakpad\\include"
2929
],
3030
"defines": [
3131
"_DEBUG",

.vscode/launch.json

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
{
2+
// Use IntelliSense to learn about possible attributes.
3+
// Hover to view descriptions of existing attributes.
4+
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5+
"version": "0.2.0",
6+
"configurations": [
7+
{
8+
"name": "(Windows) Launch",
9+
"type": "cppvsdbg",
10+
"request": "launch",
11+
"program": "${workspaceFolder}/build/bin/Release/computervision.exe",
12+
"symbolSearchPath": "${workspaceFolder}/build/bin/Release",
13+
"externalConsole": true,
14+
// "args": [],
15+
"logging": {
16+
"moduleLoad": false,
17+
"trace": true
18+
},
19+
"stopAtEntry": false,
20+
"cwd": "${workspaceFolder}",
21+
"environment": [],
22+
"console": "externalTerminal"
23+
}
24+
]
25+
}

CMakeLists.txt

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,9 @@ set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${PROJECT_OUTPUT_DIR}/lib)
1212
# Build PDB file
1313
# https://stackoverflow.com/questions/28178978/how-to-generate-pdb-files-for-release-build-with-cmake-flags
1414
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /Zi")
15-
set(CMAKE_SHARED_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} /DEBUG /OPT:REF /OPT:ICF")
16-
#install(FILES $<TARGET_PDB_FILE:${PROJECT_NAME}> DESTINATION bin OPTIONAL)
15+
#set(CMAKE_SHARED_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} /DEBUG /OPT:REF /OPT:ICF")
16+
set(CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} /DEBUG /OPT:REF /OPT:ICF")
17+
1718

1819
#set(Boost_LIBRARY_DIRS /usr/local/lib)
1920
#message("Opencv Found --opencv_version " ${OpenCV_VERSION})
@@ -51,6 +52,14 @@ message("OpenCV_LIBS : " ${OpenCV_LIBS})
5152
#link_directories (${BOOST_LIBS})
5253
#message("BOOST_INCLUDE_DIRS : " ${BOOST_INCLUDE_DIRS})
5354
#message("BOOST_LIBS : " ${BOOST_LIBS})
55+
## Breakpad
56+
set(BREAKPAD_ROOT $ENV{THIRD_PARTY}/breakpad)
57+
set(BREAKPAD_INCLUDE_DIR ${BREAKPAD_ROOT}/include)
58+
set(BREAKPAD_LIBS ${BREAKPAD_ROOT}/lib)
59+
include_directories(${BREAKPAD_INCLUDE_DIR})
60+
link_directories(${BREAKPAD_LIBS})
61+
message("BREAKPAD_INCLUDE_DIR : " ${BREAKPAD_INCLUDE_DIR})
62+
message("BREAKPAD_LIBS : " ${BREAKPAD_LIBS})
5463
#---------Linux---------
5564
ELSE()
5665
## OpenCV
@@ -66,19 +75,20 @@ ENDIF()
6675

6776
# code
6877
include_directories(${CMAKE_SOURCE_DIR}/include)
69-
include_directories(${CMAKE_SOURCE_DIR}/include/component)
7078
aux_source_directory(./src SRC)
7179
aux_source_directory(./src/component SRC_COMPONENT)
80+
aux_source_directory(./src/error_code SRC_ERRORCODE)
7281

7382
# output binary
74-
#add_executable(${PROJECT_NAME} main.cpp ${SRC} ${SRC_COMPONENT})
83+
add_executable(${PROJECT_NAME} main.cpp ${SRC} ${SRC_COMPONENT} ${SRC_ERRORCODE})
7584
# output so
76-
add_library( ${PROJECT_NAME} SHARED ${SRC} ${SRC_COMPONENT})
77-
#add_library( ${PROJECT_NAME} STATIC ${SRC} ${SRC_COMPONENT})
85+
#add_library( ${PROJECT_NAME} SHARED ${SRC} ${SRC_COMPONENT} ${SRC_ERRORCODE})
86+
#add_library( ${PROJECT_NAME} STATIC ${SRC} ${SRC_COMPONENT} ${SRC_ERRORCODE})
7887
# link library
7988

8089
IF (WIN32)
81-
target_link_libraries(${PROJECT_NAME} opencv_world349.lib)
90+
target_link_libraries(${PROJECT_NAME} opencv_world349.lib libbreakpad.lib libbreakpad_client.lib)
91+
# libbreakpad.lib libbreakpad_client.lib
8292
# boost_system-vc141-mt-x64-1_66.lib libboost_filesystem-vc141-mt-x64-1_66.lib libboost_regex-vc141-mt-x64-1_66.lib
8393
ELSE()
8494
target_link_libraries(${PROJECT_NAME} -lstdc++fs ${OpenCV_LIBS})

include/common.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,11 @@
2323
// #include "boost/filesystem.hpp"
2424
// #include "boost/regex.hpp"
2525

26+
// breakpad
27+
#ifdef _WIN32
28+
#include "client/windows/handler/exception_handler.h"
29+
#endif
30+
2631
// because c++ 11 don't have make_unique, so we make one by myself.
2732
template <typename T, typename... Args>
2833
static std::unique_ptr<T> make_unique(Args &&...args) {
@@ -75,4 +80,5 @@ inline int ConvertMatToGrayscale(const cv::Mat &src, cv::Mat &gray_dst) {
7580
}
7681
return 0;
7782
}
83+
7884
#endif //_COMMON_H_

include/component/image_proc.h

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,19 @@
11
#ifndef _IMAGE_PROC_H_
22
#define _IMAGE_PROC_H_
33

4-
#include "attribute.h"
5-
#include "opencv2/core.hpp"
6-
#include "opencv2/highgui.hpp"
7-
#include "opencv2/imgcodecs.hpp"
8-
94
#ifdef computervision_EXPORTS
105
#define IPO_API __declspec(dllexport)
116
#else
127
#define IPO_API __declspec(dllimport)
138
#endif
149

10+
#include "attribute.h"
11+
#include "opencv2/core.hpp"
12+
#include "opencv2/highgui.hpp"
13+
// #include "opencv2/imgcodecs.hpp"
14+
1515
namespace ipo {
16+
1617
#ifdef _WIN32
1718
/**
1819
* @brief Calculate the diff value between subtraction of grayscale image and fuzzy image. If the value exceed the offset value, then it equal to 255, and vice versa.

main.cpp

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,22 @@
11
#include <iostream>
22

33
#include "component/image_proc.h"
4+
// #ifdef _WIN32
5+
// #include "client/windows/handler/exception_handler.h"
6+
// #endif
7+
8+
// #ifdef _WIN32
9+
// bool callback(const wchar_t *dump_path, const wchar_t *id,
10+
// void *context, EXCEPTION_POINTERS *exinfo,
11+
// MDRawAssertionInfo *assertion, bool succeeded) {
12+
// if (succeeded)
13+
// std::cout << "Create dump file success" << std::endl;
14+
// else
15+
// std::cout << "Create dump file failed" << std::endl;
16+
// return succeeded;
17+
// }
18+
// #endif
19+
420
// ---load image---
521
cv::Mat &&src = cv::imread("../images/Okonomiyaki.png");
622
/*
@@ -18,6 +34,8 @@ cv::Mat &&src = cv::imread("../images/Okonomiyaki.png");
1834
9 : positioning by template matching
1935
------Flate-Field-Correction------
2036
10 : FlatFieldCorrection
37+
------DumpFile------
38+
11 : build dump file (windows)
2139
*/
2240
#define index 10
2341

@@ -177,4 +195,20 @@ int main() {
177195
cv::waitKey(0);
178196
return 0;
179197
}
198+
#elif index == 11
199+
200+
int main() {
201+
#ifdef _WIN32
202+
// https: //blog.csdn.net/GoForwardToStep/article/details/58295246
203+
const wchar_t *dumpPath = L"../dump_file/log";
204+
google_breakpad::ExceptionHandler eh(
205+
dumpPath, NULL, callback, NULL,
206+
google_breakpad::ExceptionHandler::HANDLER_ALL);
207+
#endif
208+
std::cout << "main start" << std::endl;
209+
int *a = NULL;
210+
*a = 0x1;
211+
std::cout << "main end" << std::endl;
212+
return 0;
213+
}
180214
#endif

src/component/correction.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
#include "correction.h"
2-
3-
#include "image_proc.h"
1+
#include "component/correction.h"
2+
#define computervision_EXPORTS
3+
#include "component/image_proc.h"
44
using namespace ipo;
55
//===========PIMPL (FlatFieldCorrection)===========
66
FlatFieldCorrection::FlatFieldCorrection() : p_pimplFlatFieldCorrection(new PimplFlatFieldCorrection) {}

src/component/image_proc.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ namespace ipo {
77
int DynamicThreshold(const cv::Mat &src, cv::Mat &dst,
88
const int &blur_ksize, const int &offset,
99
const DynamicThresholdTypes &mode) {
10-
CV_Assert(!src.empty());
10+
// CV_Assert(!src.empty());
1111
if (dst.empty()) {
1212
dst = cv::Mat::zeros(src.size(), CV_8UC1);
1313
}

src/component/positioning.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
#include "positioning.h"
1+
#include "component/positioning.h"
22

3-
#include "image_proc.h"
3+
#include "component/image_proc.h"
44

55
using namespace ipo;
66

0 commit comments

Comments
 (0)