db: don't turn RaiseError on
[smatch.git] / smatch_scripts / db / fill_db_function_ptr.pl
blob825a497c7307cae8457772c58719f7fe06b28f68
1 #!/usr/bin/perl -w
3 use strict;
4 use DBI;
6 my $warns = shift;
8 if (!defined($warns)) {
9 print "usage: $0 <warns.txt>\n";
10 exit(1);
13 my $db = DBI->connect("dbi:SQLite:smatch_db.sqlite", "", "", {AutoCommit => 0});
14 $db->do("PRAGMA synchronous = OFF");
15 $db->do("PRAGMA cache_size = 800000");
16 $db->do("PRAGMA journal_mode = OFF");
18 $db->do("delete from function_ptr;");
20 open(WARNS, "<$warns");
21 while (<WARNS>) {
22 if (!($_ =~ /info: sets_fn_ptr /)) {
23 next;
26 # kernel/ksysfs.c +87 (null)(87) info: sets_fn_ptr '(struct kobj_attribute)->show' 'profiling_show'
28 s/\n//;
30 my ($file_and_line, $file, $dummy, $struct_bit, $func, $ptr);
31 ($file_and_line, $dummy, $dummy, $dummy, $struct_bit, $ptr, $func) = split(/ /, $_);
32 ($file, $dummy) = split(/:/, $file_and_line);
34 if (!defined($func)) {
35 next;
37 if (!($struct_bit =~ /^'\(struct$/)) {
38 next;
40 if (!($func =~ /^'[\w_]+'$/)) {
41 next;
44 $struct_bit =~ s/'//;
45 $ptr =~ s/'//;
46 $func =~ s/'//g;
48 $db->do("insert into function_ptr values ('$file', '$func', '$struct_bit $ptr')\n");
50 $db->commit();
51 $db->disconnect();