1*a9fa9459Szrj /* debug.h -- Describe generic debugging information. 2*a9fa9459Szrj Copyright (C) 1995-2016 Free Software Foundation, Inc. 3*a9fa9459Szrj Written by Ian Lance Taylor <ian@cygnus.com>. 4*a9fa9459Szrj 5*a9fa9459Szrj This file is part of GNU Binutils. 6*a9fa9459Szrj 7*a9fa9459Szrj This program is free software; you can redistribute it and/or modify 8*a9fa9459Szrj it under the terms of the GNU General Public License as published by 9*a9fa9459Szrj the Free Software Foundation; either version 3 of the License, or 10*a9fa9459Szrj (at your option) any later version. 11*a9fa9459Szrj 12*a9fa9459Szrj This program is distributed in the hope that it will be useful, 13*a9fa9459Szrj but WITHOUT ANY WARRANTY; without even the implied warranty of 14*a9fa9459Szrj MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15*a9fa9459Szrj GNU General Public License for more details. 16*a9fa9459Szrj 17*a9fa9459Szrj You should have received a copy of the GNU General Public License 18*a9fa9459Szrj along with this program; if not, write to the Free Software 19*a9fa9459Szrj Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 20*a9fa9459Szrj 02110-1301, USA. */ 21*a9fa9459Szrj 22*a9fa9459Szrj #ifndef DEBUG_H 23*a9fa9459Szrj #define DEBUG_H 24*a9fa9459Szrj 25*a9fa9459Szrj /* This header file describes a generic debugging information format. 26*a9fa9459Szrj We may eventually have readers which convert different formats into 27*a9fa9459Szrj this generic format, and writers which write it out. The initial 28*a9fa9459Szrj impetus for this was writing a converter from stabs to HP IEEE-695 29*a9fa9459Szrj debugging format. */ 30*a9fa9459Szrj 31*a9fa9459Szrj /* Different kinds of types. */ 32*a9fa9459Szrj 33*a9fa9459Szrj enum debug_type_kind 34*a9fa9459Szrj { 35*a9fa9459Szrj /* Not used. */ 36*a9fa9459Szrj DEBUG_KIND_ILLEGAL, 37*a9fa9459Szrj /* Indirect via a pointer. */ 38*a9fa9459Szrj DEBUG_KIND_INDIRECT, 39*a9fa9459Szrj /* Void. */ 40*a9fa9459Szrj DEBUG_KIND_VOID, 41*a9fa9459Szrj /* Integer. */ 42*a9fa9459Szrj DEBUG_KIND_INT, 43*a9fa9459Szrj /* Floating point. */ 44*a9fa9459Szrj DEBUG_KIND_FLOAT, 45*a9fa9459Szrj /* Complex. */ 46*a9fa9459Szrj DEBUG_KIND_COMPLEX, 47*a9fa9459Szrj /* Boolean. */ 48*a9fa9459Szrj DEBUG_KIND_BOOL, 49*a9fa9459Szrj /* Struct. */ 50*a9fa9459Szrj DEBUG_KIND_STRUCT, 51*a9fa9459Szrj /* Union. */ 52*a9fa9459Szrj DEBUG_KIND_UNION, 53*a9fa9459Szrj /* Class. */ 54*a9fa9459Szrj DEBUG_KIND_CLASS, 55*a9fa9459Szrj /* Union class (can this really happen?). */ 56*a9fa9459Szrj DEBUG_KIND_UNION_CLASS, 57*a9fa9459Szrj /* Enumeration type. */ 58*a9fa9459Szrj DEBUG_KIND_ENUM, 59*a9fa9459Szrj /* Pointer. */ 60*a9fa9459Szrj DEBUG_KIND_POINTER, 61*a9fa9459Szrj /* Function. */ 62*a9fa9459Szrj DEBUG_KIND_FUNCTION, 63*a9fa9459Szrj /* Reference. */ 64*a9fa9459Szrj DEBUG_KIND_REFERENCE, 65*a9fa9459Szrj /* Range. */ 66*a9fa9459Szrj DEBUG_KIND_RANGE, 67*a9fa9459Szrj /* Array. */ 68*a9fa9459Szrj DEBUG_KIND_ARRAY, 69*a9fa9459Szrj /* Set. */ 70*a9fa9459Szrj DEBUG_KIND_SET, 71*a9fa9459Szrj /* Based pointer. */ 72*a9fa9459Szrj DEBUG_KIND_OFFSET, 73*a9fa9459Szrj /* Method. */ 74*a9fa9459Szrj DEBUG_KIND_METHOD, 75*a9fa9459Szrj /* Const qualified type. */ 76*a9fa9459Szrj DEBUG_KIND_CONST, 77*a9fa9459Szrj /* Volatile qualified type. */ 78*a9fa9459Szrj DEBUG_KIND_VOLATILE, 79*a9fa9459Szrj /* Named type. */ 80*a9fa9459Szrj DEBUG_KIND_NAMED, 81*a9fa9459Szrj /* Tagged type. */ 82*a9fa9459Szrj DEBUG_KIND_TAGGED 83*a9fa9459Szrj }; 84*a9fa9459Szrj 85*a9fa9459Szrj /* Different kinds of variables. */ 86*a9fa9459Szrj 87*a9fa9459Szrj enum debug_var_kind 88*a9fa9459Szrj { 89*a9fa9459Szrj /* Not used. */ 90*a9fa9459Szrj DEBUG_VAR_ILLEGAL, 91*a9fa9459Szrj /* A global variable. */ 92*a9fa9459Szrj DEBUG_GLOBAL, 93*a9fa9459Szrj /* A static variable. */ 94*a9fa9459Szrj DEBUG_STATIC, 95*a9fa9459Szrj /* A local static variable. */ 96*a9fa9459Szrj DEBUG_LOCAL_STATIC, 97*a9fa9459Szrj /* A local variable. */ 98*a9fa9459Szrj DEBUG_LOCAL, 99*a9fa9459Szrj /* A register variable. */ 100*a9fa9459Szrj DEBUG_REGISTER 101*a9fa9459Szrj }; 102*a9fa9459Szrj 103*a9fa9459Szrj /* Different kinds of function parameters. */ 104*a9fa9459Szrj 105*a9fa9459Szrj enum debug_parm_kind 106*a9fa9459Szrj { 107*a9fa9459Szrj /* Not used. */ 108*a9fa9459Szrj DEBUG_PARM_ILLEGAL, 109*a9fa9459Szrj /* A stack based parameter. */ 110*a9fa9459Szrj DEBUG_PARM_STACK, 111*a9fa9459Szrj /* A register parameter. */ 112*a9fa9459Szrj DEBUG_PARM_REG, 113*a9fa9459Szrj /* A stack based reference parameter. */ 114*a9fa9459Szrj DEBUG_PARM_REFERENCE, 115*a9fa9459Szrj /* A register reference parameter. */ 116*a9fa9459Szrj DEBUG_PARM_REF_REG 117*a9fa9459Szrj }; 118*a9fa9459Szrj 119*a9fa9459Szrj /* Different kinds of visibility. */ 120*a9fa9459Szrj 121*a9fa9459Szrj enum debug_visibility 122*a9fa9459Szrj { 123*a9fa9459Szrj /* A public field (e.g., a field in a C struct). */ 124*a9fa9459Szrj DEBUG_VISIBILITY_PUBLIC, 125*a9fa9459Szrj /* A protected field. */ 126*a9fa9459Szrj DEBUG_VISIBILITY_PROTECTED, 127*a9fa9459Szrj /* A private field. */ 128*a9fa9459Szrj DEBUG_VISIBILITY_PRIVATE, 129*a9fa9459Szrj /* A field which should be ignored. */ 130*a9fa9459Szrj DEBUG_VISIBILITY_IGNORE 131*a9fa9459Szrj }; 132*a9fa9459Szrj 133*a9fa9459Szrj /* A type. */ 134*a9fa9459Szrj 135*a9fa9459Szrj typedef struct debug_type_s *debug_type; 136*a9fa9459Szrj 137*a9fa9459Szrj #define DEBUG_TYPE_NULL ((debug_type) NULL) 138*a9fa9459Szrj 139*a9fa9459Szrj /* A field in a struct or union. */ 140*a9fa9459Szrj 141*a9fa9459Szrj typedef struct debug_field_s *debug_field; 142*a9fa9459Szrj 143*a9fa9459Szrj #define DEBUG_FIELD_NULL ((debug_field) NULL) 144*a9fa9459Szrj 145*a9fa9459Szrj /* A base class for an object. */ 146*a9fa9459Szrj 147*a9fa9459Szrj typedef struct debug_baseclass_s *debug_baseclass; 148*a9fa9459Szrj 149*a9fa9459Szrj #define DEBUG_BASECLASS_NULL ((debug_baseclass) NULL) 150*a9fa9459Szrj 151*a9fa9459Szrj /* A method of an object. */ 152*a9fa9459Szrj 153*a9fa9459Szrj typedef struct debug_method_s *debug_method; 154*a9fa9459Szrj 155*a9fa9459Szrj #define DEBUG_METHOD_NULL ((debug_method) NULL) 156*a9fa9459Szrj 157*a9fa9459Szrj /* The arguments to a method function of an object. These indicate 158*a9fa9459Szrj which method to run. */ 159*a9fa9459Szrj 160*a9fa9459Szrj typedef struct debug_method_variant_s *debug_method_variant; 161*a9fa9459Szrj 162*a9fa9459Szrj #define DEBUG_METHOD_VARIANT_NULL ((debug_method_variant) NULL) 163*a9fa9459Szrj 164*a9fa9459Szrj /* This structure is passed to debug_write. It holds function 165*a9fa9459Szrj pointers that debug_write will call based on the accumulated 166*a9fa9459Szrj debugging information. */ 167*a9fa9459Szrj 168*a9fa9459Szrj struct debug_write_fns 169*a9fa9459Szrj { 170*a9fa9459Szrj /* This is called at the start of each new compilation unit with the 171*a9fa9459Szrj name of the main file in the new unit. */ 172*a9fa9459Szrj bfd_boolean (*start_compilation_unit) (void *, const char *); 173*a9fa9459Szrj 174*a9fa9459Szrj /* This is called at the start of each source file within a 175*a9fa9459Szrj compilation unit, before outputting any global information for 176*a9fa9459Szrj that file. The argument is the name of the file. */ 177*a9fa9459Szrj bfd_boolean (*start_source) (void *, const char *); 178*a9fa9459Szrj 179*a9fa9459Szrj /* Each writer must keep a stack of types. */ 180*a9fa9459Szrj 181*a9fa9459Szrj /* Push an empty type onto the type stack. This type can appear if 182*a9fa9459Szrj there is a reference to a type which is never defined. */ 183*a9fa9459Szrj bfd_boolean (*empty_type) (void *); 184*a9fa9459Szrj 185*a9fa9459Szrj /* Push a void type onto the type stack. */ 186*a9fa9459Szrj bfd_boolean (*void_type) (void *); 187*a9fa9459Szrj 188*a9fa9459Szrj /* Push an integer type onto the type stack, given the size and 189*a9fa9459Szrj whether it is unsigned. */ 190*a9fa9459Szrj bfd_boolean (*int_type) (void *, unsigned int, bfd_boolean); 191*a9fa9459Szrj 192*a9fa9459Szrj /* Push a floating type onto the type stack, given the size. */ 193*a9fa9459Szrj bfd_boolean (*float_type) (void *, unsigned int); 194*a9fa9459Szrj 195*a9fa9459Szrj /* Push a complex type onto the type stack, given the size. */ 196*a9fa9459Szrj bfd_boolean (*complex_type) (void *, unsigned int); 197*a9fa9459Szrj 198*a9fa9459Szrj /* Push a bfd_boolean type onto the type stack, given the size. */ 199*a9fa9459Szrj bfd_boolean (*bool_type) (void *, unsigned int); 200*a9fa9459Szrj 201*a9fa9459Szrj /* Push an enum type onto the type stack, given the tag, a NULL 202*a9fa9459Szrj terminated array of names and the associated values. If there is 203*a9fa9459Szrj no tag, the tag argument will be NULL. If this is an undefined 204*a9fa9459Szrj enum, the names and values arguments will be NULL. */ 205*a9fa9459Szrj bfd_boolean (*enum_type) 206*a9fa9459Szrj (void *, const char *, const char **, bfd_signed_vma *); 207*a9fa9459Szrj 208*a9fa9459Szrj /* Pop the top type on the type stack, and push a pointer to that 209*a9fa9459Szrj type onto the type stack. */ 210*a9fa9459Szrj bfd_boolean (*pointer_type) (void *); 211*a9fa9459Szrj 212*a9fa9459Szrj /* Push a function type onto the type stack. The second argument 213*a9fa9459Szrj indicates the number of argument types that have been pushed onto 214*a9fa9459Szrj the stack. If the number of argument types is passed as -1, then 215*a9fa9459Szrj the argument types of the function are unknown, and no types have 216*a9fa9459Szrj been pushed onto the stack. The third argument is TRUE if the 217*a9fa9459Szrj function takes a variable number of arguments. The return type 218*a9fa9459Szrj of the function is pushed onto the type stack below the argument 219*a9fa9459Szrj types, if any. */ 220*a9fa9459Szrj bfd_boolean (*function_type) (void *, int, bfd_boolean); 221*a9fa9459Szrj 222*a9fa9459Szrj /* Pop the top type on the type stack, and push a reference to that 223*a9fa9459Szrj type onto the type stack. */ 224*a9fa9459Szrj bfd_boolean (*reference_type) (void *); 225*a9fa9459Szrj 226*a9fa9459Szrj /* Pop the top type on the type stack, and push a range of that type 227*a9fa9459Szrj with the given lower and upper bounds onto the type stack. */ 228*a9fa9459Szrj bfd_boolean (*range_type) (void *, bfd_signed_vma, bfd_signed_vma); 229*a9fa9459Szrj 230*a9fa9459Szrj /* Push an array type onto the type stack. The top type on the type 231*a9fa9459Szrj stack is the range, and the next type on the type stack is the 232*a9fa9459Szrj element type. These should be popped before the array type is 233*a9fa9459Szrj pushed. The arguments are the lower bound, the upper bound, and 234*a9fa9459Szrj whether the array is a string. */ 235*a9fa9459Szrj bfd_boolean (*array_type) 236*a9fa9459Szrj (void *, bfd_signed_vma, bfd_signed_vma, bfd_boolean); 237*a9fa9459Szrj 238*a9fa9459Szrj /* Pop the top type on the type stack, and push a set of that type 239*a9fa9459Szrj onto the type stack. The argument indicates whether this set is 240*a9fa9459Szrj a bitstring. */ 241*a9fa9459Szrj bfd_boolean (*set_type) (void *, bfd_boolean); 242*a9fa9459Szrj 243*a9fa9459Szrj /* Push an offset type onto the type stack. The top type on the 244*a9fa9459Szrj type stack is the target type, and the next type on the type 245*a9fa9459Szrj stack is the base type. These should be popped before the offset 246*a9fa9459Szrj type is pushed. */ 247*a9fa9459Szrj bfd_boolean (*offset_type) (void *); 248*a9fa9459Szrj 249*a9fa9459Szrj /* Push a method type onto the type stack. If the second argument 250*a9fa9459Szrj is TRUE, the top type on the stack is the class to which the 251*a9fa9459Szrj method belongs; otherwise, the class must be determined by the 252*a9fa9459Szrj class to which the method is attached. The third argument is the 253*a9fa9459Szrj number of argument types; these are pushed onto the type stack in 254*a9fa9459Szrj reverse order (the first type popped is the last argument to the 255*a9fa9459Szrj method). A value of -1 for the third argument means that no 256*a9fa9459Szrj argument information is available. The fourth argument is TRUE 257*a9fa9459Szrj if the function takes a variable number of arguments. The next 258*a9fa9459Szrj type on the type stack below the domain and the argument types is 259*a9fa9459Szrj the return type of the method. All these types must be popped, 260*a9fa9459Szrj and then the method type must be pushed. */ 261*a9fa9459Szrj bfd_boolean (*method_type) (void *, bfd_boolean, int, bfd_boolean); 262*a9fa9459Szrj 263*a9fa9459Szrj /* Pop the top type off the type stack, and push a const qualified 264*a9fa9459Szrj version of that type onto the type stack. */ 265*a9fa9459Szrj bfd_boolean (*const_type) (void *); 266*a9fa9459Szrj 267*a9fa9459Szrj /* Pop the top type off the type stack, and push a volatile 268*a9fa9459Szrj qualified version of that type onto the type stack. */ 269*a9fa9459Szrj bfd_boolean (*volatile_type) (void *); 270*a9fa9459Szrj 271*a9fa9459Szrj /* Start building a struct. This is followed by calls to the 272*a9fa9459Szrj struct_field function, and finished by a call to the 273*a9fa9459Szrj end_struct_type function. The second argument is the tag; this 274*a9fa9459Szrj will be NULL if there isn't one. If the second argument is NULL, 275*a9fa9459Szrj the third argument is a constant identifying this struct for use 276*a9fa9459Szrj with tag_type. The fourth argument is TRUE for a struct, FALSE 277*a9fa9459Szrj for a union. The fifth argument is the size. If this is an 278*a9fa9459Szrj undefined struct or union, the size will be 0 and struct_field 279*a9fa9459Szrj will not be called before end_struct_type is called. */ 280*a9fa9459Szrj bfd_boolean (*start_struct_type) 281*a9fa9459Szrj (void *, const char *, unsigned int, bfd_boolean, unsigned int); 282*a9fa9459Szrj 283*a9fa9459Szrj /* Add a field to the struct type currently being built. The type 284*a9fa9459Szrj of the field should be popped off the type stack. The arguments 285*a9fa9459Szrj are the name, the bit position, the bit size (may be zero if the 286*a9fa9459Szrj field is not packed), and the visibility. */ 287*a9fa9459Szrj bfd_boolean (*struct_field) 288*a9fa9459Szrj (void *, const char *, bfd_vma, bfd_vma, enum debug_visibility); 289*a9fa9459Szrj 290*a9fa9459Szrj /* Finish building a struct, and push it onto the type stack. */ 291*a9fa9459Szrj bfd_boolean (*end_struct_type) (void *); 292*a9fa9459Szrj 293*a9fa9459Szrj /* Start building a class. This is followed by calls to several 294*a9fa9459Szrj functions: struct_field, class_static_member, class_baseclass, 295*a9fa9459Szrj class_start_method, class_method_variant, 296*a9fa9459Szrj class_static_method_variant, and class_end_method. The class is 297*a9fa9459Szrj finished by a call to end_class_type. The first five arguments 298*a9fa9459Szrj are the same as for start_struct_type. The sixth argument is 299*a9fa9459Szrj TRUE if there is a virtual function table; if there is, the 300*a9fa9459Szrj seventh argument is TRUE if the virtual function table can be 301*a9fa9459Szrj found in the type itself, and is FALSE if the type of the object 302*a9fa9459Szrj holding the virtual function table should be popped from the type 303*a9fa9459Szrj stack. */ 304*a9fa9459Szrj bfd_boolean (*start_class_type) 305*a9fa9459Szrj (void *, const char *, unsigned int, bfd_boolean, unsigned int, 306*a9fa9459Szrj bfd_boolean, bfd_boolean); 307*a9fa9459Szrj 308*a9fa9459Szrj /* Add a static member to the class currently being built. The 309*a9fa9459Szrj arguments are the field name, the physical name, and the 310*a9fa9459Szrj visibility. The type must be popped off the type stack. */ 311*a9fa9459Szrj bfd_boolean (*class_static_member) 312*a9fa9459Szrj (void *, const char *, const char *, enum debug_visibility); 313*a9fa9459Szrj 314*a9fa9459Szrj /* Add a baseclass to the class currently being built. The type of 315*a9fa9459Szrj the baseclass must be popped off the type stack. The arguments 316*a9fa9459Szrj are the bit position, whether the class is virtual, and the 317*a9fa9459Szrj visibility. */ 318*a9fa9459Szrj bfd_boolean (*class_baseclass) 319*a9fa9459Szrj (void *, bfd_vma, bfd_boolean, enum debug_visibility); 320*a9fa9459Szrj 321*a9fa9459Szrj /* Start adding a method to the class currently being built. This 322*a9fa9459Szrj is followed by calls to class_method_variant and 323*a9fa9459Szrj class_static_method_variant to describe different variants of the 324*a9fa9459Szrj method which take different arguments. The method is finished 325*a9fa9459Szrj with a call to class_end_method. The argument is the method 326*a9fa9459Szrj name. */ 327*a9fa9459Szrj bfd_boolean (*class_start_method) (void *, const char *); 328*a9fa9459Szrj 329*a9fa9459Szrj /* Describe a variant to the class method currently being built. 330*a9fa9459Szrj The type of the variant must be popped off the type stack. The 331*a9fa9459Szrj second argument is the physical name of the function. The 332*a9fa9459Szrj following arguments are the visibility, whether the variant is 333*a9fa9459Szrj const, whether the variant is volatile, the offset in the virtual 334*a9fa9459Szrj function table, and whether the context is on the type stack 335*a9fa9459Szrj (below the variant type). */ 336*a9fa9459Szrj bfd_boolean (*class_method_variant) 337*a9fa9459Szrj (void *, const char *, enum debug_visibility, bfd_boolean, 338*a9fa9459Szrj bfd_boolean, bfd_vma, bfd_boolean); 339*a9fa9459Szrj 340*a9fa9459Szrj /* Describe a static variant to the class method currently being 341*a9fa9459Szrj built. The arguments are the same as for class_method_variant, 342*a9fa9459Szrj except that the last two arguments are omitted. The type of the 343*a9fa9459Szrj variant must be popped off the type stack. */ 344*a9fa9459Szrj bfd_boolean (*class_static_method_variant) 345*a9fa9459Szrj (void *, const char *, enum debug_visibility, bfd_boolean, 346*a9fa9459Szrj bfd_boolean); 347*a9fa9459Szrj 348*a9fa9459Szrj /* Finish describing a class method. */ 349*a9fa9459Szrj bfd_boolean (*class_end_method) (void *); 350*a9fa9459Szrj 351*a9fa9459Szrj /* Finish describing a class, and push it onto the type stack. */ 352*a9fa9459Szrj bfd_boolean (*end_class_type) (void *); 353*a9fa9459Szrj 354*a9fa9459Szrj /* Push a type on the stack which was given a name by an earlier 355*a9fa9459Szrj call to typdef. */ 356*a9fa9459Szrj bfd_boolean (*typedef_type) (void *, const char *); 357*a9fa9459Szrj 358*a9fa9459Szrj /* Push a tagged type on the stack which was defined earlier. If 359*a9fa9459Szrj the second argument is not NULL, the type was defined by a call 360*a9fa9459Szrj to tag. If the second argument is NULL, the type was defined by 361*a9fa9459Szrj a call to start_struct_type or start_class_type with a tag of 362*a9fa9459Szrj NULL and the number of the third argument. Either way, the 363*a9fa9459Szrj fourth argument is the tag kind. Note that this may be called 364*a9fa9459Szrj for a struct (class) being defined, in between the call to 365*a9fa9459Szrj start_struct_type (start_class_type) and the call to 366*a9fa9459Szrj end_struct_type (end_class_type). */ 367*a9fa9459Szrj bfd_boolean (*tag_type) 368*a9fa9459Szrj (void *, const char *, unsigned int, enum debug_type_kind); 369*a9fa9459Szrj 370*a9fa9459Szrj /* Pop the type stack, and typedef it to the given name. */ 371*a9fa9459Szrj bfd_boolean (*typdef) (void *, const char *); 372*a9fa9459Szrj 373*a9fa9459Szrj /* Pop the type stack, and declare it as a tagged struct or union or 374*a9fa9459Szrj enum or whatever. The tag passed down here is redundant, since 375*a9fa9459Szrj was also passed when enum_type, start_struct_type, or 376*a9fa9459Szrj start_class_type was called. */ 377*a9fa9459Szrj bfd_boolean (*tag) (void *, const char *); 378*a9fa9459Szrj 379*a9fa9459Szrj /* This is called to record a named integer constant. */ 380*a9fa9459Szrj bfd_boolean (*int_constant) (void *, const char *, bfd_vma); 381*a9fa9459Szrj 382*a9fa9459Szrj /* This is called to record a named floating point constant. */ 383*a9fa9459Szrj bfd_boolean (*float_constant) (void *, const char *, double); 384*a9fa9459Szrj 385*a9fa9459Szrj /* This is called to record a typed integer constant. The type is 386*a9fa9459Szrj popped off the type stack. */ 387*a9fa9459Szrj bfd_boolean (*typed_constant) (void *, const char *, bfd_vma); 388*a9fa9459Szrj 389*a9fa9459Szrj /* This is called to record a variable. The type is popped off the 390*a9fa9459Szrj type stack. */ 391*a9fa9459Szrj bfd_boolean (*variable) 392*a9fa9459Szrj (void *, const char *, enum debug_var_kind, bfd_vma); 393*a9fa9459Szrj 394*a9fa9459Szrj /* Start writing out a function. The return type must be popped off 395*a9fa9459Szrj the stack. The bfd_boolean is TRUE if the function is global. This 396*a9fa9459Szrj is followed by calls to function_parameter, followed by block 397*a9fa9459Szrj information. */ 398*a9fa9459Szrj bfd_boolean (*start_function) (void *, const char *, bfd_boolean); 399*a9fa9459Szrj 400*a9fa9459Szrj /* Record a function parameter for the current function. The type 401*a9fa9459Szrj must be popped off the stack. */ 402*a9fa9459Szrj bfd_boolean (*function_parameter) 403*a9fa9459Szrj (void *, const char *, enum debug_parm_kind, bfd_vma); 404*a9fa9459Szrj 405*a9fa9459Szrj /* Start writing out a block. There is at least one top level block 406*a9fa9459Szrj per function. Blocks may be nested. The argument is the 407*a9fa9459Szrj starting address of the block. */ 408*a9fa9459Szrj bfd_boolean (*start_block) (void *, bfd_vma); 409*a9fa9459Szrj 410*a9fa9459Szrj /* Finish writing out a block. The argument is the ending address 411*a9fa9459Szrj of the block. */ 412*a9fa9459Szrj bfd_boolean (*end_block) (void *, bfd_vma); 413*a9fa9459Szrj 414*a9fa9459Szrj /* Finish writing out a function. */ 415*a9fa9459Szrj bfd_boolean (*end_function) (void *); 416*a9fa9459Szrj 417*a9fa9459Szrj /* Record line number information for the current compilation unit. */ 418*a9fa9459Szrj bfd_boolean (*lineno) (void *, const char *, unsigned long, bfd_vma); 419*a9fa9459Szrj }; 420*a9fa9459Szrj 421*a9fa9459Szrj /* Exported functions. */ 422*a9fa9459Szrj 423*a9fa9459Szrj /* The first argument to most of these functions is a handle. This 424*a9fa9459Szrj handle is returned by the debug_init function. The purpose of the 425*a9fa9459Szrj handle is to permit the debugging routines to not use static 426*a9fa9459Szrj variables, and hence to be reentrant. This would be useful for a 427*a9fa9459Szrj program which wanted to handle two executables simultaneously. */ 428*a9fa9459Szrj 429*a9fa9459Szrj /* Return a debugging handle. */ 430*a9fa9459Szrj 431*a9fa9459Szrj extern void *debug_init (void); 432*a9fa9459Szrj 433*a9fa9459Szrj /* Set the source filename. This implicitly starts a new compilation 434*a9fa9459Szrj unit. */ 435*a9fa9459Szrj 436*a9fa9459Szrj extern bfd_boolean debug_set_filename (void *, const char *); 437*a9fa9459Szrj 438*a9fa9459Szrj /* Change source files to the given file name. This is used for 439*a9fa9459Szrj include files in a single compilation unit. */ 440*a9fa9459Szrj 441*a9fa9459Szrj extern bfd_boolean debug_start_source (void *, const char *); 442*a9fa9459Szrj 443*a9fa9459Szrj /* Record a function definition. This implicitly starts a function 444*a9fa9459Szrj block. The debug_type argument is the type of the return value. 445*a9fa9459Szrj The bfd_boolean indicates whether the function is globally visible. 446*a9fa9459Szrj The bfd_vma is the address of the start of the function. Currently 447*a9fa9459Szrj the parameter types are specified by calls to 448*a9fa9459Szrj debug_record_parameter. */ 449*a9fa9459Szrj 450*a9fa9459Szrj extern bfd_boolean debug_record_function 451*a9fa9459Szrj (void *, const char *, debug_type, bfd_boolean, bfd_vma); 452*a9fa9459Szrj 453*a9fa9459Szrj /* Record a parameter for the current function. */ 454*a9fa9459Szrj 455*a9fa9459Szrj extern bfd_boolean debug_record_parameter 456*a9fa9459Szrj (void *, const char *, debug_type, enum debug_parm_kind, bfd_vma); 457*a9fa9459Szrj 458*a9fa9459Szrj /* End a function definition. The argument is the address where the 459*a9fa9459Szrj function ends. */ 460*a9fa9459Szrj 461*a9fa9459Szrj extern bfd_boolean debug_end_function (void *, bfd_vma); 462*a9fa9459Szrj 463*a9fa9459Szrj /* Start a block in a function. All local information will be 464*a9fa9459Szrj recorded in this block, until the matching call to debug_end_block. 465*a9fa9459Szrj debug_start_block and debug_end_block may be nested. The argument 466*a9fa9459Szrj is the address at which this block starts. */ 467*a9fa9459Szrj 468*a9fa9459Szrj extern bfd_boolean debug_start_block (void *, bfd_vma); 469*a9fa9459Szrj 470*a9fa9459Szrj /* Finish a block in a function. This matches the call to 471*a9fa9459Szrj debug_start_block. The argument is the address at which this block 472*a9fa9459Szrj ends. */ 473*a9fa9459Szrj 474*a9fa9459Szrj extern bfd_boolean debug_end_block (void *, bfd_vma); 475*a9fa9459Szrj 476*a9fa9459Szrj /* Associate a line number in the current source file with a given 477*a9fa9459Szrj address. */ 478*a9fa9459Szrj 479*a9fa9459Szrj extern bfd_boolean debug_record_line (void *, unsigned long, bfd_vma); 480*a9fa9459Szrj 481*a9fa9459Szrj /* Start a named common block. This is a block of variables that may 482*a9fa9459Szrj move in memory. */ 483*a9fa9459Szrj 484*a9fa9459Szrj extern bfd_boolean debug_start_common_block (void *, const char *); 485*a9fa9459Szrj 486*a9fa9459Szrj /* End a named common block. */ 487*a9fa9459Szrj 488*a9fa9459Szrj extern bfd_boolean debug_end_common_block (void *, const char *); 489*a9fa9459Szrj 490*a9fa9459Szrj /* Record a named integer constant. */ 491*a9fa9459Szrj 492*a9fa9459Szrj extern bfd_boolean debug_record_int_const (void *, const char *, bfd_vma); 493*a9fa9459Szrj 494*a9fa9459Szrj /* Record a named floating point constant. */ 495*a9fa9459Szrj 496*a9fa9459Szrj extern bfd_boolean debug_record_float_const (void *, const char *, double); 497*a9fa9459Szrj 498*a9fa9459Szrj /* Record a typed constant with an integral value. */ 499*a9fa9459Szrj 500*a9fa9459Szrj extern bfd_boolean debug_record_typed_const 501*a9fa9459Szrj (void *, const char *, debug_type, bfd_vma); 502*a9fa9459Szrj 503*a9fa9459Szrj /* Record a label. */ 504*a9fa9459Szrj 505*a9fa9459Szrj extern bfd_boolean debug_record_label 506*a9fa9459Szrj (void *, const char *, debug_type, bfd_vma); 507*a9fa9459Szrj 508*a9fa9459Szrj /* Record a variable. */ 509*a9fa9459Szrj 510*a9fa9459Szrj extern bfd_boolean debug_record_variable 511*a9fa9459Szrj (void *, const char *, debug_type, enum debug_var_kind, bfd_vma); 512*a9fa9459Szrj 513*a9fa9459Szrj /* Make an indirect type. The first argument is a pointer to the 514*a9fa9459Szrj location where the real type will be placed. The second argument 515*a9fa9459Szrj is the type tag, if there is one; this may be NULL; the only 516*a9fa9459Szrj purpose of this argument is so that debug_get_type_name can return 517*a9fa9459Szrj something useful. This function may be used when a type is 518*a9fa9459Szrj referenced before it is defined. */ 519*a9fa9459Szrj 520*a9fa9459Szrj extern debug_type debug_make_indirect_type 521*a9fa9459Szrj (void *, debug_type *, const char *); 522*a9fa9459Szrj 523*a9fa9459Szrj /* Make a void type. */ 524*a9fa9459Szrj 525*a9fa9459Szrj extern debug_type debug_make_void_type (void *); 526*a9fa9459Szrj 527*a9fa9459Szrj /* Make an integer type of a given size. The bfd_boolean argument is TRUE 528*a9fa9459Szrj if the integer is unsigned. */ 529*a9fa9459Szrj 530*a9fa9459Szrj extern debug_type debug_make_int_type (void *, unsigned int, bfd_boolean); 531*a9fa9459Szrj 532*a9fa9459Szrj /* Make a floating point type of a given size. FIXME: On some 533*a9fa9459Szrj platforms, like an Alpha, you probably need to be able to specify 534*a9fa9459Szrj the format. */ 535*a9fa9459Szrj 536*a9fa9459Szrj extern debug_type debug_make_float_type (void *, unsigned int); 537*a9fa9459Szrj 538*a9fa9459Szrj /* Make a boolean type of a given size. */ 539*a9fa9459Szrj 540*a9fa9459Szrj extern debug_type debug_make_bool_type (void *, unsigned int); 541*a9fa9459Szrj 542*a9fa9459Szrj /* Make a complex type of a given size. */ 543*a9fa9459Szrj 544*a9fa9459Szrj extern debug_type debug_make_complex_type (void *, unsigned int); 545*a9fa9459Szrj 546*a9fa9459Szrj /* Make a structure type. The second argument is TRUE for a struct, 547*a9fa9459Szrj FALSE for a union. The third argument is the size of the struct. 548*a9fa9459Szrj The fourth argument is a NULL terminated array of fields. */ 549*a9fa9459Szrj 550*a9fa9459Szrj extern debug_type debug_make_struct_type 551*a9fa9459Szrj (void *, bfd_boolean, bfd_vma, debug_field *); 552*a9fa9459Szrj 553*a9fa9459Szrj /* Make an object type. The first three arguments after the handle 554*a9fa9459Szrj are the same as for debug_make_struct_type. The next arguments are 555*a9fa9459Szrj a NULL terminated array of base classes, a NULL terminated array of 556*a9fa9459Szrj methods, the type of the object holding the virtual function table 557*a9fa9459Szrj if it is not this object, and a bfd_boolean which is TRUE if this 558*a9fa9459Szrj object has its own virtual function table. */ 559*a9fa9459Szrj 560*a9fa9459Szrj extern debug_type debug_make_object_type 561*a9fa9459Szrj (void *, bfd_boolean, bfd_vma, debug_field *, debug_baseclass *, 562*a9fa9459Szrj debug_method *, debug_type, bfd_boolean); 563*a9fa9459Szrj 564*a9fa9459Szrj /* Make an enumeration type. The arguments are a null terminated 565*a9fa9459Szrj array of strings, and an array of corresponding values. */ 566*a9fa9459Szrj 567*a9fa9459Szrj extern debug_type debug_make_enum_type 568*a9fa9459Szrj (void *, const char **, bfd_signed_vma *); 569*a9fa9459Szrj 570*a9fa9459Szrj /* Make a pointer to a given type. */ 571*a9fa9459Szrj 572*a9fa9459Szrj extern debug_type debug_make_pointer_type (void *, debug_type); 573*a9fa9459Szrj 574*a9fa9459Szrj /* Make a function type. The second argument is the return type. The 575*a9fa9459Szrj third argument is a NULL terminated array of argument types. The 576*a9fa9459Szrj fourth argument is TRUE if the function takes a variable number of 577*a9fa9459Szrj arguments. If the third argument is NULL, then the argument types 578*a9fa9459Szrj are unknown. */ 579*a9fa9459Szrj 580*a9fa9459Szrj extern debug_type debug_make_function_type 581*a9fa9459Szrj (void *, debug_type, debug_type *, bfd_boolean); 582*a9fa9459Szrj 583*a9fa9459Szrj /* Make a reference to a given type. */ 584*a9fa9459Szrj 585*a9fa9459Szrj extern debug_type debug_make_reference_type (void *, debug_type); 586*a9fa9459Szrj 587*a9fa9459Szrj /* Make a range of a given type from a lower to an upper bound. */ 588*a9fa9459Szrj 589*a9fa9459Szrj extern debug_type debug_make_range_type 590*a9fa9459Szrj (void *, debug_type, bfd_signed_vma, bfd_signed_vma); 591*a9fa9459Szrj 592*a9fa9459Szrj /* Make an array type. The second argument is the type of an element 593*a9fa9459Szrj of the array. The third argument is the type of a range of the 594*a9fa9459Szrj array. The fourth and fifth argument are the lower and upper 595*a9fa9459Szrj bounds, respectively (if the bounds are not known, lower should be 596*a9fa9459Szrj 0 and upper should be -1). The sixth argument is TRUE if this 597*a9fa9459Szrj array is actually a string, as in C. */ 598*a9fa9459Szrj 599*a9fa9459Szrj extern debug_type debug_make_array_type 600*a9fa9459Szrj (void *, debug_type, debug_type, bfd_signed_vma, bfd_signed_vma, 601*a9fa9459Szrj bfd_boolean); 602*a9fa9459Szrj 603*a9fa9459Szrj /* Make a set of a given type. For example, a Pascal set type. The 604*a9fa9459Szrj bfd_boolean argument is TRUE if this set is actually a bitstring, as in 605*a9fa9459Szrj CHILL. */ 606*a9fa9459Szrj 607*a9fa9459Szrj extern debug_type debug_make_set_type (void *, debug_type, bfd_boolean); 608*a9fa9459Szrj 609*a9fa9459Szrj /* Make a type for a pointer which is relative to an object. The 610*a9fa9459Szrj second argument is the type of the object to which the pointer is 611*a9fa9459Szrj relative. The third argument is the type that the pointer points 612*a9fa9459Szrj to. */ 613*a9fa9459Szrj 614*a9fa9459Szrj extern debug_type debug_make_offset_type (void *, debug_type, debug_type); 615*a9fa9459Szrj 616*a9fa9459Szrj /* Make a type for a method function. The second argument is the 617*a9fa9459Szrj return type. The third argument is the domain. The fourth 618*a9fa9459Szrj argument is a NULL terminated array of argument types. The fifth 619*a9fa9459Szrj argument is TRUE if the function takes a variable number of 620*a9fa9459Szrj arguments, in which case the array of argument types indicates the 621*a9fa9459Szrj types of the first arguments. The domain and the argument array 622*a9fa9459Szrj may be NULL, in which case this is a stub method and that 623*a9fa9459Szrj information is not available. Stabs debugging uses this, and gets 624*a9fa9459Szrj the argument types from the mangled name. */ 625*a9fa9459Szrj 626*a9fa9459Szrj extern debug_type debug_make_method_type 627*a9fa9459Szrj (void *, debug_type, debug_type, debug_type *, bfd_boolean); 628*a9fa9459Szrj 629*a9fa9459Szrj /* Make a const qualified version of a given type. */ 630*a9fa9459Szrj 631*a9fa9459Szrj extern debug_type debug_make_const_type (void *, debug_type); 632*a9fa9459Szrj 633*a9fa9459Szrj /* Make a volatile qualified version of a given type. */ 634*a9fa9459Szrj 635*a9fa9459Szrj extern debug_type debug_make_volatile_type (void *, debug_type); 636*a9fa9459Szrj 637*a9fa9459Szrj /* Make an undefined tagged type. For example, a struct which has 638*a9fa9459Szrj been mentioned, but not defined. */ 639*a9fa9459Szrj 640*a9fa9459Szrj extern debug_type debug_make_undefined_tagged_type 641*a9fa9459Szrj (void *, const char *, enum debug_type_kind); 642*a9fa9459Szrj 643*a9fa9459Szrj /* Make a base class for an object. The second argument is the base 644*a9fa9459Szrj class type. The third argument is the bit position of this base 645*a9fa9459Szrj class in the object. The fourth argument is whether this is a 646*a9fa9459Szrj virtual class. The fifth argument is the visibility of the base 647*a9fa9459Szrj class. */ 648*a9fa9459Szrj 649*a9fa9459Szrj extern debug_baseclass debug_make_baseclass 650*a9fa9459Szrj (void *, debug_type, bfd_vma, bfd_boolean, enum debug_visibility); 651*a9fa9459Szrj 652*a9fa9459Szrj /* Make a field for a struct. The second argument is the name. The 653*a9fa9459Szrj third argument is the type of the field. The fourth argument is 654*a9fa9459Szrj the bit position of the field. The fifth argument is the size of 655*a9fa9459Szrj the field (it may be zero). The sixth argument is the visibility 656*a9fa9459Szrj of the field. */ 657*a9fa9459Szrj 658*a9fa9459Szrj extern debug_field debug_make_field 659*a9fa9459Szrj (void *, const char *, debug_type, bfd_vma, bfd_vma, enum debug_visibility); 660*a9fa9459Szrj 661*a9fa9459Szrj /* Make a static member of an object. The second argument is the 662*a9fa9459Szrj name. The third argument is the type of the member. The fourth 663*a9fa9459Szrj argument is the physical name of the member (i.e., the name as a 664*a9fa9459Szrj global variable). The fifth argument is the visibility of the 665*a9fa9459Szrj member. */ 666*a9fa9459Szrj 667*a9fa9459Szrj extern debug_field debug_make_static_member 668*a9fa9459Szrj (void *, const char *, debug_type, const char *, enum debug_visibility); 669*a9fa9459Szrj 670*a9fa9459Szrj /* Make a method. The second argument is the name, and the third 671*a9fa9459Szrj argument is a NULL terminated array of method variants. Each 672*a9fa9459Szrj method variant is a method with this name but with different 673*a9fa9459Szrj argument types. */ 674*a9fa9459Szrj 675*a9fa9459Szrj extern debug_method debug_make_method 676*a9fa9459Szrj (void *, const char *, debug_method_variant *); 677*a9fa9459Szrj 678*a9fa9459Szrj /* Make a method variant. The second argument is the physical name of 679*a9fa9459Szrj the function. The third argument is the type of the function, 680*a9fa9459Szrj probably constructed by debug_make_method_type. The fourth 681*a9fa9459Szrj argument is the visibility. The fifth argument is whether this is 682*a9fa9459Szrj a const function. The sixth argument is whether this is a volatile 683*a9fa9459Szrj function. The seventh argument is the index in the virtual 684*a9fa9459Szrj function table, if any. The eighth argument is the virtual 685*a9fa9459Szrj function context. */ 686*a9fa9459Szrj 687*a9fa9459Szrj extern debug_method_variant debug_make_method_variant 688*a9fa9459Szrj (void *, const char *, debug_type, enum debug_visibility, bfd_boolean, 689*a9fa9459Szrj bfd_boolean, bfd_vma, debug_type); 690*a9fa9459Szrj 691*a9fa9459Szrj /* Make a static method argument. The arguments are the same as for 692*a9fa9459Szrj debug_make_method_variant, except that the last two are omitted 693*a9fa9459Szrj since a static method can not also be virtual. */ 694*a9fa9459Szrj 695*a9fa9459Szrj extern debug_method_variant debug_make_static_method_variant 696*a9fa9459Szrj (void *, const char *, debug_type, enum debug_visibility, bfd_boolean, 697*a9fa9459Szrj bfd_boolean); 698*a9fa9459Szrj 699*a9fa9459Szrj /* Name a type. This returns a new type with an attached name. */ 700*a9fa9459Szrj 701*a9fa9459Szrj extern debug_type debug_name_type (void *, const char *, debug_type); 702*a9fa9459Szrj 703*a9fa9459Szrj /* Give a tag to a type, such as a struct or union. This returns a 704*a9fa9459Szrj new type with an attached tag. */ 705*a9fa9459Szrj 706*a9fa9459Szrj extern debug_type debug_tag_type (void *, const char *, debug_type); 707*a9fa9459Szrj 708*a9fa9459Szrj /* Record the size of a given type. */ 709*a9fa9459Szrj 710*a9fa9459Szrj extern bfd_boolean debug_record_type_size (void *, debug_type, unsigned int); 711*a9fa9459Szrj 712*a9fa9459Szrj /* Find a named type. */ 713*a9fa9459Szrj 714*a9fa9459Szrj extern debug_type debug_find_named_type (void *, const char *); 715*a9fa9459Szrj 716*a9fa9459Szrj /* Find a tagged type. */ 717*a9fa9459Szrj 718*a9fa9459Szrj extern debug_type debug_find_tagged_type 719*a9fa9459Szrj (void *, const char *, enum debug_type_kind); 720*a9fa9459Szrj 721*a9fa9459Szrj /* Get the kind of a type. */ 722*a9fa9459Szrj 723*a9fa9459Szrj extern enum debug_type_kind debug_get_type_kind (void *, debug_type); 724*a9fa9459Szrj 725*a9fa9459Szrj /* Get the name of a type. */ 726*a9fa9459Szrj 727*a9fa9459Szrj extern const char *debug_get_type_name (void *, debug_type); 728*a9fa9459Szrj 729*a9fa9459Szrj /* Get the size of a type. */ 730*a9fa9459Szrj 731*a9fa9459Szrj extern bfd_vma debug_get_type_size (void *, debug_type); 732*a9fa9459Szrj 733*a9fa9459Szrj /* Get the return type of a function or method type. */ 734*a9fa9459Szrj 735*a9fa9459Szrj extern debug_type debug_get_return_type (void *, debug_type); 736*a9fa9459Szrj 737*a9fa9459Szrj /* Get the NULL terminated array of parameter types for a function or 738*a9fa9459Szrj method type (actually, parameter types are not currently stored for 739*a9fa9459Szrj function types). This may be used to determine whether a method 740*a9fa9459Szrj type is a stub method or not. The last argument points to a 741*a9fa9459Szrj bfd_boolean which is set to TRUE if the function takes a variable 742*a9fa9459Szrj number of arguments. */ 743*a9fa9459Szrj 744*a9fa9459Szrj extern const debug_type *debug_get_parameter_types 745*a9fa9459Szrj (void *, debug_type, bfd_boolean *); 746*a9fa9459Szrj 747*a9fa9459Szrj /* Get the target type of a pointer or reference or const or volatile 748*a9fa9459Szrj type. */ 749*a9fa9459Szrj 750*a9fa9459Szrj extern debug_type debug_get_target_type (void *, debug_type); 751*a9fa9459Szrj 752*a9fa9459Szrj /* Get the NULL terminated array of fields for a struct, union, or 753*a9fa9459Szrj class. */ 754*a9fa9459Szrj 755*a9fa9459Szrj extern const debug_field *debug_get_fields (void *, debug_type); 756*a9fa9459Szrj 757*a9fa9459Szrj /* Get the type of a field. */ 758*a9fa9459Szrj 759*a9fa9459Szrj extern debug_type debug_get_field_type (void *, debug_field); 760*a9fa9459Szrj 761*a9fa9459Szrj /* Get the name of a field. */ 762*a9fa9459Szrj 763*a9fa9459Szrj extern const char *debug_get_field_name (void *, debug_field); 764*a9fa9459Szrj 765*a9fa9459Szrj /* Get the bit position of a field within the containing structure. 766*a9fa9459Szrj If the field is a static member, this will return (bfd_vma) -1. */ 767*a9fa9459Szrj 768*a9fa9459Szrj extern bfd_vma debug_get_field_bitpos (void *, debug_field); 769*a9fa9459Szrj 770*a9fa9459Szrj /* Get the bit size of a field. If the field is a static member, this 771*a9fa9459Szrj will return (bfd_vma) -1. */ 772*a9fa9459Szrj 773*a9fa9459Szrj extern bfd_vma debug_get_field_bitsize (void *, debug_field); 774*a9fa9459Szrj 775*a9fa9459Szrj /* Get the visibility of a field. */ 776*a9fa9459Szrj 777*a9fa9459Szrj extern enum debug_visibility debug_get_field_visibility (void *, debug_field); 778*a9fa9459Szrj 779*a9fa9459Szrj /* Get the physical name of a field, if it is a static member. If the 780*a9fa9459Szrj field is not a static member, this will return NULL. */ 781*a9fa9459Szrj 782*a9fa9459Szrj extern const char *debug_get_field_physname (void *, debug_field); 783*a9fa9459Szrj 784*a9fa9459Szrj /* Write out the recorded debugging information. This takes a set of 785*a9fa9459Szrj function pointers which are called to do the actual writing. The 786*a9fa9459Szrj first void * is the debugging handle. The second void * is a handle 787*a9fa9459Szrj which is passed to the functions. */ 788*a9fa9459Szrj 789*a9fa9459Szrj extern bfd_boolean debug_write 790*a9fa9459Szrj (void *, const struct debug_write_fns *, void *); 791*a9fa9459Szrj 792*a9fa9459Szrj #endif /* DEBUG_H */ 793