7a9389330e
gcc/: * gcc.c (default_compilers): Add entry for ".go". * common.opt: Add -static-libgo as a driver option. * doc/install.texi (Configuration): Mention libgo as an option for --enable-shared. Mention go as an option for --enable-languages. * doc/invoke.texi (Overall Options): Mention .go as a file name suffix. Mention go as a -x option. * doc/frontends.texi (G++ and GCC): Mention Go as a supported language. * doc/sourcebuild.texi (Top Level): Mention libgo. * doc/standards.texi (Standards): Add section on Go language. Move references for other languages into their own section. * doc/contrib.texi (Contributors): Mention that I contributed the Go frontend. gcc/testsuite/: * lib/go.exp: New file. * lib/go-dg.exp: New file. * lib/go-torture.exp: New file. * lib/target-supports.exp (check_compile): Match // Go. From-SVN: r167407
91 lines
2.1 KiB
Go
91 lines
2.1 KiB
Go
// Copyright 2009 The Go Authors. All rights reserved.
|
|
// Use of this source code is governed by a BSD-style
|
|
// license that can be found in the LICENSE file.
|
|
|
|
package rpc
|
|
|
|
/*
|
|
Some HTML presented at http://machine:port/debug/rpc
|
|
Lists services, their methods, and some statistics, still rudimentary.
|
|
*/
|
|
|
|
import (
|
|
"fmt"
|
|
"http"
|
|
"sort"
|
|
"template"
|
|
)
|
|
|
|
const debugText = `<html>
|
|
<body>
|
|
<title>Services</title>
|
|
{.repeated section @}
|
|
<hr>
|
|
Service {name}
|
|
<hr>
|
|
<table>
|
|
<th align=center>Method</th><th align=center>Calls</th>
|
|
{.repeated section meth}
|
|
<tr>
|
|
<td align=left font=fixed>{name}({m.argType}, {m.replyType}) os.Error</td>
|
|
<td align=center>{m.numCalls}</td>
|
|
</tr>
|
|
{.end}
|
|
</table>
|
|
{.end}
|
|
</body>
|
|
</html>`
|
|
|
|
var debug = template.MustParse(debugText, nil)
|
|
|
|
type debugMethod struct {
|
|
m *methodType
|
|
name string
|
|
}
|
|
|
|
type methodArray []debugMethod
|
|
|
|
type debugService struct {
|
|
s *service
|
|
name string
|
|
meth methodArray
|
|
}
|
|
|
|
type serviceArray []debugService
|
|
|
|
func (s serviceArray) Len() int { return len(s) }
|
|
func (s serviceArray) Less(i, j int) bool { return s[i].name < s[j].name }
|
|
func (s serviceArray) Swap(i, j int) { s[i], s[j] = s[j], s[i] }
|
|
|
|
func (m methodArray) Len() int { return len(m) }
|
|
func (m methodArray) Less(i, j int) bool { return m[i].name < m[j].name }
|
|
func (m methodArray) Swap(i, j int) { m[i], m[j] = m[j], m[i] }
|
|
|
|
type debugHTTP struct {
|
|
*Server
|
|
}
|
|
|
|
// Runs at /debug/rpc
|
|
func (server debugHTTP) ServeHTTP(w http.ResponseWriter, req *http.Request) {
|
|
// Build a sorted version of the data.
|
|
var services = make(serviceArray, len(server.serviceMap))
|
|
i := 0
|
|
server.Lock()
|
|
for sname, service := range server.serviceMap {
|
|
services[i] = debugService{service, sname, make(methodArray, len(service.method))}
|
|
j := 0
|
|
for mname, method := range service.method {
|
|
services[i].meth[j] = debugMethod{method, mname}
|
|
j++
|
|
}
|
|
sort.Sort(services[i].meth)
|
|
i++
|
|
}
|
|
server.Unlock()
|
|
sort.Sort(services)
|
|
err := debug.Execute(services, w)
|
|
if err != nil {
|
|
fmt.Fprintln(w, "rpc: error executing template:", err.String())
|
|
}
|
|
}
|