Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 3d8416b

Browse files
committed
Last state
1 parent 912ef3b commit 3d8416b

File tree

7 files changed

+371
-7
lines changed

7 files changed

+371
-7
lines changed

.gdb_history

Lines changed: 256 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,256 @@
1+
run
2+
bt
3+
up
4+
up
5+
small_ints
6+
p small_ints
7+
f
8+
p arg
9+
info sources
10+
info sharedlibrary
11+
f
12+
run
13+
run
14+
watch small_ints
15+
run
16+
run
17+
watch
18+
info watchpoints
19+
run
20+
bt
21+
run
22+
bt
23+
f 8
24+
f 7
25+
f5
26+
f 5
27+
f 3
28+
up
29+
args
30+
p args
31+
p *args
32+
p **args
33+
p PyUnicode_AsUTF8AndSize(*args)
34+
p PyUnicode_AsUTF8AndSize(*args, 9)
35+
p PyUnicode_AsUTF8AndSize(*args, 0)
36+
run
37+
bt
38+
f 4
39+
p PyUnicode_AsUTF8AndSize(*args, 0)
40+
run
41+
run
42+
run
43+
run
44+
run
45+
run
46+
small_ints
47+
p small_ints
48+
p &small_ints
49+
watch &small_ints
50+
run
51+
run
52+
run -m IPython
53+
list
54+
up
55+
up
56+
up
57+
up
58+
up
59+
up
60+
up
61+
run
62+
bt
63+
run
64+
bt
65+
up
66+
up
67+
up
68+
list
69+
run net_test.py
70+
run net_test.py mono
71+
run net_test.py core
72+
run -m IPython
73+
ipython
74+
run -m IPython
75+
run
76+
bt
77+
frame
78+
p et
79+
p et->ht_name
80+
p *et
81+
p et->et_qualname
82+
p et->ht_qualname
83+
p PyUnicode_AsUTF8AndSize(et->ht_qualname)
84+
p PyUnicode_AsUTF8AndSize(et->ht_qualname, 0)
85+
run ipython
86+
run -m IPython
87+
bt
88+
up
89+
up
90+
up
91+
up
92+
run -m IPython
93+
bt
94+
f
95+
p et
96+
p *et
97+
run -m IPython
98+
run -m IPython
99+
run -m IPython
100+
bt
101+
frame 3
102+
list
103+
p stack
104+
p stack[0]
105+
p *stack[0]
106+
p PyUnicode_AsUTF8AndSize(stack[0], 0)
107+
p small_ints
108+
p small_ints+160
109+
p PyObject_Repr(small_ints+160)
110+
p PyUnicode_AsUTF8AndSize(PyObject_Repr(small_ints+160), 0)
111+
f
112+
list
113+
list -100
114+
list
115+
l -10
116+
list
117+
f
118+
list
119+
l -10
120+
l -10
121+
l -10
122+
level
123+
p level
124+
p _PyLong_AsInt(level)
125+
p _PyLong_AsInt(level)
126+
small_ints
127+
run -m IPython
128+
bt
129+
small_ints
130+
p small_ints
131+
info small_ints
132+
p &small_ints
133+
cont
134+
cont
135+
cont
136+
p &small_ints
137+
small_ints
138+
p small_ints
139+
p small_ints[0]
140+
p _PyLong_AsInt(small_ints[0])
141+
p _PyLong_AsInt(small_ints[0])
142+
run
143+
p _PyLong_AsInt(small_ints[0])
144+
p _PyLong_AsInt(/small_ints[0])
145+
p _PyLong_AsInt(&small_ints[0])
146+
p _PyLong_AsInt(&small_ints[1])
147+
p _PyLong_AsInt(&small_ints[2])
148+
p _PyLong_AsInt(&small_ints[3])
149+
p _PyLong_AsInt(&small_ints[4])
150+
p _PyLong_AsInt(&small_ints[5])
151+
p sizeof(small_ints)
152+
p sizeof(small_ints) / sizeof(small_ints[0])
153+
set $i=sizeof(small_ints) / sizeof(small_ints[0])
154+
p $i
155+
set $n=sizeof(small_ints) / sizeof(small_ints[0]); set $i=0; while ($i .lt. $n); p _PyLong_AsInt(small_ints[i]); set $i=$i + 1; end
156+
set $n=sizeof(small_ints) / sizeof(small_ints[0]); set $i=0; while ($i .lt. $n); p _PyLong_AsInt(small_ints[i]); set $i=$i + 1; end
157+
cont
158+
cont
159+
cont
160+
bt
161+
run
162+
p _PyLong_AsInt(&small_ints[5])
163+
p _PyLong_AsInt(&small_ints[10])
164+
cont
165+
cont
166+
cont
167+
cont
168+
cont
169+
p _PyLong_AsInt(&small_ints[10])
170+
p _PyLong_AsInt(&small_ints[200])
171+
bt
172+
f 1
173+
up
174+
func
175+
p func
176+
p *func
177+
p PyUnicode_AsUTF8AndSize(func, 0)
178+
p PyUnicode_AsUTF8AndSize(PyObject_Repr(func), 0)
179+
f
180+
down
181+
down
182+
up
183+
argstuple
184+
p argstuple
185+
p PyUnicode_AsUTF8AndSize(PyObject_Repr(argstuple), 0)
186+
p PyErr_Clear()
187+
p PyUnicode_AsUTF8AndSize(PyObject_Repr(argstuple), 0)
188+
f
189+
up
190+
up
191+
up
192+
p PyErr_Clear()
193+
p PyUnicode_AsUTF8AndSize(PyObject_Repr(argstuple), 0)
194+
gc
195+
run -m IPython
196+
run -m net_test core
197+
f
198+
up
199+
f
200+
up
201+
f
202+
interp
203+
p interp
204+
p *interp
205+
f
206+
bt
207+
0
208+
f 0
209+
list
210+
cb
211+
p cb
212+
p cb->func
213+
p cb->args
214+
p i
215+
p modstate
216+
p *modstate
217+
p *modstate.atexit_callbacks
218+
p modstate->atexit_callbacks[0]
219+
p *modstate->atexit_callbacks[0]
220+
p PyObject_Repr(*modstate->atexit_callbacks[0])
221+
p PyUnicode_AsUTF8AndSize(PyObject_Repr(*modstate->atexit_callbacks[0]), 0)
222+
f
223+
r
224+
p r
225+
p *r
226+
p *small_ints[4]
227+
p *small_ints[5]
228+
p small_ints
229+
p small_ints[5]
230+
p *(PyObject*)small_ints[5]
231+
p small_ints
232+
p *(PyObject*)small_ints[5]
233+
p *(PyObject*)(&small_ints[5])
234+
r
235+
p *(PyObject*)(&small_ints[5])
236+
p r
237+
p (PyObject*)(&small_ints[5])
238+
small_ints
239+
small_ints[0]
240+
info small_ints
241+
p &small_ints
242+
p (PyObject*)(&small_ints[5])
243+
p r
244+
info
245+
info modules
246+
info
247+
info sharedlibrary
248+
p r
249+
p PyLong_FromLong
250+
p PyLong_FromLong
251+
r
252+
r
253+
r
254+
run test.py core
255+
run test.py mono
256+
bt
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
using System;
2+
using System.Reflection;
3+
using System.Runtime.InteropServices;
4+
5+
namespace Python.Loader
6+
{
7+
public static class InternalDllImportResolver
8+
{
9+
public static IntPtr Resolve(string libraryName, Assembly assembly, int? flags) {
10+
if (libraryName == "__Internal") {
11+
12+
}
13+
}
14+
15+
}
16+
}

Python.Loader/Loader.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,18 @@
55
using System.Reflection;
66
using Mono.Cecil;
77

8-
namespace Python
8+
namespace Python.Loader
99
{
10-
public class Loader
10+
public class RuntimeLoader
1111
{
1212
AssemblyDefinition assembly;
1313

14-
static public Loader FromFile(string filename)
14+
static public RuntimeLoader FromFile(string filename)
1515
{
16-
return new Loader(File.OpenRead(filename));
16+
return new RuntimeLoader(File.OpenRead(filename));
1717
}
1818

19-
public Loader(Stream stream)
19+
public RuntimeLoader(Stream stream)
2020
{
2121
assembly = AssemblyDefinition.ReadAssembly(stream, new ReaderParameters
2222
{
@@ -74,7 +74,7 @@ public static int Initialize(IntPtr data, int size)
7474
var dllPath = splitted[0];
7575
var pythonDll = splitted[1];
7676

77-
var loader = Loader.FromFile(dllPath);
77+
var loader = RuntimeLoader.FromFile(dllPath);
7878
loader.Remap(pythonDll);
7979
var assembly = loader.LoadAssembly();
8080

Python.Loader/Python.Loader.csproj

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFramework>netstandard2.0</TargetFramework>
4+
<TargetFramework>netcoreapp3.1</TargetFramework>
55
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
66
</PropertyGroup>
77

88
<ItemGroup>
99
<PackageReference Include="Mono.Cecil" Version="0.11.2" />
10+
<PackageReference Include="System.Runtime.InteropServices" Version="4.3.0" />
1011
</ItemGroup>
1112

1213
</Project>

net_test.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import os
2+
#os.environ["MONO_LOG_LEVEL"] = "debug"
3+
# os.environ["MONO_LOG_MASK"] = "cfg,dll"
4+
os.environ["COREHOST_DEBUG"] = "1"
5+
os.environ["COREHOST_TRACE"] = "1"
6+
os.environ["COREHOST_TRACE_VERBOSITY"] = "4"
7+
8+
import pythonnet, clr_loader
9+
10+
import sys
11+
12+
if sys.argv[1] == "mono":
13+
mono = clr_loader.get_mono()
14+
rt = mono
15+
elif sys.argv[1] == "core":
16+
core = clr_loader.get_coreclr("/home/benedikt/git/clr-loader/example/out/example.runtimeconfig.json")
17+
rt = core
18+
19+
pythonnet.set_runtime(rt)
20+
pythonnet.load()
21+
22+
print("Loaded pythonnet")
23+
24+
import clr
25+
from System import Console
26+
Console.WriteLine("Success")

0 commit comments

Comments
 (0)