| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Debugging object format (used to debug object format module interface) | 2 * Debugging object format (used to debug object format module interface) |
| 3 * | 3 * |
| 4 * Copyright (C) 2001-2007 Peter Johnson | 4 * Copyright (C) 2001-2007 Peter Johnson |
| 5 * | 5 * |
| 6 * Redistribution and use in source and binary forms, with or without | 6 * Redistribution and use in source and binary forms, with or without |
| 7 * modification, are permitted provided that the following conditions | 7 * modification, are permitted provided that the following conditions |
| 8 * are met: | 8 * are met: |
| 9 * 1. Redistributions of source code must retain the above copyright | 9 * 1. Redistributions of source code must retain the above copyright |
| 10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
| 11 * 2. Redistributions in binary form must reproduce the above copyright | 11 * 2. Redistributions in binary form must reproduce the above copyright |
| 12 * notice, this list of conditions and the following disclaimer in the | 12 * notice, this list of conditions and the following disclaimer in the |
| 13 * documentation and/or other materials provided with the distribution. | 13 * documentation and/or other materials provided with the distribution. |
| 14 * | 14 * |
| 15 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND OTHER CONTRIBUTORS ``AS IS'' | 15 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND OTHER CONTRIBUTORS ``AS IS'' |
| 16 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | 16 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| 17 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | 17 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
| 18 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR OTHER CONTRIBUTORS BE | 18 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR OTHER CONTRIBUTORS BE |
| 19 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | 19 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
| 20 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | 20 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
| 21 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | 21 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
| 22 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | 22 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
| 23 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | 23 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
| 24 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | 24 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
| 25 * POSSIBILITY OF SUCH DAMAGE. | 25 * POSSIBILITY OF SUCH DAMAGE. |
| 26 */ | 26 */ |
| 27 #include <util.h> | 27 #include <util.h> |
| 28 /*@unused@*/ RCSID("$Id: dbg-objfmt.c 2166 2009-01-02 08:33:21Z peter $"); | 28 /*@unused@*/ RCSID("$Id: dbg-objfmt.c 2310 2010-03-28 19:28:54Z peter $"); |
| 29 | 29 |
| 30 #include <libyasm.h> | 30 #include <libyasm.h> |
| 31 | 31 |
| 32 | 32 |
| 33 typedef struct yasm_objfmt_dbg { | 33 typedef struct yasm_objfmt_dbg { |
| 34 yasm_objfmt_base objfmt; /* base structure */ | 34 yasm_objfmt_base objfmt; /* base structure */ |
| 35 | 35 |
| 36 FILE *dbgfile; | 36 FILE *dbgfile; |
| 37 } yasm_objfmt_dbg; | 37 } yasm_objfmt_dbg; |
| 38 | 38 |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 82 } | 82 } |
| 83 | 83 |
| 84 static void | 84 static void |
| 85 dbg_objfmt_destroy(yasm_objfmt *objfmt) | 85 dbg_objfmt_destroy(yasm_objfmt *objfmt) |
| 86 { | 86 { |
| 87 yasm_objfmt_dbg *objfmt_dbg = (yasm_objfmt_dbg *)objfmt; | 87 yasm_objfmt_dbg *objfmt_dbg = (yasm_objfmt_dbg *)objfmt; |
| 88 fprintf(objfmt_dbg->dbgfile, "destroy()\n"); | 88 fprintf(objfmt_dbg->dbgfile, "destroy()\n"); |
| 89 yasm_xfree(objfmt); | 89 yasm_xfree(objfmt); |
| 90 } | 90 } |
| 91 | 91 |
| 92 static void |
| 93 dbg_objfmt_init_new_section(yasm_section *sect, unsigned long line) |
| 94 { |
| 95 yasm_object *object = yasm_section_get_object(sect); |
| 96 yasm_objfmt_dbg *objfmt_dbg = (yasm_objfmt_dbg *)object->objfmt; |
| 97 fprintf(objfmt_dbg->dbgfile, "init_new_section(\"%s\", %lu)\n", |
| 98 yasm_section_get_name(sect), line); |
| 99 yasm_symtab_define_label(object->symtab, ".text", |
| 100 yasm_section_bcs_first(sect), 1, 0); |
| 101 } |
| 102 |
| 92 static yasm_section * | 103 static yasm_section * |
| 93 dbg_objfmt_add_default_section(yasm_object *object) | 104 dbg_objfmt_add_default_section(yasm_object *object) |
| 94 { | 105 { |
| 95 yasm_objfmt_dbg *objfmt_dbg = (yasm_objfmt_dbg *)object->objfmt; | 106 yasm_objfmt_dbg *objfmt_dbg = (yasm_objfmt_dbg *)object->objfmt; |
| 96 yasm_section *retval; | 107 yasm_section *retval; |
| 97 int isnew; | 108 int isnew; |
| 98 | 109 |
| 110 fprintf(objfmt_dbg->dbgfile, "add_default_section()\n"); |
| 99 retval = yasm_object_get_general(object, ".text", 0, 0, 0, &isnew, 0); | 111 retval = yasm_object_get_general(object, ".text", 0, 0, 0, &isnew, 0); |
| 100 if (isnew) { | 112 if (isnew) { |
| 101 fprintf(objfmt_dbg->dbgfile, "(new) "); | |
| 102 yasm_symtab_define_label(object->symtab, ".text", | |
| 103 yasm_section_bcs_first(retval), 1, 0); | |
| 104 yasm_section_set_default(retval, 1); | 113 yasm_section_set_default(retval, 1); |
| 105 } | 114 } |
| 106 return retval; | 115 return retval; |
| 107 } | 116 } |
| 108 | 117 |
| 109 static /*@observer@*/ /*@null@*/ yasm_section * | 118 static /*@observer@*/ /*@null@*/ yasm_section * |
| 110 dbg_objfmt_section_switch(yasm_object *object, yasm_valparamhead *valparams, | 119 dbg_objfmt_section_switch(yasm_object *object, yasm_valparamhead *valparams, |
| 111 /*@unused@*/ /*@null@*/ | 120 /*@unused@*/ /*@null@*/ |
| 112 yasm_valparamhead *objext_valparams, | 121 yasm_valparamhead *objext_valparams, |
| 113 unsigned long line) | 122 unsigned long line) |
| (...skipping 11 matching lines...) Expand all Loading... |
| 125 | 134 |
| 126 vp = yasm_vps_first(valparams); | 135 vp = yasm_vps_first(valparams); |
| 127 if (!yasm_vp_string(vp)) { | 136 if (!yasm_vp_string(vp)) { |
| 128 fprintf(objfmt_dbg->dbgfile, "NULL\n"); | 137 fprintf(objfmt_dbg->dbgfile, "NULL\n"); |
| 129 return NULL; | 138 return NULL; |
| 130 } | 139 } |
| 131 retval = yasm_object_get_general(object, yasm_vp_string(vp), 0, 0, 0, | 140 retval = yasm_object_get_general(object, yasm_vp_string(vp), 0, 0, 0, |
| 132 &isnew, line); | 141 &isnew, line); |
| 133 if (isnew) { | 142 if (isnew) { |
| 134 fprintf(objfmt_dbg->dbgfile, "(new) "); | 143 fprintf(objfmt_dbg->dbgfile, "(new) "); |
| 135 yasm_symtab_define_label(object->symtab, vp->val, | |
| 136 yasm_section_bcs_first(retval), 1, line); | |
| 137 } | 144 } |
| 138 yasm_section_set_default(retval, 0); | 145 yasm_section_set_default(retval, 0); |
| 139 fprintf(objfmt_dbg->dbgfile, "\"%s\" section\n", vp->val); | 146 fprintf(objfmt_dbg->dbgfile, "\"%s\" section\n", vp->val); |
| 140 return retval; | 147 return retval; |
| 141 } | 148 } |
| 142 | 149 |
| 143 static /*@observer@*/ /*@null@*/ yasm_symrec * | 150 static /*@observer@*/ /*@null@*/ yasm_symrec * |
| 144 dbg_objfmt_get_special_sym(yasm_object *object, const char *name, | 151 dbg_objfmt_get_special_sym(yasm_object *object, const char *name, |
| 145 const char *parser) | 152 const char *parser) |
| 146 { | 153 { |
| (...skipping 17 matching lines...) Expand all Loading... |
| 164 32, | 171 32, |
| 165 0, | 172 0, |
| 166 dbg_objfmt_dbgfmt_keywords, | 173 dbg_objfmt_dbgfmt_keywords, |
| 167 "null", | 174 "null", |
| 168 NULL, /* no directives */ | 175 NULL, /* no directives */ |
| 169 NULL, /* no standard macros */ | 176 NULL, /* no standard macros */ |
| 170 dbg_objfmt_create, | 177 dbg_objfmt_create, |
| 171 dbg_objfmt_output, | 178 dbg_objfmt_output, |
| 172 dbg_objfmt_destroy, | 179 dbg_objfmt_destroy, |
| 173 dbg_objfmt_add_default_section, | 180 dbg_objfmt_add_default_section, |
| 181 dbg_objfmt_init_new_section, |
| 174 dbg_objfmt_section_switch, | 182 dbg_objfmt_section_switch, |
| 175 dbg_objfmt_get_special_sym | 183 dbg_objfmt_get_special_sym |
| 176 }; | 184 }; |
| OLD | NEW |