OSDN Git Service

(LibGoblin)
authorKoine Yuusuke(koinec) <koinec@users.osdn.me>
Tue, 15 Oct 2019 13:25:49 +0000 (22:25 +0900)
committerKoine Yuusuke(koinec) <koinec@users.osdn.me>
Tue, 15 Oct 2019 13:25:49 +0000 (22:25 +0900)
  * WorkBackup (with BUG: ObjectInfo_InsetObjectInfo() func. )

libgoblin/drd64_libgoblin_dwarf_tag_function.c
libgoblin/drd64_libgoblin_objinfo.c
libgoblin/drd64_libgoblin_type.h

index 3d33d63..584e35e 100644 (file)
@@ -112,7 +112,7 @@ int
        LibGoblin_BinaryFile            *p_bfile;
        LibGoblin_ProgramInfo           *p_pginfo;
        LibGoblin_ObjectInfo            *pobj_parent;
-       LibGoblin_ObjectInfo            *p_obj;
+       LibGoblin_ObjectInfo            *pobj_now;
 
        LibGoblin_DWARF_Ranges          t_ranges;
        LibGoblin_DWARF_DIEValue        *pval_name;
@@ -199,43 +199,33 @@ int
                t_ranges.ptr_high[0].value      = (PtrValue)pobj_parent->addr.ptr_addr.value;
        }
        
-       
-/*
-       p_bfile = BinaryFile_GetBinaryFile( p_binfo->i_binfile );
-       assert( NULL != p_bfile );
-
-       // (Phase1) Data Extract from .debug_info ===============================
 
-       // 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 );
-       
-
-       // Data Extract (stmt_list)---
-       pval_linestmt   = DWARF_AttrForm_GetDIEValue( p_binfo, DW_AT_stmt_list );
-       if( NULL == pval_linestmt )
-               { goto  goto_DWARF_Tag_CompileUnit_compile_unit_post; }
-
-
-       // (Phase2) Regist SrcFile from .dwarf_line ===================================
-       SrcFile_ClearSrcFileTable_inBinaryInfo( p_binfo );
+       for( i_cnt = 0; i_cnt < t_ranges.i_ranges; i_cnt++ )    {
+               pobj_now        = 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 | OBJINFO_INSETMODE_CHKNAME,
+                                               OBJINFO_TYPE_FUNCTION, pval_name->value.pstr_value );
 
-       p_srcfile       = SrcFile_DispenseSrcFile( p_bfile, pstr_filename, pstr_path);
-       if( NULL == p_srcfile ) {
-               goto    goto_DWARF_Tag_CompileUnit_compile_unit_post;
-       }
+               //p_obj->pstr_name      = pval_name->value.pstr_value;
+               //p_obj->dw_hash                = Common_CalcDJBhash( pval_name->value.pstr_value );
 
-       i_result        = SrcFile_RegistSrcFileTable_inBinaryInfo( p_binfo, p_srcfile );
-       if( 0x00 != i_result )  {
-               goto    goto_DWARF_Tag_CompileUnit_compile_unit_post;
-       }
+               // XXX: TODO(2019/10/15) Backup & Restore  elf-symbol info.
 
-       dw_lineoffset   = pval_linestmt->value.dw_value;
-       i_result                = DWARF_Line_ReadSrcFile( p_binfo, dw_lineoffset );
-       if( 0x00 != i_result )  {
-               goto    goto_DWARF_Tag_CompileUnit_compile_unit_post;
+               if( 0 == i_cnt )        {
+                       pobj_parent     = pobj_now;
+                       //pobj_now->info.function.i_objid_parent        = NO_OBJ;
+               }
+               else    {
+                       //pobj_now->info.function.i_objid_parent        = p_obj_parent->i_id;
+               }
+               //p_obj->i_srcid        = p_srcfile->i_id;
        }
+       
+/*
+       p_bfile = BinaryFile_GetBinaryFile( p_binfo->i_binfile );
+       assert( NULL != p_bfile );
 
 
        // (Phase3) Regist ObjInfo as ObjFile =========================================
index 831c26a..078d5bf 100644 (file)
@@ -398,12 +398,14 @@ LibGoblin_ObjectInfo *
                }
 
                if( ptr_value == p_objnow->addr.ptr_addr.value )        {
+//printf("DEBUG: %s (%x) : size= %lxh, obj= %lxh (%s)\n", pstr_name, dw_hash, qw_size, p_objnow->addr.qw_size, p_objnow->pstr_name );
                        if( qw_size > p_objnow->addr.qw_size )
                                { break; }
                        else if( qw_size < p_objnow->addr.qw_size )     {
                                if( b_type < p_objnow->b_type )         { break; }
                        }
                        else    {       // qw_size == p_objnow->addr.qw_size
+//printf("DEBUG: %s (%x) <=> %s (%x) is chkmode.\n", pstr_name, dw_hash, p_objnow->pstr_name, p_objnow->dw_hash );
                                if( b_type < p_objnow->b_type )         { break; }
 
                                if( OBJINFO_INSETMODE_CHKNAME & b_mode )        {
index 3564566..e2ef0fd 100644 (file)
@@ -206,6 +206,11 @@ typedef    struct  {
                        int             i_objid_type;
                        Byte    *p_dwtype;
                } type;
+
+               struct  {
+                       int             i_objid_parent;
+
+               } function;
        } info;
 
        struct  {