In the below, since the flags and callbacks are static, each call to dwflBegin smashes the previous structure. jlong lib::dwfl::Dwfl::dwflBegin(jnixx::env env, jstring jsysroot) { jstringUTFChars sysroot = jsttringUTFChars(env, jsysroot); static char* flags; if (asprintf (&flags, ".debug:%s", sysroot) < 0) return (jlong) NULL; static Dwfl_Callbacks callbacks = { &::dwfl_frysk_proc_find_elf, &::dwfl_standard_find_debuginfo, NULL, &flags, }; return (jlong) ::dwfl_begin(&callbacks); }
minecommit 4c67208accaec119dcda3f2ec795e8e98584a740 Author: Andrew Cagney <cagney@redhat.com> Date: Tue Jun 3 16:32:15 2008 -0400 Dynamically allocate/free the dwfl callback struct. The change to store a per-dwfl debug-info path in the dwfl callback struct wasn't accompanied by a change to allocate the callback struct dynamically. Consequently each successive dwfl-begin call was overwriting the previous debug-info path. frysk-sys/lib/dwfl/ChangeLog 2008-06-03 Andrew Cagney <cagney@redhat.com> * Dwfl.java (callbackBegin, callbackEnd): New. (Dwfl(String), close()): Use. * cni/Dwfl.cxx: Update. * jni/Dwfl.cxx: Update.