Reputation: 151
Background
I'm currently in the process of writing a Go interface for this library.
As a first step, I'm trying to run the tests in /test/test_pc.c
by calling them through Go wrappers. It is important to note that the tests are successful when compiled by GCC.
Important Additional Details: It is worth mentioning that currently I have all the C code that I want to run above import "C"
. The reason for this is that the relic_test.h
doesn't provide function prototypes, thus cgo does not recognize the functions through calls like C.foo()
. Therefore, I put all the test_pc.c
code in the following format:
package main
// #include<>
/*
void test1(){}
void test2(){}
.
.
void testN(){}
*/
import "C"
func main(){
C.test1()
C.testN()
}
Problem
Whenn I try running them from go, the execution gets "stuck" (i.e. the code is in execution but it just simply doesn't go to the next instruction) in one particular test. How can I find out why the code gets stuck? How can I observe the execution flow of the program?
Thing I've Tried
Again, if I try using C directly (i.e. if I compile it with GCC and run it), the code works. Thus, GDB will also work.
I've also tried using go tools cgo -debug-gcc
, but this only prints preprocessing directives. go tools cgo -gccgo
doesn't output anything. finally, the Go debugger, Delve, is not able to debug the C calls.
Upvotes: 3
Views: 6919
Reputation: 3294
Some investigation shows your only real options are as follows:
printf
or other logging.Neither of these options is very good...
This document has a section on cgo debugging seems to indicate that it works ok.
Upvotes: 3