OSDN Git Service

(LibGoblin)
authorKoine Yuusuke(koinec) <koinec@users.osdn.me>
Tue, 20 Aug 2019 05:14:23 +0000 (14:14 +0900)
committerKoine Yuusuke(koinec) <koinec@users.osdn.me>
Tue, 20 Aug 2019 05:14:23 +0000 (14:14 +0900)
  * WorkBackup

16 files changed:
libgoblin/Makefile
libgoblin/drd64_libgoblin.h
libgoblin/drd64_libgoblin_api.c
libgoblin/drd64_libgoblin_debug_objinfo.c
libgoblin/drd64_libgoblin_dwarf_info.c
libgoblin/drd64_libgoblin_dwarf_ranges.c [new file with mode: 0644]
libgoblin/drd64_libgoblin_dwarf_ranges.h [new file with mode: 0644]
libgoblin/drd64_libgoblin_dwarf_tag_compileunit.c
libgoblin/drd64_libgoblin_dwarf_tag_dispatch.h
libgoblin/drd64_libgoblin_elf.c
libgoblin/drd64_libgoblin_elf_symtab.c
libgoblin/drd64_libgoblin_srcfile.c
libgoblin/drd64_libgoblin_srcfile.h
libgoblin/drd64_libgoblin_type.h
libgoblin/drd64_libgoblin_type_dwarf.h
libgoblin/test_libgoblin_srcfile.c

index 43fe694..9b717f2 100644 (file)
@@ -70,6 +70,7 @@ OBJS = drd64_libgoblin_api.o \
                drd64_libgoblin_elf32.o \
                drd64_libgoblin_dwarf.o \
                drd64_libgoblin_dwarf_abbrev.o \
+               drd64_libgoblin_dwarf_ranges.o \
                drd64_libgoblin_dwarf_attrform.o \
                drd64_libgoblin_dwarf_info.o \
                drd64_libgoblin_dwarf_oldline.o \
@@ -114,6 +115,7 @@ HEADER = drd64_libgoblin.h \
                drd64_libgoblin_elf32.h \
                drd64_libgoblin_dwarf.h \
                drd64_libgoblin_dwarf_abbrev.h \
+               drd64_libgoblin_dwarf_ranges.h \
                drd64_libgoblin_dwarf_attrform.h \
                drd64_libgoblin_dwarf_info.h \
                drd64_libgoblin_dwarf_oldline.h \
@@ -239,6 +241,9 @@ drd64_libgoblin_dwarf.o: drd64_libgoblin_dwarf.c $(HEADER)
 drd64_libgoblin_dwarf_abbrev.o: drd64_libgoblin_dwarf_abbrev.c $(HEADER)
        $(CC) -c -o drd64_libgoblin_dwarf_abbrev.o $(FLAGS_DEBUG) \
                                drd64_libgoblin_dwarf_abbrev.c
+drd64_libgoblin_dwarf_ranges.o: drd64_libgoblin_dwarf_ranges.c $(HEADER)
+       $(CC) -c -o drd64_libgoblin_dwarf_ranges.o $(FLAGS_DEBUG) \
+                               drd64_libgoblin_dwarf_ranges.c
 drd64_libgoblin_dwarf_attrform.o: \
                drd64_libgoblin_dwarf_attrform.c $(HEADER)
        $(CC) -c -o drd64_libgoblin_dwarf_attrform.o $(FLAGS_DEBUG) \
index eaa3831..1302696 100644 (file)
@@ -95,6 +95,7 @@ Comment:
 #include"drd64_libgoblin_elf32.h"
 #include"drd64_libgoblin_dwarf_common.h"
 #include"drd64_libgoblin_dwarf_abbrev.h"
+#include"drd64_libgoblin_dwarf_ranges.h"
 #include"drd64_libgoblin_dwarf_attrform.h"
 #include"drd64_libgoblin_dwarf_info.h"
 #include"drd64_libgoblin_dwarf_oldline.h"
index 00cf92b..4332cc1 100644 (file)
@@ -90,6 +90,9 @@ int
                return -0x03;
        }
 
+       // XXX: for DEBUG!
+       Debug_ObjectInfo_Print_AllGroupLink( p_pginfo, 0xff );
+
        return  i_result;
 }
 
index 96d0c1e..dfcfd80 100644 (file)
@@ -38,22 +38,30 @@ Comment:
 #include"drd64_libgoblin.h"
 
 static char    gstr_type[256][9]       = {
-       "NULL",
-       "PROGRAM",
-       "MASTER",
-       "PROGHDR",
-       "SECTION",
-       "FUNCTION",
-       "OBJECT",
-       "COMMON",
-       "TLS",
-       "REL",
+       "NULL",                 // 0x00
+       "PROGRAM",              // 0x01
+       "MASTER",               // 0x02
+       "PROGHDR",              // 0x03
+       "SECTION",              // 0x04
+       "FUNCTION",             // 0x05
+       "OBJECT",               // 0x06
+       "COMMON",               // 0x07
+       "TLS",                  // 0x08
+       "REL",                  // 0x09
+       "OBJFILE",              // 0x0a
+       "",                             // 0x0b
+       "",                             // 0x0c
+       "",                             // 0x0d
+       "",                             // 0x0e
+       "",                             // 0x0f
+
+       "TYPE(SIG)",    // 0x10
+       "TYPE(MUL)",    // 0x11
        "", "", "", "", "", "",
        "", "", "", "", "", "", "", "",
        "", "", "", "", "", "", "", "",
        "", "", "", "", "", "", "", "",
        "", "", "", "", "", "", "", "",
-       "", "", "", "", "", "", "", "",
 
        "", "", "", "", "", "", "", "",
        "", "", "", "", "", "", "", "",
index 84c755f..45f8478 100644 (file)
@@ -139,6 +139,7 @@ Byte *
 
 /*----------------------------------------------------------------------
 ----------------------------------------------------------------------*/
+/*
 LibGoblin_SrcFile *
        DWARF_Info_RegistSrcFile_fromTagCompileUnit(
                LibGoblin_BinaryInfo    *p_binfo,
@@ -204,6 +205,7 @@ LibGoblin_SrcFile *
 
        return p_srcfile;
 }
+*/
 
 
 /*----------------------------------------------------------------------
@@ -229,8 +231,8 @@ int
        DWARF_AbbrevEntry                       *p_abbrev;
        DWARF_AbbrevEntry                       *p_arvnow;
        LibGoblin_DWARF_Info_CUHeader   t_cuheader;
-       LibGoblin_SrcFile                       *p_srcfile;
        LibGoblin_DWARF_Info_Ancestry   t_ancestry[DWARF_ANCESTRY_MAX];
+       //LibGoblin_SrcFile                     *p_srcfile;
 
        assert( NULL != p_binfo );
 
@@ -265,17 +267,20 @@ int
                                                                p_binfo, p_bfile, t_cuheader.qw_abbrev_offset );
 
                // Read DW_TAG_compile_unit & Regist SrcFile struct. ---
+/*
                p_srcfile       = DWARF_Info_RegistSrcFile_fromTagCompileUnit(
                                                                p_binfo, p_bfile, pb_info, p_abbrev, qw_size_cu, &t_cuheader );
                if( NULL != p_srcfile ) {
                        p_srcfile->dwarf.i_abbrevs      = i_abbrevs;
                        p_srcfile->dwarf.p_abbrev       = p_abbrev;
 
-                       //printf( "\n SrcFile: %s,  Orig.Path: %s\n", p_srcfile->str_filename, p_srcfile->str_srcpath );
+                       //printf( "\n SrcFile: %s,  Orig.Path: %s\n", 
+                       //                              p_srcfile->str_filename, p_srcfile->str_srcpath );
                }
-
+*/
                //printf( "    size: %ld, ver:%d, abbrev off.:%ld, addr.size: %d\n",
-               //      t_cuheader.qw_unitsize, t_cuheader.w_version, t_cuheader.qw_abbrev_offset, t_cuheader.b_pointersize);
+               //                                      t_cuheader.qw_unitsize, t_cuheader.w_version,
+               //                                      t_cuheader.qw_abbrev_offset, t_cuheader.b_pointersize);
 
                // Read & Process DWARF info TAG ---
                i_childlv       = 0;
diff --git a/libgoblin/drd64_libgoblin_dwarf_ranges.c b/libgoblin/drd64_libgoblin_dwarf_ranges.c
new file mode 100644 (file)
index 0000000..b757e14
--- /dev/null
@@ -0,0 +1,112 @@
+/*DrDeAmOn64DrDeAmOn64DrDeAmOn64DrDeAmOn64DrDeAmOn64DrDeAmOn64DrDeAmOn64
+
+                         D r . D e a m o n  6 4
+                        for INTEL64(R), AMD64(R)
+       
+   Copyright(C) 2007-2009 Koine Yuusuke(koinec). All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+    this list of conditions and the following disclaimer.
+ 2. Redistributions in binary form must reproduce the above copyright
+    notice, this list of conditions and the following disclaimer in the
+    documentation and/or other materials provided with the distribution.
+
+THIS SOFTWARE IS PROVIDED BY Koine Yuusuke(koinec) ``AS IS'' AND ANY
+EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+DISCLAIMED. IN NO EVENT SHALL Koine Yuusuke(koinec) OR CONTRIBUTORS BE
+LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
+OF THE POSSIBILITY OF SUCH DAMAGE.
+
+DrDeAmOn64DrDeAmOn64DrDeAmOn64DrDeAmOn64DrDeAmOn64DrDeAmOn64DrDeAmOn64*/
+
+/* File Info -----------------------------------------------------------
+File: drd64_.c
+Function: 
+Comment: 
+----------------------------------------------------------------------*/
+
+#define        DRD64_SRC_LIBGOBLIN_DWARF_RANGES
+#include"drd64_libgoblin.h"
+
+/*----------------------------------------------------------------------
+  Non tested. - 2019/08/20
+----------------------------------------------------------------------*/
+LIBGOBLIN_DWARF_RANGES_EXTERN
+int
+       DWARF_Ranges_Read(
+               LibGoblin_DWARF_Ranges  *p_ranges,
+               LibGoblin_BinaryInfo    *p_binfo,
+               DWord                                   dw_offset,
+               PtrValue                                ptrval_base,
+               Byte                                    b_pointersize )
+{
+       int                                             i_ranges;
+       Byte                                    *pb_ranges;
+       DWord                                   *pdw_ranges;
+       QWord                                   *pqw_ranges;
+       QWord                                   qw_remain;
+       PtrValue                                ptrval_low;
+       PtrValue                                ptrval_high;
+       LibGoblin_SectionInfo   *psec_ranges;
+
+       i_ranges        = 0;
+
+       if(( 4 != b_pointersize ) && ( 8 != b_pointersize ))
+               { goto  goto_DWARF_Tag_Ranges_Read_post; }
+
+       psec_ranges     = Section_GetSectionInfo( p_binfo, LIBGOBLIN_SECTION_ID_DEBUG_RANGES );
+       if( NULL == psec_ranges )
+               { goto  goto_DWARF_Tag_Ranges_Read_post; }
+
+       pb_ranges       = psec_ranges->pb_data + dw_offset;
+       qw_remain       = psec_ranges->qw_size;
+
+       do      {
+               if( 8 == b_pointersize )        {
+                       if( 16 > qw_remain )    { goto  goto_DWARF_Tag_Ranges_Read_post; }
+                       pqw_ranges      = (QWord *)pb_ranges;
+                       ptrval_low      = (PtrValue)*(pqw_ranges + 0);
+                       ptrval_high     = (PtrValue)*(pqw_ranges + 1);
+                       pb_ranges       += 16;
+                       qw_remain       -= 16;
+               }
+               else if( 8 == b_pointersize )   {
+                       if( 8 > qw_remain )             { goto  goto_DWARF_Tag_Ranges_Read_post; }
+                       pdw_ranges      = (DWord *)pb_ranges;
+                       ptrval_low      = (PtrValue)*(pdw_ranges + 0);
+                       ptrval_high     = (PtrValue)*(pdw_ranges + 1);
+                       pb_ranges       += 8;
+                       qw_remain       -= 8;
+               }
+
+               if( 0x00000000 == ptrval_low )
+                       { ptrval_base   = ptrval_high; }
+
+               p_ranges->ptr_low[i_ranges].value       = ptrval_low + ptrval_base;
+               p_ranges->ptr_high[i_ranges].value      = ptrval_high + ptrval_base;
+               i_ranges++;
+
+       }while(( 0x00000000 != ptrval_low ) || ( 0x00000000 != ptrval_high ));
+
+       i_ranges--;
+
+goto_DWARF_Tag_Ranges_Read_post:
+       p_ranges->i_ranges      = i_ranges;
+       return 0x00;
+}
+
+/*----------------------------------------------------------------------
+----------------------------------------------------------------------*/
+
+
+
+/* EOF of drd64_.c ----------------------------------- */
diff --git a/libgoblin/drd64_libgoblin_dwarf_ranges.h b/libgoblin/drd64_libgoblin_dwarf_ranges.h
new file mode 100644 (file)
index 0000000..edc2077
--- /dev/null
@@ -0,0 +1,56 @@
+/*DrDeAmOn64DrDeAmOn64DrDeAmOn64DrDeAmOn64DrDeAmOn64DrDeAmOn64DrDeAmOn64
+
+                         D r . D e a m o n  6 4
+                        for INTEL64(R), AMD64(R)
+       
+   Copyright(C) 2007-2009 Koine Yuusuke(koinec). All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+    this list of conditions and the following disclaimer.
+ 2. Redistributions in binary form must reproduce the above copyright
+    notice, this list of conditions and the following disclaimer in the
+    documentation and/or other materials provided with the distribution.
+
+THIS SOFTWARE IS PROVIDED BY Koine Yuusuke(koinec) ``AS IS'' AND ANY
+EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+DISCLAIMED. IN NO EVENT SHALL Koine Yuusuke(koinec) OR CONTRIBUTORS BE
+LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
+OF THE POSSIBILITY OF SUCH DAMAGE.
+
+DrDeAmOn64DrDeAmOn64DrDeAmOn64DrDeAmOn64DrDeAmOn64DrDeAmOn64DrDeAmOn64*/
+
+/* File Info -----------------------------------------------------------
+File: drd64_.h
+Function: Header 
+Comment: 
+----------------------------------------------------------------------*/
+
+#ifndef DRD64_HEADER_LIBGOBLIN_DWARF_RANGES
+#define DRD64_HEADER_LIBGOBLIN_DWARF_RANGES
+
+#include"drd64_libgoblin.h"
+
+#ifdef DRD64_SRC_LIBGOBLIN_DWARF_RANGES
+       #define LIBGOBLIN_DWARF_RANGES_EXTERN
+#else
+       #define LIBGOBLIN_DWARF_RANGES_EXTERN   extern
+#endif
+
+LIBGOBLIN_DWARF_RANGES_EXTERN
+       int DWARF_Ranges_Read(
+                       LibGoblin_DWARF_Ranges  *p_ranges, LibGoblin_BinaryInfo    *p_binfo,
+                       DWord dw_offset, PtrValue ptrval_base, Byte b_pointersize );
+
+
+#endif /* DRD64_HEADER_LIBGOBLIN_BINFO */
+
+/* EOF of drd64_.h ----------------------------------- */
index 1ec8f9d..c71f45d 100644 (file)
@@ -38,7 +38,6 @@ Comment:
 #include"drd64_libgoblin.h"
 
 /*----------------------------------------------------------------------
-DW_TAG_compile_unit
 DW_TAG_partial_unit
 DW_TAG_imported_unit
 ----------------------------------------------------------------------*/
@@ -62,6 +61,7 @@ int
 
 
 /*----------------------------------------------------------------------
+  DW_TAG_compile_unit
 ----------------------------------------------------------------------*/
 LIBGOBLIN_DWARF_TAG_COMPILEUNIT_EXTERN
 int
@@ -72,30 +72,126 @@ int
         LibGoblin_DWARF_Info_Ancestry  *p_ancestry,
                LibGoblin_DWARF_Info_CUHeader   *p_cuheader )
 {
-/*
+       int                                                     i_result;
+       int                                                     i_cnt;
+       int                                                     i_objid                 = NO_OBJ;
+       char                                            *pstr_filepath  = NULL;
        char                                            *pstr_srcpath   = NULL;
-       char                                            str_temp[DRD64_MAX_PATH+1];
-       LibGoblin_DWARF_DIEValue        *p_val;
+       char                                            str_filename[DRD64_MAX_PATH+1];
+       char                                            str_path[DRD64_MAX_PATH+1];
+       QWord                                           qw_low_pc;
+       QWord                                           qw_high_pc;
        LibGoblin_SrcFile                       *p_srcfile;
+       LibGoblin_BinaryFile            *p_bfile;
+       LibGoblin_DWARF_DIEValue        *p_val;
+       LibGoblin_DWARF_DIEValue        *pval_name;
+       LibGoblin_DWARF_DIEValue        *pval_lowpc;
+       LibGoblin_DWARF_DIEValue        *pval_highpc;
+       LibGoblin_DWARF_DIEValue        *pval_ranges;
+       LibGoblin_ObjectInfo            *p_obj_parent;
+       LibGoblin_ObjectInfo            *p_obj;
+       LibGoblin_DWARF_Ranges          t_ranges;
+       LibGoblin_ProgramInfo           *p_pginfo;
 
        assert( NULL != p_binfo );
 
+       p_bfile = BinaryFile_GetBinaryFile( p_binfo->i_binfile );
+       assert( NULL != p_bfile );
+
+       // Data Extract (DW_AT_name)--- [MUST]
+       pval_name       = DWARF_AttrForm_GetDIEValue( p_binfo, DW_AT_name );
+
+       if( NULL != pval_name ) { pstr_filepath  = pval_name->value.pstr_value; }
+       if( NULL == pstr_filepath )     {
+               goto    goto_DWARF_Tag_CompileUnit_compile_unit_post;
+       }
+
+       strncpy( str_filename, pval_name->value.pstr_value, DRD64_MAX_PATH );
+       basename( str_filename );
+
+       strncpy( str_path, pval_name->value.pstr_value, DRD64_MAX_PATH );
+       dirname( str_path );
+       if(( '.' == str_path[0] ) && ( '\0' == str_path[1] ))
+               { str_path[0]   = '\0'; }
+
+
+       // Data Extract (location)--- [MUST]
+       pval_lowpc      = DWARF_AttrForm_GetDIEValue( p_binfo, DW_AT_low_pc );
+       pval_highpc     = DWARF_AttrForm_GetDIEValue( p_binfo, DW_AT_high_pc );
+       pval_ranges     = DWARF_AttrForm_GetDIEValue( p_binfo, DW_AT_ranges );
+       
+       // Pattern A ---
+       if(( NULL != pval_lowpc ) && ( NULL != pval_highpc ))   {
+               qw_low_pc       = (( LIBGOBLIN_DWARF_INFO_TYPE_DWORD == pval_lowpc->b_type )
+                                                       ? (QWord)pval_lowpc->value.dw_value : pval_lowpc->value.qw_value );
+               qw_high_pc      = (( LIBGOBLIN_DWARF_INFO_TYPE_DWORD == pval_highpc->b_type )
+                                                       ? (QWord)pval_highpc->value.dw_value : pval_highpc->value.qw_value );
+
+               t_ranges.i_ranges                       = 1;
+               t_ranges.ptr_low[0].value       = (PtrValue)qw_low_pc;
+               t_ranges.ptr_high[0].value      = (PtrValue)qw_high_pc;
+       }
+       // Pattern B ---
+       else if(( NULL != pval_ranges ) && ( NULL == pval_lowpc ))      {
+               i_result        = DWARF_Ranges_Read(
+                                                       &t_ranges, p_binfo, pval_ranges->value.dw_value,
+                                                       (PtrValue)0x00000000, p_cuheader->b_pointersize );
+       }
+       // Pattern C ---
+       else if(( NULL != pval_lowpc ) && ( NULL != pval_ranges ))      {
+               qw_low_pc       = (( LIBGOBLIN_DWARF_INFO_TYPE_DWORD == pval_lowpc->b_type )
+                                                       ? (QWord)pval_lowpc->value.dw_value : pval_lowpc->value.qw_value );
+               i_result        = DWARF_Ranges_Read(
+                                                       &t_ranges, p_binfo, pval_ranges->value.dw_value,
+                                                       (PtrValue)qw_low_pc, p_cuheader->b_pointersize );
+       }
+       // Error ---
+       else
+               { goto  goto_DWARF_Tag_CompileUnit_compile_unit_post; }
+
+
+       // Regist ObjInfo as ObjFile ---
+       p_pginfo        = ProgInfo_GetProgInfo( p_binfo->i_pginfo );
+       assert( NULL != p_pginfo );
+
+       for( i_cnt = 0; i_cnt < t_ranges.i_ranges; i_cnt++ )    {
+               p_obj   = ObjectInfo_InsetObject(
+                                                       p_pginfo, t_ranges.ptr_low[i_cnt].value,
+                                                       (QWord)(t_ranges.ptr_high[i_cnt].value - t_ranges.ptr_low[i_cnt].value),
+                                                       NULL, OBJINFO_INSETMODE_INSET | OBJINFO_INSETMODE_ADOPT );
+               p_obj->b_type           = OBJINFO_TYPE_OBJFILE;
+               p_obj->pstr_name        = pval_name->value.pstr_value;
+               p_obj->dw_hash          = Common_CalcDJBhash( pval_name->value.pstr_value );
+               
+               if( 0 == i_cnt )        { p_obj_parent  = p_obj; }
+/*
+               printf("  DEBUG: [%d] %xh (%xh) %s\n", p_obj->i_id,
+                                                       t_ranges.ptr_low[i_cnt].value,
+                                                       (QWord)(t_ranges.ptr_high[i_cnt].value - t_ranges.ptr_low[i_cnt].value),
+                                                       pval_name->value.pstr_value );
+*/     
+       }
+
+       // Regist SrcFile from .dwarf_line ----
+/*
        p_val   = DWARF_AttrForm_GetDIEValue( p_binfo, DW_AT_name );
        if( NULL != p_val )     { pstr_srcpath  = p_val->value.pstr_value; }
        if( NULL == pstr_srcpath )      {
-               return NULL;        
+               return 0x00;        
        }
 
        strncpy( str_temp, pstr_srcpath, DRD64_MAX_PATH );
-       p_srcfile       = SrcFile_DispenseSrcFile( p_bfile, basename( str_temp ) );
+       p_srcfile       = SrcFile_DispenseSrcFile( p_bfile, basename( str_temp ), NULL );
        if( NULL == p_srcfile ) {
-               return NULL;
+               return 0x00;
        }
 
        strncpy( p_srcfile->str_srcpath, dirname( str_temp ), DRD64_MAX_PATH );
 */
 
-       return 0x00;
+goto_DWARF_Tag_CompileUnit_compile_unit_post:
+       i_objid = 0;
+       return i_objid;
 }
 
 
index a7e7616..b62de9d 100644 (file)
@@ -77,106 +77,106 @@ LIBGOBLIN_DWARF_TAG_DISPATCH_EXTERN
 
 #ifdef DRD64_SRC_LIBGOBLIN_DWARF_TAG_DISPATCH
 DWARF_TagFunction      dwarf_tag[LIBGOBLIN_DWARF_TAG_MAX]      = {
-               { 0x00,                                                 NULL },
-               { DW_TAG_array_type,                    DWARF_Tag_Array_UnImplement },          // 0x01: array
-               { DW_TAG_class_type,                    DWARF_Tag_Class_UnImplement },          // 0x02: class
-               { DW_TAG_entry_point,                   DWARF_Tag_NotClang_UnImplement },       // 0x03: notclang
-               { DW_TAG_enumeration_type,              DWARF_Tag_Array_UnImplement },          // 0x04: array
-               { DW_TAG_formal_parameter,              DWARF_Tag_Parameter_UnImplement },      // 0x05: parameter
-               { 0x06,                                                 NULL },
-               { 0x07,                                                 NULL },
-               { DW_TAG_imported_declaration,  DWARF_Tag_Class_UnImplement },          // 0x08: class
-               { 0x09,                                                 NULL },
-               { DW_TAG_label,                                 DWARF_Tag_Function_UnImplement },       // 0x0a: function
-               { DW_TAG_lexical_block,                 DWARF_Tag_Function_UnImplement },       // 0x0b: function
-               { 0x0c,                                                 NULL },
-               { DW_TAG_member,                                DWARF_Tag_Struct_UnImplement },         // 0x0d: struct
-               { 0x0e,                                                 NULL },
-               { DW_TAG_pointer_type,                  DWARF_Tag_Type_UnImplement },           // 0x0f: type
-
-               { DW_TAG_reference_type,                DWARF_Tag_Type_UnImplement },           // 0x10: type
-               { DW_TAG_compile_unit,                  DWARF_Tag_CompileUnit_UnImplement },// 0x11: compileunit
-               { DW_TAG_string_type,                   DWARF_Tag_NotClang_UnImplement },       // 0x12: notclang
-               { DW_TAG_structure_type,                DWARF_Tag_Struct_UnImplement },         // 0x13: struct
-               { 0x14,                                                 NULL },
-               { DW_TAG_subroutine_type,               DWARF_Tag_Type_UnImplement },           // 0x15: type
-               { DW_TAG_typedef,                               DWARF_Tag_Type_UnImplement },           // 0x16: type
-               { DW_TAG_union_type,                    DWARF_Tag_Struct_UnImplement },         // 0x17: struct
-               { DW_TAG_unspecified_parameters,DWARF_Tag_Parameter_UnImplement },      // 0x18: parameter
-               { DW_TAG_variant,                               DWARF_Tag_Struct_UnImplement },         // 0x19: struct
-               { DW_TAG_common_block,                  DWARF_Tag_NotClang_UnImplement },       // 0x1a: notclang
-               { DW_TAG_common_inclusion,              DWARF_Tag_NotClang_UnImplement },       // 0x1b: notclang
-               { DW_TAG_inheritance,                   DWARF_Tag_Class_UnImplement },          // 0x1c: class
-               { DW_TAG_inlined_subroutine,    DWARF_Tag_Function_UnImplement },       // 0x1d: function
-               { DW_TAG_module,                                DWARF_Tag_NotClang_UnImplement },       // 0x1e: notclang
-               { DW_TAG_ptr_to_member_type,    DWARF_Tag_Type_UnImplement },           // 0x1f: type
-
-               { DW_TAG_set_type,                              DWARF_Tag_NotClang_UnImplement },       // 0x20: notclang
-               { DW_TAG_subrange_type,                 DWARF_Tag_Array_UnImplement },          // 0x21: array
-               { DW_TAG_with_stmt,                             DWARF_Tag_NotClang_UnImplement },       // 0x22: notclang
-               { DW_TAG_access_declaration,    DWARF_Tag_Class_UnImplement },          // 0x23: class
-               { DW_TAG_base_type,                             DWARF_Tag_Type_UnImplement },           // 0x24: type
-               { DW_TAG_catch_block,                   DWARF_Tag_Exception_UnImplement },      // 0x25: exception
-               { DW_TAG_const_type,                    DWARF_Tag_Type_UnImplement },           // 0x26: type
-               { DW_TAG_constant,                              DWARF_Tag_Parameter_UnImplement },      // 0x27: parameter
-               { DW_TAG_enumerator,                    DWARF_Tag_Array_UnImplement },          // 0x28: array
-               { 0x29,                                                 NULL },
-               { DW_TAG_friend,                                DWARF_Tag_Class_UnImplement },          // 0x2a: class
-               { DW_TAG_namelist,                              DWARF_Tag_NotClang_UnImplement },       // 0x2b: notclang
-               { DW_TAG_namelist_item,                 DWARF_Tag_NotClang_UnImplement },       // 0x2c: notclang
-               { DW_TAG_packed_type,                   DWARF_Tag_NotClang_UnImplement },       // 0x2d: notclang
-               { DW_TAG_subprogram,                    DWARF_Tag_Function_UnImplement },       // 0x2e: function
-               { DW_TAG_template_type_parameter,DWARF_Tag_Class_UnImplement },         // 0x2f: class
+{ 0x00,                                                        NULL },
+{ DW_TAG_array_type,                   DWARF_Tag_Array_UnImplement },          // 0x01: array
+{ DW_TAG_class_type,                   DWARF_Tag_Class_UnImplement },          // 0x02: class
+{ DW_TAG_entry_point,                  DWARF_Tag_NotClang_UnImplement },       // 0x03: notclang
+{ DW_TAG_enumeration_type,             DWARF_Tag_Array_UnImplement },          // 0x04: array
+{ DW_TAG_formal_parameter,             DWARF_Tag_Parameter_UnImplement },      // 0x05: parameter
+{ 0x06,                                                        NULL },
+{ 0x07,                                                        NULL },
+{ DW_TAG_imported_declaration, DWARF_Tag_Class_UnImplement },          // 0x08: class
+{ 0x09,                                                        NULL },
+{ DW_TAG_label,                                        DWARF_Tag_Function_UnImplement },       // 0x0a: function
+{ DW_TAG_lexical_block,                        DWARF_Tag_Function_UnImplement },       // 0x0b: function
+{ 0x0c,                                                        NULL },
+{ DW_TAG_member,                               DWARF_Tag_Struct_UnImplement },         // 0x0d: struct
+{ 0x0e,                                                        NULL },
+{ DW_TAG_pointer_type,                 DWARF_Tag_Type_UnImplement },           // 0x0f: type
+
+{ DW_TAG_reference_type,               DWARF_Tag_Type_UnImplement },           // 0x10: type
+{ DW_TAG_compile_unit,                 DWARF_Tag_CompileUnit_compile_unit },// 0x11: compileunit
+{ DW_TAG_string_type,                  DWARF_Tag_NotClang_UnImplement },       // 0x12: notclang
+{ DW_TAG_structure_type,               DWARF_Tag_Struct_UnImplement },         // 0x13: struct
+{ 0x14,                                                        NULL },
+{ DW_TAG_subroutine_type,              DWARF_Tag_Type_UnImplement },           // 0x15: type
+{ DW_TAG_typedef,                              DWARF_Tag_Type_UnImplement },           // 0x16: type
+{ DW_TAG_union_type,                   DWARF_Tag_Struct_UnImplement },         // 0x17: struct
+{ DW_TAG_unspecified_parameters,DWARF_Tag_Parameter_UnImplement },     // 0x18: parameter
+{ DW_TAG_variant,                              DWARF_Tag_Struct_UnImplement },         // 0x19: struct
+{ DW_TAG_common_block,                 DWARF_Tag_NotClang_UnImplement },       // 0x1a: notclang
+{ DW_TAG_common_inclusion,             DWARF_Tag_NotClang_UnImplement },       // 0x1b: notclang
+{ DW_TAG_inheritance,                  DWARF_Tag_Class_UnImplement },          // 0x1c: class
+{ DW_TAG_inlined_subroutine,   DWARF_Tag_Function_UnImplement },       // 0x1d: function
+{ DW_TAG_module,                               DWARF_Tag_NotClang_UnImplement },       // 0x1e: notclang
+{ DW_TAG_ptr_to_member_type,   DWARF_Tag_Type_UnImplement },           // 0x1f: type
+
+{ DW_TAG_set_type,                             DWARF_Tag_NotClang_UnImplement },       // 0x20: notclang
+{ DW_TAG_subrange_type,                        DWARF_Tag_Array_UnImplement },          // 0x21: array
+{ DW_TAG_with_stmt,                            DWARF_Tag_NotClang_UnImplement },       // 0x22: notclang
+{ DW_TAG_access_declaration,   DWARF_Tag_Class_UnImplement },          // 0x23: class
+{ DW_TAG_base_type,                            DWARF_Tag_Type_UnImplement },           // 0x24: type
+{ DW_TAG_catch_block,                  DWARF_Tag_Exception_UnImplement },      // 0x25: exception
+{ DW_TAG_const_type,                   DWARF_Tag_Type_UnImplement },           // 0x26: type
+{ DW_TAG_constant,                             DWARF_Tag_Parameter_UnImplement },      // 0x27: parameter
+{ DW_TAG_enumerator,                   DWARF_Tag_Array_UnImplement },          // 0x28: array
+{ 0x29,                                                        NULL },
+{ DW_TAG_friend,                               DWARF_Tag_Class_UnImplement },          // 0x2a: class
+{ DW_TAG_namelist,                             DWARF_Tag_NotClang_UnImplement },       // 0x2b: notclang
+{ DW_TAG_namelist_item,                        DWARF_Tag_NotClang_UnImplement },       // 0x2c: notclang
+{ DW_TAG_packed_type,                  DWARF_Tag_NotClang_UnImplement },       // 0x2d: notclang
+{ DW_TAG_subprogram,                   DWARF_Tag_Function_UnImplement },       // 0x2e: function
+{ DW_TAG_template_type_parameter,DWARF_Tag_Class_UnImplement },                // 0x2f: class
                                                                                        // = DW_TAG_template_type_param
 
-               { DW_TAG_template_value_parameter,DWARF_Tag_Class_UnImplement },        // 0x30: class
+{ DW_TAG_template_value_parameter,DWARF_Tag_Class_UnImplement },       // 0x30: class
                                                                                        // = DW_TAG_template_value_param
-               { DW_TAG_thrown_type,                   DWARF_Tag_Exception_UnImplement },      // 0x31: exception
-               { DW_TAG_try_block,                             DWARF_Tag_Exception_UnImplement },      // 0x32: exception
-               { DW_TAG_variant_part,                  DWARF_Tag_NotClang_UnImplement },       // 0x33: notclang
-               { DW_TAG_variable,                              DWARF_Tag_Parameter_UnImplement },      // 0x34: parameter
-               { DW_TAG_volatile_type,                 DWARF_Tag_Type_UnImplement },           // 0x35: type
-               { DW_TAG_dwarf_procedure,               NULL }, // 0x36
-               { DW_TAG_restrict_type,                 DWARF_Tag_Type_UnImplement },           // 0x37: type
-               { DW_TAG_interface_type,                DWARF_Tag_Class_UnImplement },          // 0x38: class
-               { DW_TAG_namespace,                             DWARF_Tag_Class_UnImplement },          // 0x39: class
-               { DW_TAG_imported_module,               DWARF_Tag_Class_UnImplement },          // 0x3a: class
-               { DW_TAG_unspecified_type,              DWARF_Tag_Type_UnImplement },           // 0x3b: type
-               { DW_TAG_partial_unit,                  DWARF_Tag_CompileUnit_UnImplement},     // 0x3c: compileunit
-               { DW_TAG_imported_unit,                 DWARF_Tag_CompileUnit_UnImplement },// 0x3d: compileunit
-               { 0x3e, NULL },
-               { DW_TAG_condition,                             DWARF_Tag_NotClang_UnImplement },       // 0x3f: notclang
-
-               { DW_TAG_shared_type,                   DWARF_Tag_NotClang_UnImplement },       // 0x40: notclang
-               { DW_TAG_type_unit,                             NULL }, // 0x41
-               { DW_TAG_rvalue_reference_type, NULL }, // 0x42
-               { DW_TAG_template_alias,                NULL }, // 0x43
-               { 0x44,                                                 NULL },
-               { 0x45,                                                 NULL },
-               { 0x46,                                                 NULL },
-               { 0x47,                                                 NULL },
-               { 0x48,                                                 NULL },
-               { 0x49,                                                 NULL },
-               { 0x4a,                                                 NULL },
-               { 0x4b,                                                 NULL },
-               { 0x4c,                                                 NULL },
-               { 0x4d,                                                 NULL },
-               { 0x4e,                                                 NULL },
-               { 0x4f,                                                 NULL },
-
-       // DW_TAG_lo_user 0x4080 ---- 11 items
-               { DW_TAG_format_label, NULL },  // 0x4101
-               { DW_TAG_function_template, NULL },     // 0x4102
-               { DW_TAG_class_template, NULL },        // 0x4103
-               { DW_TAG_GNU_BINCL, NULL },     // 0x4104
-               { DW_TAG_GNU_EINCL, NULL },     // 0x4105
-               { DW_TAG_GNU_template_template_parameter, NULL },       // 0x4106
-               { DW_TAG_GNU_template_template_param, NULL },   // 0x4106
-               { DW_TAG_GNU_template_parameter_pack, NULL },   // 0x4107
-               { DW_TAG_GNU_formal_parameter_pack, NULL },     // 0x4108
-               { DW_TAG_GNU_call_site, NULL }, // 0x4109
-               { DW_TAG_GNU_call_site_parameter, NULL }        // 0x410a
-       // DW_TAG_hi_user 0xffff ----
+{ DW_TAG_thrown_type,                  DWARF_Tag_Exception_UnImplement },      // 0x31: exception
+{ DW_TAG_try_block,                            DWARF_Tag_Exception_UnImplement },      // 0x32: exception
+{ DW_TAG_variant_part,                 DWARF_Tag_NotClang_UnImplement },       // 0x33: notclang
+{ DW_TAG_variable,                             DWARF_Tag_Parameter_UnImplement },      // 0x34: parameter
+{ DW_TAG_volatile_type,                        DWARF_Tag_Type_UnImplement },           // 0x35: type
+{ DW_TAG_dwarf_procedure,              NULL }, // 0x36
+{ DW_TAG_restrict_type,                        DWARF_Tag_Type_UnImplement },           // 0x37: type
+{ DW_TAG_interface_type,               DWARF_Tag_Class_UnImplement },          // 0x38: class
+{ DW_TAG_namespace,                            DWARF_Tag_Class_UnImplement },          // 0x39: class
+{ DW_TAG_imported_module,              DWARF_Tag_Class_UnImplement },          // 0x3a: class
+{ DW_TAG_unspecified_type,             DWARF_Tag_Type_UnImplement },           // 0x3b: type
+{ DW_TAG_partial_unit,                 DWARF_Tag_CompileUnit_UnImplement},     // 0x3c: compileunit
+{ DW_TAG_imported_unit,                        DWARF_Tag_CompileUnit_UnImplement },// 0x3d: compileunit
+{ 0x3e, NULL },
+{ DW_TAG_condition,                            DWARF_Tag_NotClang_UnImplement },       // 0x3f: notclang
+
+{ DW_TAG_shared_type,                  DWARF_Tag_NotClang_UnImplement },       // 0x40: notclang
+{ DW_TAG_type_unit,                            NULL }, // 0x41
+{ DW_TAG_rvalue_reference_type, NULL },        // 0x42
+{ DW_TAG_template_alias,               NULL }, // 0x43
+{ 0x44,                                                        NULL },
+{ 0x45,                                                        NULL },
+{ 0x46,                                                        NULL },
+{ 0x47,                                                        NULL },
+{ 0x48,                                                        NULL },
+{ 0x49,                                                        NULL },
+{ 0x4a,                                                        NULL },
+{ 0x4b,                                                        NULL },
+{ 0x4c,                                                        NULL },
+{ 0x4d,                                                        NULL },
+{ 0x4e,                                                        NULL },
+{ 0x4f,                                                        NULL },
+
+// DW_TAG_lo_user 0x4080 ---- 11 items
+{ DW_TAG_format_label, NULL }, // 0x4101
+{ DW_TAG_function_template, NULL },    // 0x4102
+{ DW_TAG_class_template, NULL },       // 0x4103
+{ DW_TAG_GNU_BINCL, NULL },    // 0x4104
+{ DW_TAG_GNU_EINCL, NULL },    // 0x4105
+{ DW_TAG_GNU_template_template_parameter, NULL },      // 0x4106
+{ DW_TAG_GNU_template_template_param, NULL },  // 0x4106
+{ DW_TAG_GNU_template_parameter_pack, NULL },  // 0x4107
+{ DW_TAG_GNU_formal_parameter_pack, NULL },    // 0x4108
+{ DW_TAG_GNU_call_site, NULL },        // 0x4109
+{ DW_TAG_GNU_call_site_parameter, NULL }       // 0x410a
+// DW_TAG_hi_user 0xffff ----
 };
 #else
 extern DWARF_TagFunction       dwarf_tag[LIBGOBLIN_DWARF_TAG_MAX];
index 71a652b..fbbb03a 100644 (file)
@@ -192,7 +192,7 @@ int
                return i_result;
        }
 
-       Debug_ObjectInfo_Print_AllGroupLink( p_pginfo, 0xff );
+       //Debug_ObjectInfo_Print_AllGroupLink( p_pginfo, 0xff );
 
 
        /* Analyze Dwarf-Debug Info. */
index 0802c43..8c56507 100644 (file)
@@ -61,7 +61,7 @@ LibGoblin_ObjectInfo *
        // Source file.
        if( STT_FILE == ELF64_ST_TYPE( p_sym->st_info ) )       {
                p_bfile         = BinaryFile_GetBinaryFile( p_binfo->i_binfile );
-               p_srcfile       = SrcFile_DispenseSrcFile( p_bfile, (char *)pb_strtab + p_sym->st_name );
+               p_srcfile       = SrcFile_DispenseSrcFile( p_bfile, (char *)pb_strtab + p_sym->st_name, NULL );
                assert( NULL != p_srcfile );
                goto    goto_ELF64_Symtab_RegistSymbol_toObjectInfo_post;
        }
index d04661c..f2c5187 100644 (file)
@@ -144,7 +144,7 @@ LibGoblin_SrcFile   *
        SrcFile_SearchSrcFile(
                        LibGoblin_BinaryFile    *p_bfile,
                        char    *pstr_filename,
-                       char    *pstr_pathname )
+                       char    *pstr_path )
 {
        int             i_cnt;
        int             i_result;
@@ -153,7 +153,6 @@ LibGoblin_SrcFile   *
 
        assert( NULL != p_bfile );
        assert( NULL != pstr_filename );
-       assert( NULL != pstr_pathname );
 
        dw_hash = Common_CalcDJBhash( pstr_filename );
 
@@ -167,12 +166,15 @@ LibGoblin_SrcFile *
                i_result        = strncmp( pstr_filename, p_srcfile->str_filename, DRD64_MAX_PATH );
                if( 0x00 != i_result )  { continue; }
 
-               if( '\0' != *(pstr_pathname + 0) )      {
-                       i_result        = strncmp( pstr_pathname, p_srcfile->str_srcpath, DRD64_MAX_PATH );
-                       if( 0x00 != i_result )  { continue; }
-               }
+               if( NULL == pstr_path )
+                       { goto  goto_SrcFile_SearchSrcFile_post; }
 
-               goto    goto_SrcFile_SearchSrcFile_post;
+               if( '\0' == p_srcfile->str_srcpath[0] )
+                       { goto  goto_SrcFile_SearchSrcFile_post; }
+                       
+               i_result        = strncmp( pstr_path, p_srcfile->str_srcpath, DRD64_MAX_PATH );
+               if( 0x00 == i_result )
+                       { goto  goto_SrcFile_SearchSrcFile_post; }
        }
 
        p_srcfile       = NULL;
@@ -189,31 +191,27 @@ LIBGOBLIN_SRCFILE_EXTERN
 LibGoblin_SrcFile      *
        SrcFile_DispenseSrcFile(
                        LibGoblin_BinaryFile    *p_bfile,
-                       char    *pstr_filepath )
+                       char    *pstr_filename,
+                       char    *pstr_path )
 {
-       char    str_filename[DRD64_MAX_PATH + 1];
-       char    str_pathname[DRD64_MAX_PATH + 1];
        LibGoblin_SrcFile       *p_srcfile;
 
        assert( NULL != p_bfile );
 
-       strncpy( str_filename, pstr_filepath, DRD64_MAX_PATH );
-       basename( str_filename );
-
-       strncpy( str_pathname, pstr_filepath, DRD64_MAX_PATH );
-       dirname( str_pathname );
-       if(( '.' == str_pathname[0] ) && ( '\0' == str_pathname[1] ))
-               { str_pathname[0] = '\0'; }
-
-       p_srcfile       = SrcFile_SearchSrcFile( p_bfile, str_filename, str_pathname );
+       p_srcfile       = SrcFile_SearchSrcFile( p_bfile, pstr_filename, pstr_path );
        if( NULL == p_srcfile ) {
                p_srcfile       = SrcFile_AllocSrcFile( p_bfile );
        }
 
        assert( NULL != p_srcfile );
 
-       strncpy( p_srcfile->str_filename, str_filename, DRD64_MAX_PATH );
-       p_srcfile->dw_hash_filename     = Common_CalcDJBhash( str_filename );
+       strncpy( p_srcfile->str_filename, pstr_filename, DRD64_MAX_PATH );
+       p_srcfile->dw_hash_filename     = Common_CalcDJBhash( pstr_filename );
+
+       if( NULL == pstr_path )
+               { p_srcfile->str_srcpath[0]     = '\0'; }
+       else    
+               { strncpy( p_srcfile->str_srcpath, pstr_path, DRD64_MAX_PATH ); }
                                
        return  p_srcfile;
 }
index 78a5fcc..0b3147e 100644 (file)
@@ -62,9 +62,11 @@ LIBGOBLIN_SRCFILE_EXTERN
 LIBGOBLIN_SRCFILE_EXTERN
        LibGoblin_SrcFile *SrcFile_AllocSrcFile( LibGoblin_BinaryFile *p_bfile );
 LIBGOBLIN_SRCFILE_EXTERN
-       LibGoblin_SrcFile *SrcFile_SearchSrcFile( LibGoblin_BinaryFile *p_bfile, char *pstr_filename, char *pstr_pathname );
+       LibGoblin_SrcFile *SrcFile_SearchSrcFile(
+                               LibGoblin_BinaryFile *p_bfile, char *pstr_filename, char *pstr_path );
 LIBGOBLIN_SRCFILE_EXTERN
-       LibGoblin_SrcFile *SrcFile_DispenseSrcFile( LibGoblin_BinaryFile *p_bfile, char *pstr_filename );
+       LibGoblin_SrcFile *SrcFile_DispenseSrcFile(
+                               LibGoblin_BinaryFile *p_bfile, char *pstr_filename, char *pstr_path );
 LIBGOBLIN_SRCFILE_EXTERN
        int SrcFile_FreeSrcFile( LibGoblin_BinaryFile *p_bfile, LibGoblin_SrcFile *p_srcfile );
 LIBGOBLIN_SRCFILE_EXTERN
index b33f198..0a775dc 100644 (file)
@@ -225,7 +225,7 @@ typedef struct      {
        char    str_filename[DRD64_MAX_PATH];
        char    str_localpath[DRD64_MAX_PATH];
        char    str_srcpath[DRD64_MAX_PATH];    // for DW_AT_name
-       char    str_buildpath[DRD64_MAX_PATH];  // for DW_AT_comp_dir (Optional)
+       //char  str_buildpath[DRD64_MAX_PATH];  // for DW_AT_comp_dir (Optional)
 
        int             i_bfile_id;
        struct  {
@@ -344,7 +344,6 @@ typedef struct      {
 #define        LIBGOBLIN_DWARF_ATTR_EXT_MAX    53
 #define        LIBGOBLIN_DWARF_ATTR_MAX                (LIBGOBLIN_DWARF_ATTR_DEF_MAX + LIBGOBLIN_DWARF_ATTR_EXT_MAX)
 
-
 typedef struct {
        /* BinaryInfo Struct ID */
        int                     i_id;
index ffb58d8..6ac3d5b 100644 (file)
@@ -39,6 +39,15 @@ Comment:
 
 
 /*=====================================================================*/
+#define        DWARF_RANGES_MAX        32
+
+typedef        struct  {
+       int             i_ranges;
+       Ptr             ptr_low[DWARF_RANGES_MAX];
+       Ptr             ptr_high[DWARF_RANGES_MAX];
+} LibGoblin_DWARF_Ranges;
+
+/*=====================================================================*/
 #define        DWARF_ANCESTRY_MAX      64
 
 typedef        struct  {
index 1a513be..735ddf6 100644 (file)
@@ -40,13 +40,129 @@ Comment:
 
 
 /* SrcFile_DispenseSrcFile() & FreeSrcFile() *****************/
-/*--------------------------------------------------------------------*/
 typedef        struct  {
        char    str_filename[128];
+       char    str_path[128];
        DWord   dw_hash;
 } SrcFile_TestData;
 
-void Test_SrcFile_DispenseFree_test00_003( void )
+/*--------------------------------------------------------------------*/
+void Test_SrcFile_DispenseFree_test00_002( void )
+{
+       int             i_cnt;
+       int             i_filelen;
+       int             i_dir;
+       int             i_char;
+       int             i_depth;
+       int             i_pos;
+       int             i_result;
+       LibGoblin_BinaryFile    *p_bfile;
+       LibGoblin_SrcFile       *p_srcfile;
+       SrcFile_TestData        *p_test;
+       SrcFile_TestData        *p_now;
+
+       // Generate TestData ----
+       p_test  = (SrcFile_TestData *)malloc( sizeof( SrcFile_TestData ) * 500 );
+       CU_ASSERT( NULL != p_test );
+
+       memset( p_test, 0x00, ( sizeof( SrcFile_TestData ) * 500 ) );
+
+       i_filelen       = 3;
+       i_depth         = 1;
+       p_now   = p_test;
+       for( i_cnt = 0; i_cnt < 500; i_cnt++, p_now++ ) {
+               // Generate Filename ---
+               for( i_pos = 0; i_pos < i_filelen; i_pos++ )    {
+                       p_now->str_filename[i_pos]      = 'a' + (random() % 26);
+               }
+               p_now->str_filename[i_pos + 0]  = '.';
+               p_now->str_filename[i_pos + 1]  = 'c';
+               p_now->str_filename[i_pos + 2]  = '\0';
+
+               i_filelen++;
+               if( 100 == i_filelen )  { i_filelen = 3; }
+
+               p_now->dw_hash  = Common_CalcDJBhash( p_now->str_filename);
+
+               // Generate Dirname ---
+               i_pos   = 0;
+               for( i_dir = 0; i_dir < i_depth; i_dir++ )      {
+                       p_now->str_path[i_pos++]        = '/';
+                       for( i_char = 0; i_char < 8; i_char++, i_pos++ )        {
+                               p_now->str_path[i_pos]  = 'a' + (random() % 26);
+                       }
+               }
+
+               i_depth++;
+               if( 8 == i_depth )      { i_depth = 1; }
+       }
+
+       // Testing ---
+       i_result        = LibBrownie_Init();
+       CU_ASSERT( 0x00 == i_result );
+
+       i_result        = BinaryFile_Init();
+       CU_ASSERT( 0x00 == i_result );
+       
+       p_bfile         = BinaryFile_AllocBinaryFile();
+       CU_ASSERT( NULL != p_bfile );
+
+
+       i_result        = SrcFile_Init( p_bfile );
+       CU_ASSERT( 0x00 == i_result );
+
+       p_now   = p_test;
+       for( i_cnt = 0; i_cnt < 500; i_cnt++, p_now++ ) {
+               p_srcfile       = SrcFile_DispenseSrcFile( p_bfile, p_now->str_filename, NULL );
+               CU_ASSERT( NULL != p_srcfile );
+               CU_ASSERT( 0 == strcmp( p_now->str_filename, p_srcfile->str_filename) );
+               CU_ASSERT( '\0' == p_srcfile->str_srcpath[0] );
+       }
+
+       p_now   = p_test;
+       for( i_cnt = 0; i_cnt < 500; i_cnt++, p_now++ ) {
+               p_srcfile       = SrcFile_DispenseSrcFile( p_bfile, p_now->str_filename, p_now->str_path );
+               CU_ASSERT( NULL != p_srcfile );
+               CU_ASSERT( i_cnt == p_srcfile->i_id );
+               CU_ASSERT( p_now->dw_hash == p_srcfile->dw_hash_filename );
+               CU_ASSERT( 0 == strcmp( p_now->str_filename, p_srcfile->str_filename) );
+               CU_ASSERT( 0 == strcmp( p_now->str_path, p_srcfile->str_srcpath ) );
+       }
+
+       p_now   = p_test;
+       for( i_cnt = 0; i_cnt < 500; i_cnt++, p_now++ ) {
+               p_srcfile       = SrcFile_GetSrcFile( p_bfile, i_cnt );
+               CU_ASSERT( NULL != p_srcfile );
+               CU_ASSERT( i_cnt == p_srcfile->i_id );
+               CU_ASSERT( p_now->dw_hash == p_srcfile->dw_hash_filename );
+       }
+
+       for( i_cnt = 500; i_cnt > 0; i_cnt-- )  {
+               p_srcfile       = SrcFile_GetSrcFile( p_bfile, i_cnt - 1 );
+               SrcFile_FreeSrcFile( p_bfile, p_srcfile );
+               CU_ASSERT( -0x01 == p_srcfile->i_id );
+       }
+       
+       i_result        = SrcFile_Term( p_bfile );
+       CU_ASSERT( 0x00 == i_result );
+
+
+       i_result        = BinaryFile_FreeBinaryFile( p_bfile );
+       CU_ASSERT( 0x00 == i_result );
+
+       i_result        = BinaryFile_Term();
+       CU_ASSERT( 0x00 == i_result );
+
+       LibBrownie_Term();
+
+       free( p_test );
+
+       return;
+}
+
+
+/*--------------------------------------------------------------------*/
+void Test_SrcFile_DispenseFree_test00_001( void )
 {
        int             i_cnt;
        int             i_len;
@@ -95,7 +211,7 @@ void Test_SrcFile_DispenseFree_test00_003( void )
 
        p_now   = p_test;
        for( i_cnt = 0; i_cnt < 500; i_cnt++, p_now++ ) {
-               p_srcfile       = SrcFile_DispenseSrcFile( p_bfile, p_now->str_filename );
+               p_srcfile       = SrcFile_DispenseSrcFile( p_bfile, p_now->str_filename, NULL );
                CU_ASSERT( NULL != p_srcfile );
        }
 
@@ -125,11 +241,13 @@ void Test_SrcFile_DispenseFree_test00_003( void )
 
        LibBrownie_Term();
 
+       free( p_test );
+
        return;
 }
 
 
-/* SrcFile_AllocSrcFile() & FreeSrcFile() *****************/
+/* SrcFile_AllocSrcFile() & FreeSrcFile() *****************************/
 /*--------------------------------------------------------------------*/
 void Test_SrcFile_AllocFree_test00_002( void )
 {
@@ -201,7 +319,6 @@ void Test_SrcFile_AllocFree_test00_002( void )
 }
 
 
-/* EOF of drd64_.c ----------------------------------- */
 /*--------------------------------------------------------------------*/
 void Test_SrcFile_AllocFree_test00_001( void )
 {
@@ -295,10 +412,12 @@ int
                                                                 Test_SrcFile_InitTerm_test00_001 );
        CU_add_test( pt_goblin, "SrcFile_AllocFree_test00_001",
                                                                 Test_SrcFile_AllocFree_test00_001 );
-       CU_add_test( pt_goblin, "SrcFile_AllocFree_test00_001",
+       CU_add_test( pt_goblin, "SrcFile_AllocFree_test00_002",
                                                                 Test_SrcFile_AllocFree_test00_002 );
        CU_add_test( pt_goblin, "SrcFile_DispenseFree_test00_001",
-                                                                Test_SrcFile_DispenseFree_test00_003 );
+                                                                Test_SrcFile_DispenseFree_test00_001 );
+       CU_add_test( pt_goblin, "SrcFile_DispenseFree_test00_002",
+                                                                Test_SrcFile_DispenseFree_test00_002 );
 
        return 0x00;
 }