OSDN Git Service

(LibGoblin)
[drdeamon64/drdeamon64.git] / libgoblin / drd64_libgoblin_debug_dwarf_str.c
1 /*DrDeAmOn64DrDeAmOn64DrDeAmOn64DrDeAmOn64DrDeAmOn64DrDeAmOn64DrDeAmOn64
2
3                          D r . D e a m o n  6 4
4                         for INTEL64(R), AMD64(R)
5         
6    Copyright(C) 2007-2009 Koine Yuusuke(koinec). All rights reserved.
7
8 Redistribution and use in source and binary forms, with or without
9 modification, are permitted provided that the following conditions are met:
10
11  1. Redistributions of source code must retain the above copyright notice,
12     this list of conditions and the following disclaimer.
13  2. Redistributions in binary form must reproduce the above copyright
14     notice, this list of conditions and the following disclaimer in the
15     documentation and/or other materials provided with the distribution.
16
17 THIS SOFTWARE IS PROVIDED BY Koine Yuusuke(koinec) ``AS IS'' AND ANY
18 EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
19 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
20 DISCLAIMED. IN NO EVENT SHALL Koine Yuusuke(koinec) OR CONTRIBUTORS BE
21 LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
22 CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23 SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24 INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
25 CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
27 OF THE POSSIBILITY OF SUCH DAMAGE.
28
29 DrDeAmOn64DrDeAmOn64DrDeAmOn64DrDeAmOn64DrDeAmOn64DrDeAmOn64DrDeAmOn64*/
30
31 /* File Info -----------------------------------------------------------
32 File: drd64_.c
33 Function: 
34 Comment: 
35 ----------------------------------------------------------------------*/
36
37 #define DRD64_SRC_LIBGOBLIN_DEBUG_DWARF_STR
38 #include"drd64_libgoblin.h"
39
40
41 /*----------------------------------------------------------------------
42 ----------------------------------------------------------------------*/
43 LIBGOBLIN_DEBUG_DWARF_STR_EXTERN
44 char *
45         Debug_DWARF_GetTAGname(
46                         DWord   dw_tag )
47 {
48         int             i_cnt;
49         char    *pstr_name      = NULL;
50
51         if( DEBUG_DWARF_STR_TAG_MAX >= dw_tag ) {
52                 pstr_name       = gpstr_dwarf_tag_name[ dw_tag ];
53                 goto    goto_Debug_DWARF_GetTAGname_post;
54         }
55
56         for( i_cnt = 0; i_cnt < DEBUG_DWARF_STR_TAG_EXT_MAX; i_cnt++ )  {
57                 if( dw_tag == gt_dwarf_str_tag_ext[ i_cnt ].dw_tag )    {
58                         pstr_name       = gt_dwarf_str_tag_ext[ i_cnt ].pstr_tagname;
59                         break;
60                 }
61         }
62
63         if( NULL == pstr_name ) {
64                 snprintf( gstr_dwarf_tag, sizeof( gstr_dwarf_tag ), "none_TAG: 0x%02x", dw_tag );
65                 pstr_name       = gstr_dwarf_tag;
66         }
67
68 goto_Debug_DWARF_GetTAGname_post:
69         return pstr_name;
70 }
71
72
73 /*----------------------------------------------------------------------
74 ----------------------------------------------------------------------*/
75 LIBGOBLIN_DEBUG_DWARF_STR_EXTERN
76 char *
77         Debug_DWARF_GetAttributeName(
78                         DWord   dw_attr )
79 {
80         int             i_cnt;
81         char    *pstr_name      = NULL;
82
83         if( LIBGOBLIN_DWARF_ATTR_DEF_MAX >= dw_attr )   {
84                 pstr_name       = gpstr_dwarf_attribute_name[ dw_attr ];
85                 goto    goto_Debug_DWARF_GetAttributeName_post;
86         }
87
88         for( i_cnt = 0; i_cnt < LIBGOBLIN_DWARF_ATTR_EXT_MAX; i_cnt++ ) {
89                 if( dw_attr == gt_dwarf_str_at_ext[ i_cnt ].dw_at )     {
90                         pstr_name       = gt_dwarf_str_at_ext[ i_cnt ].pstr_atname;
91                         break;
92                 }
93         }
94
95         if( NULL == pstr_name ) {
96                 snprintf( gstr_dwarf_attribute, sizeof( gstr_dwarf_attribute ), "none_AT: 0x%02x", dw_attr );
97                 pstr_name       = gstr_dwarf_attribute;
98         }
99
100 goto_Debug_DWARF_GetAttributeName_post:
101         return pstr_name;
102 }
103
104
105 /*----------------------------------------------------------------------
106 ----------------------------------------------------------------------*/
107 LIBGOBLIN_DEBUG_DWARF_STR_EXTERN
108 char *
109         Debug_DWARF_GetFormName(
110                         DWord   dw_form )
111 {
112         char    *pstr_name      = NULL;
113
114         if( DEBUG_DWARF_STR_FORM_MAX >= dw_form )       {
115                 pstr_name       = gpstr_dwarf_form_name[ dw_form ];
116                 goto    goto_Debug_DWARF_GetFormName_post;
117         }
118
119         switch( dw_form )       {
120         case DW_FORM_GNU_ref_alt:       // 0x1f20
121                         pstr_name       = "DW_FORM_GNU_ref_alt";
122                         break;
123                 case DW_FORM_GNU_strp_alt:      // 0x1f21
124                         pstr_name       = "DW_FORM_GNU_strp_alt";
125                         break;
126                 default:
127                         snprintf( gstr_dwarf_form, sizeof( gstr_dwarf_form ), "none_FORM: 0x%02x", dw_form );
128                         pstr_name       = gstr_dwarf_form;
129                         break;
130         }
131
132 goto_Debug_DWARF_GetFormName_post:
133         return pstr_name;
134 }
135
136
137 /* EOF of drd64_.c ----------------------------------- */