396 |
398 |
397 //-------------------------------------------------------------------------- |
399 //-------------------------------------------------------------------------- |
398 // proc service functions |
400 // proc service functions |
399 |
401 |
400 // get process id |
402 // get process id |
401 pid_t ps_getpid(struct ps_prochandle *ph) { |
403 JNIEXPORT pid_t JNICALL |
|
404 ps_getpid(struct ps_prochandle *ph) { |
402 return ph->pid; |
405 return ph->pid; |
403 } |
406 } |
404 |
407 |
405 // ps_pglobal_lookup() looks up the symbol sym_name in the symbol table |
408 // ps_pglobal_lookup() looks up the symbol sym_name in the symbol table |
406 // of the load object object_name in the target process identified by ph. |
409 // of the load object object_name in the target process identified by ph. |
407 // It returns the symbol's value as an address in the target process in |
410 // It returns the symbol's value as an address in the target process in |
408 // *sym_addr. |
411 // *sym_addr. |
409 |
412 |
410 ps_err_e ps_pglobal_lookup(struct ps_prochandle *ph, const char *object_name, |
413 JNIEXPORT ps_err_e JNICALL |
|
414 ps_pglobal_lookup(struct ps_prochandle *ph, const char *object_name, |
411 const char *sym_name, psaddr_t *sym_addr) { |
415 const char *sym_name, psaddr_t *sym_addr) { |
412 *sym_addr = (psaddr_t) lookup_symbol(ph, object_name, sym_name); |
416 *sym_addr = (psaddr_t) lookup_symbol(ph, object_name, sym_name); |
413 return (*sym_addr ? PS_OK : PS_NOSYM); |
417 return (*sym_addr ? PS_OK : PS_NOSYM); |
414 } |
418 } |
415 |
419 |
416 // read "size" bytes info "buf" from address "addr" |
420 // read "size" bytes info "buf" from address "addr" |
417 ps_err_e ps_pdread(struct ps_prochandle *ph, psaddr_t addr, |
421 JNIEXPORT ps_err_e JNICALL |
|
422 ps_pdread(struct ps_prochandle *ph, psaddr_t addr, |
418 void *buf, size_t size) { |
423 void *buf, size_t size) { |
419 return ph->ops->p_pread(ph, (uintptr_t) addr, buf, size)? PS_OK: PS_ERR; |
424 return ph->ops->p_pread(ph, (uintptr_t) addr, buf, size)? PS_OK: PS_ERR; |
420 } |
425 } |
421 |
426 |
422 // write "size" bytes of data to debuggee at address "addr" |
427 // write "size" bytes of data to debuggee at address "addr" |
423 ps_err_e ps_pdwrite(struct ps_prochandle *ph, psaddr_t addr, |
428 JNIEXPORT ps_err_e JNICALL |
|
429 ps_pdwrite(struct ps_prochandle *ph, psaddr_t addr, |
424 const void *buf, size_t size) { |
430 const void *buf, size_t size) { |
425 return ph->ops->p_pwrite(ph, (uintptr_t)addr, buf, size)? PS_OK: PS_ERR; |
431 return ph->ops->p_pwrite(ph, (uintptr_t)addr, buf, size)? PS_OK: PS_ERR; |
426 } |
432 } |
427 |
433 |
428 // ------------------------------------------------------------------------ |
434 // ------------------------------------------------------------------------ |
429 // Functions below this point are not yet implemented. They are here only |
435 // Functions below this point are not yet implemented. They are here only |
430 // to make the linker happy. |
436 // to make the linker happy. |
431 |
437 |
432 ps_err_e ps_lsetfpregs(struct ps_prochandle *ph, lwpid_t lid, const prfpregset_t *fpregs) { |
438 JNIEXPORT ps_err_e JNICALL |
|
439 ps_lsetfpregs(struct ps_prochandle *ph, lwpid_t lid, const prfpregset_t *fpregs) { |
433 print_debug("ps_lsetfpregs not implemented\n"); |
440 print_debug("ps_lsetfpregs not implemented\n"); |
434 return PS_OK; |
441 return PS_OK; |
435 } |
442 } |
436 |
443 |
437 ps_err_e ps_lsetregs(struct ps_prochandle *ph, lwpid_t lid, const prgregset_t gregset) { |
444 JNIEXPORT ps_err_e JNICALL |
|
445 ps_lsetregs(struct ps_prochandle *ph, lwpid_t lid, const prgregset_t gregset) { |
438 print_debug("ps_lsetregs not implemented\n"); |
446 print_debug("ps_lsetregs not implemented\n"); |
439 return PS_OK; |
447 return PS_OK; |
440 } |
448 } |
441 |
449 |
442 ps_err_e ps_lgetfpregs(struct ps_prochandle *ph, lwpid_t lid, prfpregset_t *fpregs) { |
450 JNIEXPORT ps_err_e JNICALL |
|
451 ps_lgetfpregs(struct ps_prochandle *ph, lwpid_t lid, prfpregset_t *fpregs) { |
443 print_debug("ps_lgetfpregs not implemented\n"); |
452 print_debug("ps_lgetfpregs not implemented\n"); |
444 return PS_OK; |
453 return PS_OK; |
445 } |
454 } |
446 |
455 |
447 ps_err_e ps_lgetregs(struct ps_prochandle *ph, lwpid_t lid, prgregset_t gregset) { |
456 JNIEXPORT ps_err_e JNICALL |
|
457 ps_lgetregs(struct ps_prochandle *ph, lwpid_t lid, prgregset_t gregset) { |
448 print_debug("ps_lgetfpregs not implemented\n"); |
458 print_debug("ps_lgetfpregs not implemented\n"); |
449 return PS_OK; |
459 return PS_OK; |
450 } |
460 } |
451 |
461 |
452 // new libthread_db of NPTL seem to require this symbol |
462 // new libthread_db of NPTL seem to require this symbol |
453 ps_err_e ps_get_thread_area() { |
463 JNIEXPORT ps_err_e JNICALL |
|
464 ps_get_thread_area() { |
454 print_debug("ps_get_thread_area not implemented\n"); |
465 print_debug("ps_get_thread_area not implemented\n"); |
455 return PS_OK; |
466 return PS_OK; |
456 } |
467 } |