1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-06-30 06:50:31 +02:00

fix docstring assembly and fetching

* module/system/vm/assembler.scm (link-docstrs): Write pc offsets as
  byte addresses.  Works better with native code.
* module/system/vm/debug.scm (find-program-docstring): Fix the linear
  search.  How embarassing!
This commit is contained in:
Andy Wingo 2013-11-05 21:29:46 +01:00
parent 3659ef543e
commit 0a1d52ac77
2 changed files with 8 additions and 9 deletions

View file

@ -1490,9 +1490,9 @@ it will be added to the GC roots at runtime."
;;; The .guile.docstrs section is a packed, sorted array of (pc, str) ;;; The .guile.docstrs section is a packed, sorted array of (pc, str)
;;; values. Pc and str are both 32 bits wide. (Either could change to ;;; values. Pc and str are both 32 bits wide. (Either could change to
;;; 64 bits if appropriate in the future.) Pc is the address of the ;;; 64 bits if appropriate in the future.) Pc is the address of the
;;; entry to a program, relative to the start of the text section, and ;;; entry to a program, relative to the start of the text section, in
;;; str is an index into the associated .guile.docstrs.strtab string ;;; bytes, and str is an index into the associated .guile.docstrs.strtab
;;; table section. ;;; string table section.
;;; ;;;
;; The size of a docstrs entry, in bytes. ;; The size of a docstrs entry, in bytes.
@ -1508,7 +1508,7 @@ it will be added to the GC roots at runtime."
(and tail (and tail
(not (find-tail is-documentation? (cdr tail))) (not (find-tail is-documentation? (cdr tail)))
(string? (cdar tail)) (string? (cdar tail))
(cons (meta-low-pc meta) (cdar tail))))) (cons (* 4 (meta-low-pc meta)) (cdar tail)))))
(reverse (asm-meta asm)))) (reverse (asm-meta asm))))
(let* ((endianness (asm-endianness asm)) (let* ((endianness (asm-endianness asm))
(docstrings (find-docstrings)) (docstrings (find-docstrings))

View file

@ -402,15 +402,14 @@ section of the ELF image. Returns an ELF symbol, or @code{#f}."
(let lp ((pos start)) (let lp ((pos start))
(cond (cond
((>= pos end) #f) ((>= pos end) #f)
((< text-offset (bytevector-u32-native-ref bv pos)) ((< (bytevector-u32-native-ref bv pos) text-offset)
(lp (+ pos docstr-len))) (lp (+ pos docstr-len)))
((> text-offset (bytevector-u32-native-ref bv pos)) ((= text-offset (bytevector-u32-native-ref bv pos))
#f)
(else
(let ((strtab (elf-section (debug-context-elf context) (let ((strtab (elf-section (debug-context-elf context)
(elf-section-link sec))) (elf-section-link sec)))
(idx (bytevector-u32-native-ref bv (+ pos 4)))) (idx (bytevector-u32-native-ref bv (+ pos 4))))
(string-table-ref bv (+ (elf-section-offset strtab) idx)))))))))) (string-table-ref bv (+ (elf-section-offset strtab) idx))))
(else #f)))))))
(define* (find-program-properties addr #:optional (define* (find-program-properties addr #:optional
(context (find-debug-context addr))) (context (find-debug-context addr)))