• R/O
  • SSH

quipu: Commit

quipu mercurial repository


Commit MetaInfo

Revisionb83d33a615ecacba4a585a16aa18f3ed2bbfcaf7 (tree)
Time2020-04-09 07:00:02
AuthorAgustina Arzille <avarzille@rise...>
CommiterAgustina Arzille

Log Message

Better error reporting for init ops

Change Summary

Incremental Difference

diff -r 49f4c4cf72ad -r b83d33a615ec builtins.cpp
--- a/builtins.cpp Wed Apr 08 03:55:27 2020 +0000
+++ b/builtins.cpp Wed Apr 08 19:00:02 2020 -0300
@@ -333,6 +333,7 @@
333333 DISPATCH (PKG, P);
334334 DISPATCH (INSTANCE, W);
335335 #undef DISPATCH
336+#undef hash_W
336337 default:
337338 return (raw_hash (obj));
338339 }
diff -r 49f4c4cf72ad -r b83d33a615ec initop.h
--- a/initop.h Wed Apr 08 03:55:27 2020 +0000
+++ b/initop.h Wed Apr 08 19:00:02 2020 -0300
@@ -11,10 +11,12 @@
1111 struct init_op_list
1212 {
1313 dlist ops;
14+ const char *errmsg;
1415
1516 init_op_list ()
1617 {
1718 this->ops.init_head ();
19+ this->errmsg = nullptr;
1820 }
1921
2022 inline void add (init_op *op);
@@ -63,6 +65,12 @@
6365 init_op_list::global_ops().add (this);
6466 }
6567
68+ static int fail (const char *msg)
69+ {
70+ init_op_list::global_ops().errmsg = msg;
71+ return (init_op::result_failed);
72+ }
73+
6674 int call (interpreter *interp)
6775 {
6876 if (this->state == st_wip)
diff -r 49f4c4cf72ad -r b83d33a615ec quipu.cpp
--- a/quipu.cpp Wed Apr 08 03:55:27 2020 +0000
+++ b/quipu.cpp Wed Apr 08 19:00:02 2020 -0300
@@ -22,9 +22,17 @@
2222 main_interp->init ();
2323
2424 if (!init_op_list::global_ops().call (main_interp))
25- return (false);
25+ {
26+ fputs ("init ops failed: ", stderr);
27+ fputs (init_op_list::global_ops().errmsg, stderr);
28+ return (false);
29+ }
30+ else if (atexit (memory_exit) != 0)
31+ {
32+ fputs ("could not install atexit handler", stderr);
33+ return (false);
34+ }
2635
27- atexit (memory_exit);
2836 gc_enable ();
2937 return (true);
3038 }
diff -r 49f4c4cf72ad -r b83d33a615ec symbol.cpp
--- a/symbol.cpp Wed Apr 08 03:55:27 2020 +0000
+++ b/symbol.cpp Wed Apr 08 19:00:02 2020 -0300
@@ -623,7 +623,7 @@
623623 !as_symbol(s)->flagged_p (symbol::specform_flag))
624624 continue;
625625
626- *pkg_lookup(interp, ap, symname (*it)) = *it;
626+ *pkg_lookup(interp, ap, symname (s)) = s;
627627 if (ap->len * 75 <= ++syms_len(ap) * 100)
628628 {
629629 pkg_resize (interp, dstp, ap->len * 4);
@@ -1325,7 +1325,7 @@
13251325 }
13261326
13271327 if (*sf)
1328- return (init_op::result_failed);
1328+ return (init_op::fail ("more special forms than expected"));
13291329
13301330 symbol::quote = find_sym (interp, "quote", 5);
13311331
diff -r 49f4c4cf72ad -r b83d33a615ec sysdeps/io-windows.h
--- a/sysdeps/io-windows.h Wed Apr 08 03:55:27 2020 +0000
+++ b/sysdeps/io-windows.h Wed Apr 08 19:00:02 2020 -0300
@@ -484,11 +484,11 @@
484484 {
485485 HMODULE md = GetModuleHandleA ("ntdll.dll");
486486 if (!md)
487- return (init_op::result_failed);
487+ return (init_op::fail ("could not get a handle for ntdll.dll"));
488488
489489 setfh_info = (setfh_info_fn)GetProcAddress (md, "NtSetInformationFile");
490490 if (!setfh_info)
491- return (init_op::result_failed);
491+ return (init_op::fail ("could not find function in ntdll.dll"));
492492
493493 std_fhandles[0] = GetStdHandle (STD_INPUT_HANDLE);
494494 std_fhandles[1] = GetStdHandle (STD_OUTPUT_HANDLE);
@@ -499,11 +499,11 @@
499499 !fhandle_valid_p (std_fhandles[1]) ||
500500 !fhandle_valid_p (std_fhandles[2]) ||
501501 !fhandle_valid_p (interp->io_event))
502- return (init_op::result_failed);
502+ return (init_op::fail ("could not initialize standard handles"));
503503
504504 WSADATA wsd;
505505 if (WSAStartup (MAKEWORD (2, 2), &wsd) != 0)
506- return (init_op::result_failed);
506+ return (init_op::fail ("could not initialize socket subsystem"));
507507
508508 return (init_op::result_ok);
509509 }
diff -r 49f4c4cf72ad -r b83d33a615ec thread.cpp
--- a/thread.cpp Wed Apr 08 03:55:27 2020 +0000
+++ b/thread.cpp Wed Apr 08 19:00:02 2020 -0300
@@ -361,16 +361,16 @@
361361
362362 #ifdef QP_PLATFORM_WINDOWS
363363 if (!tp->handle)
364- return (init_op::result_failed);
364+ return (init_op::fail ("could not duplicate thread handle"));
365365 #endif
366366
367367 #if !defined (QP_PLATFORM_LINUX)
368368 if (!(tp->sleep_q = alloc_sleepq ()))
369- return (init_op::result_failed);
369+ return (init_op::fail ("could not allocate sleep queue"));
370370 #endif
371371
372372 if (!futex_init (interp))
373- return (init_op::result_failed);
373+ return (init_op::fail ("could not initialize futex subsystem"));
374374
375375 tp->join_ev = 0;
376376
Show on old repository browser