> From: Will Senn
> How did folks debug assembly routines in Unix v6, back in the day?
There are three different questions here, although you may not realize it:
- How did folks debug assembly routines in user programs in Unix v6
- How did folks debug assembly routines in the kernel in Unix v6
- How did folks debug assembly routines in PDP-11 standalone code created
with Unix v6
I did all three, and I used different methods for each.
For user code, there was no source-level debugger, so debugging C programs
and debugging code written in assembler were the same thing. I used 'adb'
(which is, stricly speaking, slightly post-V6 - our system at MIT was
actually sort of an early PWB clone), but V6 itself provides 'db' (and also,
IIRC, 'cdb'); all three are very similar.
For standalone code (in my case, a packet switch that ran on PDP-11's), I
used a version of DDT that was linked in with the rest of the code. The
original version was one in MACRO-11 which I inherited from Jim Mathis at
SRI, but I eventually re-wrote it in portable C, and it was used on the 68K,
uVax and 29K.
For kernel assembler code... I can't remember what I did! Although I wrote a
fair amount of it (I modified m45.s very extensively, to work with the Able
ENABLE card), so I must have done _something_, but I have no idea what. In
theory I could have linked DDT in with the kernel, but I don't think I ever
did so?
Recently I was debugging some kernel code (the splice() system call we were
discussing here), and I debugged it using... printf()'s! It was written in C,
but I don't really differentiate between debugging C code, and assembler.
> 2. No map file created by ld.
LD normally includes a symbol table in the output file, which 'nm' can dump.
> 3. No debugger that I can find.
See above.
> My workarounds include using OD to view the generated machine code
Use db/cdb/adb if you want to look at compiled code. Also, for 'cc', use the
-S flag.
Noel
All,
I'm finally returning to my study of v6 after digging a bit further into
assembly language and "other" pdp-11 operating systems. I even managed
to get hello, world working in assembly in v6 and interestingly enough,
I actually see how it works... for the most part :). Mini-note here:
http://decuser.blogspot.com/2016/01/hello-world-in-assembly-on-research.html
My question for y'all today is as follows (asked previously with a much
larger gap in understanding):
How did folks debug assembly routines in Unix v6, back in the day?
I realize that most folks didn't do assembly, but some did and I'm
curious what their approach might have been.
After having worked with RT-11 for a bit, I can see how I might develop
using RT-11 and then "port" a program across, but that seems less than
ideal. Here is my short list of missing features as I see them:
1. No listing file/cross reference list created by as.
2. No map file created by ld.
3. No debugger that I can find.
4. This is not a missing feature, but it deserves inclusion in the list,
the command as has possibly the most terse error messages I have ever
seen - B 12? Really? Thankfully, the awesome man command comes to the
rescue with the list of error codes.
My workarounds include using OD to view the generated machine code and
adding mesg calls.
Thoughts?
Will
All, I asked Peter Salus if there is an electronic version of his great
book "A Quarter Century of Unix". There isn't one, so I scanned my book
in. Peter has given TUHS the right to distribute the scanned version.
I've just added a link to the PDF of the scan here:
http://wiki.tuhs.org/doku.php?id=publications:quarter_century_of_unix
But, if you can, buy the paper version as well!
Many thanks to Peter for his generosity.
Cheers, Warren
Hoi.
Yesterday, I came across the file Berkeley_Unix_History.pdf on
my disk. It contains scanned articles of UNIX Review January 1985,
October 1985 and January 1986. Searching the web brought up this
online location for the file:
http://simson.net/ref/free_software/Berkeley_Unix_History.pdf
I read the articles for the first time and had a great time doing
so. Especially the ``Berkeley Underground'' article was pure fun!
Here, have some impression:
We modified the kernel to
support asynchronous I/O, distri-
buted files, security traces, "real-
time" interrupts for subprocess
multitasking, limited screen
editing, and various new system
calls. We wrote compilers, ass-
emblers, linkers, disassemblers,
database utilities, cryptographic
utilities, tutorial help systems,
games, and screen-oriented ver-
sions of standard utilities. User
friendly utilities for new users that
avoided accidental file deletion,
libraries to support common
operations on data structures
such as lists, strings, trees, sym-
bol tables, and libraries to perform
arbitrary precision arithmetic and
symbolic mathematics were other
contributions. We suggested im-
provements to many system calls
and to most utilities. We offered to
fix the option flags so that the dif-
ferent utilities were consistent
with one another.
To Us, nothing was sacred,
and We saw a great deal in UNIX
that could stand improvement.
Much of what We implemented, or
asked to be allowed to implement,
is now a part of System V and 4.2
BSD; others of our innovations are
still missing from all versions of
UNIX. Despite these accom-
plishments, it seemed that
whenever We asked The Powers
That Be to install Our software
and make it available to the rest of
the system's users, We were
greeted with stony silence.
Unfortunately, the scan is not complete as some pages are
missing. For example, page 43 (the title page of the mentioned
article) is among them.
Does anyone know where to get the full articles?
meillo
> From: Ronald Natalie
> a new GADS (Gateway Architecture and Data Structures) under Dave
> Mills's leadership would form which I attended until they morphed it
> into the IETF
To give a bit more detail, GADS was not producing needed stuff as fast as was
needed, so it was split into InArc and InEng, with Dave running InArc and
Corrigan (initially, Gross later) in charge.
Noel
It has been updated again:
The origin of the name cron is from the Greek word for time, χρόνος (chronos).[2][3] (Ken Thompson, author of cron, has confirmed this in a private communication with Brian Kernighan.)
So it would appear that if enough people bang on enough keyboards on the Wikipedia site, things can change.
David
All, although I can't contribute to the actual history of Unix, I can at
least document what happened "afterwards". Here's a piece about the
journey to make free Unix source code licenses available:
http://wiki.tuhs.org/doku.php?id=events:free_licenses
Comments welcome. Cheers, Warren
On 2016-01-06 01:54, Dave Horsfall <dave(a)horsfall.org> wrote:
> On Mon, 4 Jan 2016, Ronald Natalie wrote:
>> >Just never figured out how to make good use of the MARK instruction on
>> >the PDP-11.
> RSX-11 probably used it, though, as could've RSTS...
Nope. Nothing in RSX uses it. As others said, probably nothing anywhere
used it.
And, as I pointed out, if you use MARK, then you cannot really use split
I/D-space, since the stack (data) needs to be in instruction space.
Johnny
--
Johnny Billquist || "I'm on a bus
|| on a psychedelic trip
email: bqt(a)softjar.se || Reading murder books
pdp is alive! || tryin' to stay hip" - B. Idol
On 2016-01-05 18:43, Ronald Natalie<ron(a)ronnatalie.com> wrote:
>
> Just never figured out how to make good use of the MARK instruction on the PDP-11.
Not surprising. As others noted, few ever did. And apparently none
responding actually do either.
It *is* a stupid instruction in many ways. And it's not for multiple
returns either.
It's an odd way of handling stack cleanup without a frame pointer.
It's extremely bad, since it actually requires the stack to be in
instruction space. And yes, you are expected to execute on the stack.
The idea is that the caller pushes arguments on the stack, but the
cleanup of the stack is implicitly done in the subroutine itself, and at
the same time you get an argument pointer.
Example:
Calling:
MOV R5,-(SP) ; Save old R5
MOV <argn>,-(SP)
MOV <argn-1>,-(SP)
.
MOV <arg1>,-(SP)
MOV #MARKN,-(SP) ; Where the N in MARK N is the number of
arguments you just pushed.
MOV SP,R5
JSR PC,SUB
.
.
In the subroutine you then have the arguments available relative to R5.
So that arg1 is available at 2(R5) for example.
SUB: .
.
.
RTS R5
There is a lot going on at this point. The trick is to note that the
code does an RTS R5 to return. If people remember what happens at that
point, PC gets loaded with R5, while R5 gets loaded with the PC that we
actually would like to return to (since that's what is at the top of the
stack).
And R5 is pointing into the stack, at the MARK instruction, so execution
continues with actually performing the MARK.
MARK, in turn, will case SP <- PC + 2*N, thus restoring the stack
pointer to point to the place where the original R5 was stored.
Next, it does a PC <- R5, so that we now have the PC point to where we
actually want to return.
Next it does a R5 <- (SP)+, meaning we actually restored the original R5.
And so we have cleaned up the stack, preserved R5, and returned to the
caller again.
Also notice that the subroutine could have pushed any amount of data on
the stack before the return, and I suspect the idea was that the process
would not have needed to clean that up either. However, that fails,
since the RTS needs the return address at the top. But you can
essentially solve that by pushing -2(R5) before returning.
Ugly, isn't it? :-)
Johnny