]> sourceware.org Git - systemtap.git/commitdiff
Explicitly declare _stp_module_self fields
authorLukas Berk <lberk@redhat.com>
Thu, 10 Apr 2014 20:05:55 +0000 (16:05 -0400)
committerLukas Berk <lberk@redhat.com>
Thu, 10 Apr 2014 20:05:55 +0000 (16:05 -0400)
*runtime/sym.c - remove assignments for fields assigned in translate.cxx
*translate.cxx - explicitly initialize more of the fields in the
         _stp_module_self module.  This way we no longer have to
       rely on lucky ordering later on.

runtime/sym.c
translate.cxx

index ed939448ecfad860a9d3d7ef65452c7de366ba80..ba5ace4e92cfed2e82fa33c4640342ca0a1ee37b 100644 (file)
@@ -635,7 +635,7 @@ static void _stp_kmodule_update_address(const char* module,
     if(reloc && !strcmp(".strtab",reloc)){
       int i;
       unsigned long j = 0;
-      struct module *mod = find_module(THIS_MODULE->name);
+      struct module *mod = THIS_MODULE;
       if(mod){
        for(i = 0; i < mod->num_symtab; i++){
          j += sizeof(mod->symtab[i]);
@@ -644,17 +644,8 @@ static void _stp_kmodule_update_address(const char* module,
          //      _stp_printf("0x%lx, \"%s\" %d\n",(mod->symtab[i].st_value - address),(mod->strtab + mod->symtab[i].st_name), mod->num_symtab);
          //      _stp_print_flush();
        }
-       _stp_modules[_stp_num_modules-1]->num_sections++;
-       _stp_modules[_stp_num_modules-1]->sections = _stp_module_self_sections;
-       _stp_modules[_stp_num_modules-1]->sections[0].name = ".symtab";
        _stp_modules[_stp_num_modules-1]->sections[0].size = j;
        _stp_modules[_stp_num_modules-1]->sections[0].static_addr = address;
-       _stp_modules[_stp_num_modules-1]->sections[0].symbols = _stp_module_self_symbols_0;
-       _stp_modules[_stp_num_modules-1]->sections[0].num_symbols = 0;
-       _stp_modules[_stp_num_modules-1]->num_sections++;
-       _stp_modules[_stp_num_modules-1]->sections[1].name = ".text";
-       _stp_modules[_stp_num_modules-1]->sections[1].symbols = _stp_module_self_symbols_1;
-       _stp_modules[_stp_num_modules-1]->sections[1].num_symbols = 0;
       if(mod->core_text_size > mod->init_text_size)
          _stp_modules[_stp_num_modules-1]->sections[1].size = mod->core_text_size;
        else
index 51be57bb8a1fb2adbbe0b8a7014d21f1289fb821..96cf5f96ff6bb53b31e1867d7069efcf8c675aa9 100644 (file)
@@ -6576,18 +6576,38 @@ emit_symbol_data (systemtap_session& s)
   emit_symbol_data_done (&ctx, s);
 }
 
+void
+self_unwind_declarations(unwindsym_dump_context *ctx)
+{
+  ctx->output << "static uint8_t _stp_module_self_eh_frame [] = {0,};\n";
+  ctx->output << "static struct _stp_symbol _stp_module_self_symbols_0[] = {{0},};\n";
+  ctx->output << "static struct _stp_symbol _stp_module_self_symbols_1[] = {{0},};\n";
+  ctx->output << "static struct _stp_section _stp_module_self_sections[] = {\n";
+  ctx->output << "{.name = \".symtab\", .symbols = _stp_module_self_symbols_0, .num_symbols = 0},\n";
+  ctx->output << "{.name = \".text\", .symbols = _stp_module_self_symbols_1, .num_symbols = 0},\n";
+  ctx->output << "};\n";
+  ctx->output << "static struct _stp_module _stp_module_self = {\n";
+  ctx->output << ".name = \"stap_self_tmp_value\",\n";
+  ctx->output << ".path = \"stap_self_tmp_value\",\n";
+  ctx->output << ".num_sections = 2,\n";
+  ctx->output << ".sections = _stp_module_self_sections,\n";
+  ctx->output << ".eh_frame = _stp_module_self_eh_frame,\n";
+  ctx->output << ".eh_frame_len = 0,\n";
+  ctx->output << ".unwind_hdr_addr = 0x0,\n";
+  ctx->output << ".unwind_hdr = NULL,\n";
+  ctx->output << ".unwind_hdr_len = 0,\n";
+  ctx->output << ".debug_frame = NULL,\n";
+  ctx->output << ".debug_frame_len = 0,\n";
+  ctx->output << "};\n";
+}
+
 void
 emit_symbol_data_done (unwindsym_dump_context *ctx, systemtap_session& s)
 {
   // Print out a definition of the runtime's _stp_modules[] globals.
   ctx->output << "\n";
-  ctx->output << "#if defined(STP_USE_DWARF_UNWINDER) && defined(STP_NEED_UNWIND_DATA)\n";
-  ctx->output << "static struct _stp_symbol _stp_module_self_symbols_0 [] = {{ 0 },};\n";
-  ctx->output << "static struct _stp_symbol _stp_module_self_symbols_1 [] = {{ 0 },};\n";
-  ctx->output << "static struct _stp_section _stp_module_self_sections [] = {{0},};\n";
-  ctx->output << "#endif /* defined(STP_USE_DWARF_UNWINDER) && defined(STP_NEED_UNWIND_DATA) */\n";
-  ctx->output << "static struct _stp_module _stp_module_self = {0};\n";
-  ctx->output << "static struct _stp_module *_stp_modules [] = {\n";
+  self_unwind_declarations(ctx);
+   ctx->output << "static struct _stp_module *_stp_modules [] = {\n";
   for (unsigned i=0; i<ctx->stp_module_index; i++)
     {
       ctx->output << "& _stp_module_" << i << ",\n";
This page took 0.042934 seconds and 5 git commands to generate.