summaryrefslogtreecommitdiffstats
path: root/util.h
Commit message (Collapse)AuthorAgeFilesLines
* Add startswith/endswith helpersJosh Stone2010-03-111-0/+20
| | | | | Inspired by the Python equivalents, these new utility functions just make it a little cleaner to match at the beginning or end of a string.
* PR11105 part 2: tighten constraints on stap-server parameters passed to makeFrank Ch. Eigler2010-02-121-1/+1
| | | | | | | * util.h, util.cxx (assert_match_regexp): New function. * main.cxx (main): Constrain -R, -r, -a, -D, -S, -q, -B flags. * stap-serverd (listen): Harden stap-server-connect with ulimit/loop. * testsuite/systemtap.server/{client,server}_args.exp: Revised.
* Add .library("lib").mark("mark") and use it for .mark semaphores.Stan Cox2009-12-081-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | tapset-utrace.cxx (TOK_LIBRARY): New. (utrace_derived_probe::utrace_derived_probe): Add library and has_library. (utrace_builder::build): Handle library. (utrace_derived_probe_group::emit_probe_decl): Add sdt_sem_offset to emitted stap_utrace_probes. Add stap_task_finder_target mmap_callback for handling shared library. Handle sdt_sem_offset in emitted_stp_utrace_probe_cb. Add stap_utrace_mmap_found. (register_tapset_utrace): Handle .library tapset-utrace.cxx (TOK_LIBRARY): New. (base_query::base_query): Add path and has_library. (dwarf_derived_probe::dwarf_derived_probe) Likewise. (dwarf_derived_probe::register_patterns): Handle .library (sdt_query::convert_location): Likewise. (dwarf_builder::build): Likewise. (uprobe_derived_probe_group::emit_module_decls): Emit sdt_sem_address. Add sdt_sem_offset to emitted stap_uprobe_spec. Add offset and vm_flags to signature of stap_uprobe_change_plus, and handle sdt_sem_offset. Allow writeable segments in emitted stap_uprobe_mmap_found. sdt_misc.exp: Test .library util.cxx (find_executable): Add env_path to sig and use it in getenv. util.h (find_executable): Likewise. Make "PATH" the default. dtrace.in (provider): Turn on semaphores. sdt.h: Likewise.
* - Allow root, the owner of the uprobes build directory and the members of theDave Brolley2009-11-251-1/+1
| | | | | | | | | | group owner of the uprobes buld directory to build uprobes.ko. - When building uprobes.ko, make all generated files writable by the group owner of the uprobes build directory. - Don't change the group owner of the uprobes build directory during 'make install'
* Ensure uprobes/Makefile never returns failure due to setting permissions.Dave Brolley2009-11-231-1/+1
| | | | | Ensure uprobes install directory has group 'stap-server'. Rename igid_in to in_group.
* Allow members of the group stap-server to build the uprobes module.Dave Brolley2009-11-201-0/+1
|
* Simplify copy_file callsJosh Stone2009-09-281-1/+2
| | | | | | | | | | | | | | Every single copy_file call we had was converting strings to char*, printing the same error message, and optionally printing the same verbose string. Let's canonicalize that. * util.cxx (copy_file): Take string filenames, add a verbose flag, and consolidate the message printing. * cache.cxx (add_to_cache): Pass strings and remove message printing. (get_from_cache): Ditto. * main.cxx (main): Ditto. * tapsets.cxx (tracepoint_builder::get_tracequery_module): Ditto. (dwarf_cast_expanding_visitor::filter_special_modules): Ditto.
* Simplify deleting all map valuesJosh Stone2009-09-101-0/+12
| | | | | | * util.h (delete_map): New templated map deleter. * dwflpp.cxx (dwflpp::~dwflpp): Use it. * tapsets.cxx (symbol_table::~symbol_table): Use it.
* Unify lex_cast* and avoid string copiesJosh Stone2009-09-021-32/+36
| | | | | | | | | | | | | | | 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.
* PR10544: clean up stap child process error handlingFrank Ch. Eigler2009-08-211-1/+1
| | | | | | | * util.cxx (stap_system): Take extra verbosity value. Standardize error handling / tracing. * util.h: Corresponding changes. * buildrun.cxx, main.cxx, modsign.cxx: Update callers.
* Merge branch 'master' of git://sources.redhat.com/git/systemtapDave Brolley2009-06-151-1/+1
|\
| * PR10277: fix \octal escaping of utf-8 characters in path names etc.Frank Ch. Eigler2009-06-131-1/+1
| | | | | | | | * util.h (lex_cast_qstring): Use unsigned rather than signed chars.
| * Module signing and verification using a separate file for the module signature.Dave Brolley2009-05-041-0/+1
| |
* | Only sign modules if --unprivileged is specified.Dave Brolley2009-06-111-0/+2
| | | | | | | | | | | | 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-04-021-0/+2
|\| | | | | | | | | | | Conflicts: configure
| * PR10016: Purge stap of all pgrp and system() usageJosh Stone2009-04-011-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We hereby no longer try to manipulate process groups in any way. We don't set a private process group, and we never kill() our entire group either. Instead of using system(), we now have a stap_system() which saves the child PID, so when we get a terminating signal we can pass it along to the child. Signals sent through the TTY have always worked, since the TTY sends it to the entire pgrp. However, if we're running as part of a wrapper script or GUI, which may not have a separate process group for stap, we still would like to allow "kill -TERM $STAPPID" to terminate stap nicely. There's still a short window of failure in the time that staprun is active, because we can't kill a setuid process from a user process. Once staprun drops privileges and execs to stapio though, everything should work fine.
* | Merge branch 'master' of git://sources.redhat.com/git/systemtapDave Brolley2009-03-261-0/+1
|\|
| * Add the kernel tree's git revision to the hashJosh Stone2009-03-251-0/+1
| | | | | | | | | | To better support kernel developers who work out of a single source tree, this adds the git HEAD revision to our caching hash.
* | 2009-03-12 Dave Brolley <brolley@redhat.com>Dave Brolley2009-03-121-0/+1
|/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * util.cxx (remove_file_or_dir): New function. * util.h (remove_file_or_dir): New function. * systemtap.spec (stap): Add stap-env, stap-gen-cert, stap-authorize-cert, and stap-authorize-signing-cert. (stap-client): Remove stap-find-or-start-server, stap-add-server-cert. Add stap-authorize-server-cert. (stap-server): Add stap-find-servers, stap-find-or-start-server, stap-authorize-server-cert. Remove stap-gen-server-cert. * stap-find-servers: Source stap-env. Use $stap_avahi_service_tag. (initialization): Set timeout to 10. (find_servers): Run avahi-browse in the background and wait for it. Use a temp file for the output of avahi-browse. Kill avahi-browse if the timeout expires. (match_server): Set read timeout. (fatal): New function. * stap-find-or-start-server: Source stap-env. Use $stap_exec_prefix. Always exit with 0. * stap-start-server: Source stap-env. Check for the server PID as a running process and for avahi-publish-service running as a child in order to verify that the server is ready. * stap-add-server-cert: Renamed to stap-authorize-server-cert. Source stap-env. Call stap-authorize-cert. * stap-client: Source stap-env. Use $stap_user_ssl_db and $stap_root_ssl_db. Use $stap_tmpdir_prefix_client, $stap_tmpdir_prefix_server. Use $stap_exec_prefix. (configuration): Removed. (staprun_running): Removed. (interrupt): Don't kill staprun. * stap-server: Source stap-env. Use $stap_user_ssl_db and $stap_root_ssl_db. Use $stap_tmpdir_prefix_client, $stap_tmpdir_prefix_server. Use $stap_exec_prefix. (configuration): Removed. * session.h (systemtap_session): Add cert_db_path. * runtime/staprun/staprun_funcs.c (config.h): #include it. (modverify.h): #include it. (check_signature): New function. (check_groups): New function extracted from check_permissions. (check_permissions): Call check_groups and check_signature. * runtime/staprun/mainloop.c (cleanup_and_exit): Pass modpath to staprun, not modname. * main.cxx (main): Initialize cert_db_path. Handle LONG_OPT_SIGN_MODULE. Save the module signature if the module was signed and is being saved. (LONG_OPT_SIGN_MODULE): #define it. (long_options): Add --sign-module. * cache.cxx (config.h): #include it. (add_to_cache): Add the module signature file to the cache if the module has been signed. * buildrun.cxx (modsign.h): #include it. (compile_pass): Call sign_module, if requested. * configure.ac: Define HAVE_NSS if NSS libraries are available. * Makefile.am (AM_CPPFLAGS): Add -DSYSCONFDIR. (bin_SCRIPTS): Add stap-env, stap-gen-cert, stap-authorize-cert, stap-authorize-signing-cert, stap-authorize-server-cert. Remove stap-gen-server-cert, stap-add-server-cert. (stap_SOURCES): Add nsscommon.c, modsign.cxx (stap_CPPFLAGS): Add $(nss_CFLAGS), $(nspr_CFLAGS). (stap_LDADD): Add -lnss3. (staprun_SOURCES): Add nsscommon.c. * modsign.cxx: New file. * modsign.h: New file. * nsscommon.c: New file. * nsscommon.h: New file. * runtime/staprun/modverify.c: New file. * runtime/staprun/modverify.h: New file. * stap-authorize-cert: New file. * stap-authorize-signing-cert: New file. * stap-env: New file. * Makefile.in: Regenerated. * aclocal.m4: Regenerated. * config.in: Regenerated. * configure: Regenerated. * doc/Makefile.in: Regenerated. * doc/SystemTap_Tapset_Reference/Makefile.in: Regenerated. * testsuite/Makefile.in: Regenerated. * testsuite/aclocal.m4: Regenerated.
* Add Vim modelines for GNU style in stapJosh Stone2009-01-281-0/+2
|
* Merge commit 'origin/master' into pr4225Frank Ch. Eigler2008-08-281-4/+4
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * commit 'origin/master': PR5686: correct regression in semok/optimize.stp trailing whitespace removal, as approved by emacs fix global-var array index rendering fix NEWS to refer to simpler context.stp tapset functions in auto-printing blurb Document written but unread global variable automatic display. 2nd try initial Make _get_sock_addr return correct address in kernel before 2.6.16. Automatically print written but unread globals Make nodwf test passed when CONFIG_QUOTACTL unset Uses STAPCONF_DPATH_PATH instead of a kernel version check. Simplified "rpm" target a bit. Moved tar archive creation step from "rpm" target to "dist-gzip" target. remove support for "make dist" since git-archive does as well; Examples html files moved into subdir. 2008-08-25 David Smith <dsmith@redhat.com> ChangeLog Entries Robustness improvements for the stap client/server
| * trailing whitespace removal, as approved by emacsFrank Ch. Eigler2008-08-281-4/+4
| | | | | | | | (add-hook 'before-save-hook 'delete-trailing-whitespace)
* | prep find_executable() for use by process() probesFrank Ch. Eigler2008-08-091-1/+1
|/
* 2007-08-20 Martin Hunt <hunt@redhat.com>hunt2007-08-201-0/+1
| | | | | | | | | PR2424 From Lai Jiangshan <laijs@cn.fujitsu.com> * util.cxx (cmdstr_quoted): New. Properly quote command string. * buildrun.cxx (run_pass): Call cmdstr_quoted().
* 2007-08-07 Frank Ch. Eigler <fche@redhat.com>fche2007-08-081-4/+17
| | | | | | | | | | | | | | | | PR 4846 * parse.cxx (input_put): New function, sort of like stdio ungetc. (input_get): Skip cursor position changing for input_put strings. (scan): Rework $.../@... substitution into character pasting. * parse.h: Corresponding changes. * util.h (lex_cast_qstring): Octal-quote unprintable characters. * stap.1.in, NEWS: Document new behaviour. 2007-08-07 Frank Ch. Eigler <fche@redhat.com> PR 4846 * parseko/preprocess13.stp, parseok/nineteen.stp, semok/twentyfive.stp: New tests.
* 2006-12-19 Frank Ch. Eigler <fche@redhat.com>fche2006-12-191-2/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | PR 3522. * tapsets.cxx (dwflpp::emit_address): Call _stp_module_relocate only once per session. Error message cleanup: duplicate elimination etc. * session.h (saved_errors): Store a set of 'em. (num_errors): Return set size. Remove old numeric field. Update all callers. * elaborate.cxx (systemtap_session::print_errors): Print each encountered message just once. * staptree (semantic_error): Make msg2 writeable. Add a chain field. * tapsets.cxx (*var_expanding*:visit_target_symbol): Set saved semantic_error's chain field. * elaborate.cxx (register_library_aliases, visit_foreach_loop, visit_functioncall, derive_probes): Plop "while: ..." error message prefix/suffix right into the semantic_error message string. * parse.cxx (lexer::scan): Identify erroneous token better in error message for unresolvable $N/@M command line args. * util.h (lex_cast_hex): Use std::hex, not std::ios::hex. 2006-12-19 Frank Ch. Eigler <fche@redhat.com> PR 3522. * buildok/twentyfive.stp: New test for static $var access.
* 2006-11-08 Frank Ch. Eigler <fche@elastic.org>fche2006-11-081-4/+63
| | | | | | * util.h (lex_cast_qstring): Move def'n here. Also quote \. (stringify, lex_cast, lex_cast_hex): Move defn here. * buildrun.cxx, elaborate.cxx, main.cxx, staptree.cxx: Adapt.
* 2006-10-23 David Smith <dsmith@redhat.com>dsmith2006-10-231-0/+13
* main.cxx (printscript): New function containing code moved from main(). (main): Added code to create cache directory, call function to generate hash, and see if we can use cached source/module. If pass 4 is actually run to produce a new module, we call add_to_cache() to cache the result. * session.h (struct systemtap_session): Added hash/cache session data. * cache.cxx: New file handling adding/getting files from the cache. * cache.h: New header file for cache.cxx. * hash.cxx: New file containing C++ wrapper for routines in mdfour.c and the find_hash function which computes the hash file name for an input script. * hash.h: New header file for hash.cxx. * mdfour.c: New file containing MD4 hash code. * mdfour.h: New header file for mdfour.c. * util.cxx: New file containing several utility functions used by the caching code. * util.h: New header file for util.cxx. * Makefile.am: Added new C/C++ files. * Makefile.in: Regenerated.