Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
15f27fb6
Commit
15f27fb6
authored
Dec 10, 1992
by
Guido van Rossum
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Adapt to modern times...
parent
1d974174
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
27 additions
and
25 deletions
+27
-25
Tools/scripts/objgraph.py
Tools/scripts/objgraph.py
+10
-8
Tools/scripts/pdeps.py
Tools/scripts/pdeps.py
+17
-17
No files found.
Tools/scripts/objgraph.py
View file @
15f27fb6
#!/usr/local/python
#!/usr/local/
bin/
python
# objgraph
# objgraph
#
#
...
@@ -21,9 +21,9 @@
...
@@ -21,9 +21,9 @@
import
sys
import
sys
import
string
import
string
import
path
import
os
import
getopt
import
getopt
import
regex
p
import
regex
# Types of symbols.
# Types of symbols.
#
#
...
@@ -33,7 +33,7 @@ ignore = 'Nntrgdsbavuc'
...
@@ -33,7 +33,7 @@ ignore = 'Nntrgdsbavuc'
# Regular expression to parse "nm -o" output.
# Regular expression to parse "nm -o" output.
#
#
matcher
=
regex
p
.
compile
(
'(.*):
\
t
?........ (.) (.*
)$'
)
matcher
=
regex
.
compile
(
'
\
(.*
\
):
\
t
?........
\
(.
\
)
\
(.*
\
)$'
)
# Store "item" in "dict" under "key".
# Store "item" in "dict" under "key".
# The dictionary maps keys to lists of items.
# The dictionary maps keys to lists of items.
...
@@ -66,12 +66,13 @@ undef2file = {}
...
@@ -66,12 +66,13 @@ undef2file = {}
#
#
def
readinput
(
file
):
def
readinput
(
file
):
while
1
:
while
1
:
s
=
file
.
readline
(
200
)
# Arbitrary, but reasonable limit
s
=
file
.
readline
(
)
if
not
s
:
if
not
s
:
break
break
# If you get an
exception on
this line,
# If you get an
y output from
this line,
# it is probably caused by an unexpected input line:
# it is probably caused by an unexpected input line:
(
ra
,
rb
),
(
r1a
,
r1b
),
(
r2a
,
r2b
),
(
r3a
,
r3b
)
=
matcher
.
exec
(
s
)
if
matcher
.
search
(
s
)
<
0
:
s
;
continue
# Shouldn't happen
(
ra
,
rb
),
(
r1a
,
r1b
),
(
r2a
,
r2b
),
(
r3a
,
r3b
)
=
matcher
.
regs
[:
4
]
fn
,
name
,
type
=
s
[
r1a
:
r1b
],
s
[
r3a
:
r3b
],
s
[
r2a
:
r2b
]
fn
,
name
,
type
=
s
[
r1a
:
r1b
],
s
[
r3a
:
r3b
],
s
[
r2a
:
r2b
]
if
type
in
definitions
:
if
type
in
definitions
:
store
(
def2file
,
name
,
fn
)
store
(
def2file
,
name
,
fn
)
...
@@ -160,7 +161,8 @@ def main():
...
@@ -160,7 +161,8 @@ def main():
optlist
,
args
=
getopt
.
getopt
(
sys
.
argv
[
1
:],
'cdu'
)
optlist
,
args
=
getopt
.
getopt
(
sys
.
argv
[
1
:],
'cdu'
)
except
getopt
.
error
:
except
getopt
.
error
:
sys
.
stdout
=
sys
.
stderr
sys
.
stdout
=
sys
.
stderr
print
'Usage:'
,
path
.
basename
(
sys
.
argv
[
0
]),
'[-cdu] [file] ...'
print
'Usage:'
,
os
.
path
.
basename
(
sys
.
argv
[
0
]),
print
'[-cdu] [file] ...'
print
'-c: print callers per objectfile'
print
'-c: print callers per objectfile'
print
'-d: print callees per objectfile'
print
'-d: print callees per objectfile'
print
'-u: print usage of undefined symbols'
print
'-u: print usage of undefined symbols'
...
...
Tools/scripts/pdeps.py
View file @
15f27fb6
#! /usr/local/python
#! /usr/local/
bin/
python
# pdeps
# pdeps
#
#
...
@@ -21,8 +21,8 @@
...
@@ -21,8 +21,8 @@
import
sys
import
sys
import
regex
p
import
regex
import
path
import
os
import
string
import
string
...
@@ -58,15 +58,15 @@ def main():
...
@@ -58,15 +58,15 @@ def main():
# Compiled regular expressions to search for import statements
# Compiled regular expressions to search for import statements
#
#
m_import
=
regex
p
.
compile
(
'^[
\
t
]*from[
\
t
]+([^
\
t
]+
)[
\
t
]+'
)
m_import
=
regex
.
compile
(
'^[
\
t
]*from[
\
t
]+
\
([^
\
t]+
\
)[
\
t]+'
)
m_from
=
regex
p
.
compile
(
'^[
\
t
]*import[
\
t
]+([^#]+
)'
)
m_from
=
regex
.
compile
(
'^[
\
t
]*import[
\
t
]+
\
([^#]+
\
)'
)
# Collect data from one file
# Collect data from one file
#
#
def
process
(
filename
,
table
):
def
process
(
filename
,
table
):
fp
=
open
(
filename
,
'r'
)
fp
=
open
(
filename
,
'r'
)
mod
=
path
.
basename
(
filename
)
mod
=
os
.
path
.
basename
(
filename
)
if
mod
[
-
3
:]
==
'.py'
:
if
mod
[
-
3
:]
==
'.py'
:
mod
=
mod
[:
-
3
]
mod
=
mod
[:
-
3
]
table
[
mod
]
=
list
=
[]
table
[
mod
]
=
list
=
[]
...
@@ -77,11 +77,11 @@ def process(filename, table):
...
@@ -77,11 +77,11 @@ def process(filename, table):
nextline
=
fp
.
readline
()
nextline
=
fp
.
readline
()
if
not
nextline
:
break
if
not
nextline
:
break
line
=
line
[:
-
1
]
+
nextline
line
=
line
[:
-
1
]
+
nextline
result
=
m_import
.
exec
(
line
)
if
m_import
.
match
(
line
)
>=
0
:
if
not
result
:
(
a
,
b
),
(
a1
,
b1
)
=
m_import
.
regs
[:
2
]
result
=
m_from
.
exec
(
line
)
elif
m_from
.
match
(
line
)
>=
0
:
if
result
:
(
a
,
b
),
(
a1
,
b1
)
=
m_from
.
regs
[:
2
]
(
a
,
b
),
(
a1
,
b1
)
=
result
else
:
continue
words
=
string
.
splitfields
(
line
[
a1
:
b1
],
','
)
words
=
string
.
splitfields
(
line
[
a1
:
b1
],
','
)
# print '#', line, words
# print '#', line, words
for
word
in
words
:
for
word
in
words
:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment