Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
L
lyskom-server-ceder-1616-generations-topgit
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Per Cederqvist
lyskom-server-ceder-1616-generations-topgit
Commits
ffbdb06a
Commit
ffbdb06a
authored
Jul 02, 1999
by
David Byers
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
First cut at making smalloc tracing automatic.
parent
8c60d317
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
182 additions
and
11 deletions
+182
-11
ChangeLog
ChangeLog
+9
-0
src/server/handle-malloc-dump.el
src/server/handle-malloc-dump.el
+157
-2
src/server/ram-smalloc.c
src/server/ram-smalloc.c
+16
-9
No files found.
ChangeLog
View file @
ffbdb06a
1999-07-02 David Byers <davby@ida.liu.se>
Automatic operation of memory trace analysis:
* src/server/ram-smalloc.c: Mention automatic analysis. Update the
description on how to do it manually (MEMTRACE=file, ATTACH=yes)
* src/server/handle-malloc-dump.el: Added automatic operation in
batch mode. Just run -batch and watch the magic happen.
1999-07-02 David Byers <davby@ida.liu.se>
Some test cases for name lookup:
...
...
src/server/handle-malloc-dump.el
View file @
ffbdb06a
;;;;
;;;; $Id: handle-malloc-dump.el,v 1.
8 1999/05/24 09:38:27 ceder
Exp $
;;;; $Id: handle-malloc-dump.el,v 1.
9 1999/07/02 14:50:36 byers
Exp $
;;;; Copyright (C) 1991-1995, 1999 Lysator Academic Computer Association.
;;;;
;;;; This file is part of the LysKOM server.
...
...
@@ -23,6 +23,8 @@
;;;; Please mail bug reports to bug-lyskom@lysator.liu.se.
;;;;
;;;; See ram-smalloc.c for instructions on how to use this file.
(
require
'dll
)
;;; block - each block that is active is stored on a dll. The dll
...
...
@@ -89,7 +91,7 @@ mallocs/reallocs/frees to *Result*."
(
btend
(
progn
(
re-search-forward
"^==== end ===="
)
(
match-beginning
0
))))
(
message
fn
)
;
(message fn)
(
cond
((
string=
fn
"malloc"
)
(
beginning-of-line
0
)
...
...
@@ -155,3 +157,156 @@ mallocs/reallocs/frees to *Result*."
(
insert
(
format
"From char %d:\n"
b
))
(
insert-buffer-substring
gdb-buf
(
1-
b
)
(
1+
e
))))
(
setq
node
(
dll-next
stack
node
)))))
;;; Batch mode analysis
(
defvar
gdb-tty
nil
)
(
defvar
gdb-proc
nil
)
(
defvar
gdb-buffer
nil
)
(
defvar
lyskomd-pid
nil
)
(
defvar
trace-done
nil
)
(
defun
trace-collect-data
(
proc
data
)
(
goto-char
(
point-max
))
(
insert
data
))
(
defun
trace-expect
(
re
)
(
goto-char
trace-last-match
)
(
if
(
re-search-forward
re
nil
t
)
(
progn
(
set-marker
trace-last-match
(
match-end
0
))
(
match-beginning
0
))))
(
defun
trace-collect-filter
(
proc
data
)
(
save-excursion
(
set-buffer
(
process-buffer
proc
))
(
trace-collect-data
proc
data
)))
(
defun
trace-process-get-tty
(
proc
data
)
(
save-excursion
(
set-buffer
(
process-buffer
proc
))
(
trace-collect-data
proc
data
)
(
if
(
trace-expect
"\\(/dev\\S-*\\)$"
)
(
progn
(
setq
gdb-tty
(
match-string
1
))
(
message
"Tracing using gdb on tty %s"
gdb-tty
)
(
set-process-filter
proc
'trace-collect-filter
)))))
(
defun
trace-runtest-filter
(
proc
data
)
(
save-excursion
(
set-buffer
(
process-buffer
proc
))
(
trace-collect-data
proc
data
)
(
if
(
trace-expect
"Please attach to lyskomd pid \\([0-9]+\\) and hit RETURN$"
)
(
progn
(
setq
lyskomd-pid
(
string-to-int
(
match-string
1
)))
(
message
"Attaching to lyskomd pid %d"
lyskomd-pid
)
(
set-process-filter
proc
'trace-collect-filter
)))))
(
defun
trace-runtest-sentinel
(
proc
state
)
(
setq
trace-done
t
))
(
defun
trace-make-process-buffer
(
name
)
(
let
((
buf
(
get-buffer-create
name
)))
(
save-excursion
(
set-buffer
buf
)
(
erase-buffer
)
(
make-local-variable
'trace-last-match
)
(
setq
trace-last-match
(
copy-marker
(
point-min-marker
))))
buf
))
(
defun
usage
()
(
message
"\
Usage:
emacs
-batch
-l
handle-malloc-dump.el
--test
arg
[options]
Options:
--help
Show
this
help
message
--tool
arg
Use
arg
as
--tool
argument
for
runtest
(
optional
)
--test
arg
Run
the
test
case
arg
with
runtest
(
REQUIRED
)
--output
arg
Append
the
results
to
file
arg
(
optional
)
"))
(defun trace-memory ()
(let ((tool-to-test "
lyskomd
")
(test-to-run nil)
(output-file nil)
(arg nil)
(done nil)
(result nil))
(while (and command-line-args-left (not done))
(setq arg (car command-line-args-left))
(cond ((string= arg "
--usage
")
(setq command-line-args-left (cdr command-line-args-left))
(setq tool-to-test nil)
(setq done t)
(usage))
((string= arg "
--tool
")
(setq tool-to-test (car (cdr command-line-args-left)))
(setq command-line-args-left (cdr (cdr command-line-args-left))))
((string= arg "
--test
")
(setq test-to-run (car (cdr command-line-args-left)))
(setq command-line-args-left (cdr (cdr command-line-args-left))))
((string= arg "
--output
")
(setq output-file (car (cdr command-line-args-left)))
(setq command-line-args-left (cdr (cdr command-line-args-left))))
(t (setq done t))))
(if tool-to-test
(progn (if (null test-to-run)
(usage)
(setq result (trace-run-programs tool-to-test test-to-run))
(cond ((null output-file) (message "
%s
" result))
(t
(let ((tmp (get-buffer-create "
*tmp*
")))
(set-buffer tmp)
(insert result)
(append-to-file (point-min)
(point-max)
output-file)))))))))
(defun trace-run-programs (tool-to-test test-to-run)
(setq lyskomd-pid nil)
(setq gdb-tty nil)
(setq trace-done nil)
(let ((gdb-buffer (trace-make-process-buffer "
*gdb*
"))
(runtest-buffer (trace-make-process-buffer "
*runtest*
")))
(setq gdb-proc (start-process "
gdb
" gdb-buffer "
gdb
" "
..
/lyskomd
"))
(setq gdb-buffer (get-buffer-create "
*gdb*
"))
(set-process-filter gdb-proc 'trace-process-get-tty)
(process-send-string gdb-proc "
shell
echo
`
tty
`
\n
")
(while (null gdb-tty) (accept-process-output gdb-proc))
(setq runtest-proc (start-process "
runtest
"
runtest-buffer
"
runtest
"
"
--srcdir=.
"
(format "
--tool=%s
" tool-to-test)
test-to-run
"
ATTACH=yes
"
(format "
MEMTRACE=%s
" gdb-tty)))
(set-process-filter runtest-proc 'trace-runtest-filter)
(set-process-sentinel runtest-proc 'trace-runtest-sentinel)
(while (null lyskomd-pid) (accept-process-output runtest-proc))
(process-send-string gdb-proc "
source
..
/trace-mem.gdb\n
")
(process-send-string gdb-proc (format "
attach
%s\n
" lyskomd-pid))
(process-send-string gdb-proc "
continue\n
")
(process-send-string runtest-proc "
\n
")
(while (null trace-done) (accept-process-output))
(set-buffer gdb-buffer)
(message "
Resolving
trace...
")
(resolve-trace)
(set-buffer "
*Result*
")
(buffer-substring)))
;; If running in batch mode, start things right away
(if noninteractive
(progn (message "
Automatic
lyskomd
memory
trace
analysis
"
)
(
trace-memory
))
)
src/server/ram-smalloc.c
View file @
ffbdb06a
/*
* $Id: ram-smalloc.c,v 0.3
0 1999/05/24 09:34:35 ceder
Exp $
* $Id: ram-smalloc.c,v 0.3
1 1999/07/02 14:50:37 byers
Exp $
* Copyright (C) 1991-1996, 1998-1999 Lysator Academic Computer Association.
*
* This file is part of the LysKOM server.
...
...
@@ -71,13 +71,9 @@
* (gdb) source trace-mem.gdb
* (gdb) shell tty
* /dev/ttypd
* Insert the following two statements in the *.exp script before the
* call to lyskomd_start that you want to trace:
* set attach 1
* set MEMTRACE /dev/ttypd
* MEMTRACE should be set to the tty where gdb is running. Start the
* test suite:
* bash$ runtest --tool lyskomd leaks.0/99.exp
* Pass ATTACH=yes and MEMTRACE to runtest. MEMTRACE should be set
* to the tty where gdb is running. Start the test suite:
* bash$ runtest --tool lyskomd leaks.0/99.exp ATTACH=yes MEMTRACE=/dev/ttypd
* [...]
* Please attach to lyskomd pid 4711 and hit RETURN
* Attach to the process:
...
...
@@ -86,10 +82,21 @@
* Press enter to resume the test suite. Lots of output should appear
* from gdb.
*
* You can do all this automatically for test cases that succeed in
* starting the server and only start it once.
*
* emacs -batch -l handle-malloc-dump.el --tool leaks --test 99.exp
*
* This will do the above in an Emacs, then run the trace analysis
* and print the results on standard output. Use --usage to get a
* summary of available options (--help was already taken by Emacs.)
*
* This does not work with all Emacs versions.
*
*/
static
const
char
*
rcsid
=
"$Id: ram-smalloc.c,v 0.3
0 1999/05/24 09:34:35 ceder
Exp $"
;
rcsid
=
"$Id: ram-smalloc.c,v 0.3
1 1999/07/02 14:50:37 byers
Exp $"
;
#include "rcs.h"
USE
(
rcsid
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment