aboutsummaryrefslogtreecommitdiffstats
path: root/docs/afb-overview.md
AgeCommit message (Collapse)AuthorFilesLines
2017-07-27update markdown documentationRonan Le Martret1-40/+32
Change-Id: I4f466ff4b965022998d2418a9c1310d4f5e0188e Signed-off-by: Ronan Le Martret <ronan.lemartret@iot.bzh>
2017-06-19Add page-break for pdf and fix spellingSebastien Douheret1-8/+9
Change-Id: I3225f27a4e45792aeeb418eac5430c93c9d70061 Signed-off-by: Sebastien Douheret <sebastien.douheret@iot.bzh>
2017-06-13Refactor of the documentationJosé Bollo1-0/+98
#336699 } /* Name.Attribute */ .highlight .nb { color: #003388 } /* Name.Builtin */ .highlight .nc { color: #bb0066; font-weight: bold } /* Name.Class */ .highlight .no { color: #003366; font-weight: bold } /* Name.Constant */ .highlight .nd { color: #555555 } /* Name.Decorator */ .highlight .ne { color: #bb0066; font-weight: bold } /* Name.Exception */ .highlight .nf { color: #0066bb; font-weight: bold } /* Name.Function */ .highlight .nl { color: #336699; font-style: italic } /* Name.Label */ .highlight .nn { color: #bb0066; font-weight: bold } /* Name.Namespace */ .highlight .py { color: #336699; font-weight: bold } /* Name.Property */ .highlight .nt { color: #bb0066; font-weight: bold } /* Name.Tag */ .highlight .nv { color: #336699 } /* Name.Variable */ .highlight .ow { color: #008800 } /* Operator.Word */ .highlight .w { color: #bbbbbb } /* Text.Whitespace */ .highlight .mb { color: #0000DD; font-weight: bold } /* Literal.Number.Bin */ .highlight .mf { color: #0000DD; font-weight: bold } /* Literal.Number.Float */ .highlight .mh { color: #0000DD; font-weight: bold } /* Literal.Number.Hex */ .highlight .mi { color: #0000DD; font-weight: bold } /* Literal.Number.Integer */ .highlight .mo { color: #0000DD; font-weight: bold } /* Literal.Number.Oct */ .highlight .sa { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Affix */ .highlight .sb { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Backtick */ .highlight .sc { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Char */ .highlight .dl { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Delimiter */ .highlight .sd { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Doc */ .highlight .s2 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Double */ .highlight .se { color: #0044dd; background-color: #fff0f0 } /* Literal.String.Escape */ .highlight .sh { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Heredoc */ .highlight .si { color: #3333bb; background-color: #fff0f0 } /* Literal.String.Interpol */ .highlight .sx { color: #22bb22; background-color: #f0fff0 } /* Literal.String.Other */ .highlight .sr { color: #008800; background-color: #fff0ff } /* Literal.String.Regex */ .highlight .s1 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Single */ .highlight .ss { color: #aa6600; background-color: #fff0f0 } /* Literal.String.Symbol */ .highlight .bp { color: #003388 } /* Name.Builtin.Pseudo */ .highlight .fm { color: #0066bb; font-weight: bold } /* Name.Function.Magic */ .highlight .vc { color: #336699 } /* Name.Variable.Class */ .highlight .vg { color: #dd7700 } /* Name.Variable.Global */ .highlight .vi { color: #3333bb } /* Name.Variable.Instance */ .highlight .vm { color: #336699 } /* Name.Variable.Magic */ .highlight .il { color: #0000DD; font-weight: bold } /* Literal.Number.Integer.Long */
#!/bin/bash

###########################################################################
# Copyright (C) 2017-2019 IoT.bzh
#
# Author: Stephane Desneux <sdx@iot.bzh>
#         Sebastien Douheret <sebastien@iot.bzh>
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
###########################################################################

# This script should be invoked by gdb client through a ssh connection.
# It relays gdbmi protocol from gdbserver to gdb client
#
# WARNING: nothing should be sent to stdout except gdbserver output

# FIXME: add support of --debugger option to support tcf or gdb-remote


function error() {
	echo "ERR: $@" >&2
	exit 1
}
function info() {
	echo "INF: $@" >&2
}

# setup debug dir (shared with service file)
DBGDIR=@afm_platform_rundir@/debug
mkdir -p $DBGDIR

# check application name passed as first arg by gdb
APP=$1
[[ -z "$APP" ]] && error "Invalid application name"

# redirect to log file
exec 2>$DBGDIR/$APP.dbgclt.log

# activate DEBUG in environment file sourced in systemd service
AFB_WAIT_POINT="start-start"
echo "AFB_DEBUG_WAIT=$AFB_WAIT_POINT" >$DBGDIR/$APP.env

# remove debug env file on exit
trap "rm $DBGDIR/$APP.*" STOP INT QUIT EXIT

# ask appfw to start application
pid=$(afm-util start $APP)
[[ -z "$pid" || ! -e "/proc/$pid" ]] && error "Failed to start application $APP"
info "$APP started with pid=$pid"

# wait debugging process is stop/waiting at start-start point
AFB_FILE=/tmp/afb-debug-$pid
tmo=100
info "Waiting for process stopped..."
while [[ ! -e "$AFB_FILE" ]]; do
    sleep 0.1
    tmo=$(expr $tmo - 1)
    [[ "$tmo" == "0" ]] && error "Timeout waiting for process $pid stopped"
done

info "Waiting for process stopped..."
AFB_WAIT_FILE=/tmp/afb-debug-$pid
tmo=100
res=1
while [[ "$res" != "0" ]]; do
    sleep 0.1
    tmo=$(expr $tmo - 1)
    [[ "$tmo" == "0" ]] && error "Timeout waiting for process $pid stopped"
    grep $AFB_WAIT_POINT $AFB_WAIT_FILE > /dev/null 2>&1
    res=$?
done

# debugging
info "Attaching gdbserver to pid $pid ..."
gdbserver --attach - $pid

# end of debug session
info "proxy connection terminated - killing $APP (pid $pid)"
afm-util kill $pid >&2
info "$APP killed"