[syslinux:elflink] 0613 temp debug

syslinux-bot for Feng Tang feng.tang at intel.com
Thu Aug 12 21:03:13 PDT 2010


Commit-ID:  638ea79273213c72c075eff71ad927ee40aee8c5
Gitweb:     http://syslinux.zytor.com/commit/638ea79273213c72c075eff71ad927ee40aee8c5
Author:     Feng Tang <feng.tang at intel.com>
AuthorDate: Sun, 13 Jun 2010 14:59:50 +0800
Committer:  Feng Tang <feng.tang at intel.com>
CommitDate: Tue, 20 Jul 2010 11:10:03 +0800

0613 temp debug



---
 build.sh                  |    2 +-
 com32/include/stdio.h     |    2 ++
 com32/lib/free.c          |    5 +++++
 com32/lib/malloc.c        |   15 +++++++++++++--
 com32/lib/sys/open.c      |    2 ++
 core/elflink/cli.c        |   12 +++++++++---
 core/elflink/load_env32.c |    6 ++++--
 core/elflink/readconfig.c |    1 +
 core/fs/btrfs/btrfs.c     |    2 +-
 core/fs/fs.c              |   10 ++++++++++
 core/mem/free.c           |    5 ++++-
 core/mem/init.c           |    1 -
 12 files changed, 52 insertions(+), 11 deletions(-)

diff --git a/build.sh b/build.sh
index 008b8e6..63a8b63 100755
--- a/build.sh
+++ b/build.sh
@@ -1,4 +1,4 @@
-make -j 8
+make -j 8 || exit 1
 cp extlinux/extlinux /home/feng/test/syslinux/
 cp com32/elflink/modules/*.c32 /home/feng/test/syslinux/cd/
 sudo extlinux/extlinux -i /home/feng/test/syslinux/cd/
diff --git a/com32/include/stdio.h b/com32/include/stdio.h
index 57efbfd..238c396 100644
--- a/com32/include/stdio.h
+++ b/com32/include/stdio.h
@@ -102,6 +102,8 @@ __extern int vasprintf(char **, const char *, va_list);
 
 #define mp(f, x...) \
         printf("[%s()]: " f "\n", __func__,##x)
+#define mpi()	mp("enter")
+#define mpo()	mp("exit")
 
 /* No buffering, so no flushing needed */
 static __inline__ int fflush(FILE * __f)
diff --git a/com32/lib/free.c b/com32/lib/free.c
index 9fea69f..ac9c789 100644
--- a/com32/lib/free.c
+++ b/com32/lib/free.c
@@ -7,6 +7,8 @@
 #include <stdlib.h>
 #include "malloc.h"
 
+#include <stdio.h>
+
 static struct free_arena_header *__free_block(struct free_arena_header *ah)
 {
     struct free_arena_header *pah, *nah;
@@ -68,6 +70,9 @@ void __inject_free_block(struct free_arena_header *ah)
     size_t a_end = (size_t) ah + ah->a.size;
     size_t n_end;
 
+    mp("size = %d, type = 0x%x, end = 0x%x",
+	ah->a.size, ah->a.type, a_end);
+
     for (nah = __malloc_head.a.next; nah->a.type != ARENA_TYPE_HEAD;
 	 nah = nah->a.next) {
 	n_end = (size_t) nah + nah->a.size;
diff --git a/com32/lib/malloc.c b/com32/lib/malloc.c
index 136e41b..b03f456 100644
--- a/com32/lib/malloc.c
+++ b/com32/lib/malloc.c
@@ -12,6 +12,8 @@
 #include "init.h"
 #include "malloc.h"
 
+#include <stdio.h>
+
 struct free_arena_header __malloc_head = {
     {
      ARENA_TYPE_HEAD,
@@ -59,6 +61,7 @@ static int consider_memory_area(void *dummy, addr_t start,
 	    if (len >= 2 * sizeof(struct arena_header)) {
 		fp = (struct free_arena_header *)start;
 		fp->a.size = len;
+		mp("will inject a block with size %d", len);
 		__inject_free_block(fp);
 	    }
 	}
@@ -72,6 +75,8 @@ static void __constructor init_memory_arena(void)
     struct free_arena_header *fp;
     size_t start, total_space;
 
+    mp("enter");
+
     start = (size_t) ARENA_ALIGN_UP(__mem_end);
     total_space = sp() - start;
 
@@ -137,6 +142,9 @@ static void *__malloc_from_block(struct free_arena_header *fp, size_t size)
 void *malloc(size_t size)
 {
     struct free_arena_header *fp;
+    char *buf = NULL;
+
+    mp("enter, size = %d", size);
 
     if (size == 0)
 	return NULL;
@@ -148,12 +156,15 @@ void *malloc(size_t size)
 	fp = fp->next_free) {
 	if (fp->a.size >= size) {
 	    /* Found fit -- allocate out of this block */
-	    return __malloc_from_block(fp, size);
+	    //return __malloc_from_block(fp, size);
+	    buf = __malloc_from_block(fp, size);
 	}
     }
 
     /* Nothing found... need to request a block from the kernel */
-    return NULL;		/* No kernel to get stuff from */
+    //return NULL;		/* No kernel to get stuff from */
+    mp("will return 0x%p", buf);
+    return buf;
 }
 
 /* need to revisit this later */
diff --git a/com32/lib/sys/open.c b/com32/lib/sys/open.c
index cb7c1b4..d7a923b 100644
--- a/com32/lib/sys/open.c
+++ b/com32/lib/sys/open.c
@@ -57,6 +57,8 @@ int open(const char *pathname, int flags, ...)
 
     fd = opendev(&__file_dev, NULL, flags);
 
+    printf("enter, file = %s, fd = %d\n", pathname, fd);
+
     if (fd < 0)
 	return -1;
 
diff --git a/core/elflink/cli.c b/core/elflink/cli.c
index ec4d161..b3a2f91 100644
--- a/core/elflink/cli.c
+++ b/core/elflink/cli.c
@@ -21,6 +21,7 @@
 
 void clear_screen(void)
 {
+	mp("enter");
     fputs("\033e\033%@\033)0\033(B\1#0\033[?25l\033[2J", stdout);
 }
 
@@ -30,6 +31,7 @@ int mygetkey(clock_t timeout)
     clock_t tto, to;
     int key;
 
+	//mp("enter");
     if (!totaltimeout)
 	return get_key(stdin, timeout);
 
@@ -46,12 +48,16 @@ int mygetkey(clock_t timeout)
 
 	totaltimeout -= t;
 
-	if (key != KEY_NONE)
+	if (key != KEY_NONE) {
+		//mp("get key 0x%x", key);
 	    return key;
+	}
 
 	if (timeout) {
-	    if (timeout <= t)
+	    if (timeout <= t) {
+		//mp("timeout");
 		return KEY_NONE;
+		}
 
 	    timeout -= t;
 	}
@@ -79,7 +85,7 @@ const char *edit_cmdline(const char *input, int top /*, int width */ ,
 	if (getscreensize(1, &height, &width))
 	    width = 80;
     }
-    //printf("width = %d\n", width);
+    printf("width = %d\n", width);
 
     strncpy(cmdline, input, MAX_CMDLINE_LEN);
     cmdline[MAX_CMDLINE_LEN - 1] = '\0';
diff --git a/core/elflink/load_env32.c b/core/elflink/load_env32.c
index 4004162..da7c604 100644
--- a/core/elflink/load_env32.c
+++ b/core/elflink/load_env32.c
@@ -92,7 +92,9 @@ void start_ui(char *config_file)
 	char *cmdline;
 	char *argv[2] = {config_file, NULL};
 
-	parse_configs(argv);
+	mp("enter, config file = %s", config_file);
+
+	//parse_configs(argv);
 	/* run the default menu if found */
 	/*
 	if (default_menu) {
@@ -117,11 +119,11 @@ void start_ui(char *config_file)
 /* note to self: do _*NOT*_ use static key word on this function */
 void load_env32(com32sys_t * regs)
 {
+	printf("Starting 32 bit elf module subsystem...\n");
 	call_constr();
 	openconsole(&dev_rawcon_r, &dev_ansiserial_w);
 	INIT_LIST_HEAD(&cli_history_head);
 
-	printf("Starting 32 bit elf module subsystem...\n");
 	init_module_subsystem(&core_module);
 
 	start_ui(NULL);
diff --git a/core/elflink/readconfig.c b/core/elflink/readconfig.c
index faeda02..39b5d12 100644
--- a/core/elflink/readconfig.c
+++ b/core/elflink/readconfig.c
@@ -1109,6 +1109,7 @@ void parse_configs(char **argv)
     struct menu *m;
     struct menu_entry *me;
     char *cmdline;
+    mp("enter");
 
     empty_string = refstrdup("");
 
diff --git a/core/fs/btrfs/btrfs.c b/core/fs/btrfs/btrfs.c
index 72dcbe9..f78bf47 100644
--- a/core/fs/btrfs/btrfs.c
+++ b/core/fs/btrfs/btrfs.c
@@ -82,7 +82,7 @@ static void insert_map(struct btrfs_chunk_map_item *item)
 	if (chunk_map.map == NULL) { /* first item */
 		chunk_map.map_length = BTRFS_MAX_CHUNK_ENTRIES;
 		chunk_map.map = (struct btrfs_chunk_map_item *)
-			malloc(chunk_map.map_length * sizeof(*chunk_map.map));
+			hmalloc(chunk_map.map_length * sizeof(*chunk_map.map));
 		chunk_map.map[0] = *item;
 		chunk_map.cur_length = 1;
 		return;
diff --git a/core/fs/fs.c b/core/fs/fs.c
index 058a762..6c272e9 100644
--- a/core/fs/fs.c
+++ b/core/fs/fs.c
@@ -193,14 +193,19 @@ int searchdir(const char *name)
     char *part, *p, echar;
     int symlink_count = MAX_SYMLINK_CNT;
 
+//   mp("enter: name = %s", name);
+
     if (!(file = alloc_file()))
 	goto err_no_close;
+//	mp("111");
     file->fs = this_fs;
 
     /* if we have ->searchdir method, call it */
     if (file->fs->fs_ops->searchdir) {
 	file->fs->fs_ops->searchdir(name, file);
 
+//	mp("this fs has searchdir(), inode = %d",file->inode);
+
 	if (file->inode)
 	    return file_to_handle(file);
 	else
@@ -210,10 +215,13 @@ int searchdir(const char *name)
     /* else, try the generic-path-lookup method */
 
     parent = get_inode(this_fs->cwd);
+//	mp("222");
     p = pathbuf = strdup(name);
     if (!pathbuf)
 	goto err;
 
+	mp("parent->ino = %d", parent->ino);
+
     do {
     got_link:
 	if (*p == '/') {
@@ -330,6 +338,8 @@ int open_file(const char *name, struct com32_filedata *filedata)
     mangle_name(mangled_name, name);
     rv = searchdir(mangled_name);
 
+    mp("name = %s, rv = %d", name, rv);
+
     if (rv >= 0) {
 	file = handle_to_file(rv);
 	filedata->size		= file->inode->size;
diff --git a/core/mem/free.c b/core/mem/free.c
index 09d08c1..58d7bd6 100644
--- a/core/mem/free.c
+++ b/core/mem/free.c
@@ -8,6 +8,8 @@
 #include <dprintf.h>
 #include "malloc.h"
 
+#include <stdio.h>
+
 static struct free_arena_header *
 __free_block(struct free_arena_header *ah)
 {
@@ -98,7 +100,8 @@ void __inject_free_block(struct free_arena_header *ah)
     size_t a_end = (size_t) ah + ARENA_SIZE_GET(ah->a.attrs);
     size_t n_end;
 
-    dprintf("inject: %#zx bytes @ %p, heap %u (%p)\n",
+    //dprintf("inject: %#zx bytes @ %p, heap %u (%p)\n",
+    mp("inject: %#zx bytes @ %p, heap %u (%p)",
 	    ARENA_SIZE_GET(ah->a.attrs), ah,
 	    ARENA_HEAP_GET(ah->a.attrs), head);
 
diff --git a/core/mem/init.c b/core/mem/init.c
index ce9bd1b..f35501c 100644
--- a/core/mem/init.c
+++ b/core/mem/init.c
@@ -15,7 +15,6 @@ void mem_init(void)
     uint16_t *bios_free_mem = (uint16_t *)0x413;
 
     /* Initialize the head nodes */
-
     fp = &__core_malloc_head[0];
     for (i = 0 ; i < NHEAP ; i++) {
 	fp->a.next = fp->a.prev = fp->next_free = fp->prev_free = fp;



More information about the Syslinux-commits mailing list