Skip to content

Commit 44e031c

Browse files
Pau Gargallofacebook-github-bot
authored andcommitted
Back out "fbcode/mapillary/opensfm/opensfm/src"
Summary: Original commit changeset: f646c9390378 Original Phabricator Diff: D63971477 Reviewed By: bal-a Differential Revision: D72844843 fbshipit-source-id: 857420c62e42d43f2ec85f0c2ae22d72de79f223
1 parent 1f4db88 commit 44e031c

2 files changed

Lines changed: 40 additions & 0 deletions

File tree

opensfm/src/debug_c_extension.cc

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
// Tool to debug c extensions with a c debugger.
2+
//
3+
// How to use it:
4+
//
5+
// 1. Write a module in python that calls the extension you want to debug.
6+
// Make sure the extension code is called at import time.
7+
//
8+
// 2. Build opensfm/cmake_build in Debug mode.
9+
//
10+
// 3. Tell the debugger to run
11+
//
12+
// ./debug_c_extension module
13+
//
14+
// where module is the name of the module that you wrote.
15+
16+
#include <pybind11/embed.h>
17+
18+
#include <iostream>
19+
namespace py = pybind11;
20+
21+
int main(int argc, char *argv[]) {
22+
py::scoped_interpreter guard{};
23+
24+
if (argc != 2) {
25+
std::cout << "Usage: " << argv[0] << " module" << std::endl;
26+
} else {
27+
py::module sys = py::module::import(argv[1]);
28+
}
29+
}

opensfm/src/testing_main.cc

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#include <gflags/gflags.h>
2+
#include <glog/logging.h>
3+
#include <gtest/gtest.h>
4+
5+
int main(int argc, char **argv) {
6+
testing::InitGoogleTest(&argc, argv);
7+
google::ParseCommandLineFlags(&argc, &argv, true);
8+
google::InitGoogleLogging(argv[0]);
9+
10+
return RUN_ALL_TESTS();
11+
}

0 commit comments

Comments
 (0)