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