summaryrefslogtreecommitdiffstats
path: root/translate.cxx
Commit message (Collapse)AuthorAgeFilesLines
* PR10257: Add support for sprint[ln](@hist_*).Przemyslaw Pawelczyk2009-10-131-2/+20
| | | | | | | | * parse.cxx (parser::parse_symbol): Add sprint[ln] to @hist_* hack. * runtime/stat-common.c: Replace reprint with new reprint_buf, add more generic _stp_stat_print_histogram_buf and call it from the older one. Also correct some formatting issues. * translate.cxx (c_unparser::visit_print_format): Add sprint case.
* Generate safety net assertions in probe function not authorized for ↵Dave Brolley2009-10-091-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | unprivileged users. 2009-10-08 Dave Brolley <brolley@redhat.com> * elaborate.h (emit_unprivileged_assertion): New virtual method of deriv ed_probe. (emit_process_owner_assertion): New static method of derived_probe. (check_unprivileged): New virtual method of derived_probe_builder. (match_node::unprivileged_ok): Removed. (match_node::allow_unprivileged): Removed. (match_node::unprivileged_allowed): Removed. * elaborate.cxx (translate.h): #include it. (emit_unprivileged_assertion): New virtual method of derived_probe. (emit_process_owner_assertion): New static method of derived_probe. (check_unprivileged): New virtual method of derived_probe_builder. (match_node::unprivileged_ok): Removed. (match_node::allow_unprivileged): Removed. (match_node::unprivileged_allowed): Removed. (find_and_build): Don't check for unprivileged restrictions here. Call t he builder's check_unprivileged method. (alias_expansion_builder::check_unprivileged): New virtual method. * tapset-been.cxx (be_derived_probe::emit_unprivileged_assertion): New v irtual method. (be_builder::check_unprivileged): Likewise. (never_derived_probe::emit_unprivileged_assertion): Likewise. (never_builder::check_unprivileged): Likewise. (register_tapset_been): Don't call allow_unprivileged. * tapset-itrace.cxx (itrace_derived_probe::emit_unprivileged_assertion): New virtual method. (itrace_builder::check_unprivileged): Likewise. (register_tapset_itrace): Don't call allow_unprivileged. * tapset-utrace.cxx (utrace_derived_probe::emit_unprivileged_assertion): New virtual method. (utrace_builder::check_unprivileged): Likewise. (register_tapset_utrace): Don't call allow_unprivileged. * tapset-timer.cxx (timer_derived_probe::emit_unprivileged_assertion): N ew virtual method. (timer_builder::check_unprivileged): Likewise. (register_tapset_timers): Don't call allow_unprivileged. * tapsets.cxx (uprobe_derived_probe::emit_unprivileged_assertion): New v irtual method. (uprobe_builder::check_unprivileged): Likewise. (register_standard_tapsets): Don't call allow_unprivileged. (register_statement_variants): Remove unprivileged_ok_p parameter. Don't call allow_unprivileged. (register_function_variants): Likewise. (register_function_and_statement_variants): Likewise. (register_patterns): Don't call allow_unprivileged. * translate.cxx (emit_probe): Call v->emit_unprivileged_assertion.
* Cache Dwfl's for reuse between pass 2 and pass 3.Mark Wielaard2009-09-291-7/+8
| | | | | | | | | | * setupdwfl.h: Introduce DwflPtr. * setupdwfl.cxx: Cache kernel_dwfl and user_dwfl. Keep track of last used module strings. Return cached versions if same query used. * dwflpp.h: Use DwflPtr instead of Dwfl*. * dwflpp.cxx: Use DwflPtr and don't dwfl_end(). * translate.cxx: Likewise. Run through dwfl_getmodules() with returned ptr offset.
* Factor out duplicated code to setup user/module Dwfl from dwflpp/translate.Mark Wielaard2009-09-291-27/+6
| | | | | | | | | * setupdwfl.h: Add setup_dwfl_user() and is_user_module(). * setupdwfl.cxx: Likewise. * dwflpp.cxx (setup_user): Use setup_dwfl_user(). * translate.cxx (emit_symbol_data): Likewise and is_user_module(). * tapsets.cxx (dwarf_cast_expanding_visitor::visit_cast_op): Use is_user_module().
* Factor out duplicated code to setup kernel/module Dwfl from dwflpp/translate.Mark Wielaard2009-09-281-66/+12
| | | | | | | | | | | * setupdwfl.h: New header file. * setupdwfl.cxx: New source file containing shared setup_dwfl_kernel() code. * dwflpp.cxx (dwfl_report_offline_predicate): Removed. (setup_kernel): Call setup_dwfl_kernel(). * translate.cxx (dwfl_report_offline_predicate2): Remove. (emit_symbol_data): Call setup_dwfl_kernel(). * Makefile.am (stap_SOURCES): Add setupdwfl.cxx. * Makefile.in: Regenerated.
* * sdt.h (STAP_SEMAPHORE): New. Add guard to utrace probe points.Stan Cox2009-09-161-0/+1
| | | | | | | | | | | | | | * itrace.h (__access_process_vm): Moved from here... * runtime/access_process_vm.h: New. ...to here. * translate.cxx (translate_pass): Include access_process_vm.h * session.h (sdt_semaphore_addr): New. * tapsets.cxx (sdt_query::record_semaphore): New. Record sdt_semaphore_addr. (uprobe_derived_probe_group::emit_module_decls): Allow for uprobe guard variable to be set and unset. (uprobe_derived_probe_group::emit_module_decls): Likewise. (uprobe_derived_probe_group::emit_module_exit): Likewise. * tapset-utrace.cxx (utrace_derived_probe_group::emit_probe_decl): Likewise. (utrace_derived_probe_group::emit_module_decls): Likewise. (utrace_derived_probe_group::emit_module_exit): Likewise.
* PR10524: reduce massive-uprobe script modules' .data consumptionFrank Ch. Eigler2009-09-081-32/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | The general approach is to rip out task_finder_tgt's from all over the place (including the unwindsym vmcbs, and the stap_uprobe_specs), and instead have a small handful of them: one for all unwindsyms, and one per abstract probed process (PID or NAME). These are in turn shared by all new stap_unwind_specs by index. Before: probe process("./stap").function("*") -rw-r--r--. 1 fche users 11775283 2009-09-08 20:26 /var/tmp/fche/systemtap/cache/96/stap_96c0479d674db55ec98d8a8750a790e7_7989596.ko text data bss dec hex filename 445158 8351944 4306472 13103574 c7f1d6 /var/tmp/fche/systemtap/cache/96/stap_96c0479d674db55ec98d8a8750a790e7_7989596.ko After: (Note how data shrank, though text gained a bit in const-init-data.) -rw-r--r--. 1 fche users 4021569 2009-09-08 20:27 /var/tmp/fche/systemtap/cache/e4/stap_e46e88634efd850b1586e81c231c239a_8058419.ko text data bss dec hex filename 1896511 2192 4324808 6223511 5ef697 /var/tmp/fche/systemtap/cache/e4/stap_e46e88634efd850b1586e81c231c239a_8058419.ko * tapsets.cxx (uprobe_derived_probe_group): Rewrite emit_module_decls, and adjust emit_module_init. * runtime/sym.c (_stp_sym_init): Initialize unwindsyms-shared vmcb. * runtime/sym.h (_stp_module): Remove *vmcb field. * translate.cxx (emit_module_init, dump_unwindsyms): Adapt. * translate.h (assert_0_indent): Flush output before possibly assert-failing.
* Fix build-id check for relocatable kernelEugeniy Meshcheryakov2009-09-071-2/+3
| | | | | | Save offset of build id relative to _stext instead of absolute address for kernel and apply relocations at run-time. This fixes Debian bug #545277 (http://bugs.debian.org/545277).
* Merge branch 'master' of sourceware.org:/git/systemtapJosh Stone2009-09-031-0/+2
|\
| * Allow process begin/end probes for unprivileged users.Dave Brolley2009-09-031-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 2009-09-03 Dave Brolley <brolley@redhat.com> * tapsets.cxx (visit_cast_op): Don't disallow unprivileged users. Annotate synthesized function with /* unprivileged */. * tapset-utrace.cxx (register_tapset_utrace): Call allow_unprivileged for process begin and end probes. * translate.cxx (translate_pass): Generate '#define STP_PRIVILEGED 1' unless --unprivileged was specified. * runtime/transport/transport.c: Don't define _stp_unprivileged_user. * runtime/task_finder.c (__stp_utrace_attach_match_filename): Check that _stp_uid equals the task euid when STP_PRIVILEGED is not defined. (stap_start_task_finder): Likewise. * runtime/staprun/staprun.c (insert_stap_module): Don't generate module option _stp_unprivileged_user.
* | Unify lex_cast* and avoid string copiesJosh Stone2009-09-021-18/+18
|/ | | | | | | | | | | | | | | We always use lex_cast either to string or from string, so I made that explicit, and got rid of some string copies in the process. There was also stringify(), which was redundant to lex_cast<string>. We also always used lex_cast_hex to string, so that's now hard-coded and again eliminated a string copy. For lex_cast_qstring<string>, there's no need to write the streamify the input, so a specialization now operates directly on the input. Hopefully this is a bit cleaner, and I do measure it to be a little faster on scripts with many probes.
* PR10589: switch to kernel vscnprintf for _stp_{dbug,warn,error} calls in runtimeFrank Ch. Eigler2009-09-021-1/+1
| | | | | | | | | | | _stp_vscnprintf is only suitable for calls from the script, with slightly different conventions (64-bit ints/pointers, extra formatting directives). * runtime/runtime.h (_stp_{dbug,warn,error}): Add __attribute__ format(printf). * runtime/io.c (_stp_vlog): Ditto. Use vscnprintf(). * runtime/sym.c (_stp_module_check): Remove hexdumping (%.*M) of mismatching buildids. Switch to _stp_warn from printk (KERN_WARNING). * translate.cxx, runtime/unwind.c: Numerous print formatting tweaks.
* cleanup: rename task_finder_target->pathname -> procnameFrank Ch. Eigler2009-08-211-2/+2
| | | | | | | | | | The previous name made it easy to misread the purpose of this field. It is only for matching executable names, not for shared libraries. * runtime/task_finder.c (task_finder_target): Rename field. (*): Adjust. * tapset-itrace.cxx, tapset-utrace.cxx, tapsets.cxx, translate.cxx: Ditto.
* PR10228: fix non-utrace building regression - cont'dWenji Huang2009-08-201-1/+1
| | | | | | | * runtime/task_finder.c (non-UTRACE): Return 0 for stap_start_task_finder. * translate.cxx (emit_module_init): Let vma tracker specific to utrace.
* PR10228: fix non-utrace building regressionFrank Ch. Eigler2009-08-191-2/+4
| | | | | | | * translate.cxx (dump_unwindsyms): Decide based on modname[] not mainfile[] to emit a vmcb. * runtime/task_finder.c (non-UTRACE): Include dummy stap_{start,stop}_* functions.
* PR10518: context shrinkage with function recursion analysis feeding MAXNESTINGFrank Ch. Eigler2009-08-181-5/+83
| | | | | | | | * translate.cxx (emit_common_header, translate_pass): Use new recursion_info visitor to calculate appropriate MAXNESTING value for scripts with or without recursion. * tapsets.cxx (common_probe_entryfn_prologue): Initialize c->nesting = -1. * stap.1.in: Clarify MAXNESTING value.
* PR10516: reduce context sizeFrank Ch. Eigler2009-08-181-3/+9
| | | | | | * translate.cxx (emit_common_header): Emit probe locals into a separate union, not into the locals[] array. (emit_probe): Adapt.
* Unlocks global variables, then calls _stp_print_flush().David Smith2009-08-171-4/+4
| | | | | * translate.cxx (c_unparser::emit_probe): Unlocks global variables, then calls _stp_print_flush() (instead of the other way around).
* PR10228: use task_finder_vma for -d /user/object files.Frank Ch. Eigler2009-08-141-2/+33
| | | | | | | | | | | | * main.cxx (main): For "-d /path" arguments, enable task finder. * runtime/sym.h (_stp_module): Add *vmcb member. * task_finder{.cxx,.h} (emit_vma_callback_probe_decl): Zap. * tapset-itrace.cxx, tapset-utrace.cxx: Use unwindsyms_modules instead. * tapsets.cxx (uprobe::emit_module_decls): Ditto. * translate.cxx (emit_module_init): Emit task finder registrations for vmcb's associated with _stp_modules. (dump_unwindsyms): Associate vmcbs with user-space unwindsyms entries.
* Simplify _ELFUTILS_PREREQ checkingJosh Stone2009-08-101-12/+2
| | | | | | | We were jumping through a few hoops to deal with elfutils < 0.138 that did not have the _ELFUTILS_PREREQ macro. I've added an always-false dummy macro to take its place when it doesn't exit. All of the other "#ifdef _ELFUTILS_PREREQ" ugliness can now go away.
* PR10486 Raise default MAXSTRINGLEN.Mark Wielaard2009-08-071-1/+10
| | | | | | | | * translate.cxx (translate_pass): Raise MAXSTRINGLEN to 256 for 32bit arches and to 512 for 64bit arches. * testsuite/systemtap.context/backtrace.tcl: Don't set MAXSTRINGLEN. * testsuite/systemtap.exelib/ustack.tcl: Likewise. * testsuite/systemtap.string/str_replace.exp: Explicitly set MAXSTRINGLEN.
* Merge branch 'master' of git://sources.redhat.com/git/systemtapDave Brolley2009-08-041-8/+8
|\ | | | | | | | | | | Conflicts: cache.cxx
| * PR2049: support arbitrary $target-array indexingJosh Stone2009-08-031-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Rather than just numeric literals, we can now support arbitrary expressions for the index value. Note that loc2c won't allow this for noncontiguous arrays, as the access methods need to be statically computed, but for contiguous arrays and pointers-as-arrays it works just fine. * staptree.h (target_symbol::component): Add expression_array_index. * staptree.cxx (target_symbol::visit_components): New helper. (target_symbol::assert_no_components): Recognize new array type. (target_symbol::component::print): Print subexpressions. (traversing_visitor::visit_target_symbol, visit_cast_op): Visit the indexing components too. (varuse_collecting_visitor::visit_target_symbol): Ditto. (update_visitor::visit_target_symbol, visit_cast_op): Ditto. * elaborate.cxx (void_statement_reducer::visit_target_symbol): New. (void_statement_reducer::visit_cast_op): Save indexes too. * parse.cxx (parser::parse_target_symbol_components): Parse expressions. * tapsets.cxx (dwarf_var_expanding_visitor::visit_target_symbol): Pass expression-indexes as parameters (indexN) to the dwarf function. (dwarf_cast_expanding_visitor::visit_cast_op): Ditto. (tracepoint_var_expanding_visitor::visit_target_symbol_arg): Ditto. (sdt_var_expanding_visitor::visit_target_symbol): Visit the new @cast. * dwflpp.cxx (dwflpp::translate_components): Use THIS->indexN. * translate.cxx (c_unparser::visit_target_symbol): Correct error msg. * testsuite/systemtap.base/pointer_array.stp: Use a simple index.
| * PR10459. Disable all warning messages on -w.Mark Wielaard2009-07-301-7/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | * stap.1.in: Document that -w disables all warning messages. * dwflpp.cxx (get_module_dwarf): Only output warning when session suppress_warnings is not set. * translate.cxx (dump_unwindsyms): Likewise. (emit_symbol_data_done): Likewise. * tapsets.cxx (query_module_symtab): Likewise. (read_from_elf_file): Take systemtap_session, check suppress_warnings before emitting warning. (read_from_text_file): Likewise. (get_symtab): Call read_from_elf_file and read_from_text_file with session.
* | Merge branch 'master' of git://sources.redhat.com/git/systemtapDave Brolley2009-07-081-11/+48
|\|
| * PR3498: speed up pass-2 and pass-3 for kernel offline dwfl module searchingFrank Ch. Eigler2009-07-071-11/+48
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * dwflpp.cxx (dwflpp ctor): Parametrize for user/kernel modes. Update callers. (dwfl_report_offline_predicate): New function. Filter and abort searches early if possible. (setup_kernel): Use new predicate. * dwflpp.h: Corresponding changes. * tapsets.cxx (dwfl_report_offline_predicate): Remove this shared implementation. (dwarf_builder): Turn kern_dw into module_name->dwflpp* map, just like user_dw. (get_kern_dw): Adapt. (dwarf_build_no_more): Adapt. * tapsets.h: Remove old shared predicate. * translate.cxx (dwfl_report_offline_predicate2): New function. Filter and abort searches early if possible. (emit_symbol_data): Use it.
* | Merge branch 'master' of git://sources.redhat.com/git/systemtapDave Brolley2009-07-011-7/+12
|\|
| * Special case _stp_kretprobe_trampoline emission for -1Roland McGrath2009-06-301-7/+12
| | | | | | | | | | | | * translate.cxx (emit_symbol_data_done): Special case _stp_kretprobe_trampoline emission for -1, which is invalid in hex if host width > target width.
* | Merge branch 'master' of git://sources.redhat.com/git/systemtapDave Brolley2009-06-291-3/+8
|\|
| * PR10323 Some ustack exelib.exp tests fail with prelinked shared libs.Mark Wielaard2009-06-251-3/+8
| | | | | | | | | | | | | | | | | | | | | | | | For shared libraries (.dynamic sections) we need the eh frame section address offset. This is the sh_addr if the shared library isn't prelinked (since the base load address is zero in that case), otherwise it is the module start address minus the bias (which also works for the non-prelinked case). * translate.cxx (get_unwind_data): Adjust eh_addr for module start and bias if module isn't absolute (has no relocations). * testsuite/systemtap.exelib/ustack.tcl: Accept all prelink tests.
* | Disallow embedded C in tapset functions ifor unprivileged users unless ↵Dave Brolley2009-06-251-2/+3
| | | | | | | | tagged by /* unprivileged */.
* | Merge branch 'master' of git://sources.redhat.com/git/systemtapDave Brolley2009-06-221-6/+7
|\|
| * PR10298: tweak global param initialization for NULL etc.Frank Ch. Eigler2009-06-181-6/+7
| | | | | | | | | | * translate.cxx (translate_pass): Emit module_parm stuff at the very end. * testsuite/buildok/null.stp: New test.
* | Merge branch 'master' of git://sources.redhat.com/git/systemtapDave Brolley2009-06-111-1/+9
|\|
| * PR10260: Clean up all resources after init errorsJosh Stone2009-06-101-0/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | When anything in systemtap_module_init fails, and we return non-zero, then the module load is aborted. The normal module unload path (systemtap_module_exit) is not even attempted, so we need to make sure that all partially-allocated resources are returned. Our timer callbacks for the gettimeofday subsystem are a classic example of this error. If we don't unregister the timers before aborting init, they will later be called and cause a kernel fault. We also were neglecting to free the percpu context. A memory leak is less harmful, but that's fixed now too.
| * build compatibility fix for gcc 3.4Frank Ch. Eigler2009-06-091-1/+1
| | | | | | | | * translate.cxx (emit_symbol_data): Use ~0 instead of -1 for big unsigned constant
* | Only sign modules if --unprivileged is specified.Dave Brolley2009-06-111-33/+0
| | | | | | | | | | | | Don't generate an error message for unsigned modules. Make sure module signature exists before attempting to copy to the cache. Allow timer p[robes for unprivileged users.
* | Merge branch 'master' of git://sources.redhat.com/git/systemtapDave Brolley2009-06-031-1/+14
|\|
| * Detect kretprobe trampoline and use fallback unwinder.Mark Wielaard2009-06-031-1/+14
| | | | | | | | | | | | | | | | | | | | | | | | * runtime/sym.h (_stp_kretprobe_trampoline): Document. * translate.cxx (unwindsym_dump_context): Add stp_kretprobe_trampoline_addr. (dump_unwindsyms): Detect kretprobe_trampoline_holder symbol address. (emit_symbol_data): Initialize and emit _stp_kretprobe_trampoline. * runtime/transport/symbols.c (_stp_do_relocation): Detect kernel load address and adjust _stp_kretprobe_trampoline. * runtime/stack-i386.c (__stp_stack_print): Always use fallback unwinder when hitting kretprobe_trampoline_holder. * runtime/stack-x86_64.c (__stp_stack_print): Likewise.
* | Merge branch 'master' of git://sources.redhat.com/git/systemtapDave Brolley2009-05-291-0/+1
|\|
| * PR10206: Include NOTYPE symbols in stap-symbols.hAnanth N Mavinakayanahalli2009-05-281-0/+1
| | | | | | | | | | On powerpc, function descriptors are in the .opd section as NO_TYPE. Include them in stap-symbols.h
* | Merge branch 'master' of git://sources.redhat.com/git/systemtapDave Brolley2009-05-221-39/+105
|\|
| * Fix gcc warning about Dwarf_Addr initialization.Mark Wielaard2009-05-211-1/+1
| | | | | | | | * translate.cxx (dump_unwindsyms): Initialize eh_frame to 0, not NULL.
| * PR10177: init/kill time in sleepy context onlyJosh Stone2009-05-201-0/+14
| | | | | | | | | | | | | | | | | | | | | | | | Previously, _stp_init_time and _stp_kill_time were being called from begin/end/error probes, which will run with preemption disabled. The BUG reported on RT kernels showed that cpufreq_unregister_notifier can end up sleeping, which violates our preemption block. This patch moves the init/kill into systemtap_module_init/exit, where it is safe to sleep. The code maintains a new predicate with the define STAP_NEED_GETTIMEOFDAY, so we don't still incur any timer overhead if it's not used.
| * Properly read eh_frame and pass is_ehframe correctly.Mark Wielaard2009-05-201-2/+2
| | | | | | | | | | | | | | | | | | * runtime/unwind.c (adjustStartLoc): Add extra dbug_unwind. (_stp_search_unwind_hdr): Always pass true for is_ehframe. (unwind_frame): Properly pass through is_ehframe to adjustStartLoc(). (unwind): Add extra dbug_unwind. * translate.cxx (dump_unwindsyms): Output and use correct eh_frame and eh_len.
| * Fetch and store both debug_frame and eh_frame tables.Mark Wielaard2009-05-201-39/+91
| | | | | | | | | | | | | | | | | | | | | | | | | | * runtime/sym.h (_stp_module): Remove unwind_data, unwind_data_len and unwind_is_ehframe fields. Add debug_frame, eh_frame, debug_frame_len, eh_frame_len and eh_frame_addr fields. * runtime/unwind.c: Use debug_frame and debug_frame_len instead of unwind_data and unwind_data_len throughout. (cie_for_fde): Take unwind_data and is_ehframe as direct arguments. * runtime/unwind/unwind.h (cie_for_fde): New function declaration. * translate.cxx (get_unwind_data): Fetch and return both debug_frame and eh_frame tables. (dump_unwindsyms): Dump both debug_frame and eh_frame tables.
* | Merge branch 'master' of git://sources.redhat.com/git/systemtapDave Brolley2009-04-231-1/+1
|\| | | | | | | | | | | Conflicts: Makefile.in
| * PR 9941: Add predicate function callback to check for an early abortRajan Arora2009-04-221-1/+1
| | | | | | | | | | | | | | * tapsets.cxx: Add dwfl_report_offline_predicate to check pending interrupts for an early abort. * tapsets.h: Declare it. * translate.cxx: Add callback to function call.
* | Merge branch 'master' of git://sources.redhat.com/git/systemtapDave Brolley2009-04-221-5/+1
|\|
| * Simplify section size logic.Mark Wielaard2009-04-221-5/+1
| | | | | | | | | | | | * translate.cxx (dump_unwindsyms): Just check that dwfl_module_relocations() return more than 1 relocation section bases before calling dwfl_module_address_section().