Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Lua: more debugging info
authorChristophe Thiéry <christopho128@gmail.com>
Thu, 13 Oct 2011 11:44:21 +0000 (13:44 +0200)
committerChristophe Thiéry <christopho128@gmail.com>
Thu, 13 Oct 2011 11:44:21 +0000 (13:44 +0200)
examples/lua/SimSplay/TODO
examples/lua/SimSplay/splay_school.lua
examples/lua/state_cloner/duplicated_globals.lua
src/bindings/lua/lua_state_cloner.c
src/bindings/lua/lua_utils.c
src/bindings/lua/simgrid_lua.c

index 42dcb7f..4e9ad79 100644 (file)
@@ -11,7 +11,7 @@ Ideally, its usage would be:
 simsplay platform_file.{xml|lua} deployment_file.{xml|lua} splay_script.lua [simgrid_options...]
 
 I'm not sure about the format of the platform and deployment files yet.
-We could accept both XML and Lua files, since their is a great Lua API to
+We could accept both XML and Lua files, since there is a great Lua API to
 describe platforms, or only the XML ones.
 
 The simsplay executable (which is compiled C) would initialize SimGrid, create
index 51cd58c..358c36f 100644 (file)
@@ -2,10 +2,10 @@ require("sim_splay")
 
 function SPLAYschool()
   log:print("My ip is: "..job.me.ip())
-  for i = 1000,10000 do
+  for i = 1,200 do
     log:print(i)
   end
-
+--[[
   events.sleep(5)
 
   if job.me.ip() == job.nodes[1].ip then
@@ -13,6 +13,7 @@ function SPLAYschool()
   end
   events.sleep(5)
   os.exit()
+  --]]
 end
 
 function call_me(from)
@@ -21,4 +22,5 @@ end
 
 events.thread("SPLAYschool")
 start.loop()
+log:print("Simulation finished")
 
index d4c2331..516cc77 100644 (file)
@@ -22,7 +22,7 @@ function replace(...)
   please_dont_replace_me(...)
 end
 
--- Show a hello message and prints the global string
+-- Shows a hello message and prints the global string
 function please_dont_replace_me(...)
 
   simgrid.info("Hello from please_dont_replace_me(). I'm lucky, I still exist in this state.")
index 4e35f18..c5abebb 100644 (file)
@@ -13,7 +13,7 @@
 #include <lauxlib.h>
 #include <lualib.h>
 
-XBT_LOG_NEW_DEFAULT_SUBCATEGORY(lua_state_cloner, lua, "Lua state management");
+XBT_LOG_NEW_DEFAULT_SUBCATEGORY(lua_state_cloner, bindings, "Lua state management");
 
 static void sglua_add_maestro_table(lua_State* L, int index, void* maestro_table_ptr);
 static void* sglua_get_maestro_table_ptr(lua_State* L, int index);
@@ -409,7 +409,7 @@ static void sglua_copy_function(lua_State* src, lua_State* dst) {
     /* it's a Lua function: dump it from src */
 
     s_sglua_buffer_t buffer;
-    buffer.capacity = 64;
+    buffer.capacity = 128; /* an empty function uses 77 bytes */
     buffer.size = 0;
     buffer.data = xbt_new(char, buffer.capacity);
 
@@ -417,6 +417,12 @@ static void sglua_copy_function(lua_State* src, lua_State* dst) {
     int error = lua_dump(src, sglua_memory_writer, &buffer);
     xbt_assert(!error, "Failed to dump the function from the source state: error %d",
         error);
+    XBT_DEBUG("Fonction dumped: %zu bytes", buffer.size);
+
+    /*
+    fwrite(buffer.data, buffer.size, buffer.size, stderr);
+    fprintf(stderr, "\n");
+    */
 
     /* load the chunk into dst */
     error = luaL_loadbuffer(dst, buffer.data, buffer.size, "(dumped function)");
@@ -609,7 +615,7 @@ lua_State* sglua_clone_maestro(void) {
                                             /* -- */
 
   /* opening the standard libs is not necessary as they are
-   * be inherited like any global values */
+   * inherited like any global values */
   /* luaL_openlibs(L); */
 
   XBT_DEBUG("New state created");
index 50b37ee..84b8ca2 100644 (file)
@@ -10,7 +10,7 @@
 #include "xbt.h"
 #include "xbt/log.h"
 
-XBT_LOG_NEW_DEFAULT_SUBCATEGORY(lua_utils, lua, "Lua helper functions");
+XBT_LOG_NEW_DEFAULT_SUBCATEGORY(lua_utils, bindings, "Lua helper functions");
 
 /**
  * @brief Returns a string representation of a value in the Lua stack.
index 5fdd7c1..09dd183 100644 (file)
@@ -10,7 +10,7 @@
 #include "lua_state_cloner.h"
 #include "lua_utils.h"
 
-XBT_LOG_NEW_DEFAULT_CATEGORY(lua, "Lua Bindings");
+XBT_LOG_NEW_DEFAULT_SUBCATEGORY(lua, bindings, "Lua Bindings");
 
 static lua_State *lua_maestro_state;
 
@@ -314,13 +314,19 @@ static int Host_at(lua_State * L)
 
 static int Host_self(lua_State * L)
 {
+                                  /* -- */
   m_host_t host = MSG_host_self();
   lua_newtable(L);
-  m_host_t *lua_host =(m_host_t *)lua_newuserdata(L,sizeof(m_host_t));
+                                  /* table */
+  m_host_t* lua_host = (m_host_t*) lua_newuserdata(L, sizeof(m_host_t));
+                                  /* table ud */
   *lua_host = host;
   luaL_getmetatable(L, HOST_MODULE_NAME);
+                                  /* table ud mt */
   lua_setmetatable(L, -2);
+                                  /* table ud */
   lua_setfield(L, -2, "__simgrid_host");
+                                  /* table */
   return 1;
 }