Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/cache/cache.c
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ get_cache_entry_loading_count(void)
struct cache_entry *
find_in_cache(struct uri *uri)
{
//LOG_JS("%s", uri->data);
struct cache_entry *cached;
int proxy = (uri->protocol == PROTOCOL_PROXY);

Expand Down
8 changes: 6 additions & 2 deletions src/document/html/parser/general.c
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,10 @@ html_script(struct html_context *html_context, char *a,
if (type) {
pos = type;

if (!c_strncasecmp(type, "text/", 5)) {
if (!c_strcasecmp(type, "module")){
mem_free(type);
goto lang;
} else if (!c_strncasecmp(type, "text/", 5)) {
pos += 5;

} else if (!c_strncasecmp(type, "application/", 12)) {
Expand All @@ -273,6 +276,7 @@ html_script(struct html_context *html_context, char *a,
} else {
mem_free(type);
not_processed:
LOG_JS("skipping %s", get_attr_val(a, "src", html_context->doc_cp));
/* Permit nested scripts and retreat. */
html_top->invisible++;
return;
Expand All @@ -297,7 +301,7 @@ html_script(struct html_context *html_context, char *a,

mem_free(type);
}

lang:
/* Check that the script content is ecmascript. The value of the
* language attribute can be JavaScript with optional version digits
* postfixed (like: ``JavaScript1.1'').
Expand Down
2 changes: 1 addition & 1 deletion src/document/html/renderer.c
Original file line number Diff line number Diff line change
Expand Up @@ -2392,7 +2392,7 @@ html_special(struct html_context *html_context, html_special_type_T c, ...)
#ifdef CONFIG_ECMASCRIPT
if (document) {
struct uri *uri = va_arg(l, struct uri *);

/* LOG_JS("%s", uri->data); */
add_to_uri_list(&document->ecmascript_imports, uri);
}
#endif
Expand Down
2 changes: 2 additions & 0 deletions src/document/renderer.c
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,8 @@ render_document(struct view_state *vs, struct document_view *doc_view,
vs->doc_view = doc_view;

cached = find_in_cache(vs->uri);

//LOG_JS("%s", vs->uri->data);
if (!cached) {
INTERNAL("document %s to format not found", struri(vs->uri));
return;
Expand Down
1 change: 1 addition & 0 deletions src/ecmascript/ecmascript-c.c
Original file line number Diff line number Diff line change
Expand Up @@ -383,6 +383,7 @@ check_events_for_element(struct ecmascript_interpreter *ecmascript, dom_node *el
void
ecmascript_reset_state(struct view_state *vs)
{
LOG_JS("");
struct form_view *fv;
int i;

Expand Down
6 changes: 2 additions & 4 deletions src/ecmascript/ecmascript.c
Original file line number Diff line number Diff line change
Expand Up @@ -305,12 +305,10 @@ run_jobs(void *data)
void
check_for_rerender(struct ecmascript_interpreter *interpreter, const char* text)
{
#ifdef ECMASCRIPT_DEBUG
fprintf(stderr, "%s:%s %s %d\n", __FILE__, __FUNCTION__, text, interpreter->changed);
#endif
LOG_JS("%s %d", text, interpreter->changed);
run_jobs(interpreter);

if (interpreter->changed && !program.testjs) {
if (interpreter->changed) {
struct document_view *doc_view = interpreter->vs->doc_view;
struct document *document = doc_view->document;
struct session *ses = doc_view->session;
Expand Down
4 changes: 2 additions & 2 deletions src/ecmascript/mujs.c
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ mujs_get_interpreter(struct ecmascript_interpreter *interpreter)
interpreter->backend_data = ctx;
JS_SetContextOpaque(ctx, interpreter);

// JS::SetWarningReporter(ctx, error_reporter);
JS::SetWarningReporter(ctx, error_reporter);

JS_SetInterruptHandler(rt, js_heartbeat_callback, interpreter);
// JS::RealmOptions options;
Expand Down Expand Up @@ -267,7 +267,7 @@ mujs_eval(struct ecmascript_interpreter *interpreter,
struct string *code, struct string *ret)
{
assert(interpreter);

LOG_JS("%.100s...", code->source);
js_State *J = (js_State *)interpreter->backend_data;
interpreter->ret = ret;
js_dostring(J, code->source);
Expand Down
7 changes: 3 additions & 4 deletions src/ecmascript/quickjs.c
Original file line number Diff line number Diff line change
Expand Up @@ -371,12 +371,10 @@ error_reporter(struct ecmascript_interpreter *interpreter, JSContext *ctx)
set_led_value(ses->status.ecmascript_led, 'J');
#endif

if (!get_opt_bool("ecmascript.error_reporting", ses)) {
return;
}

if (init_string(&f)) {
js_dump_error(ctx, &f);
LOG_JS("%s", f);
if (!get_opt_bool("ecmascript.error_reporting", ses)) return;

if (!init_string(&msg)) {
done_string(&f);
Expand All @@ -401,6 +399,7 @@ quickjs_eval(struct ecmascript_interpreter *interpreter,
// if (!js_module_init_ok) {
// return;
// }
LOG_JS("%.100s...", code->source);
ctx = (JSContext *)interpreter->backend_data;
interpreter->heartbeat = add_heartbeat(interpreter);
interpreter->ret = ret;
Expand Down
2 changes: 1 addition & 1 deletion src/ecmascript/quickjs.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ inline int operator<(JSValueConst a, JSValueConst b)
extern "C" {
#endif

#ifdef ECMASCRIPT_DEBUG
#ifdef ECMASCRIPT_DEBUG_OBJ

#define RETURN_JS(obj) \
fprintf(stderr, "%s:%d obj=%p\n", __FILE__, __LINE__, JS_VALUE_GET_PTR(obj)); \
Expand Down
1 change: 1 addition & 0 deletions src/ecmascript/quickjs/console.c
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ js_console_log_common(JSContext *ctx, JSValueConst this_val, int argc, JSValueCo
if (!str) {
return JS_EXCEPTION;
}
LOG_JS("%s",str);
FILE *f = fopen(log_filename, "a");

if (f)
Expand Down
1 change: 1 addition & 0 deletions src/ecmascript/quickjs/element.c
Original file line number Diff line number Diff line change
Expand Up @@ -2051,6 +2051,7 @@ js_element_set_property_textContent(JSContext *ctx, JSValueConst this_val, JSVal
dom_node_unref(el);
return JS_EXCEPTION;
}
LOG_JS("%s",str);
dom_string *content = NULL;
dom_exception exc = dom_string_create((const uint8_t *)str, len, &content);
JS_FreeCString(ctx, str);
Expand Down
2 changes: 1 addition & 1 deletion src/elinks.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
* config.h. */
#include "setup.h"

#ifdef CONFIG_DEBUG
#ifdef CONFIG_DEBUG_MEMLEAK
#define DEBUG_MEMLEAK
#endif

Expand Down
6 changes: 3 additions & 3 deletions src/main/object.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ extern "C" {

struct elinks_object {
int refcount;
#ifdef CONFIG_DEBUG
#ifdef CONFIG_DEBUG_OBJ
char *name;
#endif
};
Expand All @@ -28,7 +28,7 @@ struct object_head {

#ifdef DEBUG_REFCOUNT
#include "util/error.h"
#ifdef CONFIG_DEBUG
#ifdef CONFIG_DEBUG_OBJ
#define object_lock_debug(obj, info) \
DBG("object %s[%p] lock %s to %d", (obj)->object.name, obj, \
info, (obj)->object.refcount)
Expand All @@ -40,7 +40,7 @@ struct object_head {
#define object_lock_debug(obj, info)
#endif /* DEBUG_REFCOUNT */

#ifdef CONFIG_DEBUG
#ifdef CONFIG_DEBUG_OBJ
#include "util/error.h"
#define object_sanity_check(obj) \
do { \
Expand Down
2 changes: 1 addition & 1 deletion src/main/timer.c
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ install_timer(timer_id_T *id, milliseconds_T delay, void (*func)(void *), void *
{
struct timer *new_timer, *timer;

assert(id && delay > 0);
assert(id && delay >= 0);

#ifdef USE_LIBEVENT
char *q = (char *)mem_alloc(sizeof_struct_event + sizeof(struct timer));
Expand Down
2 changes: 1 addition & 1 deletion src/osdep/osdep.c
Original file line number Diff line number Diff line change
Expand Up @@ -885,7 +885,7 @@ int
get_output_handle(void)
{
if (program.testjs) {
return open("/dev/null", O_WRONLY);
// return open("/dev/null", O_WRONLY);
}

return 1;
Expand Down
3 changes: 2 additions & 1 deletion src/session/session.c
Original file line number Diff line number Diff line change
Expand Up @@ -862,6 +862,7 @@ request_additional_file(struct session *ses, const char *name, struct uri *uri,
ftl->pri = pri;
ftl->ses = ses;

/* LOG_JS("%s", ftl->uri->data); */
add_to_list(ses->more_files, ftl);

return ftl;
Expand Down Expand Up @@ -892,7 +893,7 @@ process_file_requests(struct session *ses)
continue;

ftl->req_sent = 1;

LOG_JS("%s", ftl->uri->data);
load_additional_file(ftl, CACHE_MODE_NORMAL);
more = 1;
}
Expand Down
2 changes: 1 addition & 1 deletion src/session/task.c
Original file line number Diff line number Diff line change
Expand Up @@ -656,7 +656,7 @@ follow_url(struct session *ses, struct uri *uri, char *target,

uristring = uri && !uri->post ? get_uri_string(uri, URI_BASE_FRAGMENT)
: NULL;

LOG_JS("%s", uristring);
/* Do nothing if we do not have a URI or if it is a POST request
* because scripts can corrupt POST requests leading to bad
* things happening later on. */
Expand Down
12 changes: 11 additions & 1 deletion src/setup.h
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,16 @@
#define FG_POLL_TIME 500
#define TERMINAL_POLL_TIMEOUT 1000

//#define ECMASCRIPT_DEBUG 1
#ifdef CONFIG_DEBUG
//#define CONFIG_ASSERT
//#define CONFIG_DEBUG_DUMP
//#define CONFIG_DEBUG_LIST
//#define CONFIG_DEBUG_MEMLEAK
//#define CONFIG_DEBUG_MEMLIST
//#define CONFIG_DEBUG_OBJ
//#define CONFIG_DEBUG_STRING
// #define ECMASCRIPT_DEBUG
//#define ECMASCRIPT_DEBUG_OBJ
#endif

#endif
24 changes: 13 additions & 11 deletions src/util/error.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ er(int bell, int shall_sleep, const char *fmt, va_list params)

int errline;
const char *errfile;
const char *errfun;

void
elinks_debug(const char *fmt, ...)
Expand Down Expand Up @@ -110,13 +111,13 @@ elinks_internal(const char *fmt, ...)
va_start(params, fmt);

snprintf(errbuf, sizeof(errbuf),
"\033[1mINTERNAL ERROR\033[0m at %s:%d: %s",
errfile, errline, fmt);
"\033[1mINTERNAL ERROR\033[0m at %s %d %s: %s",
errfile, errline, errfun, fmt);

er(1, 1, errbuf, params);

va_end(params);
#ifdef CONFIG_DEBUG
#ifdef CONFIG_DEBUG_DUMP
force_dump();
#endif
}
Expand Down Expand Up @@ -191,25 +192,26 @@ done_log(void)
loctime);
errbuf[len] = '\0';

fprintf(log_file, "[%-5s %-15s %4s]: Log stopped at %s\n\n\n",
fprintf(log_file, "[%-5s %-15s %4s]: Log stopped at %s\n",
"", "", "", errbuf);

fclose(log_file);
}

void
elinks_log(char *msg, char *file, int line,
elinks_log(char *msg, char *file, int line,char*fun,
const char *fmt, ...)
{
static char *log_files = NULL;
static char *log_msg = NULL;
char errbuf[4096];
char tbuf[32];
va_list params;
time_t curtime = time(NULL);
struct tm *loctime = localtime(&curtime);

if (!log_file) {
char *log_name;
time_t curtime = time(NULL);
struct tm *loctime = localtime(&curtime);
int len;

log_files = getenv("ELINKS_FILES");
Expand All @@ -223,8 +225,7 @@ elinks_log(char *msg, char *file, int line,
loctime);
errbuf[len] = '\0';

fprintf(log_file, "\n\n[%-5s %-15s %4s]: Log started at %s\n",
"type", "file", "line", errbuf);
fprintf(log_file, "Log started at %s\n",errbuf);

atexit(done_log);
}
Expand All @@ -237,8 +238,9 @@ elinks_log(char *msg, char *file, int line,

va_start(params, fmt);

snprintf(errbuf, sizeof(errbuf), "[%-5s %-15s %4d]: %s",
msg, file, line, fmt);
strftime(tbuf, sizeof(tbuf), "%T", loctime);
snprintf(errbuf, sizeof(errbuf), "[%s %s %s %d %s]: %s",
tbuf, msg, file, line, fun, fmt);

vfprintf(log_file, errbuf, params);
fputc('\n', log_file);
Expand Down
Loading