Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
pike
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
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
pikelang
pike
Commits
f52cf69b
Commit
f52cf69b
authored
Apr 10, 1998
by
Henrik (Grubba) Grubbström
Browse files
Options
Downloads
Patches
Plain Diff
Added new_error() to make it possible to get the arguments of
C functions in the backtrace. Rev: src/error.c:1.16
parent
1792a7a6
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/error.c
+68
-6
68 additions, 6 deletions
src/error.c
with
68 additions
and
6 deletions
src/error.c
+
68
−
6
View file @
f52cf69b
...
@@ -15,7 +15,7 @@
...
@@ -15,7 +15,7 @@
#include
"builtin_functions.h"
#include
"builtin_functions.h"
#include
"backend.h"
#include
"backend.h"
RCSID
(
"$Id: error.c,v 1.1
5
1998/04/
06 04:15:52 h
ubb
e
Exp $"
);
RCSID
(
"$Id: error.c,v 1.1
6
1998/04/
10 15:20:48 gr
ubb
a
Exp $"
);
#undef ATTRIBUTE
#undef ATTRIBUTE
#define ATTRIBUTE(X)
#define ATTRIBUTE(X)
...
@@ -79,13 +79,23 @@ void pike_throw(void) ATTRIBUTE((noreturn))
...
@@ -79,13 +79,23 @@ void pike_throw(void) ATTRIBUTE((noreturn))
longjmp
(
recoveries
->
recovery
,
1
);
longjmp
(
recoveries
->
recovery
,
1
);
}
}
void
push_error
(
char
*
description
)
{
push_text
(
description
);
f_backtrace
(
0
);
f_aggregate
(
2
);
}
struct
svalue
throw_value
=
{
T_INT
};
struct
svalue
throw_value
=
{
T_INT
};
int
throw_severity
;
int
throw_severity
;
static
char
*
in_error
;
/* FIXME: NOTE: This function uses a static buffer.
* Check sizes of arguments passed!
*/
void
va_error
(
char
*
fmt
,
va_list
args
)
ATTRIBUTE
((
noreturn
))
void
va_error
(
char
*
fmt
,
va_list
args
)
ATTRIBUTE
((
noreturn
))
{
{
char
buf
[
2000
];
char
buf
[
2000
];
static
char
*
in_error
;
if
(
in_error
)
if
(
in_error
)
{
{
char
*
tmp
=
in_error
;
char
*
tmp
=
in_error
;
...
@@ -110,9 +120,63 @@ void va_error(char *fmt, va_list args) ATTRIBUTE((noreturn))
...
@@ -110,9 +120,63 @@ void va_error(char *fmt, va_list args) ATTRIBUTE((noreturn))
if
((
long
)
strlen
(
buf
)
>=
(
long
)
sizeof
(
buf
))
if
((
long
)
strlen
(
buf
)
>=
(
long
)
sizeof
(
buf
))
fatal
(
"Buffer overflow in error()
\n
"
);
fatal
(
"Buffer overflow in error()
\n
"
);
push_string
(
make_shared_string
(
buf
));
push_error
(
buf
);
free_svalue
(
&
throw_value
);
throw_value
=
*--
sp
;
throw_severity
=
THROW_ERROR
;
in_error
=
0
;
pike_throw
();
/* Hope someone is catching, or we will be out of balls. */
}
void
new_error
(
char
*
name
,
char
*
text
,
struct
svalue
*
oldsp
,
INT32
args
,
char
*
file
,
int
line
)
ATTRIBUTE
((
noreturn
))
{
int
i
;
if
(
in_error
)
{
char
*
tmp
=
in_error
;
in_error
=
0
;
fatal
(
"Recursive error() calls, original error: %s"
,
tmp
);
}
in_error
=
text
;
if
(
!
recoveries
)
{
#ifdef DEBUG
dump_backlog
();
#endif
fprintf
(
stderr
,
"No error recovery context!
\n
%s():%s"
,
name
,
text
);
exit
(
99
);
}
push_text
(
text
);
f_backtrace
(
0
);
f_backtrace
(
0
);
if
(
file
)
{
push_text
(
file
);
push_int
(
line
);
}
else
{
push_int
(
0
);
push_int
(
0
);
}
push_text
(
name
);
for
(
i
=-
args
;
i
;
i
++
)
{
push_svalue
(
oldsp
+
i
);
}
f_aggregate
(
args
+
3
);
f_aggregate
(
1
);
f_add
(
2
);
f_aggregate
(
2
);
f_aggregate
(
2
);
free_svalue
(
&
throw_value
);
free_svalue
(
&
throw_value
);
throw_value
=
*--
sp
;
throw_value
=
*--
sp
;
throw_severity
=
THROW_ERROR
;
throw_severity
=
THROW_ERROR
;
...
@@ -168,9 +232,7 @@ void debug_fatal(char *fmt, ...) ATTRIBUTE((noreturn,format (printf, 1, 2)))
...
@@ -168,9 +232,7 @@ void debug_fatal(char *fmt, ...) ATTRIBUTE((noreturn,format (printf, 1, 2)))
(
void
)
VFPRINTF
(
stderr
,
fmt
,
args
);
(
void
)
VFPRINTF
(
stderr
,
fmt
,
args
);
d_flag
=
t_flag
=
0
;
d_flag
=
t_flag
=
0
;
push_text
(
"Attempting to dump backlog (may fail).
\n
"
);
push_error
(
"Attempting to dump backlog (may fail).
\n
"
);
f_backtrace
(
0
);
f_aggregate
(
2
);
APPLY_MASTER
(
"describe_backtrace"
,
1
);
APPLY_MASTER
(
"describe_backtrace"
,
1
);
if
(
sp
[
-
1
].
type
==
T_STRING
)
if
(
sp
[
-
1
].
type
==
T_STRING
)
write_to_stderr
(
sp
[
-
1
].
u
.
string
->
str
,
sp
[
-
1
].
u
.
string
->
len
);
write_to_stderr
(
sp
[
-
1
].
u
.
string
->
str
,
sp
[
-
1
].
u
.
string
->
len
);
...
...
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