Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
063c9b1
WIP
teto Jul 8, 2016
f9518d2
wip
teto Jul 11, 2016
2cf72ee
WIP
teto Jul 12, 2016
ef9e17f
WIP
teto Jul 12, 2016
e07a21e
Ideally we should automatically generate the .i. Now we need to write…
teto Jul 13, 2016
763c311
Be careful of __isoc99_sscanf that was disabled
teto Jul 13, 2016
eaffe9b
For now you need to generate the libc-ns3.generated.h
teto Jul 13, 2016
ed92e5d
Identified commented functions with REGRESSION comments
teto Jul 14, 2016
d863fd7
C linkage might be broken
teto Jul 14, 2016
7899193
Problem lies in libc-ns3.so not containing cxa_finalize symbols.
teto Jul 15, 2016
92ce4f0
libc-ns3.so generated through:
teto Jul 15, 2016
87630a7
Need to see
teto Jul 15, 2016
3c8d6b7
I can't alias undefined symbols, hence I can't add symbols of NATIVE …
teto Jul 17, 2016
99edf04
I give up, NATIVE should embed the prototype . Also one can pass -Wl…
teto Jul 18, 2016
372f6c4
Problems to separate type from macro name
teto Jul 20, 2016
ae3202a
Included the P99 library to count macro arguments
teto Jul 22, 2016
2313cec
could not find libc_setup...
teto Jul 22, 2016
02249c2
Looks like I am able to generate those damn wrappers
teto Jul 22, 2016
063c101
TODO use subprocess.call to launch gcc on libc-ns3.h
teto Jul 23, 2016
8b0f4c4
Still many problems in pygccxml
teto Jul 25, 2016
15dbdec
Many fixes, must be careful of linking.
teto Aug 1, 2016
cc3d7b0
Compiles !! (not tested) added even more exceptions
teto Aug 1, 2016
daa458a
Previous commit compiled with gcc, not with clang:
teto Aug 2, 2016
56d0166
Added noexcept specifier where appropriate.
teto Aug 2, 2016
0e2e4ce
Added bug.py for testing
teto Aug 2, 2016
37c41a7
Now compiles but fails to link
teto Aug 2, 2016
0e21276
Fixed linking problems but not test coverage pbs
teto Aug 3, 2016
1765839
Temporary removal of code coverage
teto Aug 3, 2016
610ee7c
Fixed a few prototypes generation
teto Aug 3, 2016
83e1bac
__newlocale is not detected because aliases are not generated: use ro…
teto Aug 3, 2016
6443491
Has improved a bit but tests fail when using ns3testing
teto Aug 5, 2016
78774a5
Fixed pb of __newlocale, it was exported with a wrong symbol version.
teto Aug 7, 2016
9aa48d9
To apply after regenerating headers
teto Aug 7, 2016
0c019a1
Hum Be careful !! disabled some tests in fd-simple.
teto Aug 8, 2016
669f681
Made some tests pass + improved doc
teto Aug 8, 2016
b8d650c
The bug in test-exec comes from the fact that in C
teto Aug 8, 2016
0add90d
WIP: forward ellipsis as va_lsit
teto Aug 9, 2016
0d4a18b
Fixed va_list having no name in function declaration
teto Aug 10, 2016
9be8bff
Added doc and lldbinit
teto Aug 10, 2016
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
124 changes: 124 additions & 0 deletions bug.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
#!/usr/bin/env python3
# Example taken out of http://pygccxml.readthedocs.io/en/develop/examples/searching1/example.html
from pygccxml import utils
from pygccxml import declarations
from pygccxml import parser
from pygccxml.declarations import declaration_utils
import os
import argparse
import csv
import subprocess
import logging
import sys


"""
Must be able to generate:
-

todo do same for dl/pthread/rt
"""

log = logging.getLogger("dce")
# log.setLevel(logging.DEBUG)
log.addHandler(logging.StreamHandler())

class Generator:
def __init__(self):
pass

def parse(self, filename):
"""
cache parsing
"""
utils.loggers.set_level(logging.DEBUG)

# Find the location of the xml generator (castxml or gccxml)
generator_path, generator_name = utils.find_xml_generator()

# Configure the xml generator
xml_generator_config = parser.xml_generator_configuration_t(
xml_generator_path=generator_path,
xml_generator=generator_name,
cflags=" -nostdinc -I/usr/include",

# asked on tracker to generate va_list but not ok
# flags= ["f1"]
)
# config.flags =
# The c++ file we want to parse
# printf is declared in stdio.h
# filename = "/home/teto/glibc/libio/stdio.h"
filename = "test.h"
code = """
#include <signal.h>
"""

self.project_reader = parser.project_reader_t(xml_generator_config)
self.decls = self.project_reader.read_string(code)


def generate_wrappers(self, input_filename, out_filename):
"""
Generate wrappers + headers
"""

# input_filename = "natives.h.txt"
# out_filename =
global_namespace = declarations.get_global_namespace(self.decls)

locations = {}

# look for a match
criteria = declarations.calldef_matcher(name="exit")
results = declarations.matcher.find(criteria, global_namespace)

# print("decl", results)
decl = results[0]
# print( "islist ? len",len(func1))
name = declaration_utils.full_name(decl)
if name[:2] == "::":
name = name[2:]
log.info("Parsing function %s" % name)
extern="extern" if decl.has_extern else ""
rtype = "%s" % (decl.return_type if decl.return_type is not None else "void")

temp = []
for arg in decl.arguments:
s = str(arg.decl_type)
if s.startswith("?unknown?"):
print("UNKNOWN")
s = "va_list"
elif "(" in s:
print ("TOTO")
s= s.rstrip("*")
temp.append(s)

for arg in temp:
print("arg=%s"% arg)

# temp = ["va_list" else str(a.decl_type) for a in decl.arguments]
fullargs = ",".join(temp)
res = """
{extern} {ret} {name} ({fullargs});

""".format(
extern=extern,
ret=rtype,
fullargs=fullargs,
name=name,
retstmt="return" if rtype is not "void" else "",
arg_names=",".join([arg.name for arg in decl.arguments]),
)
print(res)



def main():
parser = argparse.ArgumentParser()
g = Generator()
g.parse("toto")
g.generate_wrappers("temp", "model/libc.generated.cc")

if __name__ == "__main__":
main()
31 changes: 31 additions & 0 deletions dce-stat.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
diff --git a/model/sys/dce-stat.h b/model/sys/dce-stat.h
index 0a180ea..218f544 100644
--- a/model/sys/dce-stat.h
+++ b/model/sys/dce-stat.h
@@ -14,19 +14,19 @@ extern "C" {

__mode_t dce_umask (__mode_t __mask) noexcept;

- int dce___xstat (int __ver,char const * __filename,stat * __stat_buf) noexcept;
+ int dce___xstat (int __ver,char const * __filename,struct stat * __stat_buf) noexcept;

- int dce___lxstat (int __ver,char const * __filename,stat * __stat_buf) noexcept;
+ int dce___lxstat (int __ver,char const * __filename,struct stat * __stat_buf) noexcept;

- int dce___fxstat (int __ver,int __fildes,stat * __stat_buf) noexcept;
+ int dce___fxstat (int __ver,int __fildes,struct stat * __stat_buf) noexcept;

- int dce___xstat64 (int __ver,char const * __filename,stat64 * __stat_buf) noexcept;
+ int dce___xstat64 (int __ver,char const * __filename,struct stat64 * __stat_buf) noexcept;

- int dce___lxstat64 (int __ver,char const * __filename,stat64 * __stat_buf) noexcept;
+ int dce___lxstat64 (int __ver,char const * __filename,struct stat64 * __stat_buf) noexcept;

- int dce___fxstat64 (int __ver,int __fildes,stat64 * __stat_buf) noexcept;
+ int dce___fxstat64 (int __ver,int __fildes,struct stat64 * __stat_buf) noexcept;

- int dce___fxstatat (int __ver,int __fildes,char const * __filename,stat * __stat_buf,int __flag) noexcept;
+ int dce___fxstatat (int __ver,int __fildes,char const * __filename,struct stat * __stat_buf,int __flag) noexcept;

int dce_fstat64 (int __fd, struct stat64 *__buf) noexcept;

2 changes: 1 addition & 1 deletion example/ccnx/dce-tap-ccnd.cc
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
#include <fstream>
#include <sys/stat.h>
#include <sys/wait.h>
#include <string.h>
#include <cstring>
#include <list>
#include <errno.h>

Expand Down
2 changes: 1 addition & 1 deletion example/ccnx/dce-tap-udp-echo.cc
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
#include <fstream>
#include <sys/stat.h>
#include <sys/wait.h>
#include <string.h>
#include <cstring>
#include <list>
#include <errno.h>

Expand Down
2 changes: 1 addition & 1 deletion example/ccnx/dce-tap-vlc.cc
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
#include <fstream>
#include <sys/stat.h>
#include <sys/wait.h>
#include <string.h>
#include <cstring>
#include <list>
#include <errno.h>

Expand Down
2 changes: 1 addition & 1 deletion example/dccp-client.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#include <sys/types.h>
#include <sys/socket.h>
#include <netdb.h>
#include <string.h>
#include <cstring>
#include <iostream>
#include <stdio.h>
#include <errno.h>
Expand Down
2 changes: 1 addition & 1 deletion example/dccp-server.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#include <sys/types.h>
#include <sys/socket.h>
#include <netdb.h>
#include <string.h>
#include <cstring>
#include <iostream>
#include <arpa/inet.h>

Expand Down
2 changes: 1 addition & 1 deletion example/freebsd-iproute.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#include <sys/socket.h>
#include <sys/ioctl.h>
#include <stdio.h>
#include <string.h>
#include <cstring>
#include <arpa/inet.h>

struct sockaddr_in_f {
Expand Down
2 changes: 1 addition & 1 deletion example/sctp-client.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
//
#include <stdio.h>
#include <stdlib.h>
#include <string.h> /* for memset */
#include <cstring> /* for memset */
#include <unistd.h> /* for memset */
#include <sys/socket.h>
#include <sys/types.h>
Expand Down
2 changes: 1 addition & 1 deletion example/sctp-server.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
//
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <unistd.h>
#include <sys/socket.h>
#include <sys/types.h>
Expand Down
2 changes: 1 addition & 1 deletion example/tcp-client.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#include <sys/types.h>
#include <sys/socket.h>
#include <netdb.h>
#include <string.h>
#include <cstring>
#include <iostream>


Expand Down
2 changes: 1 addition & 1 deletion example/tcp-loopback.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#include <sys/types.h>
#include <sys/socket.h>
#include <netdb.h>
#include <string.h>
#include <cstring>
#include <iostream>

#define SERVER_PORT 2000
Expand Down
2 changes: 1 addition & 1 deletion example/tcp-server.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#include <sys/types.h>
#include <sys/socket.h>
#include <netdb.h>
#include <string.h>
#include <cstring>
#include <iostream>

#define SERVER_PORT 2000
Expand Down
2 changes: 1 addition & 1 deletion example/udp-client.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#include <sys/types.h>
#include <sys/socket.h>
#include <netdb.h>
#include <string.h>
#include <cstring>
#include <iostream>


Expand Down
2 changes: 1 addition & 1 deletion example/udp-echo-client.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#include <sys/types.h>
#include <sys/socket.h>
#include <netdb.h>
#include <string.h>
#include <cstring>
#include <iostream>
#include <stdlib.h>
#include <errno.h>
Expand Down
2 changes: 1 addition & 1 deletion example/udp-echo-server.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#include <sys/types.h>
#include <sys/socket.h>
#include <netdb.h>
#include <string.h>
#include <cstring>
#include <errno.h>
#include <iostream>
#include <stdlib.h>
Expand Down
2 changes: 1 addition & 1 deletion example/udp-perf.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#include <time.h>
#include <sys/time.h>
#include <stdbool.h>
#include <string.h>
#include <cstring>
#include <stdlib.h>
#include <stdio.h>
#include <sys/socket.h>
Expand Down
2 changes: 1 addition & 1 deletion example/udp-server.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#include <sys/types.h>
#include <sys/socket.h>
#include <netdb.h>
#include <string.h>
#include <cstring>
#include <errno.h>
#include <iostream>
#include <stdlib.h>
Expand Down
2 changes: 1 addition & 1 deletion example/unix-client.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#include <sys/types.h>
#include <sys/socket.h>
#include <netdb.h>
#include <string.h>
#include <cstring>
#include <iostream>
#include <stdlib.h>
#include <stdio.h>
Expand Down
2 changes: 1 addition & 1 deletion example/unix-server.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#include <sys/types.h>
#include <sys/socket.h>
#include <netdb.h>
#include <string.h>
#include <cstring>
#include <iostream>
#include <stdlib.h>
#include <stdio.h>
Expand Down
Loading