Created
April 24, 2012 05:42
-
-
Save moritz/2476861 to your computer and use it in GitHub Desktop.
Trouble connecting to SQLite
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
gdb --args perl6 sqlite-test.pl | |
GNU gdb (GDB) 7.0.1-debian | |
Copyright (C) 2009 Free Software Foundation, Inc. | |
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html> | |
This is free software: you are free to change and redistribute it. | |
There is NO WARRANTY, to the extent permitted by law. Type "show copying" | |
and "show warranty" for details. | |
This GDB was configured as "x86_64-linux-gnu". | |
For bug reporting instructions, please see: | |
<http://www.gnu.org/software/gdb/bugs/>... | |
Reading symbols from /home/moritz/bin/perl6...done. | |
(gdb) run | |
Starting program: /home/moritz/bin/perl6 sqlite-test.pl | |
[Thread debugging using libthread_db enabled] | |
connection status OK? True | |
connection defined? True | |
Program received signal SIGSEGV, Segmentation fault. | |
0x00007ffff0f78622 in dyncall_wb_ca (obj=0x3919888) at nqp_dyncall_ops.c:345 | |
345 if (repr_data->elem_kind == CARRAY_ELEM_KIND_NUMERIC) | |
(gdb) bt | |
#0 0x00007ffff0f78622 in dyncall_wb_ca (obj=0x3919888) | |
at nqp_dyncall_ops.c:345 | |
#1 0x00007ffff0f88009 in Parrot_nqp_native_call_p_p_p_p ( | |
cur_opcode=0x39b0120, interp=0x610050) at nqp_dyncall_ops.c:3745 | |
#2 0x00007ffff7a6d4c6 in runops_fast_core (interp=0x610050, | |
runcore_unused=<value optimized out>, pc=0x0) at src/runcore/cores.c:499 | |
#3 0x00007ffff7a6d33a in runops_int (interp=0x610050, | |
offset=<value optimized out>) at src/runcore/main.c:220 | |
#4 0x00007ffff7a54f3e in runops (interp=<value optimized out>, | |
offs=<value optimized out>) at src/call/ops.c:126 | |
#5 0x00007ffff7a507f6 in Parrot_pcc_invoke_from_sig_object (interp=0x610050, | |
sub_obj=<value optimized out>, call_object=<value optimized out>) | |
at src/call/pcc.c:338 | |
#6 0x00007ffff40e5e54 in Parrot_SixModelObject_invoke (interp=0x610050, | |
_self=0x35ec820, next=0x63533a8) at sixmodelobject.c:586 | |
#7 0x00007ffff7a6d4c6 in runops_fast_core (interp=0x610050, | |
runcore_unused=<value optimized out>, pc=0x0) at src/runcore/cores.c:499 | |
#8 0x00007ffff7a6d33a in runops_int (interp=0x610050, | |
offset=<value optimized out>) at src/runcore/main.c:220 | |
#9 0x00007ffff7a54f3e in runops (interp=<value optimized out>, | |
offs=<value optimized out>) at src/call/ops.c:126 | |
#10 0x00007ffff7a507f6 in Parrot_pcc_invoke_from_sig_object (interp=0x610050, | |
sub_obj=<value optimized out>, call_object=<value optimized out>) | |
at src/call/pcc.c:338 | |
#11 0x00007ffff7a44c9d in Parrot_ext_call (interp=0x610050, sub_pmc=0x1532380, | |
signature=<value optimized out>) at src/extend.c:175 | |
#12 0x00007ffff7b22e78 in Parrot_Task_invoke (interp=<value optimized out>, | |
_self=<value optimized out>, next=<value optimized out>) | |
at src/pmc/task.c:166 | |
#13 0x00007ffff7a507a2 in Parrot_pcc_invoke_from_sig_object (interp=0x610050, | |
sub_obj=0x1531f20, call_object=0x15323a8) at src/call/pcc.c:330 | |
#14 0x00007ffff7a44c9d in Parrot_ext_call (interp=0x610050, sub_pmc=0x1531f20, | |
signature=<value optimized out>) at src/extend.c:175 | |
#15 0x00007ffff7a716ad in Parrot_cx_outer_runloop (interp=0x610050) | |
at src/scheduler.c:147 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use NativeCall; | |
enum SQLITE ( | |
SQLITE_OK => 0 , # Successful result | |
SQLITE_ERROR => 1 , # SQL error or missing database | |
# rest removed for clarity | |
); | |
sub sqlite3_open(Str $filename, CArray[OpaquePointer] $handle) | |
returns Int | |
is native('libsqlite3') | |
{ ... } | |
# http://www.sqlite.org/c3ref/prepare.html | |
sub sqlite3_prepare_v2(OpaquePointer, Str, Int, | |
CArray[OpaquePointer], CArray[OpaquePointer]) | |
returns Int | |
is native('libsqlite3') | |
{ ... } | |
my @conn := CArray[OpaquePointer].new(); | |
@conn[0] = OpaquePointer; | |
my $status = sqlite3_open('test.sqlite3', @conn); | |
say 'connection status OK? ', $status == SQLITE_OK; | |
@conn[1] = OpaquePointer; | |
say 'connection defined? ', @conn[0].DEFINITE; | |
my @stmt := CArray[OpaquePointer].new(); | |
@stmt[0] = OpaquePointer; | |
$status = sqlite3_prepare_v2(@conn[1], 'SELECT 1+2', -1, @stmt, OpaquePointer); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment