Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
Spack
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
eic_tools
Spack
Commits
294ad3e8
Commit
294ad3e8
authored
8 years ago
by
becker33
Committed by
GitHub
8 years ago
Browse files
Options
Downloads
Plain Diff
Merge pull request #2343 from krafczyk/features/better_diagnostics
Improve diagnostics to ease debugging
parents
760bca30
f1b26cb7
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
bin/spack
+3
-0
3 additions, 0 deletions
bin/spack
lib/spack/llnl/util/tty/__init__.py
+39
-2
39 additions, 2 deletions
lib/spack/llnl/util/tty/__init__.py
with
42 additions
and
2 deletions
bin/spack
+
3
−
0
View file @
294ad3e8
...
@@ -128,6 +128,8 @@ parser.add_argument('-p', '--profile', action='store_true',
...
@@ -128,6 +128,8 @@ parser.add_argument('-p', '--profile', action='store_true',
help
=
"
Profile execution using cProfile.
"
)
help
=
"
Profile execution using cProfile.
"
)
parser
.
add_argument
(
'
-v
'
,
'
--verbose
'
,
action
=
'
store_true
'
,
parser
.
add_argument
(
'
-v
'
,
'
--verbose
'
,
action
=
'
store_true
'
,
help
=
"
Print additional output during builds
"
)
help
=
"
Print additional output during builds
"
)
parser
.
add_argument
(
'
-s
'
,
'
--stacktrace
'
,
action
=
'
store_true
'
,
help
=
"
Add stacktrace information to all printed statements
"
)
parser
.
add_argument
(
'
-V
'
,
'
--version
'
,
action
=
'
version
'
,
parser
.
add_argument
(
'
-V
'
,
'
--version
'
,
action
=
'
version
'
,
version
=
"
%s
"
%
spack
.
spack_version
)
version
=
"
%s
"
%
spack
.
spack_version
)
...
@@ -155,6 +157,7 @@ def main():
...
@@ -155,6 +157,7 @@ def main():
# Set up environment based on args.
# Set up environment based on args.
tty
.
set_verbose
(
args
.
verbose
)
tty
.
set_verbose
(
args
.
verbose
)
tty
.
set_debug
(
args
.
debug
)
tty
.
set_debug
(
args
.
debug
)
tty
.
set_stacktrace
(
args
.
stacktrace
)
spack
.
debug
=
args
.
debug
spack
.
debug
=
args
.
debug
if
spack
.
debug
:
if
spack
.
debug
:
...
...
This diff is collapsed.
Click to expand it.
lib/spack/llnl/util/tty/__init__.py
+
39
−
2
View file @
294ad3e8
...
@@ -28,12 +28,14 @@
...
@@ -28,12 +28,14 @@
import
fcntl
import
fcntl
import
termios
import
termios
import
struct
import
struct
import
traceback
from
StringIO
import
StringIO
from
StringIO
import
StringIO
from
llnl.util.tty.color
import
*
from
llnl.util.tty.color
import
*
_debug
=
False
_debug
=
False
_verbose
=
False
_verbose
=
False
_stacktrace
=
False
indent
=
"
"
indent
=
"
"
...
@@ -45,6 +47,10 @@ def is_debug():
...
@@ -45,6 +47,10 @@ def is_debug():
return
_debug
return
_debug
def
is_stacktrace
():
return
_stacktrace
def
set_debug
(
flag
):
def
set_debug
(
flag
):
global
_debug
global
_debug
_debug
=
flag
_debug
=
flag
...
@@ -53,10 +59,35 @@ def set_debug(flag):
...
@@ -53,10 +59,35 @@ def set_debug(flag):
def
set_verbose
(
flag
):
def
set_verbose
(
flag
):
global
_verbose
global
_verbose
_verbose
=
flag
_verbose
=
flag
def
set_stacktrace
(
flag
):
global
_stacktrace
_stacktrace
=
flag
def
process_stacktrace
(
countback
):
"""
Gives file and line frame
'
countback
'
frames from the bottom
"""
st
=
traceback
.
extract_stack
()
# Not all entries may be spack files, we have to remove those that aren't.
file_list
=
[]
for
frame
in
st
:
# Check that the file is a spack file
if
frame
[
0
].
find
(
"
/spack
"
)
>=
0
:
file_list
.
append
(
frame
[
0
])
# We use commonprefix to find what the spack 'root' directory is.
root_dir
=
os
.
path
.
commonprefix
(
file_list
)
root_len
=
len
(
root_dir
)
st_idx
=
len
(
st
)
-
countback
-
1
st_text
=
"
%s:%i
"
%
(
st
[
st_idx
][
0
][
root_len
:],
st
[
st_idx
][
1
])
return
st_text
def
msg
(
message
,
*
args
):
def
msg
(
message
,
*
args
):
cprint
(
"
@*b{==>} %s
"
%
cescape
(
message
))
st_text
=
""
if
_stacktrace
:
st_text
=
process_stacktrace
(
2
)
cprint
(
"
@*b{%s==>} %s
"
%
(
st_text
,
cescape
(
message
)))
for
arg
in
args
:
for
arg
in
args
:
print
indent
+
str
(
arg
)
print
indent
+
str
(
arg
)
...
@@ -66,8 +97,13 @@ def info(message, *args, **kwargs):
...
@@ -66,8 +97,13 @@ def info(message, *args, **kwargs):
stream
=
kwargs
.
get
(
'
stream
'
,
sys
.
stdout
)
stream
=
kwargs
.
get
(
'
stream
'
,
sys
.
stdout
)
wrap
=
kwargs
.
get
(
'
wrap
'
,
False
)
wrap
=
kwargs
.
get
(
'
wrap
'
,
False
)
break_long_words
=
kwargs
.
get
(
'
break_long_words
'
,
False
)
break_long_words
=
kwargs
.
get
(
'
break_long_words
'
,
False
)
st_countback
=
kwargs
.
get
(
'
countback
'
,
3
)
cprint
(
"
@%s{==>} %s
"
%
(
format
,
cescape
(
str
(
message
))),
stream
=
stream
)
st_text
=
""
if
_stacktrace
:
st_text
=
process_stacktrace
(
st_countback
)
cprint
(
"
@%s{%s==>} %s
"
%
(
format
,
st_text
,
cescape
(
str
(
message
))),
stream
=
stream
)
for
arg
in
args
:
for
arg
in
args
:
if
wrap
:
if
wrap
:
lines
=
textwrap
.
wrap
(
lines
=
textwrap
.
wrap
(
...
@@ -105,6 +141,7 @@ def warn(message, *args, **kwargs):
...
@@ -105,6 +141,7 @@ def warn(message, *args, **kwargs):
def
die
(
message
,
*
args
,
**
kwargs
):
def
die
(
message
,
*
args
,
**
kwargs
):
kwargs
.
setdefault
(
'
countback
'
,
4
)
error
(
message
,
*
args
,
**
kwargs
)
error
(
message
,
*
args
,
**
kwargs
)
sys
.
exit
(
1
)
sys
.
exit
(
1
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment