FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
pythonnet-rawsvnmig/pythonnet/src/runtime/debughelper.cs at master · pythonnet/pythonnet-rawsvnmig · GitHub
Uh oh!
There was an error while loading.
Please reload this page
.
This repository was archived by the owner on Jun 4, 2019. It is now read-only.
pythonnet
/
pythonnet-rawsvnmig
Public archive
Notifications
You must be signed in to change notification settings
Fork
1
Star
0
Code
Issues
0
Pull requests
0
Actions
Projects
Wiki
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Wiki
Security and quality
Insights
Expand file tree
Breadcrumbs
pythonnet-rawsvnmig
/
pythonnet
/
src
/
runtime
/
debughelper.cs
Copy path
More file actions
More file actions
Latest commit
History
History
History
128 lines (99 loc) · 4.13 KB
Breadcrumbs
pythonnet-rawsvnmig
/
pythonnet
/
src
/
runtime
/
debughelper.cs
Copy path
File metadata and controls
128 lines (99 loc) · 4.13 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
// ==========================================================================
// This software is subject to the provisions of the Zope Public License,
// Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
// THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
// WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
// WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
// FOR A PARTICULAR PURPOSE.
// ==========================================================================
using
System
;
using
System
.
Collections
;
using
System
.
Reflection
;
using
System
.
Runtime
.
InteropServices
;
using
System
.
Diagnostics
;
using
System
.
Threading
;
namespace
Python
.
Runtime
{
/// <summary>
/// Debugging helper utilities.
/// The methods are only executed when the DEBUG flag is set. Otherwise
/// they are automagically hidden by the compiler and silently surpressed.
/// </summary>
internal
class
DebugUtil
{
[
Conditional
(
"DEBUG"
)
]
public
static
void
Print
(
string
msg
,
params
IntPtr
[
]
args
)
{
string
result
=
msg
;
result
+=
" "
;
for
(
int
i
=
0
;
i
<
args
.
Length
;
i
++
)
{
if
(
args
[
i
]
==
IntPtr
.
Zero
)
{
Console
.
WriteLine
(
"null arg to print"
)
;
}
IntPtr
ob
=
Runtime
.
PyObject_Repr
(
args
[
i
]
)
;
result
+=
Runtime
.
GetManagedString
(
ob
)
;
Runtime
.
Decref
(
ob
)
;
result
+=
" "
;
}
Console
.
WriteLine
(
result
)
;
return
;
}
[
Conditional
(
"DEBUG"
)
]
public
static
void
Print
(
string
msg
)
{
Console
.
WriteLine
(
msg
)
;
}
[
Conditional
(
"DEBUG"
)
]
internal
static
void
DumpType
(
IntPtr
type
)
{
IntPtr
op
=
Marshal
.
ReadIntPtr
(
type
,
TypeOffset
.
tp_name
)
;
string
name
=
Marshal
.
PtrToStringAnsi
(
op
)
;
Console
.
WriteLine
(
"Dump type: {0}"
,
name
)
;
op
=
Marshal
.
ReadIntPtr
(
type
,
TypeOffset
.
ob_type
)
;
DebugUtil
.
Print
(
" type: "
,
op
)
;
op
=
Marshal
.
ReadIntPtr
(
type
,
TypeOffset
.
tp_base
)
;
DebugUtil
.
Print
(
" base: "
,
op
)
;
op
=
Marshal
.
ReadIntPtr
(
type
,
TypeOffset
.
tp_bases
)
;
DebugUtil
.
Print
(
" bases: "
,
op
)
;
//op = Marshal.ReadIntPtr(type, TypeOffset.tp_mro);
//DebugUtil.Print(" mro: ", op);
FieldInfo
[
]
slots
=
typeof
(
TypeOffset
)
.
GetFields
(
)
;
int
size
=
IntPtr
.
Size
;
for
(
int
i
=
0
;
i
<
slots
.
Length
;
i
++
)
{
int
offset
=
i
*
size
;
name
=
slots
[
i
]
.
Name
;
op
=
Marshal
.
ReadIntPtr
(
type
,
offset
)
;
Console
.
WriteLine
(
" {0}: {1}"
,
name
,
op
)
;
}
Console
.
WriteLine
(
""
)
;
Console
.
WriteLine
(
""
)
;
op
=
Marshal
.
ReadIntPtr
(
type
,
TypeOffset
.
tp_dict
)
;
if
(
op
==
IntPtr
.
Zero
)
{
Console
.
WriteLine
(
" dict: null"
)
;
}
else
{
DebugUtil
.
Print
(
" dict: "
,
op
)
;
}
}
[
Conditional
(
"DEBUG"
)
]
internal
static
void
DumpInst
(
IntPtr
ob
)
{
IntPtr
tp
=
Runtime
.
PyObject_TYPE
(
ob
)
;
int
sz
=
(
int
)
Marshal
.
ReadIntPtr
(
tp
,
TypeOffset
.
tp_basicsize
)
;
for
(
int
i
=
0
;
i
<
sz
;
i
+=
IntPtr
.
Size
)
{
IntPtr
pp
=
new
IntPtr
(
ob
.
ToInt64
(
)
+
i
)
;
IntPtr
v
=
Marshal
.
ReadIntPtr
(
pp
)
;
Console
.
WriteLine
(
"offset {0}: {1}"
,
i
,
v
)
;
}
Console
.
WriteLine
(
""
)
;
Console
.
WriteLine
(
""
)
;
}
[
Conditional
(
"DEBUG"
)
]
internal
static
void
debug
(
string
msg
)
{
StackTrace
st
=
new
StackTrace
(
1
,
true
)
;
StackFrame
sf
=
st
.
GetFrame
(
0
)
;
MethodBase
mb
=
sf
.
GetMethod
(
)
;
Type
mt
=
mb
.
DeclaringType
;
string
caller
=
mt
.
Name
+
"."
+
sf
.
GetMethod
(
)
.
Name
;
Thread
t
=
Thread
.
CurrentThread
;
string
tid
=
t
.
GetHashCode
(
)
.
ToString
(
)
;
Console
.
WriteLine
(
"thread {0} : {1}"
,
tid
,
caller
)
;
Console
.
WriteLine
(
" {0}"
,
msg
)
;
return
;
}
}
}
Back
|
FazBrowse Home
|
New Git URL